Posts

Showing posts from May, 2012

Java arraylist. I need to pass random numbers to an array list and pass them to another class to check those numbers against another set of numbers -

i confused passing arraylist values 1 class another. used array in these classes before. changed arraylists. i have 2 classes. class has arraylist called "locationcells". programs 3 random digits class , uses inputs , check if inputs match 3 digits. it's more guessing game. import java.util.arraylist; class simpledotcom { private arraylist<string> locationcells; public void setlocationcells(arraylist<string> locs) { locationcells = locs; } public string checkyourself(string stringguess) { string result = " miss"; int index = locationcells.indexof(stringguess); if (index >= 0) { locationcells.remove(index); if (locationcells.isempty()) { result = "kill"; } else { result = &

Detect the underlying OS in a Chrome Packaged App -

since packaged apps can run on different platforms, there way distinguish between windows , mac ? i show vis-à-vis keyboard shortcuts , being able detect os in example showing command ⌘ c or ctrl c accordingly. you can use window.navigator in js. typically have information you're looking for. in window.navigator.platform.

MySQL based variable coming up as NULL in PHP -

the following code in php file building. building dynamic form show product names , other information in html divs. now, coming problem, think relatively simple. trying echo $name; coming empty, put in test echo see if perhaps echoing different place had expected, nope, test came right up. so, did var_dump($name); , came null. define in line before echo it, why coming null? <?php $productquery = mysqli_query($connection, 'select * products pid="$productid"'); $productrow = mysqli_fetch_assoc($productquery); //$dbidlogin = $row5['id']; ?> <?php $name = $productrow['productname']; echo var_dump($name); echo "<br>why?"; ?> update: vardump($productrow['productname']) null. vardump ing $productquery gives this: object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(18) ["lengths"]=> null ["num_rows"]=> int(0) ["ty

GNOME 3 - can't start eclipse no "java" in PATH -

i downloaded eclipse kepler , jdk 1.7 debian-machine , setup eclipse in /usr/local/bin/eclipse and jdk to /usr/share/ when work in terminal, can start fine. now, wanted add link gnome 3 applications menu. cat 1 of files, , changed accordingly. when click on icon in applications-menu displayed with "either jdk or jre must present in eclipse/jre. java not found in path". can go around putting jre folder? how can adjust path when use applications-menu? add eclipse.ini file: --launcher.gtk_version 2

html - Aside elements not showing -

i trying out guide youtube, can't right_aside , left_aside elements show on screen. have been looking hours now, , can't find problem. did miss something? this html: <!doctype html> <html lang="en"> <head> <title>my websitebeta</title> <meta charset="utf-8"> <meta name="keywords" content=""> <meta name="description" content=""> <link rel="stylesheet" type="text/css" href="indexstyle.css" /> </head> <body> <header id="main_header"> <div id="second_header"></div> </header> <menu id="main_menu"></menu> <div id="main_wrapper"> <table width="100%" cellpadding="0" cellspacing=&qu

php - CodeIgniter db->query returning false on SELECT -

this particular application has been in use on year now, , uses several dozen models, , having trouble 1 particular new function. public function get_slides($promo = null) { $sql = "select description alt, image, link " . config_database . ".slides active = '1' , acct_no = '" . api_acct . "' order priority asc;"; $query = $this->db->query($sql); var_dump($sql); var_dump($query); return $query->result_array(); } the results of are: string 'select description alt, image, link web_config_development.slides active = '1' , acct_no = '10001' order priority asc;' (length=143) boolean false followed by: fatal error: call member function result_array() on non-object the query works fine in mysql workbench. in searching issue have come across docs referring true/false responses on insert , delete, not on select. this not make sense ... if have ide

google cast - what video formats supported by chromecast device (mp4,flv,m3u8,flv,avi)? -

how can send mp4,m3u8,rtmp,flv,avi urls iphone chromecast play them? these format supported chromecast ? do need specific iphone app send mp4,m3u8,rtmp,flv,avi urls chromecast? or can send media urls using iphone chrome browser(i not talking screen mirroring here)? if can send direct media urls via iphone chromecast device how sending url of media page instead of actual media url chromecast device play media ? supported media can found on developers site : https://developers.google.com/cast/supported_media_types right support ios native apps casting content iphone/ipad.

xpath - XSLT 2.0: How to replace() part of an element's value and use the result in a select operation? -

