Posts

Showing posts from February, 2014

c - Why does wcwidth return -1 with a sign that I can print on the terminal? -

why here wcwidth return "-1" (not printable wide character) width "Ԥ" (0x0524)? #include <stdio.h> #include <wchar.h> #include <locale.h> int wcwidth(wchar_t wc); int main() { setlocale(lc_ctype, ""); wchar_t wc1 = l'合'; // 0x5408 int width1 = wcwidth(wc1); printf("%lc - print width: %i\n", wc1, width1); wchar_t wc2 = l'Ԥ'; // 0x0524 int width2 = wcwidth(wc2); printf("%lc - print width: %i\n", wc2, width2); return 0; } output: 合 - print width: 2 Ԥ - print width: -1 most u+0524 not valid character when libc character database created. added in unicode 5.2. font may include character already, wcwidth not @ font used.

ruby on rails - Kaminari and Sunspot undefined method page -

i trying return records match search in kaminari , paginate results. however, getting following error: undefined method 'page' my controller code: @search = sunspot.search(building) fulltext params[:search] end @buildings = @search.results.page(params[:page]).per(15) i think not understanding how use kaminari? page method can call in relation, can this: @buildings = building.where(id: @search.results.map(&:id)).page(params[:page]).per(5)

android - Nullpointer returns when trying to create a file -

i have code save float array file future use. when call order savearray("the x",x); x float array want save, returns null file , not created. public void savearray(string filename, float[] array) { try { fileoutputstream fos = new fileoutputstream(filename); objectoutputstream out = new objectoutputstream(fos); out.writeobject(array); out.flush(); out.close(); } catch (ioexception e) { system.out.println(e); } } public float[] loadarray(string filename) { try { fileinputstream fis = new fileinputstream(filename); objectinputstream in = new objectinputstream(fis); float[] saved_array = (float[])in.readobject(); in.close(); return saved_array; } catch (exception e) { system.out.println(e); } return null; } this return m

Rails Asset Pipeline loads all files -

