Posts

sql - find out list of inverted hierarchy in mysql -

imagine have table (mysql myisam) child->parent relationship (categories , multiple levels of subcategories) +--------+---------+ | id |parent_id| +--------+---------+ | 1 | null | | 2 | 1 | | 3 | 2 | | 4 | 7 | | 5 | 1 | | 6 | 5 | +--------+---------+ how find children of id, querying id 1 output : 2,5,3,6 ? (order has no importance) so in other words, how reverted children lookup on parent_link ? at moment, cycle in php , query parent_id, again , concatenate results in string while there results, slow... create table my_table( id int, parent_id int ); insert my_table values (1,null), (2,1), (3,2), (4,7), (5,1), (6,5); this stored procedure children of given id delimiter $$ drop procedure if exists get_children$$ create procedure get_children(in v_key int) proc: begin declare vid text; declare oid text; declare count int; create temporary table temp_child_nodes( id int ); ...

ios - set navigation bar back to default -

in app's uiapplicationdelegate customizing background of navigation bar code: [[uinavigationbar appearance] setbackgroundimage:[uiimage imagenamed:myimage] forbarmetrics:uibarmetricsdefault]; everything working fine, when launching example image picker, set navigation bar default, , when user has picked picture, restore custom background. possible? i have tried setting backgroundcolor property nil nothing. instead of changing appearance uinavigationbar (which affect every navigation bar), make subclass of uinavigationbar, use in appearance code. then in navigation controller, set navigation bar class of 1 subclassed.

Java create bat file and escape spaces -

my app creating .bat file in users startup directory able auto run when users logs in. this how creating .bat : file startupfile=getstartupfile(); printwriter out=new printwriter(new filewriter(startupfile)); out.println("@echo off"); out.println("start " + system.getproperty("user.dir") + fileseparator +"myapp.exe"); out.println("exit"); out.close(); } btw: startupfile location startup directory the problem seems system.getproperty("user.dir") contains spaces in path. example second line can be: start c:\program files (x86)\myapp\myapp.exe and breaks .bat file when tries find application run. any ideas how can make .bat understand find application? no matter been installed? quoting file location in every case (with or without space) should work out.println("start \"" + system.getproperty("user.dir") + fileseparator +"myapp.exe\"");

selenium - Two elements with same parent element -

i using selenium ide test tree. i having 2 elements same parent element, 1 check box , other text. my question is, can use text element make selenium click on check box?! in way, can connect 2 elements each others how?!! as me right click on browser webpage want test. , can chose show available command. note when right click on browser need open selenium-ide . hope helpful.

winapi - How to interpret the "code" passed to CallNextHookEx -

i'm wondering values 2nd parameter (code) of callnexthookex function may take, unfortunately msdn documentation quite vague parameter: the hook code passed current hook procedure. next hook procedure uses code determine how process hook information. i assume values code parameter may take defined somwhere among " hook structures " how can interpret values correctly? am allowed manipulate value or expected pass code received it? the value explained in documentation of hook procedure. e.g. getmsgproc : specifies whether hook procedure must process message. if code hc_action , hook procedure must process message. if code less zero, hook procedure must pass message callnexthookex function without further processing , should return value returned callnexthookex. the documentation code parameter similar above (all?) procedures. that means should process calls code equal hc_action . otherwise, should call callnexthookex original p...

java - Where am I wrong in this program? -

this program reverse array. now, how create function print reversed array? public class question1 { public static void main( string [] args ) { char[] myname = { 'h', 'a', 's', 'h', 'i', 'm' }; reverse(myname); } public static void reverse(char[] array) { (int = 5; >= 0; i--) { char reversearray = array[i]; } } } you try using charat method: class reversestring { public static void main(string args[]) { string original, reverse = ""; scanner in = new scanner(system.in); system.out.println("enter string reverse"); original = in.nextline(); int length = original.length(); ( int = length - 1 ; >= 0 ; i-- ) reverse = reverse + original.charat(i); system.out.println("reverse of entered string is: "+reverse); } }

shell - How to get the duration of a file in milliseconds -

i trying duration of audio file (.wav) in milliseconds. i have seen command lines using ffmpeg , library deprecated (remplaced avconv ) on ubuntu version, , didn't find on it. i can duration running avconv -i <file> looking result in milliseconds . wrote small stand-alone .sh file: file="$1" info=$(sox $file -n stat 2>&1) full_length=$(echo "$info" | sed -n 's#^length (seconds):[^0-9]*\([0-9.]*\).*$#\1#p') seconds=$(echo $full_length | cut -f1 -d.) if [ -n "$seconds" ]; milliseconds=$(echo $full_length | cut -f2 -d. | cut -c -3) result=$(($seconds * 1000)) result=$(($result + $milliseconds)) echo "$result" exit fi echo "0" exit call like new-file.sh test.wav to result (duration in ms) 1337 (you can find full code sources used on github )