i've done bit of xpath in c++ , c# applications, first time using directly in xslt. have xml file formatted this: <toplevel> <foo> <bar>prefix1_taxi</bar> ... </foo> <foo> <bar>prefix1_schoolbus</bar> ... </foo> ... <foo> <bar>prefix2_taxi</bar> ... </foo> <foo> <bar>prefix2_schoolbus</bar> ... </foo> </toplevel> first, want select <foo> elements have <bar> element starts "prefix1_." appears work: <xsl:for-each select="foo[bar[starts-with(., 'prefix1_')]]"> <!-- style , format values child elements of "prefix1_" <foo> --> </xsl:for-each> from inside for-each block, want select <foo> element contains corresponding "prefix2_" element. want pull data out of each see fit. for example, when for-each has selected &quo

parsing - Parse HTML and Get All h3's After an h2 Before the Next h2 Using PHP -

i looking find first h2 in article. once found, h3's until next h2 found. rinse , repeat until headings , subheadings have been located. before flag or close question duplicate parsing question, please take note of question title , isn't basic node retrieval. i've got part down. i using domdocument parse html using domdocument::loadhtml() , domdocument::getelementsbytagname() , domdocument::savehtml() retrieve important headings of article. my code follows: $matches = array(); $dom = new domdocument; $dom->loadhtml($content); foreach($dom->getelementsbytagname('h2') $node) { $matches['heading-two'][] = $dom->savehtml($node); } foreach($dom->getelementsbytagname('h3') $node) { $matches['heading-three'][] = $dom->savehtml($node); } if($matches){ $this->key_points = $matches; } which gives me output of like: array( 'heading-two' => array( '<h2>here first heading t

Use Font Awesome Icon As Favicon -

is possible use font awesome icon favicon icon? know, little icon appears along-side website title in browser tab? yes, is. take screenshot of desired character, cut part want , save image (.ico). seriously now, may want check formats supported each browser: http://en.wikipedia.org/wiki/favicon#file_format_support if characters image or vector files, you'll ok browsers ie (because ms hates you) . otherwise, well, you'll have save them images first.

c# - Using Linq2Twitter and cached OAuth tokens withing a ServiceStack api -

i want use linq2twitter make twitter api call within rest api written in servicestack. i have following information: consumerkey consumersecret cached oauth token when user authenticated our app on site cached oauth tokensecret when user authenticated our app on site how create twittercontext using information can make api calls? looking @ documentation , see webform, mvc, desktop examples, none current use case. don't think can use webform/mvc ones try redirect user authorization page if token/token secret bad. looked @ desktop example , uses pin authorization, don't think can use either. i understand token/token secret may bad if user decides revoke access after have cached these values, need way verify , nothing if fails. this question isn't same, authorizer concept might interesting you: how use linq twitter inside web service? essentially, want instantiate authorizer, assigning values credentials property, this: var auth = new single

java - Map with Class as keys and values having objects operating on key class instances -

i have problem java generics , i'm not sure if it's possible want get. title says let me give example. have this: private static map<class<? extends exception>, exceptiontranslator<?>> map; which being used in following way: map.put(someexception.class, new exceptiontranslator<someexception>()); but enforce translator of exception type passed key, similar on methods: <t extends exception> map<class<t>, exceptiontranslator<t>> map; this of course not correct code , guess generics-foo not strong enough this. possible in java? you can't normal map; have own wrapping method enforces type constraint. see related question java generics enforce same type keys , values of map .

list - Creating a 'grid' of instanecs of a class in Python -

i've been using site lot finding answers various programming questions, , firstly want thank tons of you've been throughout journey of programming. anyway, off question: i want create list of lists of instances of class. wow, mouthful. let me try explain better in code. example, following 3x3 'grid': foo = [bar(), bar(), bar()], bar(), bar(), bar()], bar(), bar(), bar()]] which works perfectly, however, don't know dimensions of 'grid' beforehand. in mind, logical attempt following: foo = [[bar()]*num]*num however, not work properly. believe error python populating 'grid' full of same instance of bar(), problematic. there way 'nice' can complete task of filling grid different instances of bar()? foo = [[bar() _ in xrange(num)] _ in xrange(num)] sequence multiplication makes big grid of references same object. need use list comprehensions evaluate bar() expression repeatedly.

javascript - Transclude in Angular directive putting elements inside a single 'span' -