i have multiple files in app/assets/javscripts folder, application.js.erb , page.js.erb , sections.js.erb & scraped.js.erb . rails loads them in layout <%= javascript_include_tag "application" %> in application.html.erb layout. called pagescontroller . i not want scraped.js.erb loaded @ & sections.js.erb loaded sectionscontroller . from understanding (after reading http://guides.rubyonrails.org/asset_pipeline.html ) that's how asset pipeline worked. if called pagescontroller load application.js.erb & page.js.erb that's not case. am doing wrong? explain me how asset pipeline works? , how can use select assets rather of them? check manifest file, in assets/javascript got file application.js, contains //= require_tree . include during compilation files of directory tree. if want exclude files can either require files 1 one: // require my_file , either create sub directories in javascript directory , use //= require_di

Indentation Error after While Loop in Python -

i have following function, receive indentation error whenever try run it: def fib(n): # write fibonacci series n """print fibonacci series n.""" a, b = 0, 1 while < n: print a, b = b, a+b # call function defined: fib(2000) error message: print ^ indentationerror: expected indented block how resolve indentationerror error in python? you need indent code properly. other languages use brackets, python uses indentation: def fib(n): # write fibonacci series n """print fibonacci series n.""" a, b = 0, 1 while < n: print a, b = b, a+b

cocos2d iphone - Finding point of touch on a shape -

in box2d project need create revolutejoint between 2 polygonshaped bodies @ exact point user double tapped. i have point of touch, , list of vertices each of 2 shapes (obviously set not collide each other.) if understand correctly, point of touch in terms of world location, , vertices describing shape, reside in world. how "translate" 1 another? for example, user double tapped @ (3.63,5.07). the vertices shape 1 are: [(0.37485206,-0.17777264), (-0.2880008,-0.033603553), (-0.1609711,-0.2395713), (-0.04113376,-0.31708732), (0.26274818,-0.38661742), (0.35696936,-0.29765773)] the vertices shape 2: [(-0.015462875,0.24353802), (-0.13529873,0.31698608), (-0.36852637,0.4127499), (-0.4136281,0.17009032), (-0.2880008,-0.033603553)] the revolutejoint: revolutejointdef jd = new revolutejointdef(); jd.bodya = touchedbodies.get(0); jd.bodyb = touchedbodies.get(1); jd.collideconnected = false; jd.localanchora.set(?????); jd.localanchorb.set(?????); world.createjoint(jd); a

How to get a text field value from the form in PHP by using jQuery Tagit -

i using jquery tags plugin , when user enter tags comma separated want tags after form submit using php. my coding... <?php if(isset($_request['submit_tag'])) { print_r($_request['tags']); } ?> <!-- tags --> <script src="http://webspirited.com/tagit/demo/js/jquery.1.7.2.min.js"></script> <script src="http://webspirited.com/tagit/demo/js/jquery-ui.1.8.20.min.js"></script> <script src="http://webspirited.com/tagit/js/tagit.js"></script> <link rel="stylesheet" type="text/css" href="http://webspirited.com/tagit/demo/css/jquery-ui-base-1.8.20.css"> <link rel="stylesheet" type="text/css" href="http://webspirited.com/tagit/css/tagit-awesome-blue.css"> <script type="text/javascript"> $(function () { $('#demo3').tagit({triggerkeys:['enter', 'comma', 't

c# - The ObjectContext instance has been disposed and can no longer be used for operations that require a connection -

i'm building application using user controls have main form , display user controls code: modules.ctrllistcontractors mo = new modules.ctrllistcontractors(); splitcontainercontrol.panel1.controls.clear(); splitcontainercontrol.panel1.controls.add(mo); and within user control can put problem error message : the objectcontext instance has been disposed , can no longer used operations require connection. i have relations tables displayed gridview inside ctrllistcontractors , when click menu button show ctrllistcontractors above error message , think it's because lazy loading need execute more queries additional data related tables. i have code execute @ user control load event: using (contractorsentities context = new contractorsentities(properties.settings.default.connection)) { memberbindingsource.datasource = context.members.tolist(); } i think problem solved if can data main table , related tables @ sa

frequency - How to create missing values in table in R? -

i have 40 pairs of birds each male , female in pair scored colour. colour score categorical variable value range of 1 9. create table number of each combination (1/1, 1/2, 1/3, ... 9/7, 9/8, 9/9). problem there combinations not exist in data when try create table (in these cases zeros missing values). below data , sample code. pretty sure answer lies in using 'expand.grid()' command, e.g. see post , unsure how implement it. suggestions? ## dataset pairs of males , females , colour classes pair_colours <- structure(list(male = c(7, 6, 4, 6, 8, 8, 5, 6, 6, 8, 6, 6, 5, 7, 9, 5, 8, 7, 5, 5, 4, 6, 7, 7, 3, 6, 5, 4, 7, 4, 3, 9, 4, 4, 4, 4, 9, 6, 6, 6), female = c(9, 8, 8, 9, 3, 6, 8, 5, 8, 9, 7, 3, 6, 5, 8, 9, 7, 3, 6, 4, 4, 4, 8, 8, 6, 7, 4, 2, 8, 9, 5, 6, 8, 8, 4, 4, 5, 9, 7, 8)), .names = c("male", "female"), class = "data.frame", row.names = c(na, 40l)) pair_colours$male <- as.factor(pair_colours$male) pair_colours$female <- as.f

big o - Complexity of factorial recursive algorithm -

today in class teacher wrote on blackboard recursive factorial algorithm: int factorial(int n) { if (n == 1) return 1; else return n * factorial(n-1); } she said has cost of t(n-1) + 1 . then iteration method said t(n-1) = t(n-2) + 2 = t(n-3) + 3 ... t(n-j) + j , algorithm stops when n - j = 1 , j = n - 1 . after that, substituted j in t(n-1) + 1 , , obtained t(1) + n-1 . she directly said n-1 = 2 (log 2 n-1) , cost of algorithm exponential. i lost last 2 steps. can please explain them me? let's start off analysis of algorithm. can write recurrence relation total amount of work done. base case, 1 unit of work when algorithm run on input of size 1, so t(1) = 1 for input of size n + 1, algorithm 1 unit of work within function itself, makes call same function on input of size n. therefore t(n + 1) = t(n) + 1 if expand out terms of recurrence, that t(1) = 1 t(2) = t(1) + 1 = 2 t(3) = t(2) + 1 = 3 t(4) = t(3) + 1 =

Type conversion in opencl -

i want convert 'unsigned char' 'uchar16'. @ first, direct convert it, run error. uchar16* out; unsigned char ciphertext[16]; /* * */ out[0] = (uchar16)(ciphertext[0], ciphertext[1], ciphertext[2], ciphertext[3], ciphertext[4], ciphertext[5], ciphertext[6], ciphertext[7], ciphertext[8], ciphertext[9], ciphertext[10], ciphertext[11], ciphertext[12], ciphertext[13], ciphertext[14], ciphertext[15]); when use real value instead of variable, runs. out[0] = (uchar16)(0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c); i searched in google , stackoverflow, , did not find answer. for vector conversion in opencl there suite of functions: convert_desttype(sourcetype) see point 6.2.3 of standard (v1.2). in case be: uchar16 out = convert_uchar16(ciphertext);

r - How to create a new ordinal variable according to other variables? -

hi members of community. question might seems identical asked time before, may repetition request output different previous question. i have following db: id1=rep((1:1),20) id2=rep((2:2),20) id3=rep((3:3),20) id<-c(id1,id2,id3) date1=rep("2013-1-1",10) date2=rep("2013-1-2",10) date=c(date1,date2) in<-data.frame(id,date=rep(date,3)) and create new variable identify how many burst (a burst defined cycle of observation within each day) recorded each id, this: in$bursttrue<-rep(c(rep(1,10),rep(2,10)),3) until have try solution (but unfortunately doesn't work because correctly identifies each burst, not according each id). in$burst<-with(in,as.numeric(interaction(in$id,in$date,lex.order=true))) i suppose function ave useful solve task: tried several combinations none work report solution more near request output. suggestion appreciate! first create data.frame in parameter stringsasfactors=false follows: in <- data.frame

postgresql - perform true on joined tables -

in postgresql 8.4.13 have 2 tables representing card games (each 3 players) , score results of games. players identified id column , games gid : # \d pref_games table "public.pref_games" column | type | modifiers --------+-----------------------------+---------------------------------------------------------- gid | integer | not null default nextval('pref_games_gid_seq'::regclass) rounds | integer | not null stamp | timestamp without time zone | default now() indexes: "pref_games_pkey" primary key, btree (gid) referenced by: table "pref_scores" constraint "pref_scores_gid_fkey" foreign key (gid) references pref_games(gid) on delete cascade # \d pref_scores table "public.pref_scores" column | type | modifiers ---------+-----------------------+----------- id

javascript - Have an input button show depending on a selected value -

i have <select> drop down gets populated database. when list of items generated drop down, buttons display more information of each item. but, keep every button hidden except 1 corresponds selected value of drop down. so let's user chooses third value of drop down. have javascript monitors change , based on value corresponding button shown. user clicks button , information of selected option displayed on alert window. user changes value again other option, previous button hidden because values don't match, , 1 shown. please note javascript used on external file, , form has multiple drop downs need take in parameters. javascript function determinedisplay(item, itemview) { var locateitem = document.getelementbyid(item); var locateview = document.getelementbyclassname('.' + itemview); locateitem.change(function() { if(locateitem.value == locateview.id) { locateview.style = "block"; locateview.show();

encoding - simpleXML with special chars in XML-Url -

i have little problem code. trying pull song id's spotify. works fine me, not special characters in url (like ü,ö,ä). i warning (first line echoed url): http://ws.spotify.com/search/1/track?q=sportfreunde+stiller+and+track:frühling warning: simplexmlelement::__tostring() [simplexmlelement.--tostring]: node no longer exists in /applications/ampps/www/spotify.php on line 28 this code: function getid($artist,$title){ $url = utf8_decode("http://ws.spotify.com/search/1/track?q=".$artist."+and+track:".$title); echo $url; $xml = simplexml_load_file($url); $id= $xml->track->attributes(); return($id); } echo getid("sportfreunde+stiller","frühling"); how solve this? tried utf_encode(), didn't work out. thank you! this has nothing utf-8 encoding, , not badly named utf8_decode / utf8_encode functions, should named utf8_to_iso8859_1 / iso8859_1_to_utf8 , , right answer encoding problem. urls can, stric

javascript - show hide polylines google maps -

when page loaded polyline autoloaded on map. m need hide , when click chekcbox show on map. how can it? polylines has categories.. rayon.. call on checkbox categories rayon.. p.s. sorry english code: function getline() { var mpenc = new google.maps.infowindow(); function pinfo(poly, html) { google.maps.event.addlistener(poly,"mouseover",function(){ poly.setoptions({ strokecolor:'#ffffff', strokeopacity: .8});}); google.maps.event.addlistener(poly,"mouseout",function(){ poly.setoptions({strokecolor:colorr});}); google.maps.event.addlistener(poly,'click', function(event) { mpenc.setcontent(html); mpenc.setposition(event.latlng); mpenc.open(map); }); } alert('loading lines.. please wait 10 sec.'); downloadurl("all.php", function(doc) { alert('lines loaded..'); var g = google.maps; var xmldoc = xmlparse(doc); bounds = new goo

How to display an element in the middle of CSS3 animation -

in example , want display element in step of animation. however, not possible, because if set display:none in main css rule, animation not override it. #test { -webkit-animation: test 2s; display:none; // here problem, animation not override it. } @-webkit-keyframes test { 0%{margin:5px} 20%{display:block} 70%{margin:40px} } note simplified example, , in practice, need use display:none hide element before becomes visible animation. thus, other tricks opacity not satisfy need. i'm not sure you're trying do, if want hide element , show when animation starts, make use of visibility property this: #test { -webkit-animation: test 2s; visibility:hidden; } @-webkit-keyframes test { 0%{margin:5px} 20%{visibility:visible} 70%{margin:40px} } fiddle example

retrive oath token and oauth secret from android twitter login using dialog -

i'm making android login using twitter api last step made open url on dialog contains webview code @override protected string doinbackground(void... params) { string url = null; try { log.i(tag, "retrieving request token google servers"); url = provider.retrieverequesttoken(consumer, constants.oauth_callback_url); log.i(tag, "popping browser authorize url : " + url); } catch (exception e) { log.e(tag, "error during oauth retrieve request token", e); } return url; } then open dialog url , sign twitter need make tweet , retrieve username of user use twitteroauthview getting accesstoken.

Bash: the run-command to the result header -

i run script different parameters , on. when run script std-outputs header: header must contain command run. how can have running command in header? goal $ head ~/dominances_0_0.25_0.5_0.75_1.txt ----------------------------------------- system testing file bepo timestamp: 201305041511 pwd: /users/abc/abc/systemtestfiles run-command: ./bin/diffexpectedactual.sh > ~/dominances_0_0.25_0.5_0.75_1.txt ----------------------------------------- failure $ ./bin/diffexpectedactual.sh > ~/dominances_0_0.25_0.5_0.75_1.txt $ head bin/diffexpectedactual.sh #!/bin/bash echo "-----------------------------------------" echo "system testing file bepo" echo "timestamp: " `date +"%y%m%d%h%m"` echo "pwd: " `pwd` echo "command: " some_command_here_to_tell_the_run_command?!?! echo "-----------------------------------------" you can easily, 3 step process. first, must setup bash executing precmd . copyin

ASP.NET MVC Routing doesn't affect the changes -

i'm using asp.net mvc3 , wanna define custom route, test route in other project , works in main project doesn't! made question before here interesting comment of defined route , still works before! (my project doesn't routing !) possible mvc render page in case ??? have done this protected void application_start() { arearegistration.registerallareas(); // registerglobalfilters(globalfilters.filters); // registerroutes(routetable.routes); // initializer database.setinitializer(new initializer()); //ninject controllerbuilder.current.setcontrollerfactory(new ninjectdependencyresolver()); } notice line of code comment ! // registerroutes(routetable.routes); i think has override mvc routing change in routing doesn't affect in project ,what problem ??

javascript - JS getting day of week + current time and displaying messages based on it -

i have schedule web radio's site, , every day has different order of playlists, while hours differ well. want display previous, current , next playlist on site. clear: should based on 1 timezone (preferably est), , not on user's current time. i've searched couple of hours yesterday, couldn't find useful enough, although have messed many examples found. i'm new this, makes kind of hard. let friend me, unfortunately busy exams coming time. can me this? appreciated!

KSH script won't email when nohup -

i have unique issue, in unix environment , have ksh script ssh's multiple sites, executes code , returns response , emails response email address. the script works when run it, since must run several hours wish nohup script. here problem is. when nohup script email not sent. have scoured boards looking reason or solution no avail. if point me in right direction appreciate it. here mail portion of script: mail -s "subject" email@address.com < /usr/etc/bin/mydir/infofile.out && rm -f infofile.out exit; edit: environment aix 6.1.7.1 finally figured out answer, , thou being dumb, feel have responsibility answer anyway, in case else runs across issue. turns out when nohup script send email correctly. nohuping , logging out forces email sent unix mail utility's default email address, , in environment address sends out hundreds of useless alerts, of have filtered in outlook go trash folder, email sending ended in trash folder. thanks r

Java: nested class function? -

ob instance of object. if call function getname returns class type ob.getclass().getname() my doubt is, how come getclass , getname 2 functions, how nested? no, aren't. getclass return class object . class object contains method called getname . code posted similar to: class cls = ob.getclass(); string name = cls.getname();

OpenCV VideoCapture cannot read video in Python but able in VS11 -

as title, not able read video using videocapture in python following code: v = 'c:\\test.mp4' import cv2 cap = cv2.videocapture(v) if cap.isopened(): print "finally" else: print "boom" boom being printed. sigh whereas in vs11, following code works: #include "stdafx.h" #include <opencv2\highgui\highgui.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char* argv[]) { string v = "c:\\test.mp4"; videocapture cap; cap.open(v); if (cap.isopened()) { cout << "yes!" << endl; } else { cout << "boom" << endl; } return 0; } i realize there's number solution in so, nothing works me. have following dlls in c:\python27 , c:\python27\dlls, in path opencv_ffmpeg.dll opencv_ffmpeg_64.dll opencv_ffmpeg_245_64.dll opencv_ffmpeg_245.dll i have no more idea have not done. please me. thank

android - How to set the spinner mode dynamically? -

i have created spinner dynamically, easy new spinner(context) . need set spinnermode dynamically, , find no method so. what should do? in android >= 3.0 (api 11) can use : spinner spinner = new spinner(this,null,android.r.style.widget_spinner,spinner.mode_dropdown);

Why don't I see the values of the integers in a returned array in Java? -

here main method: public static void main(string[] args) { int[] myarray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; (int = 0; < myarray.length; i++) { system.out.println(myarray[i]); } int[] sortedarray = insertionsort.sorter(myarray); (int = 0; < sortedarray.length; i++) { system.out.println(sortedarray); } } and here insertionsort.sorter looks like: public static int[] sorter(int[] a) { return a; } and output: 1 2 3 4 5 6 7 8 9 10 [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b so missing? for (int = 0; < sortedarray.length; i++) { system.out.println(sortedarray); } what missing array index: for (int = 0; < sortedarray.length; i++) { system.out.println(sortedarray[i]); // note [i] } or (using for-each loop): for (int i: sortedarray){ system.out.println(i); } what doing print whole array (which not pretty in java

objective c - Working with QTTime in milliseconds -

i current time of qtmovieview so: qttime time = self.movieview.movie.currenttime; and put smpte form nsstring *smpte_string; int days, hour, minute, second, frame; long long result; result = time.timevalue / time.timescale; // second frame = (time.timevalue % time.timescale) / 100; second = result % 60; result = result / 60; // minute minute = result % 60; result = result / 60; // hour hour = result % 24; days = result; smpte_string = [nsstring stringwithformat:@"%02d:%02d:%02d:%02d", hour, minute, second, frame]; // hh:mm:ss:ff but don't want have end frame number. want end in milliseconds (hh:mm:ss.mil) the following should work: double second = (double)time.timevalue / (double)time.timescale; int result = second / 60; second -= 60 * result; int minute = result % 60; result = result / 60; int hour = result % 24; int days = result / 24; nsstring *smpte_string = [nsstring stringwithformat:@"%02d:%02d:%06.3f", hour, minute, second];

opengl - My texture keeps showing up white on screen -

i cant seem load image , use texture program: image 512*512 in size , dont know im doing wrong, can me? main function: int main(int argc, char** argv) { glutinit (&argc, argv); glutinitwindowsize (800,600); glutinitdisplaymode (glut_single | glut_rgb); glutcreatewindow ("cs248 glut example"); glutdisplayfunc (display); glutreshapefunc (reshape); glutmainloop (); return 0; } the display function: void display() { glclear(gl_color_buffer_bit); glenable(gl_texture_2d); glcolor3f(1.0f,1.0f,1.0f); texture = loadtexture("space.bmp"); glbindtexture(gl_texture_2d, texture); glbegin(gl_quads); gltexcoord2f(0.0, 0.0); glvertex3f(-20.0,-20.0,0); gltexcoord2f(0.0, 1.0); glvertex3f(-20.0, 20.0, 0.0); gltexcoord2f(1.0, 1.0); glvertex3f(20.0, 20.0, 0.0); gltexcoord2f(1.0, 0.0); glvertex3f(20.0, -20.0, 0.0); glend(); glflush(); } so, call here loadtexture function gluint texture, wa

C++ passing an object -

i'm learning c++, doesn't works expected. made classes bowlinggame (just text-based) , works well. want pass object of bowlinggame class, called scorecalculator. the header file looks like: #ifndef scorecalculator_h #define scorecalculator_h #include "bowlinggame.h" class scorecalculator { private: bowlinggame * game; public: //constructor scorecalculator(const bowlinggame &game); //setters void setgame(const bowlinggame &game); }; #endif // scorecalculator_h and implementation looks like: #include "scorecalculator.h" #include "bowlinggame.h" #include <iostream> using namespace std; scorecalculator::scorecalculator(const bowlinggame &game) { setgame(game); } void scorecalculator::setgame(const bowlinggame &gamse) { //* game = gamse; fails //cout << gamse.getlastframenummer(); works } i save 'bowlinggame object' in instance var game, reason console application cr

java - Arraylist of Arrays, How to make last array size somehow different from other arrays in the list -

explanation of trying acheive: i given file , have read data file , create blocks of sizes 1 kb. example : if file size 5.8 kb have 5 blocks of 1 kb each , 1 last block of 0.8 kb. after having these in block have sha 256 encoding last block , append second last block, after have apply encoding second last block , append third last , on. problem if given multiple of 1024 byte file size code works well. if last block size not 1024 code doesnot work intended. the way doing : bufferedinputstream bis = new bufferedinputstream(new fileinputstream(f)); int sizeofblock = 1024; int sizeofhash = 256; messagedigest md; md = messagedigest.getinstance("sha-256"); byte[] block = new byte[sizeofblock]; list <byte []> blocklist = new arraylist <byte []>(); int tmp = 0; while ((tmp = bis.read(block)) > 0) { system.out.println(tmp); blocklist.add(block); } (int j = blocklist.size()-1; j > 0;){ system.out.println(blocklist.get(

javascript - Increment elements ID -

but code checkbox elements have same id... var count; var length = $('input[type=checkbox]').length for(count=1;count<=length;count++){ $('input[type=checkbox]').attr('id',count) } set elements id using .prop() or .attr() $(':checkbox').prop("id", function( ){ return i; }); jsbin demo set elements id using .each() $(':checkbox').each(function( ){ this.id = i; }); jsbin demo both examples return: <input id="0" type="checkbox"> <input id="1" type="checkbox"> <input id="2" type="checkbox"> <input id="3" type="checkbox"> if want start 1 use: this.id = i+1; since numerical id not supported in non html5 (older) browsers, add string prefix id number "el"+ (i+1)

php - Codeigniter routes with arguments -

i want wont work, means doing wrong. $route['print/:num'] = "user/doprint/goprint/:num"; let me explain. have controller doprint under user folder , goprint method inside doprint accepts id argument. dont want users visit mydomain.com/user/doprint/goprint/2 . want them visit mydomain.com/print/2 . my controller below class doprint extends user_controller { public function index() { $data['subview'] = 'print'; $this->load->view('main_layout', $data); } public function goprint($id=null) { $data['model'] = $this->usermodel_model->get($id); $data['subview'] = 'print'; $this->load->view('main_layout', $data); } } the route rule syntax (per documentation) : $route['print/(:num)'] = "user/doprint/goprint/$1";

android - Reboot a device from phonegap -

is there way reboot device phonegap/cordova? how go doing this? think may not possible on ipad/iphone on androids. first can't done unless device rooted/jailbreaken (depending talking android or ios ). now comes fun part if have rooted/jailbreaken device not able unless can java / objective c development. basically phonegap plugin don't exist because functionality not needed unless doing phone on basic level. but if have enough knowledge can self. phonegap plugin can created easy, , can find more in tutorial . want create simple plugin execute java / objective c code when need it. android/java example : try { process proc = runtime.getruntime().exec(new string[] { "su", "-c", "reboot" }); proc.waitfor(); } catch (exception ex) { log.i(tag, "could not reboot", ex); } ios/objective c example unfortunately don't have experience functionality on ios need trust answer .

Rails 3 - adding inputs with values (nested-form) -

i have troubles rails3 , nested-form gem. adding empty inputs great want have select tag predefined filled forms, , when choose 1 of options script add inputs defined value form. how can add input fields values nested form? i think nested form add methods form builder, through standard helpers: - f.fields_for :nested_model |nested_builder| = nested_builder.select :method, model.all.collect {|m| [ m.name, m.id ] }, { :include_blank => true }

javascript - creating cascaded elements in JQuery -

i've got following assignment: create div button dynamically, , in turn should create (div button), on. yet following code not work: <div id="m-0"> <div id="m-0c"></div> <input id="add_container" name="add_container" class="cua" type="button" value="addition container" > </div> and jquery code is: $(document).ready(function() { $(".cua").live("click", function(e){ var father = $(this).parent(); var id_new=father.attr('id')+'.m-'; var number=0; while( $('#'+id_new+number).length ){ number=number+1; } id_new=id_new+number; alert('here '+id_new); $('#'+father.attr('id')+'c').append('<div id="'+id_new+'"><div id="'+id_new+'c"></div><input

sublimetext2 - Extensions/Plugins for Sublime Text for Non-Coding Purposes -

probably strange place ask this, but, figured there's no better one. i've been using sublimetext of coding/programming needs while , have gotten incredibly used it. hate switching openoffice/ms word/etc. non code documents , losing keymapping , great features. wondering if knows of plugins make everyday word processing work little bit more palatable , formatted. thanks, you try learning latex, though that's quite undertaking in opinion. use latextools . for general note taking, turn on word wrap reasonable , turn spellcheck on. use markdown symbols denote list, headers, etc. markdown because haven't taken time remember markdown specific things. "non-coding purposes" kind of broad, hope 1 of 2 things mentioned help.

hibernate - Cannot serialize JPA bean due to presence of proxies -

i trying expose object xml using jax-rs. i have class called client , returning instance this: @transactional(readonly=true) @get @produces("application/xml") @path("/{clientid}.xml") public client getcleintasxml(@pathparam("clientid") int clientid) { client c = em.find(client.class, clientid); return c; } but client object has list of group objects , group object in turn has list of other objects. when jax-rs tries serialize client object traverses entire object graph. when ecounters hibernate proxy groups code breaks because lazy loading works inside transaction. fair enough, load groups eagerly before exiting transaction. but still fails because each group object in turn has one-to-many relations i.e. more proxied lists. i don't need them in output. realize problem solved if these proxies removed i.e set null. i don't want manually set them null error prone , not maintainable. t

clojure - How do I write an Enlive selector to return "clusters" of tags? -

i'm writing clojure code using enlive process set of xml documents. they're in xml format borrows heavily html adds custom tags, , job convert them real html. custom tag that's bothering me right <tab> , being used in kinds of places shouldn't be. example, it's used make lists should have been made <ol> , <li> . here's example of kind of thing i'm encountering: <p class="normal">some text</p> <p class="listwithtabs">(a)<tab />first list item</p> <p class="listwithtabs">(b)<tab />second list item</p> <p class="listwithtabs">(c)<tab />third list item</p> <p class="normal">some more text</p> <p class="anotherlist">1.<tab />another list</p> <p class="anotherlist">2.<tab />two items time</p> <p class="normal">some final text</p> i wan

python - Broadcasting message to all clients using Pika + sockjs-tornado -

i'm new realtime apps based on websockets, , stucked @ 1 point. app has following components: simple python script fired when generic event occurs. receives data , sends queue (rabbitmq) using pika. tornado app (with sockjs-tornado) receiving message queue (pika asynchronous client), processing content, saving new app state database , broadcastig data clients (sockjs clients). communication clients in 1 direction - connect server , receive data. the problem can't figure out how pass data received queue clients. i've done pub/sub exchange, when user connects server, new connection established rabbitmq every user, that's not want. below i've got far. common/pika_client.py : import logging import pika pika.adapters.tornado_connection import tornadoconnection class pikaclient(object): def __init__(self, exchange, host='localhost', port=5672, vhost=''): # default values self.connected = false self.connecting

ruby - native gem installs fine on 1.9.3 but fails on 2.0.0 -

a private gem native extensions have had worked fine since ruby 1.8.2 , 1.9.3 failing in wird mode install on ruby 2.0.0. instead of installing required shared object .so file, copies executable. there not changes gem sources, going ruby 1.9.3 (and it's gemset) works fine. here relevant 2.0.0-p0 verbose output gem install : linking shared-object mygem/mygem.so make install /usr/bin/install -c -m 0755 mygem.so /home/remus/.rvm/gems/ruby-2.0.0-p0/gems/mygem-0.1.12/lib/mygem installing default mygem libraries installed mygem-0.1.12 ... 1 gem installed and these artifacts installed: $ ls -al total 2252 -rwxr-xr-x 1 remus remus 2289443 may 4 13:08 mygem -rw-rw-r-- 1 remus remus 62 may 4 13:08 mygem.rb for comparison 1.9.3-p194 output is: linking shared-object mygem/mygem.so make install /usr/bin/install -c -m 0755 mygem.so /home/remus/.rvm/gems/ruby-1.9.3-p194/gems/mygem-0.1.12/lib/mygem installing default mygem libraries installed mygem-0.1.12 1 gem installed

.net - Search active directory for groups like a SQL LIKE statement -

is possible search active directory group this: - give me groups contain name sample ? in sql write select * group name %sample% i found on msdn hints expressions =, <= not like. http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher.filter.aspx thanks hints. if looking search name of group, link @ bottom of page linked tells not take directly page for more information ldap search string format, see " search filter syntax " (i added correct link) use query (&(objectclass=group)(cn=*sample*)) looking for. if searching if user member of group, not list of groups match pattern, need use memberof , wildcards not work on memberof search

itunesconnect - Testing in app purchase on iOS -

i want add in-app purchase mechanishm application. understand apple documents, have send binary before add in-app purchasing code. i'm not sure something. if send binary 1.0 version, able publish application 1.0 version in future? because add in-app purchase after app reviewed , accepted apple , send (or update it) again. how mechanishm works in apple? how can handle this? you have upload binary , apple approve application. when apple have approved application can either choose release app-store or wait , add more code.

java - Using an ArrayList to draw images (JPanel, JFrame) -

Image
i having trouble using arraylist draw multiple images within jpanel/jframe. project create yar's revenge type game. far, no near here have: import java.awt.color; import java.awt.component; import java.awt.graphics; import java.awt.image; import java.awt.toolkit; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.awt.event.keylistener; import java.awt.image.imageobserver; import java.util.arraylist; import javax.swing.jpanel; public class gamepanel extends jpanel implements actionlistener, keylistener, imageobserver { public image ship; public image enemy; public image shot; private int xloc; private int yloc = 180; private int xloc2 = 700; private int yloc2 = 180; private int xvel; private int yvel; private int xvel_en; private int xvel_sh; private imageobserver observer; private arraylist<base> shi

How to fill an arraylist with an information from an array (java) -

i trying create program reads txt file (this thing in file "5,5,5,0"). want take information, put in array, use array fill array list. use arraylist write infromation file. here have far in class file: import java.io.*; import java.util.scanner; import java.util.arraylist; public void setmoney() throws ioexception { file moneyfile = new file ("money.txt"); scanner moneyscan = new scanner(moneyfile); string [] tokens = moneyfile.split(","); arraylist<integer> money = new arraylist<integer>(arrays.aslist(tokens)); for(int i=0;i<tokens.length;i++){ money.append(tokens[i]); } string s = integer.tostring(tokens[i]); fileoutputstream fos = new fileoutputstream("money.txt"); fos.write(money); fos.close(); } money.append giving me error: error: cannot find symbol money.append(tokens[i]); ^ symbol: method append

javascript - Problems inheriting XMLHttpRequest / ActiveXObject classes -

i have following javascript class: var server = function(onerror) { /* public as, onerror; */ var that, key, headers; this.__construct = function() { = this; that.as = false; that.onerror = onerror; that.resetheaders(); onerror = null; // here try call parent constructor (it seems can't). if(window.xmlhttprequest) that.xmlhttprequest(); else that.activexobject('microsoft.xmlhttp'); } this.request = function(file, postdata, function) { var method, headerkey; if(postdata == null) method = 'get'; else method = 'post'; try { that.open(method, file, that.as); /* each request sets x-requested-with xmlhttprequest default. if postdata given, treat it's content type form.*/ that.setrequestheader('x-requested-with

ajax - SoundCloud: how to stop playing when hash change -

i'm using ajax page switching method soundcloud script. how stop playing music when user leaves page soundcloud container? i've found these stokes: // stop players, might useful, before replacing player dynamically $.scplayer.stopall = function() { $('.sc-player.playing a.sc-pause').click(); }; currently call initialization $(".sc-player").scplayer(); inside .load function, need put code stop playing audio before page switching? you can add event listener window.onhashchange = stopall; and definition of stopall() be stopall = function() { $('.sc-player.playing a.sc-pause').click(); };

Magento: improving default search engine -

so, changed default magento search engine slightly, , works close how want it. (i.e. or term search and ). however, there 1 more thing i'd implement. when person searches series of terms, green apple a , i'd product green apple show first. right now, and operator, results in order pulled db. so, green apple might show in anywhere. here function prepares results.. bit complicated me, , i'm wondering if there's easy way "append" search result looks specific sequence of inputted terms , concatenates results, giving priority, shows first. (sorry long code. typically don't posting large amount of code) from fulltext.php in /stores/my_website/app/code/local/mage/catalogsearch/model/resource public function prepareresult($object, $querytext, $query) { $adapter = $this->_getwriteadapter(); if (!$query->getisprocessed()) { $searchtype = $object->getsearchtype($query->getstoreid()); $preparedterms = mage::getresou