Posts

Showing posts from January, 2012

php - if statement does not work inside while loop which is inside for loop -

i've spent hours on problem , , searched answer online, found nothing helped me. so, making filter hotel website, , 1 of criteria hotel search district hotel located. use method: <?php if (isset($_get['district1'])){ $district1= ($_get["district1"]); }else ($district1=0); if (isset($_get['district2'])){ $district2= ($_get["district2"]); }else ($district2=0); if (isset($_get['district3'])){ $district3= ($_get["district3"]); }else ($district3=0); if (isset($_get['district4'])){ $district4= ($_get["district4"]); }else ($district4=0); ?> where $district1, $district2, $district3, $district4 4 different districts of city. what trying build district variables using for loop (the digit @ end of variable name ascending 1 : $district1.. 2 .. 3 .. 4 ), then place these district variables in if clause inside while loop follows: <?php $districts_filter_query="

Objective-C: How to check if date occurred between two dates? -

i searched question before , found: if (([datetocompare compare:4hoursearlier] == nsorderedascending) && ([datetocompare compare:specifieddate] == nsordereddescending)) { nslog(@"datetocompare between 4hoursearlier , specifieddate"); // } unfortunately, seems not work (the nslog never gets printed). i have loop goes through array (which contains dates). need check if specified date within 4 hours of date. have (pseudocode): specifieddate = date specify; datetocompare = current date gathered in loop; 4hoursearlier = 4 hours before specifieddate; how can check if specifieddate within 4 hours of datetocompare (a date gathered array/for loop)? i think got comparisons wrong way around. exchange nsorderedascending , nsordereddescending in condition. my memory aid is [obj1 compare:obj2] == nsorderedascending : obj1, obj2 ascending sequence [obj1 compare:obj2] == nsordereddescending : obj1, obj2 descending sequence therefore, check if

iphone - iOS stream song from url with http header -

i have server has songs on it. stream server iphone , realize can avplayer , initwithurl . however, catch url requires authentication header. there way send http header song stream it? if not, know of workarounds? thanks. do danh said - use nsmutableurlrequest pass auth data, , nsurlconnection write audio data file. can check how data you've downloaded in didreceivedata:. once file "big enough" (you'll have decide means), can play using avaudioplayer's initwithcontentsofurl (pass file url there). i've got app on store using technique , works fine. 1 piece of advice, files cause avaudioplayer return bizarre error ([error code] == 2003334207). if that, wait until file downloads completely, play.

Heroku "We're sorry, but something went wrong" for a simple rails app -