here directive: myapp.directive('envtable', function () { return { restrict: 'e', replace: true, transclude: true, template: '<table class="table" ng-transclude></table>' }; }); this how use in html (using bootstrap css) <envtable> <tr> <td>os</td> <td>{{env.osname}}</td> </tr> <tr> <td>os version</td> <td>{{env.osversion}}</td> </tr> </envtable> however, code generated looks in chrome: <table class="table" ng-transclude=""><span class="ng-scope ng-binding"> os windows 8 os version 6.2 </span></table> as can see, angular ignored tr/td tags , put contents in single span element. why happening? btw, experiment, tried using transcluded p tag in envtable instead of tr\td tags , in case angular adds ng

Android: How to set Text size of Button on a Dialog programatically? -

i writing android app need put bigger text on buttons of dialog windows programatically. i saw there 2 options set (positive, negative or neutral) buttons on alertdialog.builder : setpositivebutton(charsequence text, dialoginterface.onclicklistener listener) setpositivebutton(int textid, dialoginterface.onclicklistener listener) , in option 1, can set text , in option 2, can use resource id of text value. none of options allow me add styled button. is there other way? there no need create custom view. the dialog builder create method returns alertdialog object gives access buttons. alertdialog.builder alert = new alertdialog.builder(your_context); alertdialog dialog = alert.create(); // positive dialog.getbutton(dialoginterface.button_positive).settextsize(the_size); // negative dialog.getbutton(dialoginterface.button_negative).settextsize(the_size);

php - form select with ajax -

i'm building bug tracker tool. when create project, can change project status (open, in progress & finished) on project page using select form: <form action="classes/projectstatus.class.php" method="post"> <label> change project status </label> <select name="status" id="status"> <option value="open">open</option> <option value="in progress">in progress</option> <option value="finished">finished</option> </select> <input type='hidden' name='hdnid' value="<?php echo $id;?>"> <input class="small button" value="change status" type="submit"> </form> this projectstatus.class.php file: $status = $_post['status']; $id = $_post['hdnid'

jenkins - m2 release plugin couldn't recognize assembly file with parameterized name -

in pom.xml file, using assembly plug in. want build assemble things based on assembly file, name parametrized. build works fine. however, if use m2 release plug in using perform release action in jenkins, release plugin not substitute value $env , pick assembly.xml file. following exception. caused by: org.apache.maven.plugin.assembly.io.assemblyreadexception: error locating assembly descriptor: src/main/assembly/${env}.xml i have attached log , pom file. pom file build portion: <plugin> <artifactid>maven-assembly-plugin</artifactid> <version>2.4</version> <executions> <execution> <id>jar-with-dependencies</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration>

CAML Query throwing error -

pretty new caml queries, trying query list based on status = completed , date range. it throwing following error "unexpected error: 1 or more field types not installed properly. go list settings page delete these fields. microsoft.sharepoint" status , created both system columns, pretty sure have field names correct have tested query without date range , runs expected, think problem somewhere in between , . have read, created expects time follow date. query below, appreciated. <where> <and> <and> <eq><fieldref name="status" />value type="choice">completed</value></eq> </and> <geq> <fieldref name="created" /><value includetimevalue="true" type="datetime">2013-07-02t00:00:01z</value> </geq> <leq> <fieldref nam

php - Using a regular expression to validate an email address -

Image
over years have developed regular expression validates email addresses correctly, assuming don't use ip address server part. i use in several php programs, , works of time. however, time time contacted having trouble site uses it, , end having make adjustment (most realized wasn't allowing 4-character tlds). what best regular expression have or have seen validating emails? i've seen several solutions use functions use several shorter expressions, i'd rather have 1 long complex expression in simple function instead of several short expression in more complex function. the fully rfc 822 compliant regex inefficient , obscure because of length. fortunately, rfc 822 superseded twice , current specification email addresses rfc 5322 . rfc 5322 leads regex can understood if studied few minutes , efficient enough actual use. one rfc 5322 compliant regex can found @ top of page @ http://emailregex.com/ uses ip address pattern floating around internet bu

SSH tunnel and Python 3.3 -

i need create application (python 3.3 strictly) users save/load settings online remote hosted database. not wish change database listening other thing localhost security reasons, assume best solution me make program create ssh tunnels before saving/loading happens. would policy make database unsecure? how make work? tried installing paramiko not python 3+ ready. thought maybe include application's installation, putty tray , proper scripting can create tunnel, im looking clever , efficient here. ofcourse really prefer avoiding tray icons or shells appearing every time tunnel activate. im asking here can hear opinion expirience. im lacking of :) . suggestion? thx in advance i dealing similar problems @ moment (trying use docker's remote api @ moment doesn't offer authentication). using bgtunnel , though i'm getting errors , (usually resolved webpage refresh) - @ first glance due trying establish connection when 1 exists. can solved using thread.isaliv

