Posts

Showing posts from September, 2014

php - Dropbox XAMPP & MySQL -

i have relocated htdocs folder within dropbox folder , similar thing mysql databases. don't know if possible or advisable love hear anyones advice , thoughts. should doing , if how? i discourage :) but... can change you're path whatever want... http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_datadir you can add flag each time start mysqld, or add [mysqld] section of user-wide/machine-wide mysql config file. you need initialize tables first, using mysql_install_db script ( http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html )

javascript - Uncaught SyntaxError passing multiple values to function -

i trying call function, running struggles escaping values , passing properly. have: function selectdone(sel, title_id, status_type) { ... } $(function() { $("td.status-updates").click(function() { if ($(this).find('#sel').length == 0) { var before = $(this).text(); var title_id = $(this).parent().attr('id'); var status_type = $(this).attr('class'); $(this).html("<select id='sel' onchange='selectdone(this," + title_id + "," + status_type +");'... <option>ns</option></select>"); } }); the error keep getting uncaught syntaxerror: unexpected identifier . however, if pass 'selectdone(this," + title_id + ");... works, if try , pass 3 raises error. note: there spaces in status_type variable (multiple classes). to repeat myself last question: $(this).ht...

how to assign lua variable by reference -

how can assign variable reference in lua one? for example: want equivalent of "a = b" pointer b background: have case have this: local a,b,c,d,e,f,g -- lots of variables if answer == 1 -- stuff elsif answer == 1 -- stuff b . . . ps. example in below appears apparent b=a value. note: i'm using corona sdk. a = 1 b = a = 2 print ("a/b:", a, b) -- output: a/b: 2 1 edit: regarding clarifed post , example, there no such thing type of reference want in lua. want variable refer variable. in lua, variables names values. that's it. the following works because b = a leaves both a , b referring same table value: a = { value = "testing 1,2,3" } b = -- b , refer same table print(a.value) -- testing 1,2,3 print(b.value) -- testing 1,2,3 = { value = "duck" } -- refers different table; b unaffected print(a.value) -- duck print(b.value) -- testing 1,2,3 you can think of variable assignments in lua reference...

runtime - How do I run compiled java classes with GPU libraries (Jogamp JOCL)? -

does know how run java code command line dependency on gpu libraries in case jogamps jocl. i have compiled test program hellojocl.java error during run time. i tried javac -classpath "./lib/jocl.jar:./lib/jocl-natives-macosx-universal.jar:./lib/jocl-natives-linux-i586.jar:./lib/jocl-natives-linux-amd64.jar:./lib/gluegen-rt.jar:./lib/gluegen-rt-natives-linux-amd64.jar:./lib/gluegen-rt-natives-macosx-universal.jar:./lib/gluegen-rt-natives-linux-i586.jar" ./hellojocl.java java -classpath "./lib/jocl.jar:./lib/jocl-natives-macosx-universal.jar:./lib/jocl-natives-linux-i586.jar:./lib/jocl-natives-linux-amd64.jar:./lib/gluegen-rt.jar:./lib/gluegen-rt-natives-linux-amd64.jar:./lib/gluegen-rt-natives-macosx-universal.jar:./lib/gluegen-rt-natives-linux-i586.jar:." hellojocl but error exception in thread "main" java.lang.noclassdeffounderror: com/jogamp/opencl/clcontext @ java.lang.class.getdeclaredmethods0(native method) did try ad...

php - How to put information dynamically on tables using jQuery based on certain criteria? -

let's imagine have make table following structure php. every cell identified namedayhour indicator ( mon0, mon1, , on every day ). should put information on cells, different every day , hour. the whole structure : <table border="1" > <th>hour</th> <th>mon 25-06-2012</th> <th>tue 26-06-2012</th> <th>wed 27-06-2012</th> <th>thu 28-06-2012</th> <th>fri 29-06-2012</th> <tr><td>8:00</td><td>mon0</td><td>tue0</td><td>wed0</td><td>thu0</td><td>fri0</tr> <tr><td>8:20</td><td>mon1</td><td>tue1</td><td>wed1</td><td>thu1</td><td>fri1</tr> <tr><td>8:40</td><td>mon2</td><td>tue2</td><td>wed2</td><td>thu2</td><td>fri2</tr> <tr><td>9:00</td><td>mon...

c++ - Get submatrix of matrix with smaller size -

i representing map ( matrix rows x columns ) bits using bitset stl or dynamic_bitset<> boost ( can use whatever want ). need submatrix of matrix smaller size( example a(2,2) a(2,3) a(3,2) a(3,3) there size 2 ). there efficient structure representing matrix bits , getting submatrix startindex , length without iteration ? it possible efficiently share data between matrices , submatrices. trick track 3 variables in class. row_stride start data the data needs shared_ptr structure underlying data can destroyed once done it. start pointer data referenced data , row_stride tells how far move next row. additional things might track column stride (this can allow take other interesting views matrix, , support transpose efficiently). row , column length - these can handy debugging or if want make loops, , multiplies easier work with. here's how might non-bit based approach (i've omitted .. gist). template<typename t> struct matrixdata { ...

asp.net - EF, UoW and Repository - When to dispose the UnitOfWork in WebForms? -

recently started digging concept of repository patterns , unitofwork exploring entityframework. made own implementation based on mvc example, disposing unitofwork controller so: protected override void dispose(bool disposing) { unitofwork.dispose(); base.dispose(disposing); } i'm not mvc @ all, , pretty new in webforms well, assume overriding controller dispose method in order dispose unitofwork "everything" else disposed. basically i'd implement same concept in asp.net webforms website , dispose unitofwork used behind page's code disposing of page itself. i considered adding same page_unload event life cycle, wasn't sure if proper way haven't messed such things before. idea follows: protected void page_unload(object sender, eventargs e) { unitofwork.dispose(); base.dispose(); } how can achieve safely, , on right track? first of all: don't invent wheel. use dependency injection frameworks like: structurem...

asp.net mvc - Add View Dialog MVC3 -

i busy changing default t4 templates gets generated when click on "add view" dialog controller. know how change templates. following can not wrap head around. i want able generate following when user clicks on add view. a partial view contains form part of view generated default a view calls partial view generated above. is possible generate 2 files using t4 templates ? thanks in advance why? going routinely doing exact same thing on , on again? if so, t4 template may make sense. if you're doing once or twice, modify files hand.

java - Is there a way to receive broadcast each time any activity is launched? -

for android developers my goal saved when activity launched... for instant there 3 activity launched during last hour, want save database. of course launch service , check every seconds activity launched use phone battery! thanks answers. maybe implement application class, similar singleton method. store data within application every time call new activity. application : http://developer.android.com/reference/android/app/application.html

python - importing a module that imports the main module -

i'm working on text adventure stores levels massive dictionary called 'places'. instead of having in main file, thought make separate file called 'levels.py' contain it, making code cleaner , eliminating need go through 450+ lines of other code add it. so, main game file: from levels import places class thing: #some stuff levels.py: from game import * places = { "bleh" : thing("bleh"), } it seems 'places' isn't defined in game, however. i think what's happening there's import 'loop'. however, if levels.py needs import classes game.py, how prevent that? it's possible refactor eliminate circular dependencies. move thing thing.py , in game.py , in levels.py use from thing import thing . rinse , repeat.

java - Regarding JFileChooser -

i have developed program counting number of lines in file shown below scanner in=new scanner(system.in); system.out.println("enter drive name c,d,e etc"); string drive=in.next(); system.out.println("enter main folder name"); string main_folder=in.next(); file directory=new file(drive+":"+"//"+main_folder+"//"); map<string, integer> result = new hashmap<string, integer>(); //file directory = new file("c:/test/"); file[] files = directory.listfiles(); (file file : files) { if (file.isfile()) { scanner scanner = new scanner(new filereader(file)); int linecount = 0; try { (linecount = 0; scanner.nextline() != null; linecount++); } catch (nosuchelementexception e) { result.put(file.getname(), linecount); } }} for( map.entry<string, integer> entry:result.entryset())...

Twitter bootstrap - Dynamically added tabs not working -

i using twitter bootstrap in application. in specific case, need add tabs dynamically after ajax request. i added li tag tab head , respective content area relevent id specified in href of tab head anchor. but newly added tabs not working bootstrap tabs. tried refresh tabs functionality calling $("#tabs1").tabs() right after new tab added dynamically, no use. please suggest me on how use bootstrap tabs dynamic data. note : other tabs there during page load works fine. you have initialize tabs using $(...).on() instead of $(...).click() . on way can bind click event parent #mytab -element , not directly child a -tags. $("#mytab").on("click", "a", function(e){ e.preventdefault(); $(this).tab('show'); }); now click -event bount #mytab -element , delegated child a -tags. here can find running demo read jquery doc more info on "on event handlers"

web services - stub generation failed with java.net.unknownhostexception -

Image
iam trying generate stub files using java sunwireless tool kit. iam able open link in chrome iam getting error how resolve it save wsdl *.xml browser, generate stub, url local file's path *.xml; notice wsdl have 2 status in browser, this: http://webservice.webxml.com.cn/webservices/weatherws.asmx browser deal read http://webservice.webxml.com.cn/webservices/weatherws.asmx?wsdl pure xml

PHP rename failed for filename with utf-8 arabic charset string -

i have issue php rename function, fail if file name in arabic words spaces. e.g. rename(temp/أم كلثوم ثوار - ثوار.mp3,audio/13408831061.mp3); no such file or directory in (path) please note: أم كلثومxxxxxxxxثوار - ثوار.mp3 xxxxxxx here atleast 6 spaces. i tried urlencode() still no result. any suggestion! to check $file_id correct, on unix-like system: echo "<pre>\n"; // html output system("echo -n '$file_id' | od -tx1"); with value, should reported filename (you can echo check) $file_id = "\xd9\x83\xd9\x84\xd8\xab\xd9\x88\xd9\x85 \xd8\xab\xd9\x88\xd8\xa7\xd8\xb1 - \xd8\xab\xd9\x88\xd8\xa7\xd8\xb1.mp3"; the output is 0000000 d9 83 d9 84 d8 ab d9 88 d9 85 20 d8 ab d9 88 d8 0000020 a7 d8 b1 20 2d 20 d8 ab d9 88 d8 a7 d8 b1 2e 6d 0000040 70 33 0000042 (as can see, sequence ending b1 repeats itself, last 4 bytes .mp3 ) in directory file should can issue a ls -1 | od -tx1 and see filenames ...

c# - Can't reference dataset in visual studio 2010 Express -

Image
for reason i'm getting error states can't find dataset in project when there. i've attached screenshot, notice red squares i've drawn on screenshot. datasource there, database there, still getting error in code. getting frustrating!! there i'm missing here?? just because dataset in project not mean can reference in class. need create instance of dataset in class. honestralphsusedcarsdataset yourdataset = new honestralphsusedcarsdataset(); edit: typo in original post, if copy/pasted before, try now.

excel - Macro Formatting a csv file -

i using macro generate file 3 columns ( a,b,c) , save csv. have working fine except when save it. file saves correct saves lines in columns after data " " " in rows of each line. need clean up. ending line different everyday, , need delete first open line end of workbook. i tried this: selection.end(xldown).select range("a100:c100").select range(selection, activecell.specialcells(xllastcell)).select selection.delete shift:=xlup but cell reference change everyday, tried: selection.end(xldown).select range("a:c").select range(selection, activecell.specialcells(xllastcell)).select selection.delete shift:=xlup and deletes data. great below example of data , how looks. need rid of " " " , these show when view in notepad, program use looks @ " " " data 6/27/2012 0:00,aaaa,-0.011111 6/27/2012 0:00,bbbb,-0.22222 6/27/2012 0:00,cccc,-0.03333 6/27/2012 0:00,ddddd,-0.0044 6/27/2012 0:00,xxxxxx,-0.0555 ' ...

c# - Deserialize XML to object (need to return a list of objects) -

started practicing xml , c# , have error message of "there error in xml document (3,2)". after looking @ file, can't see wrong (mind you, missed since i'm noob). i'm using console application c# right now. i'm trying return list of adventurers , side note, gear element optional. here have far: xml file - test1 <?xml version="1.0" encoding="utf-8"?> <catalog> <adventurer> <id>001</id> <name>john smith</name> <address>123 fake street</address> <phone>123-456-7890</phone> <gear> <attack> <item> <iname>sword</iname> <iprice>15.00</iprice> </item> <item> <iname>wand</iname> <iprice>20.00</iprice> ...

java - Null Pointer Exception while setting arraylist in struts 1.3 -

while thought of setting array list value array list bean returning null pointer exception. please check action class: public actionforward execute(actionmapping mapping, actionform form, httpservletrequest request, httpservletresponse response) throws exception { arraylist dailysheetdata; dailysheetform dailyform = (dailysheetform) form; class.forname("com.mysql.jdbc.driver"); connection connect = drivermanager.getconnection("jdbc:mysql://localhost/stonecrusher?" + "user=stonecrusher&password=xxxxxx"); system.out.println("connection"+connect); dailysheetdata = stonecrusherdata.getdailysheetdata(connect); if(dailysheetdata==null) system.out.println("dailysheetdata null"); else if(dailyform==null) system.out.println("dailyform null"); else dailyform.setarraylist(dailysheetdata) ;//iam getting exception here return mapping....

Javascript - determining if value in array is positive, negative (use switch) -

ok i'm trying write code determine whether or not values in static array positive, negative or equal zero. so array populated , i'd use switch statement go through values , output text depending on if above, below or equal zero. here's of code i've been doing far this. please keep answers pertain use of switches! in advance. note: i'm teaching myself js, i'm new this. here's code far: // javascript document var numbers=new array(); numbers[0]="1"; numbers[1]="2"; numbers[2]="3"; numbers[3]="-1"; numbers[4]="-2"; numbers[5]="-3"; numbers[6]="0"; switch (numbers) { case "positive": if (numbers>0) {alert("derp")}; break; case "negative": if (numbers<0) {alert("no derp")}; break; case "zero": if (numbers==0) {alert("still derp")...

java - php - save whole webpage (HTML + CSS + Javascript) -

lets have url webpage <html lang="en"> <head> <title>newegg.com - hp envy 14-3010nr </title> <link rel="stylesheet" type="text/css" href="css/style.css"> <script type="js/swfobject.v1.5.js"></script> </head> <body> <div id="message2olderbrowser"> <p>newegg.com - great place buy computers</p> <p>if reading message, </p> . . . </div> . . . </body> </html> i need tool (written in php or java) call function like savewebpage($url); and in result have these files: newegg.html css/style.css js/swfobject.v1.5.js is there tool or function ?

How can I use YUI Node with jQuery? -

i'm using portal software uses yui library native js framework , want use jquery on various yui nodes. can please show me how done? i've tried following no success... yui().use('node', function (y) { var oneelementbyid = y.one('#foo'); $(oneelementbyid).css('color','red'); }); ​ for you're doing in example, like: var nativedomelementbyid = y.one('#foo').getdomnode(); $(nativedomelementbyid).css('color','red'); in general, fluency between yui , jquery, see http://jsrosettastone.com site kevin mentioned. have careful when "crossing streams" between yui , jquery, use different abstractions around nodes & events. if you're working jquery , yui in yui sandbox -- say, want load jquery plugin alongside yui, recipe yui 3 cookbook might helpful: https://github.com/evangoer/yui3-cookbook/blob/master/examples/loading/use_jquery.html and if stuck, drop #yui irc channel on ...

Reading file in Android SDK -

i have 1 class called "global" , 2 other activities. in each activity want create instance of class global reading first line of text file called "textfile". reason, not work here code of global class (in file global.java): import android.app.activity; public class global extends activity { public string line; public global() { inputstream file = getresources().openrawresource(r.raw.textfile); bufferedreader input = new bufferedreader(new inputstreamreader(file)); try { line = input.readline(); } catch (ioexception e) { e.printstacktrace(); } } } here codes antivity called "helloworld" (in file helloworld.java) has instance of class global , display of first line of "textfile" public class helloworld extends activity{ global gb; textview mytv; protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub ...

android - Updating download progress bar into notification area from AsynTask -

i have implemented async task service. here initializing of progress notification, calling onpreexecute . mprogressnotificationmanager = (notificationmanager) .getsystemservice(context.notification_service); charsequence tickertext = "download"; mprogressnotification = new notification(r.drawable.ic_launcher, tickertext, system.currenttimemillis()); context = this.getapplicationcontext(); intent mnotificationintent = new intent(context, activityclass.class); pendingintent mpendingintent = pendingintent.getactivity(context, 0, mnotificationintent, 0); //mprogressnotification.flags |= notification.flag_auto_cancel; mprogressnotification.flags = mprogressnotification.flags | notification.flag_ongoing_event; charsequence title = "downloading initializing..."; remoteviews contentview = new remoteviews(getpackagename(), r.layout.noti); contentview.setimageviewresource(r.id.status_icon, r....

How to automatically make copies of rows in Excel? -

i have excel file looks this: row1_cell1 row1_cell2 row1_cell3 row2_cell1 row2_cell2 row2_cell3 row3_cell1 row3_cell2 row3_cell3 how can make 3 (or number of) copies of each row have in sheet, added after row being copied? so, in end have kind of result: row1_cell1 row1_cell2 row1_cell3 row1_cell1 row1_cell2 row1_cell3 row1_cell1 row1_cell2 row1_cell3 row2_cell1 row2_cell2 row2_cell3 row2_cell1 row2_cell2 row2_cell3 row2_cell1 row2_cell2 row2_cell3 row3_cell1 row3_cell2 row3_cell3 row3_cell1 row3_cell2 row3_cell3 row3_cell1 row3_cell2 row3_cell3 this how rows on sheet: option explicit sub multiplyrows() dim rwscnt long, lr long, insrw long rwscnt = application.inputbox("how many copies of each row should inserted?", "insert count", 2, type:=1) if rwscnt = 0 exit sub lr = range("a" & rows.count).end(xlup).row application.screenupdating = false insrw = lr 1 step -1 rows(insrw).copy rows(insrw + 1).resize(rwscnt...

Running Javadoc and Sonar in Hudson -

?i trying run sonar , javadoc using maven3. seems both of them call clean gaol before running javadoc:javadoc , sonar:sonar. due output of 1 of them lost. pom entries are <build> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>sonar-maven-plugin</artifactid> <version>2.0</version> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-javadoc-plugin</artifactid> <version>2.8.1</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </build> <reporting> <plugins> ...

php - I need to get NID from the array -

array(1) { [0] => object(stdclass)#53 (14) { ["cart_item_id"]=> string(2) "64" ["cart_id"]=> string(1) "1" ["nid"]=> string(3) "204" ["qty"]=> string(1) "1" "changed"]=> string(10) "1340948878" ["data"]=> array(3) { ["shippable"]=> string(1) "1" ["restrict_qty"]=> string(1) "0" ["module"]=> string(10) "uc_product" } ["title"]=> string(5) "songs" ["vid"]=> string(3) "204" ["cost"]=...

iphone - UIWebView touch event not getting fired -

i new iphone developer, i want detect touch in webview tried method not getting fired, in .h file @interface epubreaderviewcontroller : uiviewcontroller in .m file ... - (void)sendevent:(uievent *)event{ nslog(@"touch detected") ; } ... even tried also, - (void) touchesbegan:(nsset*)touches withevent:(uievent*)event { nslog(@"touches began"); } thanks in advance ! user going zoom in , zoom out on website, touch click hpyerlinks etc. that'w shy touch methods won't respond uiwebview . if want enable touch, might need subclass uiwebview while forbidded in developer docs, check following threads more discussion- handling touches inside uiwebview https://stackoverflow.com/questions/2122745/how-to-detect-touch-event-in-uiwebview how intercept touches events on mkmapview or uiwebview objects? handling touches inside uiwebview you can go through tutorial - http://mithin.in/2009/08/26/detecting-taps-and-events...

javascript - Maximum string length for eval -

i have string of length 65000 needs eval ed convert json object. unexpected token error. want know there maximum string length above eval won't work? you try running through json parser. var obj = json.parse(str);

android - How do I apply a force to a body in the direction it is traveling (Box2D)? -

i'm using andengine/box2d develop game. have ball bounces around screen. i've made ignore gravity applying opposite force, has tenancy slow down after initial impulse, elasticity set 1. want to: if(speed < a number ) apply force or impulse (which better?) in direction of motion how might this? well unfortunately, ball interacting other objects setting velocity did not work, have found solution! using forces , extensive trig, came with: private static class ball extends sprite { body body; public ball(final float px, final float py, final itextureregion ptextureregion, final vertexbufferobjectmanager pvertexbufferobjectmanager) { super(px, py, ptextureregion, pvertexbufferobjectmanager); body = physicsfactory.createcirclebody(mphysicsworld, this, bodytype.dynamicbody, physicsfactory.createfixturedef(0, 1, 0)); body.applylinearimpulse(((float)5),(float) 5, body.getworldcenter().x, body.getworldcenter().y); mphysic...

wordpress - Custom post type image upload with meta box -

i can't find attached image in custom post type. code in functions.php $prefix = 'custom_'; $custom_meta_fields = array( array( //'label' => 'textarea', 'desc' => 'a description field.', 'id' => $prefix.'textarea', 'type' => 'textarea' ) ); // default metabox custom post types. function avz_custom_meta_box() { // $post_types = get_post_types( array( 'public' => true ) ); $post_types = get_post_types(); foreach ( $post_types $post_type ) { if ( $post_type == 'page' || $post_type =='post' ) continue; add_meta_box( $prefix.'image', 'header image upload box', 'show_avz_custom_meta_box', $post_type, 'normal', 'high' ); } } add_action('add_meta_boxes', 'avz_custom_meta_box')...

tridion - Extending the GUI fields -

i extend individual gui elements, custom processing , later call default function. for example: whenever particular input element selected in component window, show tootip user associated field. kindly provide pointers. # sorry earlier attempt in framing question reframing again. # actually have schema 4 fields, requirement show text, whenever focus on particular field. one of field holds country name: when focus on country name ( single text field ) need show "please enter country name" on text field. editor understands same, without using schema description field. so question can capture events types of fields ( multimedia, rtf, single line ) in component edit view ? hope able make question more clear you have extend component-edit screen this. suggest read-up on tridion gui extensions: www.sdltridionworld.com , sdllivecontent tridion developer blog also, searching stackoverlow might help: exte...

php - curl + "Validation of viewstate MAC failed." -

i using curl post data server, between each posting use function fetch hidden fields "__viewstate". worked charm before, updated there website, rewriten code use new fieldnams, on last step gets error: "validation of viewstate mac failed." if same step in webbrowser works should, used addon fetch postdata browser sending , compared script sending, , looks same. my knowledge of asp.net minimal, , info can find here error recomendates changes on asp-net-server. so hope here can guide me find out why in browser have 100% successrate, , curl have 0% successrate on page, using same functions on previus pages, works 100% curl. postdata browser sending: __eventtarget= __eventargument= __viewstate=%2fwepdwukltk2mdaxnju3ma9kfgjmd2qwagidd2qwdgifd2qwagibdw8wah4evgv4daufrso2cmv0ywdzz3j1chblbibpiefdtnrlym9yzybbqmrkagcpdxyehwafh0bdtnjldgfnc2dydxbwzw4gasbhw7z0zwjvcmcgquiec05hdmlnyxrlvxjsbr1%2bl0nsawvudenhcmquyxnwed9dbgllbnrjrd05ogrkagkpdxychgdwaxnpymxlz2rkagspdxyehw...

objective c - Image appearing pixelerated -

this trying do create uiimage view. do drawing on it press share button share image drawings on it. my code works perfect on ipad , iphone. problem comes retina display. guess scale not handled correctly, not sure doing wrong. code // create uiimageview named centercanvas // drawing cgpoint origin = centercanvas.frame.origin; cgsize size = centercanvas.frame.size; cgsize screensize = [self returnscreensize]; cgrect rect = cgrectmake(origin.x, origin.y, size.width, size.height); uigraphicsbeginimagecontext(screensize); cgcontextref context = uigraphicsgetcurrentcontext(); [self.view.layer renderincontext:context]; uiimage *img = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); cgimageref imageref = cgimagecreatewithimageinrect([img cgimage], rect); [shareview setimage:[uiimage imagewithcgimage:imageref]]; -(cgsize) returnscreensize { cgrect screenbounds = [[uiscreen mainscreen] bounds]; cgfloat screenscale = [[uiscreen mainscreen] ...

Lua use a variable in an object reference? -

is possible use variable in object reference in lua? example, a.value string, , a.value = "b". access a.b.c.d, or a.(a.value).c.d. how can accomplish this? the syntax a.b shorthand a["b"] . want, you'd rid of "b" , instead use variable, this: a[a.value].c.d

How to get Twitter trending topics for a given day in a given location? -

this question twitter api, doesn't provide information on issue. it's possible current trending topic location, example: united states: https://api.twitter.com/1/trends/23424977.json where 23424977 location code united states. it's possible hourly trending topic given day, world-wide: https://api.twitter.com/1/trends/daily.json?date=2012-06-10/ however, have not been able find out how trending topics on given day in given location, is, way combine these 2 separate calls together. anyone has solution this? thanks. you can't information twitter api directly. must regularly query locations interested in current trends. if interested in covering globe, need oauth drones past 150/350 request limit per hour. and in no time have own archive of trending topics.

javascript - Iterating through object's properties lists things in the prototype -

i'm trying make "copy" function , add object's prototype. planned recursively typecheck , assign properties new object , return object... but, there seems problem, see snippet of code: object.prototype.copy = function() { (prop in this) { console.log(prop); //logs copy (the function)!!! } } x = {"a": 1}; y = x.copy(); as i've pointed out in comment, found weird behavior, why happening? copy function should in object.prototype , not in instanced object itself! how fix it? can set this.copy = undefined , , still rely on object.prototype.copy ? this full code sample, requested: object.prototype.copy = function() { var object = this; //the object copying. var newobject = {}; //the object return. //cycle through properties of object creating, copy them recursively. (prop in object) { if (!object.prototype.hasownproperty.call(this, prop) || object[prop] == null) { continue; ...

Protected field alternatives in Java? -

i have code using protected field in super class. how can avoid it, because think field should private? /** "abstract builder" */ abstract class pizzabuilder { protected pizza pizza; public pizza getpizza() { return pizza; } public void createnewpizzaproduct() { pizza = new pizza(); } public abstract void builddough(); public abstract void buildsauce(); public abstract void buildtopping(); } /** "concretebuilder" */ class hawaiianpizzabuilder extends pizzabuilder { public void builddough() { pizza.setdough("cross"); } public void buildsauce() { pizza.setsauce("mild"); } public void buildtopping() { pizza.settopping("ham+pineapple"); } } /** "concretebuilder" */ class spicypizzabuilder extends pizzabuilder { public void builddough() { pizza.setdough("pan baked"); } public void buildsauce() { pizza.setsauce("hot"); } public void buildto...

c++ - how to split cin input -

i facing problem split input in c++, similar python split function. input given 1001-43 1003-45 1008-67 in different lines. want know how take these inputs split '-' , store them in different variables. in python it's: a, x = input().split('-') have @ boost. string algorithms library includes of can find in python including split function splits string stl container of choice. example (lifted docs) splitting on dash or asterisk: std::string str1("hello abc-*-abc-*-abc goodbye"); std::vector< std::string > splitvec; // #2: search tokens split( splitvec, str1, is_any_of("-*"), token_compress_on ); // splitvec == { "hello abc","abc","abc goodbye" }

objective c - preventing selection on MKPointAnnotation -

is there way prevent annotation in mkmapview instance being enabled. in other words, when user taps red pin on map, there way prevent highlighting pin. right pin turns dark when touched... edit: i'm using following code return mkpinannotationview // future mkmapview users - don't forget set _mapview's delegate _mapview.delegate = self; _annotation = [[mkpointannotation alloc] init]; _annotation.coordinate = mylocation; [_mapview addannotation:_annotation]; -(mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation{ mkpinannotationview *pin = [[mkpinannotationview alloc] initwithannotation:_annotation reuseidentifier:@"id"]; pin.enabled = no; return pin; } set enabled no on mkpinannotationview , return -mapview:viewforannotation: delegate method (if haven't implemented it, it). - (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id <mkannotation>)annotation { ...

cross browser - What's the JavaScript equivalent of CSS Media Queries? -

i'm experienced in using media queries target css specific browser sizes/or contexts, i'm interested in doing js, having more control on how scripts run on browsers of different abilities. i'm not asking how duplicate functionality of media queries in js, more methods controlling code gets run on browsers? is there method or system give me control without resorting detecting browsers? there isn't control how code run unless ground work in detecting situations want code run in , wrapping things in if blocks. can use conditional statements in html, if blocks in generating server code, or in js itself.

regex - Format a file based on the IFS -

i using sed concatenate contents of file as: cat source.c | sed -e :a -e '$!n; s/\n/ /; ta' the file contains relevant informations [ series of strings ] separated pipe | . want change ifs pipe | and output may piping new ifs thereby displaying new formatted file stdout. an instance of source.c after concatenation : void f0 (***) | void f1 (***) | void f2 (***)| void f3 (***) what hope achieve setting ifs : void f0 (***) void f1 (***) void f2 (***) void f3 (***) thanks in advance replies .i not sure if possible files , , dont want involve variables or arrays here . edit : source file appears in beginning : void f0 (***) | void f1 (***) | void f2 (***) | void f3 (***) so first concatenate double space each word group , split using ...

python - How to find the path of a changing directory name? -

i want access following path on ubuntu in python code: ~/.mozilla/firefox/dh4ytbdj.default/bookmarkbackups which contains firefox bookmarks the problem part before ' .default ' different every user , machine. there way can specify general path directory , make python access , retrieve desired file? and possible implement ' ~ ' in python code access current user's home? >>> import os >>> os.path.expanduser('~/.mozilla/firefox/dh4ytbdj.default/bookmarkbackups') '/home/username/.mozilla/firefox/dh4ytbdj.default/bookmarkbackups' for system-wide access of personal firefox directories (with sufficient rights) try: >>> import glob >>> glob.glob('/home/*/.mozilla/firefox/*.default/bookmarkbackups') as @nedbatchelder noted, can combined 1 command: import os, glob next(glob.iglob(os.path.expanduser('~/.mozilla/firefox/*.default/bookmarkbackups'))) which returns 1 (if existing) ...

url rewriting - How to rewrite urls -

i have site @ xyz.com, reasons want redirect access www.xyz.com url xyz.com. if add 'www', want alter address in bar xyz.com. there way? first enable mod_rewrite in web server use .htaccess file in directory content: rewriteengine on rewritecond %{http_host} ^www\.xyz\.com$ rewriterule ^(.*)$ "http\:\/\/xyz\.com\/$1" [r=301,l]

qt - How to put several QImage in a QGraphicsView? -

i have scene several items added. problem when items displayed, overlapping. there way indicate in qgraphicsview or qgraphicsscene position each item should appear? yes, have use qgraphicsitem::setpos() method. suppose added qgraphicspixmapitem , : qgraphicsscene *scene = ... ; // scene qimage image = ... ; // qimage want add scene qpixmap pixmap = qpixmap::fromimage(image) ; // add image item scene qgraphicspixmapitem * imageitem = scene->addpixmap(pixmap) ; // modify item's position in scene coordinates qpointf imagepos = ... ; // whatever scene pos want imageitem->setpos(imagepos) ;

How to Login in a JSF page using java -

i'm trying login in .jsf intranet page, here part of it: <form method="post" action="j_security_check" name="loginform" id="loginform"> <input name="j_username" type="text" class="textbox" maxlength="30"/> <input name="j_password" type="password" class="textbox" maxlength="30"/> <input type=submit value="enter" class="button"> <input type=submit value="exit" class="button"> </form> i've searched , tryied @ java, didn't worked, same page result: httppost post = new httppost("http://xxxx/login.jsf"); list <namevaluepair> parameters = new arraylist <namevaluepair>(); parameters.add(new basicnamevaluepair("j_username", "92232...

ruby on rails - Custom POST routes for create action not fired up -

# explaining context puts "i learning rails, building simple forum application." puts "i pretty satisfied got far routes... " puts "...still figuring them out." puts "been 2 days trying sorts of things." puts "this now, , not working expected." puts "any help/pointers appreciated! :)" # problem puts "i want forum's create path '/helpcenter' , not '/helpcenter/cat'." puts "when access form create new forum , hit submit, " puts "the form post '/helpcenter' correctly (firebuged)" puts "but index, not create!" puts "i put debugger in create action not being called." # config/routes.rb scope "/helpcenter" resources :cat, :controller => "forums", :as => :forums resources :topics , :controller => "forum_topics", :as => :topics resources :posts, :controller => "forum_posts", :as =...

perl - How to Append Next Line to Current Line -

i struggling find way append next line current line if timestamp matches. here code far: open(fh, "error_log:); @data = <fh> foreach $line (@data) { if ( ($line =~ /notice/)) { $line =~ s/ /,/g; @l1 = split(/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy, +|rd,|wr,|ka,|log,|dns,|cls,|bsy:,|in,|/, $line); $line =~ s/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,|rd,| +wr,|ka,|log,|dns,|cls,|bsy:,|in,//g; print $line; note printed see output. output following: wed,jun,13,10:40:35,2012,758,42,0,29,11,0,0,2 wed,jun,13,10:40:35,2012,29,mod_was_ap22_http.c wed,jun,13,10:41:35,2012,761,39,0,34,5,0,0,0 wed,jun,13,10:41:35,2012,34,mod_was_ap22_http.c wed,jun,13,10:42:35,2012,769,31,0,22,6,0,0,3 wed,jun,13,10:42:35,2012,22,mod_was_ap22_http.c wed,jun,13,10:43:35,2012,754,46,0,29,17,0,0,0 i number (29 on 2nd line) placed in csv form after others on first line corresponding timestamp. rest of l...

mysql - Python sql database server -

is there pure python sql server implentation? ie. way host database python can accessed on network. mysql server in python. thanks obviously mysql server not in python, can't that. there multiple pure python databases, such gadfly, snakesql, , buzhug. without knowing want, it's hard pick. gadfly mature sql database in pure python, supports subset of sql. snakesql supports more of language, it's less secure. if don't need sql, buzhug faster, more stable, , easier use else i've tried. but still, unless matters language database written it, makes more sense use mysql plus python bindings.