this first time using heroku, don`t know errors mean. used rails , bootstrap create site (with links, no dynamic features). ←[36m2013-04-17t21:47:59.413491+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>' ←[36m2013-04-17t21:47:59.413491+00:00 app[web.1]:←[0m script/rails:6:in `require' ←[36m2013-04-17t21:47:59.413491+00:00 app[web.1]:←[0m script/rails:6:in `<main>' ←[36m2013-04-17t21:47:59.413199+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands/server.rb:59:in `start' ←[36m2013-04-17t21:47:59.419753+00:00 app[web.1]:←[0m exiting ←[36m2013-04-17t21:48:00.637162+00:00 heroku[web.1]:←[0m process exited status 1 ←[36m2013-04-17t21:48:00.653135+00:00 heroku[web.1]:←[0m state changed starting crashed ←[36m2013-04-17t21:48:04.188831+00:00 heroku[web.1]:←[0m error r12 (exit timeout) -> @ least 1 process failed exit within 10 seco

php - Nesting controllers in Code Igniter -

i'm using ci class extends core ci_loader allowing me load template within template: $this->load->view('wrapper','category',$data); this loads template of category in master template wrapper. this means in controllers have make sure populate data needs fed in wrapper view inner view. of classes include methods needed pull in stuff dynamic navigation , categories displayed in wrapper view...then in controllers generating inner view have call these methods , assign them output. my controllers can end looking this: public function product_listing($store,$category,$product_slug) { //these needed populate wrapper view $data['categories'] = $this->get_categories(); $data['navigation'] = $this->navigation(); $data['cart'] = $this->get_cart(); $data['store'] = $store; //then needed inner view $data['products'] = $this->model_products>get_product($store,$category,$p

popup - Requery subform (1) after adding a new subform (1) record via pop-up subform (2) - Access 2007 -

i have form 2 subforms (1 , 2). subform 1 stores data continously account breakdowns. using pop-up subform (subform 2), user enters data change or update account breakdown stored on subform 1. on submit, information stored in sub-table linked subform 1, data not refresh , add new information in new record in subform 1 unless manually click refresh button in home tab. so far, have tried following code on form_afterupdate of subform 2, requery subform 1 automatically creates run-time error (2450) when main form closed: private sub form_afterupdate() on error goto err_form_afterupdate forms!frmspendplan!frmspendplansub.form.requery exit_form_afterupdate: exit sub err_form_afterupdate: msgbox err.description resume exit_form_afterupdate end sub if has way automatically requery subform 1 data once subform 2 submitted without creating error please let me know, appreciate can provide. thanks! i have same problem sometimes! form doesn't refresh properly.

Reshape 1xn vector with matlab -

hii have vector dimension of 1x55 , want reshape row row , 11x5 matrix. can me ? here´s example: a=[1,2,3,4,5,6,7,8,9...55] after reshaping b=[1,2,3,4,5 6,7,8,9,10 11,12,13... ... 55] thanks lot reshape , transpose: reshape(a, 5, 11)'

Switching between different JMS implementations - Eclipse RCP -

i have eclipse rcp application connects jms broker (sonicmq) on app start up. have sonicmq jar part of bundle classpath , broker connection global i.e same broker used through out application. now have requirement switch between active mq & sonic mq jms brokers. planning control switch using eclipse preference api.. once appropriate broker selected in preference window, can ask user restart application application booted fresh designated broker connection. i connect either sonic mq or active mq based on user preference.. having both activemq & sonicmq jar part of plugin classpath.. in code, referring javax.jms apis. as far know, classpath scanned based on order given in bundle classpath. so, if code refers javax.jms.apis , creating topic connection, use designated broker (say sonicmq) , bundle class path should have sonic mq jar ahead of active mq right? having in mind, how can control bundle classpath precedence order on application start up? any appreciated.

c# - Cheap way to wrap .exe for Custom Tool? -

i have custom script language , compiler (an exe written in c) turns language in c# code. i'd hook script compiler custom tool on script files in solution, , have generate c# code behind. i've seen articles , tutorials online , , have generate com interfaces , register custom dll registry , gac, , don't want deal that. is there wrapper or hack or 3rd party plugin somewhere make easier? if there way run batch script custom tool, , have code behind file generated stdout of that, pipe file compiler stdout. first off, know said don't want register through msft way, suggest reconsider. details here: http://msdn.microsoft.com/en-us/library/vstudio/bb166527.aspx now got out of way, suggestion you: put exe in fixed location (best spot right in root of solution or repository). next, run tool manually once, way have .cs files or whatever generating can add them solution. way c# compiler knows there , have hit build button , it'll have files build.

linq - Getting Sum of Multiple Columns and summing up values for the same id from a list -

i have list returns. grade col1 col2 col3 col4 t1 2 1 3 2 t2 2 5 1 5 t1 2 6 4 4 first, need add values in each row corresponding grade , have grade sum(sum of 4 columns) t1 8 t2 13 t1 16 and result should like: grade total t1 8+16 = 24 t2 13 i'm newbie linq., can suggest me approach using linq, returning result.?? thanks following linq query group rows grade , produce sum of columns each grade: var query = r in list group r r.grade g select new { grade = g.key, total = g.sum(x => x.col1 + x.col2 + x.col3 + x.col4) };

pydev eclipse unresolved import within package -

i have basic project hierarchy goes project->src->package->module. when try import module module within same package, unresolved import error. made sure interpreters system pythonpath includes /site-packages folder. tried rescanning folder seen here: pydev doesn't find python library after installation , , tried removing , adding interpreter again force rescan. importing works in terminal, not in eclipse, sys.path same in eclipse , in terminal, except when view sys.path through eclipse includes users/user/documents/workspace/project/src. how eclipse import modules within same package?

Converting string to byte array in C# -

i'm quite new c#. i'm converting vb c#. having problem syntax of statement: if ((searchresult.properties["user"].count > 0)) { profile.user = system.text.encoding.utf8.getstring(searchresult.properties["user"][0]); } i see following errors: argument 1: cannot convert 'object' 'byte[]' the best overloaded method match 'system.text.encoding.getstring(byte[])' has invalid arguments i tried fix code based on this post, still no success string user = encoding.utf8.getstring("user", 0); any suggestions? if have byte array need know type of encoding used make byte array. for example, if byte array created this: byte[] tobytes = encoding.ascii.getbytes(somestring); you need turn string this: string = encoding.ascii.getstring(tobytes); if can find in code inherited, encoding used create byte array should set.

dns - What does the authority section mean in dig results? -

yesterday changed domain's name server cloudflare dnspod. , used dig test it. answer section old name servers. ;; authority section: amazingjxq.com. 21336 in ns kim.ns.cloudflare.com. amazingjxq.com. 21336 in ns brad.ns.cloudflare.com. is answer section stand name servers? if why not changed? the authority section indicates server(s) ultimate authority answering dns queries domain. the reason section can query any* dns server(s) answer query you. server may choose though answer query cache. however, if want ensure authoritative response ("from horses mouth" speak) - should ask server(s) in authority section. (* = server accept query, is.)

objective c - Access a website when tapping an image in cocos2d -

i making app using cocos2d using images display data. want make display image "link". so, when user taps image, opens particular website. using cocos2d , objective-c first time. don't know how proceed this any appreciated. thanks! try this: -(void)createimagebutton { ccsprite *image_1 = [ccsprite spritewithfile:@"image_1.png"]; ccsprite *image_2 = [ccsprite spritewithfile:@"image_2.png"]; ccmenuitemsprite *imagebtn = [ccmenuitemsprite itemfromnormalsprite: image_1 selectedsprite:image_2 target:self selector:@selector(imagebtnpress:) ]; imagebtn.position = ccp(width*0.5f, height*0.5f); ccmenu *menu = [ccmenu menuwithitems: imagebtn, nil]; menu.position = ccp(0.0f, 0.0f); [self addchild: menu z:100]; } -(void) imagebtnpress:(id)sender { /

How do I ensure that an image is fluid and will resize? -

i trying use css ensure image on page resize if screen below resolution or window below size. have read use {max-width:100%}, have incorporated code, image isn't resizing @ all. image 500px wide. thank you! css , html: .left{ float:left; width:600px; } .right{ float:right; width:400px; } #logoimage{ width: 100%; margin: 50px auto; max-width: 100%; } #navbar{ text-align: center; font-family: 'special elite', cursive; color:white; font-size: 80px; font-style: bold; display: block; margin: 60px auto; } <body> <div class="left"> <div id="logo"> <img src="/pictures/logo.png"> </div> </div> your css id logoimage not being applied anything. have img element, has no id specified. change <img src="/pictures/logo.png"> <img id="logoimage" src="/pictures/logo.png" /> take effect. also, there's no point setting width 100% , max-width 100%. i

mysql - Query not working when looking for null values on the where clause -

i got query works perfectly: select folder.folderid, folder.foldername folder inner join collaborators on collaborators.folderid = folder.folderid collaborators.userid = 23 but when added on clause: "and folder.parent = null" doesnt work. complete query is: select folder.folderid, folder.foldername folder inner join collaborators on collaborators.folderid = folder.folderid collaborators.userid = 23 , folder.parent = null does know whats going on? thanks when dealing null , cannot use = or <> since values unknown instead use is null or is not null , where collaborators.userid = 23 , folder.parent null mysql - working null values

java - Helloworld Doesn't run on Emulator -

okay, ticking me off. ran on both emulator , on android device. code not display "helloworld, android -mykong.com". start app, find on emulator, click on it, , goes interface of app. however, blank screen! error not issue of me finding app, not emulator or android phone, issue has lie either in code or in way code structured/built. know the helloworld code 100% correct because reputable tutorial site. these 3 pairs of code. please help, in desperate need! androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test123" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon="@drawable/ic_launc

android - onScroll gets called when I set listView.onScrollListener(this), but without any touch -

when set onscrolllistener listview , calls onscroll . causes crash because things haven't been initialized. is normal? note: happening without me touching phone. public class mainactivity1 extends activity implements onclicklistener, onscrolllistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.layout1); listview lv = (listview)findviewbyid(r.id.listview1); lv.setonscrolllistener(this); ... } ... public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount){ if( firstvisibleitem+visibleitemcount == totalitemcount ){ pullcontactlist(); } } it's normal because source code setonscrolllistener in abslistview (the superclass of listview ) this: public void setonscrolllistener(onscrolllistener l) { monscrolllistener = l; invokeonitemscrolllistener(); } and invokeonitemscrolll

How come when I move a python file into scipy.stats folder in ubuntu it disappears? -

i downloaded http://projects.scipy.org/scipy/attachment/ticket/846/mvncdf.py i: sudo mv ~/downloads/mvncdf.py /usr/lib/pyshared/python2.7/scipy/stats and disappears i tried saving directly /usr/lib/pyshared/python2.7/scipy/stats , still disappears. overall i'm not sure how move can call python program if have imported scipy.stats, scipy.stats.kde, etc. i'm trying solve. there few ways import external libraries in python. simplest launch program or interpreter same directory file, so $ mkdir new_program $ mv ~/downloads/mvncdf.py new_program/. $ cd new_program $ python >>> import mvncdf alternatively, suggested @tcaswell, can add local path pythonpath environment variable, $ mkdir ~/python_scripts $ mv ~/downloads/mvncdf.py python_scripts/. $ pythonpath=$pythonpath:$home/python_scripts $ export pythonpath the last 2 lines can placed in ~/.bashrc or ~/.bash_profile variable set every time log in. a more permanent way find directory in

legacy code - Drawing Effect Sketches - any tools support it? -

could tell me if there tools draw effect sketches described in michael feathers' book "working legacy code"?? the purpose of effect sketches show interactions between fields , methods in group of coupling classes while browsing through code. for more information effect sketches, please refer following blogs: http://www.markhneedham.com/blog/2009/11/04/reading-code-unity/ http://www.markhneedham.com/blog/2010/02/23/coding-effect-sketches-and-the-mikado-method/ thanks! ben wu the second article demonstrates such tool: graphviz . @ example given , write dot file. run through dot command line program form graphviz , you'll end graph looks 1 in article. a dot file description of relationships. more on dot file syntax read documentation graphviz site or wikipedia entry: http://en.wikipedia.org/wiki/dot_(graph_description_language)

audio - How to play external sound file in Java -

how play sound in java not internally saved in java project? have tried code work file compiled in java project.. want make sound file directory apart java project. private void sound (int s) { try { clip clip = audiosystem.getclip(); audioinputstream inputstream = audiosystem.getaudioinputstream(main.class.getresourceasstream("music/sound"+s+".wav")); clip.open(inputstream); clip.start(); } catch (lineunavailableexception | unsupportedaudiofileexception | ioexception e) { system.err.println(e.getmessage()); } }

javascript - Object [object HTMLAnchorElement] has no method 'attr' -

i'm examining dom element using console.log. dom element anchor: <a href="#" class="videoimage" data-id="ks3h_s3e-wc"></a> when try access id , output using either of following lines: console.log($this.attr(data-id)); or console.log($this.data('id')); i error: object [object htmlanchorelement] has no method 'attr' ('data' in second case) does anchor element not have attr or data methods, or mistake else? that looks because this reference not jquery object. try these instead: $(this).data('id') $(this).attr('data-id')

Upload data to HDFS running in Amazon EC2 from local non-Hadoop Machine -

i set hadoop cluster of 2 nodes on amazon ec2. works well. can upload data hdfs master node or other instances in same amazon zone hadoop cluster using hadoop api (java program attached). however, when want local non-hadoop machine, turns out exceptions below: i login hadoop namenode check command line. folder "testdir" created, size of uploaded file "myfile" 0. ==================this separator=============================== these exceptions apr 18, 2013 10:40:47 org.apache.hadoop.hdfs.dfsclient$dfsoutputstream createblockoutputstream info: exception in createblockoutputstream 10.196.153.215:50010 java.net.connectexception: connection timed out apr 18, 2013 10:40:47 org.apache.hadoop.hdfs.dfsclient$dfsoutputstream nextblockoutputstream info: abandoning block blk_560654195674249927_1002 apr 18, 2013 10:40:47 org.apache.hadoop.hdfs.dfsclient$dfsoutputstream nextblockoutputstream info: excluding datanode 10.196.153.215:50010 apr 18, 2013 10:41:09 org.apac

Ruby modulo 3 with negative numbers is unintuitive -

ruby modulo rules negative numbers unclear. in irb: -7 % 3 == 2 should 1 ! why? when 1 of operands % negative, there’s no clear best answer result return. every programming language has own rules. wikipedia page modulo operation has giant table of how each programming language has decided handle this, , there’s no clear consensus: $ # modulus sign is: $ $ curl 'http://en.wikipedia.org/w/index.php?title=modulo_operation&action=edit&section=1' \ | egrep -o 'divisor|dividend|always positive|closest zero|not defined|implementation defined' \ | sort | uniq -c | sort -nr 67 dividend 42 divisor 7 positive 4 closest 0 2 not defined 2 implementation defined some choose sign of left-hand operand, , right-hand operand. others don’t specify. example, the c programming language says: the sign of result % [is] machine-dependent negative operands instead of making particular choice how handle this, c returns whatever

browser - Java IO Exception for a Web Based CSV Export -

i have 'download csv' link on 1 of reporting webpages , typical output .csv file 4mb typically takes around 5 minutes complete running query , serving results using single thread. one of users continues run issue: [com.jspbook.gzipresponsewrapper:finishresponse] exception :java.io.ioexception: output stream has been closed there reference broken pipe exception in server logs. when user runs error notice server's perspective completes on time. for user export link spins infinite , never returns data. what causes issue , there way persist connection browser? check connection timeout setting of server. waiting 5 minutes long time. looks connection timed out or broken. server tries write response when query finishes connection closed. if generation cannot made faster push user when file available via web socket or continuous polling client.

javascript - Source code lost. Minified file available. How to unminify the file. -

i have javascript file in minified version. have lost original source code. how can recover source code minified version? variable names appearing _1, _2 etc. there way through can change variable names meaningful. minification must have minified script, if variable names have been changed means used kind of uglifier. there several online tools available http://jsbeautifier.org/ that'd unminify code, uglification can not undone, you've rename variables manually. protip: use version control system git keep revisions/history , take backups don't loose source code in future. i understand strange issues occur, hope resolve them. luck!

java - jdbc postgresql transaction error occurred -

public class jdbc { static connection con; static statement stmt; public static void main(string argv[]){ connect(); con.setautocommit(false); // statement s= conn.createstatement(); con.settransactionisolation(connection.transaction_serializable); //set savepoint system.out.println("savepoint1"); string sql = "insert flight values (1000, '22/7/2013', 'lgw', 'man', 10,40)"; stmt.executeupdate(sql); savepoint savepoint1 = conn.setsavepoint("savepoint1"); string sql2 = "update flight set flightid = 500 flightid = 1000"; stmt.executeupdate(sql2); con.rollback(savepoint1); con.commit(); system.out.println("end"); } static void connect() throws sqlexception, classnotfoundexception, datasourceexception { try { // load database driver driver class.forname(datasource.getclassname());

unix - Trying to return a simple echo statement -

i want output "you have not entered file". if user literally inputs nothing after calling unix script, receive error message. for var in "$@" file=$var if [ $# -eq 0 ] echo "you have not entered file" elif [ -d $file ] echo "your file directory" elif [ -e $file ] sendtobin else echo "your file $file not exist" fi i cannot figure out wrong, believe it's in first if statement i rewrite this: #!/bin/bash if (( $# == 0 )); echo "you have not entered file" else file in "$@"; if [ -d "$file" ]; echo "your file directory" elif [ -e "$file" ]; echo sendtobin "$file" else echo "your file $file not exist" fi done fi important points: the structure of script should first check if arguments passed. if there aren’t any, print appropriate message. otherwise ha

constraints - Neo4j Client: Can we throw an exception if there are already maxium number of relationship reached? -

if have 1 many relationship 1 vehicle has 1 4 wheels, if try call graphclient.create(wheel, new vehiclehaswheel(vehicle.reference)); can expect graphclient throw exception don't have 5 wheels on car? we can define maxium number 4 relationship carhaswheel. right if have check constrain need manaully query database existing wheels decide whether should create one. neo4j not provide these types of constraints in box, doesn't have way specify schema that. you achieve similar solution doing mutations via cypher queries though: start ... ... create ... that integrates 2 queries (decide, mutate) one. to know if created or not, return it: start ... ... create ... return ...

datepicker + PHP + MySQL -

in same page have datepicker , following code: <?php $query = mysqli_query($conn, " select * divulgacaoeventos order datepicker ") or die(mysqli_errno("não há registro de eventos.")); $row = mysqli_num_rows($query); if($row != 0){ while ($evento = mysqli_fetch_object($query)){ echo "evento: ".$evento->eventname."<br/>"; echo "local: ".$evento->local."<br/>"; echo "cidade: ".$evento->cidadeestado."<br/>"; echo "data: ".$evento->datepicker."<br/>"; echo "hora: ".$evento->hour."<br/>"; echo "atrações: ".$evento->atracoes."<br/>"; echo "contato: ".$evento->contato."<br/>"; echo "r$: ".$evento->valoringresso01." ".$evento->tipoingresso01."<br/>";

Filter in django: the last post of each user -

i have 2 models, author , post , how can make filter can select last post (by id field) of each author in 1 line?, bad approach me : authors = author.objects.all() queryset = [] author in authors: posts = post.objects.filter(author=author).order_by('-id') if loc: queryset.append(posts[0]) specifically, filter tastypie resource "postresource", filter can give me last post of each user, ordered creation complete solution okm answer , tastypie custom filter: class locationresource(modelresource): user = fields.foreignkey(accountresource,'user' ) class meta: queryset = location.objects.all().order_by('-id') resource_name = 'location' #excludes = ['id',] list_allowed_methods = ['post','get'] authentication = apikeyauthentication() authorization= authorization() filtering = {'user': all_with_relations} def obj_create(self,

java - Printing fibonacci series in recursion -

i trying print fibonacci series using recursion , code not ending recursion . can tell me if missed something.i think second recursion going infinite loop , not able figure out why happening class main { public static void main (string[] args) { int k=7; int x=0,y=1; fib(x,y,k,0); return; } public static void fib(int x,int y,int k,int cnt) { int z; if(cnt>k) return; if(cnt<=k) { z=x+y; x=y; y=z; system.out.println("value is"+z); fib(x,y,k,cnt++); } } } you don't seem understand concept of fibonacci number. please read wikipedia article . following code function. public static int fib(int n) { if(n == 0 || n == 1) return n; return fib(n-1) + fib(n-2); }

jquery - Javascript - how to update elements inner html? -

i have this: var stopwatch = function (item) { window.setinterval(function () { item.innerhtml = myinteger++; }, 1000); } this code supposed display myinteger , not updating values of item . why ( item div text inside)? there lot of reasons (we need see more of code), here working example: var myinteger = 1, stopwatch = function (item) { window.setinterval(function () { item.innerhtml = myinteger++; }, 1000); } stopwatch(document.queryselector('div')); important changes: calling stopwatch (you this) - innerhtml +innerhtml (the case matters). won't error setting innerhtml ; set property , won't notice anything. initialize myinteger . http://jsfiddle.net/q4krm/

Facebook api php get friend photos where I'm tagged -

i want specific friend photos i'm tagged in, , photos same friend tagged in. i'm using fql, this, $_post[friend_id] passed form friends listed: $facebook_login = "0"; $user = $facebook->getuser(); $perms = array('scope' => 'email,user_photos,read_mailbox'); if ($user) { try { $user_profile = $facebook->api('/me'); $facebook_login = "1"; } catch (facebookapiexception $e) { $user = null; } } else { die('<script>top.location.href="'.$facebook->getloginurl($perms).'";</script>'); } //friend photos i'm tagged in $query = "select id photo = $_post[friend_id] , tags in ($user)"; $result = $facebook->api(array( 'method' => 'fql.query', 'query' => $query, )); echo sprintf('<pre>%s</pre>', print_r($result,true)); //my photos friend tagged in $query = "select id photo = $user , tags in ($_p

java - Shortest Path LinkedList -

i want find shortest path on list of linked list, represents directed graph cost per edge/path. the output this, tells me cost take me vertex 0 other vertices: d[0 0] = 0 d[0 1] = 20 d[0 2] = 10 this how populate list testing. linkedlist<graphdata> g = new linkedlist[3]; (int = 0; < 3; i++) weight[i] = new linkedlist<graphdata>(); g[0].add(new graphdata(1, 20); g[0].add(new graphdata(2, 10); the graphdata class looks this: int vertex, int edgecost; now problem: i want find shortest path vertex v others. public static int[] shortestpaths(int v, linkedlist<graphdata>[] cost) { // set of vertices int n = cost.length; // dist[i] distance v int[] dist = new int[n]; // s[i] true if there path v boolean[] s = new boolean[n]; // initialize dist for(int = 0; < n; i++) dist[i] = cost[v].get(i).getcost(); s[v] = true; // determine n-1 paths v ( int j = 2 ; j < n ; j++ ) {

iphone - Display a rendered icon in UImage -

i have 57x57 png icon image use app's main icon. how programatically use ios's rendering system produce glossy effect in same way icon rendered in home screen? preferbably use uimage passing raw image. there doesn't seem class called uiprerenderedicon accomplish this, although there property in settings? it's kind of weird hack, why not go home screen on simulator, take screen shot, , cut out there via photoshop, inkscape, or similar? might quickest way accomplish this.

claim processing with policy variants using drools and jbpm? -

i'm trying build claim processing system. there multiple variations of insurance policies (based on negotiations individual clients). aim keep base policies per provider , apply variations them per client ensure easy maintenance of top level policies (like damage due fire covered or not). policies should easy created non-technical business users. what best approach this? i'm thinking on lines of using drools come basic rules , create jbpm processes per policy provider consume rules. guvnor authoring , maintenance of rules , processes. assuming no human tasks (its going set of rules need fired , results thrown out), using jbpm going overkill? there better alternatives in open source world? drools closely integrated jbpm use cases this, won't overkill, work nicely together. jbpm not human interactions, can used automatic processing. one remark, might possible not have 1 process per provider have 1 (or small set of) process(es) , use rules handle variations

.net - How can I read a C# Console app's entire command line, as it was typed? -

this question has answer here: getting raw (unsplit) command line in .net 3 answers i writing little repl console app, , read command, split it, , use piss-poor switch statement decide method call (instead of using strategy pattern). place each command history, audit. the command line when starting app, typed, lost split. prefer have whole command line , on loop , it's own split routine. is possible whole command line somehow? you can entire command line passed program via environment.commandline

diff - Implementing Google's DiffMatchPatch API for Python 2/3 -

i want write simple diff application in python using google's diff match patch apis . i'm quite new python, want example of how use diff match patch api semantically comparing 2 paragraphs of text. i'm not sure of how go using diff_match_patch.py file , import it. appreciated! additionally, i've tried using difflib , found ineffective comparing largely varied sentences. i'm using ubuntu 12.04 x64. google's diff-match-patch api same languages implemented in (java, javascript, dart, c++, c#, objective c, lua , python 2.x or python 3.x). therefore 1 can typically use sample snippets in languages other one's target language figure out particular api calls needed various diff/match/patch tasks . in case of simple "semantic" comparison need import diff_match_patch texta = "the cat in red hat" textb = "the feline in blue hat" #create diff_match_patch object dmp = diff_match_patch.diff_match_patch() # depending

algorithm - what is the difference between set and unordered_set in C++? -

came across question, similar not @ same since talks java, has different implementation of hash-tables, virtue of having synchronized accessor /mutators differences between hashmap , hashtable? so difference in c++ implementation of set , unordered_set ? question can ofcourse extended map vs unordered_map , on other c++ containers. here initial assessment set : while standard doesnt explicitly asks implemented trees, time-complexity constraint asked operations find/insert, means implemented tree. rb tree (as seen in gcc 4.8), height-balanced. since height balanced, have predictable time-complexity find() pros : compact (compared other ds in comparison) con : access time complexity o(lg n) unordered_set : while standard doesnt explicitly asks implemented trees, time-complexity constraint asked operations find/insert, means implemented hash-table. pros : faster (promises amortized o(1) search) easy convert basic primitives thread-safe, compared tree-ds co

Eclipse regularly resets settings -

eclipse juno regularly resets of settings (.metadata). starts clear desktop if installed. need restore .metadata once week or two. why happen? known eclipse problem? updated this happens every time when switch off second display. do not put .metadata under version control. put contents of workspace (i.e. projects) under version control. manipulating .metadata directory during checkouts, breaking workspace yourself. the metadata directory cannot shared design , lead trouble. see what of eclipse project .metadata can safely ignore in git/mercurial? or which eclipse files belong under version control? more pointers that.

java - It is possible that a weblogic ssl communication accept all certificates? -

i want implement client application information of weblogic server. communication has secure because weblogic server configure secure. now i'm able establish ssl communication. following settings: system.setproperty("weblogic.security.trustkeystore", "customtrust"); system.setproperty("weblogic.security.customtrustkeystorefilename", tmptruststore.getabsolutepath()); system.setproperty("weblogic.security.customtrustkeystorepassphrase", "somepw"); system.setproperty("weblogic.security.customtrustkeystoretype", "jks"); it possible weblogic ssl communication accept certificates? make application more convenient in handling. think of solution similar override of x509trustmanager. if so, can give me example? otherwise can give me answer reasons? no not possible. having ssl connection between 2 entities in 1 accepts data defeats purpose of having secure connection. either use non-ssl port convenience

How can I remove junk characters with regex? -

i have web application reads contents of web page , parses sentences using nlp algorithm. have been using regex split contents single sentences , parsing them. i remove characters  sentences. these characters, imagine, because of html encoding. i cannot use regex [^\w\d]+ or variations because need punctuations intact. of course add individual exceptions each of punctuation [^\w\d\.,:]+ , on, if there easier way this, character class knows a... funny character? any appreciated. thanks. edit: app built php , using simple file_get_contents() fetch html data site , reading contents inside <p> tags. this mentioned in comments @thegreatco able create character class of "special" characters. can use hex code values create range in character class. special character on ascii 127 this. [\x80-\xfe] that match basic characters. reference sake, here's list of ascii character table hex codes . this page discusses different ways can reference spe

matplotlib - How to set the nodes color with a given graph -

i using networkx , matplotlib now want set color of nodes,and read graph text file g=nx.read_edgelist("edge.txt") nx.draw(g) plt.show() here edge file of example 0 1 0 2 3 4 here did,and failed import networkx nx import matplotlib.pyplot plt g = nx.read_edgelist("edge.txt") pos = nx.spring_layout(g) nx.draw_networkx_nodes(g,pos,node_list=[0,1,2],node_color='b') nx.draw_networkx_nodes(g,pos,node_list=[3,4],node_color='r') plt.show() the result lot of blue nodes without edges so if want set nodelista=[0,1,2] blue, nodelistb=[3,4] red how can that? draw nodes explicitly calling top-level function, draw_networkx_nodes and pass in node list value parameter node_list , , value parameter node_color , so nx.draw_network_nodes(g, pos, node_list=nodelista, node_color="#5072a7") the argument pos python dictionary keys nodes of graph , values x, y positions; easy to supply pos pass graph object spring_layout retu

javascript - Populate text area when dropdown item is selected -

i quite new in coding. let me come directly question. have dropdown in jsp gets populated entity kinds datastore(jdo) when page loaded. want. when select entity kind dropdown, text area should populate column names of particular entity kind. can in javascript or jquery. pls help! something looking for? <div> <textarea id="carpark"></textarea> </div> <div> <select id="cardealer"> <option value="volvo">volvo</option> <option value="saab">saab</option> <option value="mercedes">mercedes</option> <option value="audi">audi</option> </select> </div> function putit(e) { $("#carpark").val(e.target.value); } $("#cardealer").on("change", putit); it's on jsfiddle play with

transactions - Spring JNDI Configuration -

using spring jndi look-up our data access requirements. making calls multiple stored procedures (in sybase). wanted way control auto-commit property of transactions while calling these stored procs. able achieve basicdatasource (property name="defaultautocommit"). got stuck when moved doing jndi look-up (from weblogic). <jee:jndi-lookup jndi-name="wl_data_source" id="datasource" /> <bean id="procedurehandlerbean" class="myclass"> <property name="procdatasource" ref="datasource"/> </bean> after researching few days, appears me can use jtatransactionmanager. however, not sure if can use transaction manager configure auto-commit on per procedure call basis (due different chained/unchained mode requirements of different procs). there clean way achieve this?

Php returning success to java after data found in database and on insert of database -

<?php include("db_config.php"); $myusername = $_get['username']; $mypassword = $_get['password']; $sql="select id tablename username='$myusername' , password='$mypassword'"; echo $sql; $result=mysql_query($sql); $row=mysql_fetch_array($result); $active=$row['active']; $count=mysql_num_rows($result); // if result matched $myusername , $mypassword, table row must 1 row if($count==1) { echo "<strong> <font size='18'>login success</font></strong>"; } else { echo "<strong> <font size='18'>login failed</font></strong>"; } ?> i tried response array on success.. in java file wen receive .. showing null.. using line receive success success=json.getint(tag_success); also used in json parser class check if server returns success. if (response.getstatusline().getstatuscode() == 200) and login giving login failed..

admin - Cant access remote share in explorer if software is elevated uac (c++) -

i have problem access network share drives mapped in explorer software if runs administrator rights. if disable uac runs well, can enumerate network drives mapped in explorer. my question is: how can accesss network drives or enumerate them when uac on? i tried change: localaccounttokenfilterpolicy in registry, doesnt work. any solutions? with kind regards xen the problem not uac per se, nor running administrator rights . problem you're running under different user account . "run administrator" that. each user account has own network shares. when you're running different user, therefore enumerate different shares. try running explorer.exe different user; you'll see explorer.exe find same shares do. this not worked around, design. it's harder malware spread when each user account can access drives , shares needs. the correct solution not run uac/administrator rights. if really, need to, it's 1 single administrative task. tas

xpages - Converter and validators messages in dutch -

i have question converters. on 1 of fields added converter change field value date. whenever user enters incorrect date/time format error shown " field not valid date. ". i want force in dutch. change local show in dutch or should write custom converter ( don't hope ) dutch message returned? related , think, messages validators. have expression validator returns "expression invalid" message when computed expression ( saved in notes document , read on page load ) invalid. can somehow change dutch? user knows going on?

javascript - ajax prevent double posting on mouseenter -

can point out need in code stop doubling on data when mouseenter on hyperlink tag. put flag in there isloading still continues double up. i've done wrong have through code , see whats wrong - see if can prevent double posting on mouseenter. please show me you're changes - kdm. (function($){ $.fn.rating_display = function() { var _this = this; var id = $(_this).data('id'); var position = $(this).parent().position(); var left = position.left - 15; var top = position.top + $(this).height() + 13; var isloading = false; function clear_ratings() { $('.ratings-content').html(""); } $(document).on('click', function(e) { var element = e.target; /*else if($(element).closest('.rating').length){ $('.ratings-display').show(); }*/ }); // here i'm having t

java - Logcat Null Check Returning False Positive -

i'm doing simple test (attempting null check value) , kicks decided null check make believe / nonexistant value: "striiing" not exist anywhere in source code. checked logcat , realized non existent value appears as: 04-18 04:40:22.197: d/com.game.demo.level1(15800): broken value! debug! debug! when executing following: if ("striiing" != null) { log.d(tag, "broken value! debug! debug!"); prefs.getboolean("name", true); prefs.getboolean("player", true); prefs.getboolean("points", true); prefs.getboolean("level", true); prefs.getboolean("gear", true); can explain why non existent value could/would show being not null? it's quite bizarre. "striiing" string literal, non null object in java. try instead: string s = null; if (s == null) ... and should work expected.

r - Calculations on selected groups of variables -

i have dataframe variable names looking like: a.1, a.3, a.5, a.6, a.9, a.10, a.12 b.1, b.3, b.5, b.6, b.9, b.10, b.12 and on j. the variables' names represent assessed parameters , visit number in longitudinal study. the dataframe contains fixed baseline parameters. i create new variables represent changes since last visit each parameter: delta.a.3 <- a.3 - a.1 delta.a.5 <- a.5 - a.3 and on visits parameters. is there way perform task automatically? here extract dataframe: id diab age 20mpace.0 20mpace.1 20mpace.3 20mpace.5 kooskpl.0 kooskpl.1 kooskpl.3 kooskpl.5 1 9000099 0 59 1.3280 1.2946 1.3500 1.2772 100.00 88.89 80.56 83.33 2 9000296 0 69 1.3658 1.3142 na 1.3944 100.00 100.00 100.00 100.00 3 9000622 0 71 1.4305 1.5178 na na 100.00 100.00 na na 4 9000798 0 56 1.0636 1.2342 1.1969 1