ios - What are some of the use cases of explicitly creating a CATransaction? -

core animation docs state that: "one of main reasons use transactions within confines of explicit transaction, can change duration, timing function, , other parameters." doable explicit caanimation. of reasons why want create catransaction?

what is the PHP equivalent of Javascript Number.MIN_VALUE? -

what php equivalent of number.min_value? i able find php constants, unable spot php_ini_min. http://php.net/manual/en/reserved.constants.php such constant exist? any idea? here numbers getting javascript: number.max_value=1.7976931348623157e+308 number.min_value=5e-324 here numbers php: define("php_int_min", -1 - ( pow(2, 8*php_int_size - 1) - 1) ); php_int_max = 2147483647 php_int_min = -2147483648 they not coincide well, easy calculate. divide 1.0 2.0 until reaching zero, number right before 0 equals number.min_value . see this codepad php <?php $a = 1.0; while (1) { $b = $a; $a /= 2.0; if ($a == 0.0) break; } var_dump($b); ?> output float(4.9406564584125e-324) but remember give smallest positive number on server not client . if want interpret number coming client-side, better send number.min_value client server through or post request.

Starting multiple files through batch file -

i trying write batch file when invoked through cmd launch 3 programs consecutively. here have far: cd c:\program files\cpuid\cpu-z\ cpuz.exe cd "c:\program files\core temp\" "core temp.exe" cd "c:\program files (x86)\evga precision x\" evgaprecision.exe the problem when execute batch file launches first program , pauses. when close first program go on second command. keep in mind each of these programs require permission user run through "do want allow following program make changes computer?" thing. the ideal scenario have program launch @ same time out prompting permission, if impossible, i'm fine clicking "yes" each 1 of them long still launch consecutively , don't have close each program. this should looking for: start "" "c:\program files\cpuid\cpu-z\cpuz.exe" start "" "c:\program files\core temp\core temp.exe" start "" "c:\program files (x86)\evga

function - jQuery and passing variables from decision structure -

i'm using jquery , i'm having issue passing variable function value of checkbox. can pass function switch statement, not if then. i'm looking assistance why. $("input[type=checkbox]").change( function() { if($(this).is(":checked")){ passvar = ( $(this).val() ); addtoorder(passvar); alert(passvar); } else { alert("off"); } }); any assistance appreciated. its working fine. see fiddle $("input[type=checkbox]").change( function() { if($(this).is(":checked")){ passvar = ( $(this).val() ); alert(passvar); addtoorder(passvar); } else { alert("off"); } }); function addtoorder(t) { alert(t); tempstring = t.split(","); receipttext = receipttext + "<br>" + tempstring[0] + " - " + tempstring[1]; //alert(t); }

Transfer data from access table into mysql table -

i'm trying transfer data access table mysql table using c#, since have big data can't transfer of data @ once using query select * record so instead used query transfer data datatable ds = tempaccesscon.exexutesql("select top 100 * record time between #7/1/2013# , #7/31/2013#") but problem query doesn't return of dates between #7/1/2013# , #7/31/2013# please me transfer of data without repeating rows , missing row thank maybe date field datetime type try datatable ds = tempaccesscon.exexutesql("select top 100 * record time between #7/1/2013 00:00:00# , #7/31/2013 23:59:59#")

java - Return type with try-catch-finally -

this question has answer here: java's return value in try-catch-finally mechanism 4 answers i have tried following code snippet: private integer getnumber() { integer = null; try { = new integer(5); return i; } catch(exception e) { return 0; } { = new integer(7); } } this method returns 5 , not 7. why returns 5 , not 7? thanks in advance. this happens because finally block of try..catch..finally runs after code within try..catch has completed (be or not); in case of code when return i has occured. because of behaviour value of i has been placed return variable of method before assign new value of 7 it. following work: private integer getnumber(){ integer = null; try { = new integer(5); } catch(exception e){ = new integer(0); } finally{ = new integer(7); }

hibernate - Lucene not indexing table -

i hope can me, have 10 tables indexed lucene, 1 table not indexed , cant figure out why. setup glassfish 3.1.2 hibernate 4.2.3. i'm using jpa in stateless beans, entity annotated @indexed , @field. other tables indexed 1 won't index , i'm not getting errors in log file. has run same problem ? first of all, use program called luke ( https://code.google.com/p/luke/ ), check index , see, if these tables indexed or not? if yes, , 9 tables indexed, not last - need check configuration, find difference in classes

Maven direct and transitive dependencies resolution -

