Posts

Showing posts from July, 2012

c++ - Polygon intersection with Boost::geometry severe performance deterioration -

i have particle system , using boost::geometry approximate elliptical particles polygons , use intersection function of library find overlap area. calculating "inner" , "outer" ellipse(polygon) area assign "potential" each particle-particle interaction. my potential function this: double potential(cell* current, cell* next) { double arearep, areaatt; double distance = distance(current,next); double a1 = current->getlength(); double b1 = a1/2.0; double theta1 = current->gettheta(); //*180.0/m_pi double x1 = current->getcurrx(); double y1 = current->getcurry(); double a2 = next->getlength(); double b2 = a2/2.0; double theta2 = next->gettheta(); double x2 = next->getcurrx(); double y2 = next->getcurry(); polygon_2d poly1, poly2, poly3, poly4; double lamda1, lamda2; lamda1 = 0.0005; lamda2 = 0.00001; if(distance < 2.0*1.5*a1) { ellipse2poly(theta1, a

asp.net mvc - Download functionality MVC 4 -

i have created web api connects users dropbox via oauth. using api interact dropbox, works locally like, when deploy api azure server, unable download. had anticipated happen, api hard codded path on machine. here method using: note: i call method through actionresult, part of mvc portion of project public filesysteminfo downloadfile(string root, string path) { var uri = new uri(new uri(dropboxrestapi.apicontentserver), string.format("files?root={0}&path={1}", root, uppercaseurlencode(path))); var oauth = new oauth(); var requesturi = oauth.signrequest(uri, _consumerkey, _consumersecret, _accesstoken); var request = (httpwebrequest) webrequest.create(requesturi); request.method = webrequestmethods.http.get; var response = request.getresponse(); var metadata = response.headers["x-dropbox-metadata"]; var file = parsejson

verilog - Use SystemVerilog parameters to decide which module to instantiate -

is there way select module want instantiate using parameter values passed parent module? example below module parent (); parameter word = 1; child_`word child (); // not work endmodule if word == 1 , instantiate child_1 module, word == 2 , child_2 module , on. surely, has had need before? if want conditionally instantiate module, need use generate block. generate if (word == 1) begin child_1 child(); end if (word == 2) begin child_2 child(); end endgenerate below full working example. note accounts presence of child_1 , child_2. cannot use parameter part of module type name instantiating. if have n child modules , don't want explicitly enumerate them in generate block, need create helper macro. btw, valid verilog code; doesn't use systemverilog features. module child_1(); initial begin $display("child_1 %m"); end endmodule module child_2(); initial begin $display("child_2 %m"); end endmodule m

JavaScript VS PHP: The same calculation returns different result -

i'm trying simple math (?) in javascript: ( 1023 * 2 ) + 76561197960265728; i did same calculation in php, results different: javascript: 76561197960267780 php: 76561197960267774 (the right result) i tried following: http://jsfiddle.net/yxba4/ is there "limit" in javascript high numbers in calculations? //edit: thanks answers, use bignumber one. my full working code now: on jsfiddle the value 76561197960265730 id greater maximum allowed number size in javascript. note there no real integers in javascript number type 64bit floating point value , platform independent. largest possible integer value 2^53 because 11 bits @ least reserved numbers after comma , signage bit. in example can see doing: alert(76561197960265728); what give error, without calculations. (output: '76561197960265730') in php maximum integer value depends on system. if on 64 bit system, max integer value 2^64 greater (2 * 1023) + 76561197960265728. th

Add images to a database(access) using visual studio -

i'm working on making website sell computer parts. trying display picture along other information table in database. picture column ole object data type. some people have mentioned store images in server , url of images in database. how achieve that? thanks

Get git stash parent commit -

is there way retrieve commit stash created? when creating stash default command git stash original commit saved in stash message, looks like: stash@{0}: wip on master: abc123 message of commit. however, if git stash save 'a stash message' used, commit not appear in stash list: stash@{1}: on master: own message so how retrieved? i'd say git log -1 commitish^ e.g. git log -1 stash@{0}^ otherwise, git log -g --no-walk --parents refs/stash

java - Ant Javac Task Deletes Method -

i have run trully bizarre behavior in java project. situation javac seems removing method class during compilation. the class looks this: public class messedup extends x { //a bunch of variables here //a bunch of methods here public void thisdisappears(string arg){ } //a bunch more methods here } there class instantiates , calls method: public class wontcompile { public void dosomething(){ messedup mu = new messedup(); mu.thisdisappears("something"); } } the first class compiles fine, second doesn't. javac outputs following: [javac] c:\mypath\wontcompile.java:251: error: cannot find symbol [javac] mu.thisdisappears("something"); [javac] ^ [javac] symbol: method thisdisappears(string) [javac] location: variable mu of type messedup i know code fine because have been using in eclipse couple of years (i'm tracking down problem try use ant file ec

sql - Missing int values when importing from csv into MySQL -

i'm building database works helping students build class schedule. i've "succeeded" in importing 2 of 3 columns using csv file i'm having issues importing id numbers fields classes apart of. think has id being int file, since other 2 columns varchar's. having column int makes rest of project incredibly easy... a small portion of csv file reads: 1,afam,2000 1,afam,3150 1,psyc,3150 1,afam,3880 1,afam,4200 2,pols,4200 2,afam,4490 2,afam,6490 2,dram,4490 2,dram,6490 2,afam,4500 then use in mysql: load data local infile 'course_requirements.csv' table courses fields terminated ',' lines terminated '\n'; when go select * courses; view table shows this: id | classname | classnumber | afam | 2000 | afam | 3150 | psyc | 3150 | afam | 3880 | afam | 4200 | pols | 4200 | afam | 4490 | afam | 6490 | dram | 4490 | dram

file io - converting a string to double using atof in c -

i trying read file , store in matrix using c. code have readsparseinput (int nvtxs,int nsize, double vector[], int rowptr[] ,int colind [] , double values[]) { int index,row=0,column=0; int sparsity_value, nvtxs_local; int vector_size =50; double value; double randvect[vector_size]; int length=0; char buf[bufsiz]; file *fp; fp=fopen("/home/lopez380/parallel/m10-a.ij", "r"); index =0; nvtxs_local = 0; rowptr[0] = 0; char *p1; while ( !feof(fp)) { // null buffer, read line buf[0] = 0; fgets(buf, bufsiz, fp); // if it's blank line, ignore if(strlen(buf) > 1) { p1 = strtok(buf, " "); row=atoi(p1); #ifdef debug fprintf(stdout, "row : %d ", row); #endif p1 = strtok(null, " "); column=atoi(p1); #ifdef debug

c++ - Resizing group box after hiding elements? -

in project, have group box few elements may need hidden, other elements above , below. if hide elements sethidden(true), elements hidden leaves large space in between other elements. how able compact group box after hiding elements, there isn't such big space? the reason not in invalidate(). it's because have improper layout on groupbox content. if hide() or show() qwidget qt automatically invalidates top-most parent can affected visibility change. in case qgroupbox missing layout, hide element there nothing change in regards of qgroupbox geometry, that's why don't see expected stretching.

MSVCR100.dll, 0xc000007b Python cx_freeze -

i finished first program! i'm having trouble making binary using python 3 , cx_freeze. binary runs on computer, on computer i'm testing on, message "can't find mscvr100.dll". looked up, , appears visual studio c++ file. i located dllin windows/syswow64 directory, , moved application directory on computer error. (both win 8 64-bit) receive error 0xc000007b, appears 64-bit compatibility error. this website describes receieving these 2 errors in sequence, presumably using c++. found fix installing visual studio. doesn't make sense. very little of information available on either dll or 07b error mentions python or cx_freeze, why i'm stumped. program use qt, feel may have it. ideas?

xcode - Unrecognized Selector Sent To Class Error -

so have class called iap .h , .m file. .h looks this: #import <uikit/uikit.h> #import <storekit/storekit.h> @interface iap : uiviewcontroller <skproductsrequestdelegate, skpaymenttransactionobserver, uialertviewdelegate> +(void)myiapwithitem; @end but when call function myiapwithitem , error. call this: [iap myiapwithitem]; also there item paramater took off test. do have implementation in .m file? // in iap.m @implementation iap +(void)myiapwithitem { // } @end

ruby - Error running WEBrick: Can't Connect to MySQL server -

hey can't figure out fix error message. started ruby rails , trying set can learn more , stuck on trying webrick work. help, thanks! c:\users\brandon\documents\sites\simple_cms>rails server => booting webrick => rails 3.2.13 application starting in development on http://0.0.0.0:3000 => call -d detach => ctrl-c shutdown server exiting c:/ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connec tion_adapters/mysql_adapter.rb:411:in `real_connect': can't connect mysql ser ver on 'localhost' (10061) (mysql::error) c:/ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_ record/connection_adapters/mysql_adapter.rb:411:in `connect' c:/ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_ record/connection_adapters/mysql_adapter.rb:131:in `initialize' c:/ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_ record/connection_adapters/mysql_adapter.rb:38:in `new' c:/ruby1

django - Overriding get_absolute_url from a model for the sitemap -

hey have model can accesed through 2 different urls(depending on domain). , use them in views , templates without problems. when building sitemap get_absolute_url should not return same thought: can subclass model , override get_absolute_url method: class fanpitconcert(bandtasticconcert): def get_absolute_url(self): return ('event_checkout',(),{'artist_slug':self.slug_name, 'year': self.get_date().year, 'month': self.get_date().month, 'day': self.get_date().day, }) class meta: abstract = true and use subclassed model sitemap class class concertssitemap(sitemap): def items(self): return fanpitconcert.objects.all().filter(app='fanpit') but when access /sitemap.xml django still calling get_absolute_url original model is there dark magic django do

sql - Access Query Syntax -

i converting sql based query access runs on sql server. have converted access compatible format, except there problem in putting number of brackets. got following error "syntax error in clause", please help select cint(mid(tc2.childcounter, 7, len(tc2.childcounter)) ) pkchildid ,tc2.visittype ,max(iif( tktresults.taskcounter in ( '001410' ,'001463' ,'001431' ), tktresults.result, null) ) kwa_quitoffered ,max(iif( tktresults.taskcounter in ( '001411' ,'001464' ,'001432' ), tktresults.result, null) ) kwa_quitreferral ((tblconsultations tc2 inner join tblchild tc on tc2.childcounter = tc.childcounter) left join tbldelivery td on td.childcounter = tc.childcounter) left join ( select ttr.resultcounter ,ttr.childcounter ,tkt.visittype ,ttr.result ,ttr.taskcounter tbltaskresults ttr left join tlkpkeytasks tkt on tkt.taskcounter = ttr.taskcounter , tkt.taskcounter in ( '001410'

c - Header file help & structures -

i have header file, dimensions.h , in it: #ifndef dim_h #define dim_h typedef struct dimensions { int width; int height; } dim; dim * getheader (file * fp); #endif from here have c file has this: #include "dimensions.h" . . . dim * getheader (file * fp) { char s[1024]; struct dimensions * d = (struct dimensions *)malloc(sizeof(dimensions)); if (fgets(s, sizeof(s), fp) != null) { printf("%s", s); d->width = atoi(strtok(s, " \n\0")); d->height = atoi(strtok(null, " \n\0")); } return d; } but when run errors dimensions undeclared . played around code changing dimensions dim (still not understanding 2 name 'scheme'. struct dim * d = (struct dim *)malloc(sizeof(dim)); then errors d->width , d->height saying it's dereferencing pointers incomplete types, swapped -> . , error request member width/height in not structure or union . so not sure

java - Why isn't there a JTextField being displayed here? -

public class wasd extends jframe{ ellipse2d.double ball; int ballx = 100; int bally = 100; static jtextfield typingarea; public static void main(string[] args){ javax.swing.swingutilities.invokelater(new runnable() { public void run() { createandshowgui(); } }); } private static void createandshowgui(){ wasd frame = new wasd("frame"); frame.setdefaultcloseoperation(exit_on_close); frame.addcomponentstopane(); frame.pack(); frame.setvisible(true); } private void addcomponentstopane(){ typingarea = new jtextfield(20); //typingarea.addkeylistener(this); } public wasd(string name){ super(name); } } when run program empty window. jtextfield doesn't show up. thanks! (apparently post has code, i'm adding make let me submit. ignore sentence , previous one.) the jtextfield needs added frame after created. private void addcomponentstopane(){ typingarea = new jtextfield(20); frame.

Maven local install artifact does not include remote dependencies after war build -

i building target a.war, , a.war dependent on b.jar. b.jar has been installed locally. b.jar has dependencies in remote repository. when a.war built (which says successful) none of dependencies of b.jar included in final target a.war. you're saying b.jar "installed locally". unclear means. if b.jar maven artifact , "installed locally" means "installed in local maven repository", should take @ b.jar 's pom.xml file , inspect dependencies element. dependencies scope of compile , runtime , test end being included in a.war . you can execute mvn dependency:tree against b module , see how dependencies calculated. if b.jar not maven artifact, maven can't know b.jar 's dependencies are. if happen refer "dependencies" "entries in manifest.mf file", then, well, that's not enough maven.

c++ - pointers to a multidimensional array in classes -

i'm trying bottom of error, wonder if please? i'm having bit of issue array pointers @ moment. have 3 classes, 1 parent, , 2 children speak. 1 of children has 2d array of type struct, , i'm trying access elements of other child. i wondering, code valid correct format/syntax array pointers? ochild1 creates , fills out 2d array, i'm saving pointer in parent, , passing pointer ochild2, , plan on using contents of array further processing. struct boardtile { float fposx; float fposy; boardtiles() { fposx = 0.0f; fposy = 0.0f; } }; class cchild1 { public: boardtile boardtilearray[18][18]; cchild1() { } writeboardtilearray() { (int = 0; <= 17; i++) { (int j = 0; j <= 17; j++) { boardtilearray[i][j].fposx = (float) * 5.0f; boardtilearray[i][j].fposy = (float) j * 7.0f; } } } }; class cchild2 {

Global variable sencha touch 2.1 -

hi need define global variable use in anywhere of application. declare global variable baseurl in app.js . please see below app.js //<debug> ext.loader.setpath({ 'ext': 'touch/src',//location of sencha touch source files 'bluebutton': 'app', }); //</debug> ext.application({ name: 'bluebutton',//application path, classes in app. eg bluebutton.view.main.case sensitive views: ['main', 'bluebutton.couponmain', 'bluebutton.couponlist', 'bluebutton.couponlist2', 'bluebutton.couponlist3', 'bluebutton.transactionmain', ], stores : [ 'bluebutton.globalvariable', ], models : ['bluebutton.globalvariable', 'bluebutton.memberdetail', ], controllers: ['main', 'bluebutton.memberlist', ], requires: [ 'ext.messagebox', ],

Rails Stylesheets on Heroku -

on local machine, when view rails app, stylesheets linked @ /assets/stylesheets/ on heroku, changed /stylesheets/ presumably in public directory , not work! how stylesheets move public/stylesheets on compilation? edit: file directory after rake assets:precompile app assets stylesheets application.css application.min.css home.css home.css.scss home.min.css scaffolds.css scaffolds.css.scss scaffolds.min.css startups.css startups.css.scss public assets application-3701cb84bbc3c20d5a7ec1aac608fbdb.js application-3701cb84bbc3c20d5a7ec1aac608fbdb.js.gz application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css.gz manifest-ad3babc6c84cc0b38f1a98eb594b8235.json rails-afd7b40a0142ed24738b640e78388de4.png here stylesheet link in application.html.haml : stylesheet_link_tag "flat-ui", "home.min", media: "all" gem flatu

php - PNG - preserving transparency -

Image
i'm trying redesign site original square, tile-based rendering of images can more of cutout of image... rid of grid pattern. here's how looked originally... here's rough mock-up of i'm going for: so resaved image thumbnail transparent background... want dog show, , square transparent show site's background underneath. yet when render on page, has black background. i've checked css see if there sort of img class, or class rendered comics... or bootstrap see there may background-color being assigned black (and searched hex code 000000), didn't find one... then found had way thumbnailing script resampling png... since i'm getting black background supposedly transparent image, blame imagecreatetruecolor() returns image identifier representing black image of specified size. . i tried following cheekysoft's question here preserving transparency after resampling... didn't work... 2 main points being: imagealphablending( $ta

java - utilizing JPA Named Queries -

when create entity class database in netbeans, gives me option create named queries persistent fields. accordingly, see these named queries listed @ top of entity class. what these queries, , how can utilize/"call" them? i'm aware question more general preferred on so, i'm happy accept link tutorial answers these questions, i've been unable find 1 myself. see jpa named queries if have: @namedquery(name="country.findall", query="select c country c") public class country { ... } use with: typedquery<country> query = em.createnamedquery("country.findall",country.class); list<country> results = query.getresultlist(); see also: annotation type namedquery tutorial: build web application (jsf) using jpa

r - how to to write a function that demonstrates the central limit theorem with graphics -

i'm trying write function creates animated graphics(without using animation package) users can control inputs(sample size , distribution ect..) demonstrates central limit theorem. in theory want having trouble writing function users can control inputs mentioned above. msample <- na # set empty vector ns <-3 # sample size for(i in 1:500){ sam <- runif(ns) * 10 # draw sample msample[i] <- mean(sam) # save mean of sample h <- hist(msample, breaks=seq(0,10, len=50), # histogram of means xlim=c(0,10), col=grey(.9), xlab="", main="central limit theorem", border="blue", las=1) points(sam, rep(max(h$count), length(sam)), pch=16, col=grey(.2)) # add sampled values points(msample[i], max(h$count), # add sample mean value col="red", pch=15) text(10, max(h$count), paste("sample no", i)) hist(msample[i], breaks=seq(0,10, len=50), # ovelay sample mean xlim=c(0,10), col="red", add=t, # in histogram xlab=""

sqlite - Unable to insert data in sqllite database in android -

i have written contentvalues insertion, code compiles fine data not getting inserted in database. problem here that, tables getting created data not getting inserted, have no clue. my code goes this: has 2 classes first class has database connection information , second class has table creation , data insertion statements. class 2: create table , insert method has content values , returning value main class class 1: database connection , database open command. can please guide new android , trying learn on own. here 2 classes 1 create database connection , other class insert user (using user class object) in database public class userdatahelper extends sqliteopenhelper { public userdatahelper(context context, string name, cursorfactory factory, int version) { super(context, name, factory, version); // todo auto-generated constructor stub } @override public void oncreate(sqlitedatabase database) { // todo auto-generated method stub databas

java - code efficiency, debugging, objects methods, arrays -

i practicing more objects, arrays, , methods. right writing simple book keeping program add book, search books title, author, price, inventory number, , genre. have few questions on one, fixing program (adding book in method fillbook(), two, how delete book object class, , three, how can make program more efficient. researching, , reading on ioexception class. this error getting java:66: error: constructor book in class book cannot applied given types; book tempbook = new book(); ^ required: string,string,double,int,string found: no arguments reason: actual , formal argument lists differ in length 1 error tool completed exit code 1 template object class public class book { private string title; private string author; private double price; private int inventorynumber; private string category; private static int numberofbooks = 0; public book(string booktitle, string bookauthor, double bookprice, int bookinventorynumber, strin

.net - Viewing Row number in GridView Control C# -

Image
i want know if possible add row number each row in gridview control in boxes shown in image. is possible or not? you can use code foreach (datagridviewrow r in datagridview1.rows) { datagridview1.rows[r.index].headercell.value = (r.index + 1).tostring(); }

soapheader - How to get Soap Header at server side with Spring WS Client -

i new web service development. developing web service using spring ws. need add soap header in request below code add header in request @ client side. getwebservicetemplate() .sendsourceandreceivetoresult(source, new webservicemessagecallback(){ public void dowithmessage(webservicemessage message) throws ioexception, transformerexception{ saajsoapmessage soapmessage = (saajsoapmessage) message; soapheaderelement messageid = soapmessage.getsoapheader().addheaderelement(new qname("http://www.w3.org/2005/08/addressing", "messageid", "wsa")); messageid.settext("test security token"); } },result); how header out of request in server side class? i have used eclipse axis plugin generate wsdl class skeleton. using spring 2. i got solution. code have w

c - OpenGL: Save framebuffer to image, file -

i wrote lines of code draw spinning rectangle: #include "glut.h" static glfloat spin = 0.0; /* current angle */ void init(void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel (gl_flat); } void display(void) { glclear(gl_color_buffer_bit); glpushmatrix(); glrotatef(spin, 0.0, 0.0, 1.0); /* rotate oxyz (oz) */ glcolor3f(1.0, 1.0, 1.0); /* bgr-color: white; */ glrectf(-25.0, -25.0, 25.0, 25.0); /* rectangle */ glpopmatrix(); glutswapbuffers(); /* swap 2 buffer */ } void spindisplay(void) { spin = spin + 2.0; /* add 2 degrees every loop action */ if (spin > 360.0) spin = spin - 360.0; glutpostredisplay(); /* alert: redraw */ } /* change window mode */ void reshape(int w, int h) { glviewport (0, 0, (glsizei) w, (glsizei) h); /* change viewport */ glmatrixmode(gl_projection); glloadidentity(); glortho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glmatrixmode(gl_modelview); glloadidentity(); }

java - Comparison method throws general contract exception -

below block of code results in exception indicated, code : collections.sort( arraylist, new comparator() { public int compare( object o1, object o2 ) { typeadaptersort tas1 = ( typeadaptersort ) o1; typeadaptersort tas2 = ( typeadaptersort ) o2; if ( tas1.order < tas2.order ) return -1; else return 1; } } ); exception : java.lang.illegalargumentexception: comparison method violates general contract! @ java.util.timsort.mergelo(timsort.java:747) @ java.util.timsort.mergeat(timsort.java:483) @ java.util.timsort.mergeforcecollapse(timsort.java:426) @ java.util.timsort.sort(timsort.java:223) @ java.util.timsort.sort(timsort.java:173) @ java.util.arrays.sort(arrays.java:65

python - Future Value of yearly investments -

suppose have investment plan invest fixed amount @ beginning of every year. compute total value of investment @ end of last year. inputs amount invest each year, interest rate, , number of years of investment. this program calculates future value of constant yearly investment. enter yearly investment: 200 enter annual interest rate: .06 enter number of years: 12 value in 12 years is: 3576.427533818945 i've tried few different things, below, doesn't give me 3576.42, gives me $400. ideas? principal = eval(input("enter yearly investment: ")) apr = eval(input("enter annual interest rate: ")) years = eval(input("enter number of years: ")) in range(years): principal = principal * (1+apr) print("the value in 12 years is: ", principal) if it's yearly investment, should add every year: yearly = float(input("enter yearly investment: ")) apr = float(input("enter annual interest rate: ")) years = int(i

javascript - how to set the cursor: hand for jquery data table -

i need set cursor: hand particular jquery data table row selection .i try code not working. $(document).ready(function () { $("#table tr").css('cursor', 'hand'); }); this answer , simple : <table class="display" id="table" style="cursor:pointer" width="100%"> </table>

c++ - Reference initialization in C++11 default constructor -

struct x {}; struct y { y() = default; x& x; }; works fine in c++11. wish know how y::x initialized behind scenes? it doesn't compile in major compiler. compile, until of creation of object of type y . if create object of type y , output of clang be error: call implicitly-deleted default constructor of 'y' note: explicitly defaulted function implicitly deleted here y() = default; note: default constructor of 'y' implicitly deleted because field 'x' of reference type 'x &' not initialized x& x; when declare user-defined constructor, empty function, there error, without creation of object. michael burr right. implicitly-defaulted constructor works fine. there no problems diagnostic here, can see.

payflowlink - Receiving Response CSCMATCH=Y while entering 1-digit CSC for Test Credit Card Transaction in PayPal Payflow link -

in setup of paypal manager, have set in security options column, csc = full have entered 1-digit csc number receiving cscmatch=y test credit transaction in paypal payflow link but,i think , transaction should failed while entering 1-digit csc number. csc number should 3-digit or 4-digit number can please explain me how test,whether csc verification works fine or not? please guide me. thanks in advance when testing, there no check tests see if csc 3 or 4 digits when entered. passed on simulator. example value of "9" enter recognized "009". however, once go live value of 9 example come failure since passes on processor , card issuing bank. if wanting trigger csc failure, can enter "999" value. values can enter trigger specific csc matches listed in developers guide.

vb.net - Microsoft SQL Server SELECT statement -

i need retrieving receiptno column database table , saving textbox or label referencing. code: dim da2 new sqldataadapter da2.selectcommand = new sqlcommand("select recepitno receipt (paidfor=@paidfor , regno=@regno)") da2.selectcommand.parameters.add("@paidfor", sqldbtype.varchar).value = cbmonth.text da2.selectcommand.parameters.add("@regno", sqldbtype.int).value = lblregno.text cn.open() da2.update(ds.tables("receipt")) 'da2.selectcommand.executenonquery() da2.selectcommand.executereader() cn.close() you need use sqldatareader , , start loop read values returned example work assuming receiptno text field cn.open() dim reader = da2.selectcommand.executereader() while reader.read() textbox1.text = reader("receiptno").tostring() end while in alternative, if sure query returns 0 or 1 record , interested in receiptno field, can use executescalar dim cmd = new sqlcommand("select recepitno receipt (p

javascript - LESS — data-uri painter mixin -

i’m trying implement mixin customizing underline of text, polyfill css3 text-decoration properties : line, style, color, not supported yet browsers. my idea perform painting proper line in canvas, convert data-uri , use background target element. problem when compiling less node.js, there no canvas in environment. technically use node-canvas perform task, don’t want make dependencies node compile less. is there , simple alternative way paint micro-image somehow , form data-uri based on this, not engaging external libraries or dependencies? solved: png data-generator code , demos here . it’s .png mixin generates indexed-color png, accepts stream of bytes (string) data, 00 - transparent color, 01 - passed color. i not sure how want implement mixin (what want mixin), maybe of can help. first: can use javascript interpolations in javascript implementations of less , using back-ticks. second: there solutions available drawing micro images in less ... came across b

recursion - Prolog maze solving algorithm -

i want implement maze solving algorithm in prolog. therefore searched maze solving algorithms , found following: http://www.cs.bu.edu/teaching/alg/maze/ find-path(x, y): if (x,y outside maze) return false if (x,y goal) return true if (x,y not open) return false mark x,y part of solution path if (find-path(north of x,y) == true) return true if (find-path(east of x,y) == true) return true if (find-path(south of x,y) == true) return true if (find-path(west of x,y) == true) return true unmark x,y part of solution path return false i build matrix in prolog, represents maze , 0 open , 1 wall, example (starting position (2|1) , goal located @ (4|1)): 11111 10001 10101 further more defined clause named mazedataat(coord_x, coord_y, mazedata, result) , gives me value of matrix on position. so far. have problem implementing algorithm in prolog. tried "the dirty way" (translate 1 one use of nested if statements), escalated complexity , don't think it's way in pro

php - Floating number calculation -

this question has answer here: php - display small floating number is 1 answer i have 2 floats: time1: 0.009925 time2: 0.01 when return time1 - time2 this: difference -7.5e-5 time2 - time1 returns 7.5e-5 well. how return normal float? try number_format http://us3.php.net/number-format echo number_format(0.009925 - 0.01,5); //-0.00008

r - How to find the amount of positive numbers -

i new in world of r , , have rather easy questions, troubles me. i have load of numbers: abc=rnorm(100, mean=0, sd=1) i want find out how many of these numbers positive. tried: length(which(abc>0) but didn't work. suggestions? what want is: sum(abc > 0) try abc > 0 first. give boolean vector true abc values positive, length of both abc , boolean vector identical. since true equal 1 , false equal 0, sum of elements of vector give desired count. common trick in r, why felt answer in case. another useful trick doing same mean , e.g. mean(abc > 0) give proportion of values in abc positive. your original approach work (provided correct bracketing), taste which() not function intended such use.

How to set value to `Item` of struct using F# -

how set value item of struct? have tried following 2 types both end value must mutable error. module test1 = [<struct>] type test (array: float []) = member o.item = array.[i] , set value = array.[i] <- value let test = test [|0.0|] test.[0] <- 4.0 module test2 = [<struct>] type test = val mutable array: float [] new (array: float []) = { array = array } member o.item = o.array.[i] , set value = o.array.[i] <- value let test = test [|0.0|] test.[0] <- 4.0 please try replace: let test = test [|0.0|] with: let mutable test = test [|0.0|]

java - Passing a class constant in param -

i've little problem in java. think i'm not still awake. i have 2 classes: the first 1 use constants jar (example : highgui.cv_load_image_color). in second 1 user select in list constant want use. so, second class call method of first one, "stringify" constant use in param. but first 1 can't use string in param has real class constant. i know, that's stupid problem, i'm pretty sure i'm missing obvious. someone have idea deal that? edit : a piece of code more clarity : in class2 class1.finder("c:aaa.jpg","highgui.cv_load_image_color"); in class1 public void finder(string path1, string constant){ mat object = highgui.imread(path1, highgui.cv_load_image_color); //i want use "constant" instead of highgui.cv_load_image_color } this looks design problem. passing strings around, containing name of java constant, not idea. why don't create class, or enum, containing value of color ,