artifact_a has both direct dependency , transitive dependency on artifact_b within same scope. does direct dependency precede transitive dependency , or 1 of higher version prevail? is there reference better illustration on maven dependencies resolution chapter maven reference manual - project dependencies ? the dependency-resolution mechanism can complicated. if there's managed version ( dependencymanagement ), take precedence. speaking, maven use highest-requested version satisfies of requirements (for example, servlet package might require [2.4,3.0) while package requires 2.5 , maven use 2.5). if maven can't find such version (in above sample, if second package required [3.0,4.0) ), produce error. if have specific issue you're running into, feel free post question details.

android - removing, restoring items in ListView and database -

i have listview items added dynamically. when item added, added listview , inserted sqlite database items in list can saved. can remove specific items getting postion if item , removing information. this how add items (i use multiple classes): in datamodel.class : public void additem(object data) { string string = string.valueof(data); mplanetslist.add(createplanet("planet", string)); history history = new history(); history.getdatahashmap().put("planet", data); history.addtohistorydb(); mhistorylist.add(history); if (null != monitemaddhandler) { monitemaddhandler.onitemadded(data); } } in history .class: public void addtohistorydb() { mysqliteopenhelper mdbhelper = mysqliteopenhelper.getinstance(); sqlitedatabase db = mdbhelper.getwritabledatabase(); contentvalues values = getcontentvalues(); rawid = (int) db.insert(table_name,

tomcat - AWS Data Transfer issue -

i've spot problem in aws cloud. i'm getting big bill data transfer(month data transfer out). ec2 instance contains tomcat server mobile application. have 1.5k users , use rest webservices. i've setup benchmarks , showed send 1 - 3gb per month responses. got bill 9.5 tb data transfer out. few days ago monitoring instance , see server output trafic approx 200gb/day. don't know, maybe hacked, use security groups on aws , users have access 80 port , ip has access 22(ssh) only. can find solution? or maybe have suggestion can be? lot. i'd enable access logging on tomcat, , ensure isn't data coming out of tomcat. should able sum amount of traffic access logs , determine if tomcat source. i assume don't have apache in front, , you're using elastic load balancer translate 80 8080? if have apache or similar in front, enable access logging on that. don't running tomcat root on port 80. what other components using in setup? check isn't a

How to change commit tag (author name) in CVS of a file already committed? -

i didn't have own development environment, , copied vm different user. had did cvs update , did cvs commit . i did not observe, cvs\root file had username of other user instead of mine, , changes committed. in same way, there has been multiple commits me, , there has been changes on top of other developers. now, how change author name of committed file other user's name name? the short answer can't. cvs not provide capabilities edit history. the longer answer sort of can if edit ,v file directly in cvs repository. requires have access server containing cvs repository. the ,v file contains revision history of file working on , contains entries this: 1.2 date 2005.11.20.22.43.32; author burhan; state exp; branches; next 1.1; i suspect able change author there have not tried myself cannot confirm if work. note not recommend doing unless absolutely have have potential corrupt revision history. you'll have balance risk vs desire hav

scalatra - No params in route for ajax post -

when post data scalatra route, no params seen. on client: $.ajax({ type: 'post', url: window.location.origin + '/move', contenttype: 'application/octet-stream; charset=utf-8', data: {gameid: 1, from: from.touppercase(), to: to.touppercase()}, success: function(result) { console.log('ok posting move', result); }, error: function(e) { console.log('error posting move', e); } }); in dev tools network view: payload gameid=1&from=b1&to=c3 in scalatra route: params("gameid") // -> java.util.nosuchelementexception: key not found: gameid however, if change ajax call removing data field , setting url to: type: 'post', url: window.location.origin + '/move?gameid=1&from=' + from.touppercase() + '&to=' + to.touppercase(), then scalatra can see params ok, though seems wrong put params in query string post. why can't

keyboard shortcuts - Can't remap Ctrl+W to the F2 key in autohotkey -

my mind blown; seems easiest thing but: w::f2 works ^w::f2 doesn't work no matter what if mapped ctrl + w , doesn't perform it, doesn't press f2 either. from file documentation should work... it's not here, either. documentation says "autohotkey's remapping feature described below not pure , effective ...." expected direct remapping doesn't work. use instead ^w::send,{f2}

Marking one article as Featured to show on the Taxonomy Landing Page in Drupal 7 -

on taxonomy (category) landing page, listing articles in chronological format. want show 1 article (that select) or latest 1 featured article on landing page. featured article, i'd show following custom fields within article:- featured image title couple of other custom fields my question how probable customized loop or module. many help. create view (block) , setup fields. add taxonomy term id contextual filter choose "provide default value" in "when filter value not available" section choose "taxonomy term id url" in type. save contextual filter , save view. have view block display on taxonomy term pages.

gwt - Font Size in EM does not behave as expected for a VerticalPanel -

i wish fix 1 font-size in 'px' in start (let's onmoduleload) , have rest of widgets , themes in 'em'. me change , feel different screen resolutions dynamically. here's sample code trying out. root = rootpanel.get(); root.getelement().getstyle().setfontsize(40, unit.px); root.setsize("100%", "100%"); label l = new label("hello world"); l.getelement().getstyle().setfontsize(1, unit.em); root.add(l); verticalpanel vp = new verticalpanel(); root.add(vp); l = new label("hello world"); l.getelement().getstyle().setfontsize(1, unit.em); vp.add(l); ideally both labels of same font-size. second 1 far smaller first one. following code, works expected. root = rootpanel.get(); root.getelement().getstyle().setfontsize(40, unit.px); root.setsize("100%", "100%"); label l = new label("hello world"); l.getelement().getstyle().setfont

error:AttributeError: 'super' object has no attribute 'db_type' when run "python manage.py syncdb" in django -

i working on django project , have 2 databases "mysql " , " neo4j" .i install neo4django package , change setting.py below: setting.py databases = { 'default': { 'engine': 'django.db.backends.mysql', 'name': 'mylifetime', 'user': 'root', 'password': 'mypassword', 'host': '', 'port': '', } } neo4j_databases = { 'default' : { 'host':'localhost', 'port':7474, 'endpoint':'/db/data' } } and models have neo4j models: models.py: from neo4django.db import models class user(models.nodemodel): ... #my user models ... .... class post(models.nodemodel): ... #my post models ... when run command python manage.py syncdb got error : $ python ../manage.py syn

javascript - Unable to uglify js script with guard-uglify -

i have bunch of javascript files concatenated 1 file guard , afterwards file scripts gets uglified. i'm getting following error when uglify process starts. error - uglifying public/js/app.js failed: "\xef" on us-ascii i've narrowed problem down 1 specific file, if leave file out of concat function uglify process succeeds. but weird thing is, when delete code failing file, still fails same error. whats going on here? the file giving problem canvasjs library. after bit of degugging found out character being throwing error ‰ it's part of regex , on place part of if statement. why character throwing error on uglifyjs?

c# - The SqlParameterCollection only accepts non-null SqlParamter type objects, not String objects -

sqlcommand cmd = con.createcommand(); cmd.commandtext = "insert records ([student id], [first name], [last name], " + "[middle initial], gender, address, status, year, email, course, " + "[contact number]) values ( @student id, @first name, @last name, " + "@middle initial, @gender, @address, @status, @year, @email, " + "@course, @contact number)"; sqlparameter p1 = new sqlparameter("@[student id]", sqldbtype.int); p1.value = textbox1.text; cmd.parameters.add("1"); sqlparameter p2 = new sqlparameter("@first name", sqldbtype.varchar); p2.value = textbox2.text; cmd.parameters.add("p2"); sqlparameter p3 = new sqlparameter("@last name", sqldbtype.nvarchar); p3.value = textbox3.text; cmd.parameters.add("p3"); sqlparameter p

Using hibernate to get 2 objects which both are linked with a logical foreign key (reference key) -

i new hibernate , tables follows: tb_user userid (pk) userfirstname userlastname userlogin userpwd tb_order orderid (pk) userid (logical fk) orderdate orderremarks my dao class's function: public list<tborder> getuserordering(tborder tborder) throws exception{ criteria _criteria = getsession().createcriteria(tborder.class); if(tborder.getuserid() != null) _criteria.add(restrictions.eq("userid", tborder.getuserid())); return (list<tborder>) _criteria.list(); } my entity class: class tborder { long orderid; long userid; public tborder(){ } public tborder(long orderid, long userid){ this.orderid = orderid; this.userid = userid; } public long getorderid() { return orderid; } public void setorderid(long orderid) { this.orderid = orderid; } public long getuserid() { return userid; } public void setuserid(long userid

asp.net - How to create jQuery function to validate custom validator on ASP checkbox list -

here code checkbox list: data bounded table <asp:checkboxlist id="cbl_appliancepresent" clientidmode="static" cssclass="cbl_appliancepresent" runat="server" datatextfield="appliance" datavaluefield="applianceid" repeatdirection="horizontal"> </asp:checkboxlist> here custom validator : <asp:customvalidator id="specifyappliances" clientidmode="static" runat="server" enableclientscript="true" errormessage="please select vacant-not secure reasons" font-bold="true" clientvalidationfunction="validatenotsecure" forecolor="red" font-size="small"></asp:customvalidator> function: function validatenotsecure(source, args) { var options = $('.cbl_appliancepresent'); (var = 0; < options.length; i++) { if (optio

xml - Extract the value of namespace declaration using xpath -

i've got xml document declaration <document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.04" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="urn:iso:std:iso:20022:tech:xsd:pain.008.001.04 file://be-file01/tverschu$/sr%20(standards%20release)/sr2013/iso/payments%20initiation/sr2013_mx_schemas_paymentsinitiation/pain.008.001.04.xsd"> effectively want use xpath(1.0) within xslt trasnfromation @ contents of either xmlns namespace attribute, or xsi:schemalocation attrubite, can strip out / recreate name of xsd file. using: /*/namespace::* gives me http>//wwww.w3.org/xml/1998/namespace but whatever try don't seem able actual contents of these attributes, ideas? you should able query @schemalocation using /*/@xsi:schemalocation . xmlns "attributes" namespaces declarations, not attributes. cannot query them such. /*/namespace::* works totally fine me. /* querying <

ios - Cant drawing rectangles over image in custom UIView -

i have scene of storyboard uiviewcontroller. inside scene have uiimageview contains background image, uibutton, , uiview. this uiview have overrided drawrect method with: - (void)drawrect:(cgrect)rect { [super drawrect:rect]; [self setneedsdisplay]; cgfloat height = self.bounds.size.height; cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextclearrect(context, rect); cgcontextsetfillcolorwithcolor(context, [uicolor graycolor].cgcolor); cgfloat barwidth = 30; int count = 0; nsarray *values = [nsarray arraywithobjects:@1, @0.5, nil]; (nsnumber *num in values) { cgfloat x = count * (barwidth + 10); cgrect barrect = cgrectmake(x, height - ([num floatvalue] * height), barwidth, [num floatvalue] * height); cgcontextaddrect(context, barrect); count++; } cgcontextfillpath(context); } my question is: how can set image background of custom uiview , drawing rectangles on it? regards

ruby - Rails currency exchange gem that works? -

just wondering if has used currency exchange ruby gem gets exchange rates external api , works. have tried following gems have not been able of them function described: goog_currency, yahoo_currency, google_currency, yahoo_finance_currency one of these uses deprecated code , hence not work correctly. i trying display currency exchange rate in rails view has been grabbed external api. i have considered trying parse json yahoo/google finance urls seems harder should. i picked google_currency list popular , has been maintained. worked fine me, ran code synopsis without problem. if saw message: you using old or stdlib version of json gem please upgrade recent version adding gemfile: gem 'json', '~> 1.7.7' then may need update copy of multi_json avoid json deprecation warnings: gem install json gem install multi_json which should (at time of writing) install json 1.8.0 , multi_json 1.7.8. or of course, if project, should able pick these

python - How to install FLANN and pyflann on Windows -

how can setup flann on python (pyflann) on windows? know flann in opencv need standalone version. instructions here suggest compiling flann binary or downloading version pointclouds can't use of these. i compiled source after tried run setup.py got error: > c:\python27\flann-1.8.4-src\src\python>python setup.py install running install running build running build_py traceback (most recent call last): file "setup.py", line 27, in <module> package_data={'pyflann.lib': ['libflann.so', 'flann.dll', 'libflann.dll', 'libflann.dylib']}, file "c:\python27\lib\distutils\core.py", line 152, in setup dist.run_commands() file "c:\python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) file "c:\python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() file "c:\python27\lib\distutils\command\install.py", line 563, in run self.run_co

jquery - Search an associate array / hash in Javascript -

this question has answer here: finding matching objects in array of objects? 2 answers i have array looks var data = [ {"target": "production", "datapoints": [[165.0, 136], [141.0, 176], [null, 176]]}, {"target": "test", "datapoints": [[169.0, 100], [151.0, 160], [null, 120]]}, {"target": "backup", "datapoints": [[1.0, 130], [32.0, 120], [13.0, 130]]} ] is possible search array return hash contains example "production" {"target": "production", "datapoints": [[165.0, 136], [141.0, 176], [null, 176]]} i looked @ http://api.jquery.com/jquery.inarray/ didn't know how use it. you can do: var target = "production"; var result = $.grep(data, function(e){ return e.target == target; }); console.log(result);

utf 8 - JPA utf-8 characters not persisted -

i have simple web application use jpa. i have entity called blogentry . when submit new blogentry, when debug application see utf8 characters fine. for example em.persist(entity); in line, if debug example: entity.gettitle() i can successfuly see utf-8 characters in ide. ( ğğ, or çç ) also, database has utf8 collation , can insert utf-8 characters fine sql using "insert into..." however, jpa, characters persisted ???? why might be? regards. here persistence.xml: <?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="persistence"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <class>com.tugay.blog.core.model.blogentry</class> <properties> <property name="javax.persistence.jdbc.driver" value="com.mys

PHP: Create ajax auto-suggest -

i create simple ajax auto-suggest can retrieve data database. you can see here : index.php <html> <head> <script type="text/javascript"> function suggest() { var txtsearch = document.getelementbyid('txtsearch').value; if (window.xmlhttprequest) { xmlhttp = new xmlhttprequest(); } else { xmlhttp = new activexobject('microsoftxmlhttp'); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid('mydiv').innerhtml = xmlhttp.responsetext; } } var target = 'include.inc.php?txtsearch=' + txtsearch; xmlhttp.open('get', target, true); xmlhttp.send(); } </script> </head> <body> <input type="text" id="txtsearch" onkeyup="suggest();"/> <div id="mydiv"></div> </body> </html> incldu

php - MySQLi "bind_param" in cycle -

why can not use "bind_param" this? there alternative ways use binding in cycle? $insert = $this->db->prepare('insert '.$tablename.' ('.implode($colum, ', ').') values ('.implode($placeholder, ', ').'); '); ($i=0;$i<$count;$i++) { $insert->bind_param($query[$i]['type'], $query[$i]['value']); } well, error makes pretty clear: $placeholder array doesn't contain same number of placeholders have parameters in $query array. check code building $placeholder , $query arrays. if can't find problem, add piece of code in question. ok, sorry, i'm not used mysqli . apparently have pass parameters in 1 call bind_param . that's annoying, there's workaround. the call_user_func_array function allows pass arguments function array. so can: construct string of types looping through parameters; make array $params string @ index 0, , parameters' values @ sub

Ruby string include? all characters -

is there in ruby returns true if string contains whole word, in case 'hello'. dont want include? returns true if pieces present: 'hello whats up'.include? 'll' => true > 'hownowbrowncow'['now'] => "now" # nil if not found and if want require word boundaries... 'hownowbrowncow'[/\bnow\b/] => nil it doesn't matter if returns true or false, since other nil or false fulfill conditional test. if true , false, well, can turn arbitrary expression true or false number of ways, 1 way is: 'now'.nil? => false !'now'.nil? => true

upgrade redis 2.4.14 to redis 2.6.14, command "service redis start" always hangs -

i installed redis2.4.14 before. yestoday, got redis2.6.14, , directly "cd redis-2.6.14/src ; make && make install". , removed dump.rdb , redis.log of redis-2.4.14. upgraded configuration file 2.6.14. added redis service when installed redis-2.4.14. execute command "service redis start", hangs no "ok" information. [tys@localhost bin]# service redis start starting redis-server: i can use redis nomally [tys@localhost redis]# redis-cli redis 127.0.0.1:6379> set name tys ok redis 127.0.0.1:6379> name "tys" but if type "ctrl + c" or "ctrl + z", "redis-cli" hang on. when reboot system, linux boot process hangs on "starting redis-server" (sorry, "young" post image. https://groups.google.com/forum/#!topic/redis-db/iqnlyaawe9y ) but can ssh it.it's virtual machine. there no error in redis.log. [1420] 11 aug 04:27:05.879 # server started, redis version 2.6.14 [1420] 11 a

image - Detecting a large square region of same color in a video -

Image
imagine there video , in video there "pixelated" region region of 100×100 pixels occupied smaller 25×25 squares of same color. within video (which may contain of colors of edge squares, i.e. black, red, blue, etc background): i need find individual regions (which square) outline entire region occupied these squares. full region not have square or of particular shape, there 5 "large-pixels" in cross shape. i seeking algorithm that, preferably stand alone (without external libraries). have no preference of language (anything python java or lisp c++). p.s. video can have dimensions, example 500×600 pixels or 1920×1080, size of single "large-pixel" relative size of video, in other words 500×600 may have 25-high , 1920×1080 may 100-high. p.s.s. issue neighboring "large-pixels" may of same color , should detected individual squares.