Posts

Showing posts from April, 2014

scala - Passing selected value of a select to form action -

i have menu want differ based on account selected in system. i have page allows user select account html select. when user submits form account selection page want call menu method on controller passing in selected value url looks correct. here existing template page allows user select account: @helper.form(action = routes.accounts.menu { <table> <tr> <td><select id="accountnames"> @accountnames.map { name => <option value="@name">@name</option> } </select></td> </tr> <tr> <td> <p> <input type="submit" value="choose"> </p> </td> </tr> </table> } from routes file: get /account/:accountname/menu controllers.accounts.menu(accountname: string) ...

javascript - Inline JS (OnMouseOver) - Repeat Something Until MouseOut Occurs -

is there way run given function every 10ms, considering limited running inline code (no external js files or tags)? i can use: <div onmouseover="functions here" onmouseout="functions here"> to more specific want move element left 50px every 10ms using marginleft, can not run externail functions or js libraries mentioned above. i thinking of maybe incorporating in onmouseover setinterval(function, 10), don't see way of stopping when mouseout occurs. i know can use jquery event handlers .on, these not option here since have externally loaded (not inline) set global variable: <div onmouseover="if (!window.intervalid) window.intervalid=setinterval(function() {/*your code*/}, 10);" onmouseout="clearinterval(window.intervalid); window.intervalid=null;">

tcpclient - Indy TCP - Read data in a loop -

a tcp server sending data frames continuosly every 8ms. want program client able receive these data frames. there procedure in indy 9 know if there data available in buffer? my current programs following (i using thread): procedure tthreadread.execute; var buffer: array [0..755] of byte; //s1: string; //i: integer; begin idtcpclient1.recvbuffersize:= 756; idtcpclient1.connect; while terminated = false begin if idtcpclient1.inputbuffer.size = 0 idtcpclient1.readfromstack(true,0,false); while idtcpclient1.inputbuffer.size > 0 begin readbuffer(buffer, fclient.inputbuffer.size); //s1:= ''; //for i:=0 length(buffer)-1 // s1:=s1+inttohex(ord(buffer[i]),2); //read values-->global var //form1.memo1.text:=s1; end; end; end; is there more efficient solution reading tcp data continuously (like onread event in udp)? thanks in advance. tidtcpclient not asynchronous component. not tell whe...

c# - Is locking some object in one method is also makes it locked in other method? -

when thread locks mylist in somemethoda , while executing block inside lock , other thread can execute mylist.add(1) in somemethodb or wait because 'mylist' locked in somemethoda ? class { private list<int> mylist; public void somemethoda() { lock(mylist) { //... } } public void somemethodb() { mylist.add(1); } } edit explicit answer: no , need lock list explicitely in somemethodb . compiler not automatically add locks why ever have explicitely lock otherwise? things horribly slow. far better forbid multi threading lock each object access 1 the recommended idiom this: class { private list<int> mylist; private readonly object _lockobject = new object(); public void somemethoda() { lock(_lockobject) { //... } } public void somemethodb() { lock(_lockobject) { mylist.add(1); } } ...

git push --force by default -

when git push , git forced updates automatically if necessary, if had specified --force option. have configured long time ago. don't want behavior anymore, , can't find configuration variable affects behavior. can't find relevant in .gitconfig or .git/config files. edit: added current config files: my .gitconfig: [user] name = xxxx xxxx email = xxxx [core] excludesfile = /users/xxxx/.gitignore_global [difftool "sourcetree"] cmd = opendiff \"$local\" \"$remote\" path = [mergetool "sourcetree"] cmd = /applications/sourcetree.app/contents/resources/opendiff-w.sh \"$local\" \"$remote\" -ancestor \"$base\" -merge \"$merged\" trustexitcode = true local repo config: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true [remote "origin"] url = ssh://xxxx@xxxx.com/var/git/tw...

windows - Facebook integration with javascript FB Graph api Post on wall Unknown error in firefox -

i posting on user`s wall using fb graph api function post on wall follow: function posttowall() { var mymessage = 'my message'; var mypic = 'http://myapp/a.jpg'; var mylink = 'http://www.myapp.com'; var myname = 'myapp'; var mydesc = 'my desc .'; fb.api('/me/feed', 'post', { message: mymessage, picture: mypic, link: mylink, name: myname, description: mydesc }, function (response) { if (!response || response.error) { alert(response.error.message); } else { alert('post id: ' + response.id); } }); // alert('do want continue ? '); }; it works fine in crome when use same in firefox prompts unknown error alert(response.error.message); .and in error console of firefox error error: uncaught exception: [exception... "prompt aborted user" nsresult: "0x80040111 (n...

What's the Groovy equivalent to Python's dir()? -

in python can see methods , fields object has with: print dir(my_object) what's equivalent of in groovy (assuming has one)? looks particulary nice in groovy (untested, taken link code credit should go there): // introspection, know details classes : // list constructors of class string.constructors.each{println it} // list interfaces implemented class string.interfaces.each{println it} // list methods offered class string.methods.each{println it} // list methods names string.methods.name // fields of object (with values) d = new date() d.properties.each{println it} the general term looking introspection .

Appcelerator Titanium Facebook Like Menu -

at moment i'm developing app want use facebook menü here: https://github.com/mpociot/titanium-facebook-slide-menu // alphabytes // facebook menu window var leftmenu = ti.ui.createwindow({ backgroundcolor: 'red', top: 0, left: 0, width: 150, zindex: 1 }); var data = [{title:"row 1"},{title:"row 2"},{title:"row 3"},{title:"row 4"}]; var tableview = ti.ui.createtableview({ data: data }); leftmenu.add(tableview); leftmenu.open(); // facebook menu window var rightmenu = ti.ui.createwindow({ backgroundcolor: 'red', top: 0, right: 0, width: 150, zindex: 1 }); var data = [{title:"row 1"},{title:"row 2"},{title:"row 3"},{title:"row 4"}]; var tableview = ti.ui.createtableview({ data: data }); rightmenu.add(tableview); rightmenu.open(); // animations var animateleft = ti.ui.createanimation({ left: 150, curve: ti.ui.ios.animat...

android - How can get an image from an image view? -

i trying image put image view. approach: // image in image view bytearrayoutputstream outputstream = new bytearrayoutputstream(); bitmap mybitmap = mimageview.getdrawingcache(); mybitmap.compress(compressformat.png, 0, outputstream); then want insert database: mdbhelper.createreminder(outputstream); the databaseadapter looks this: public long createreminder(bytearrayoutputstream outputstream) { contentvalues initialvalues = new contentvalues(); initialvalues.put(key_image, outputstream.tobytearray()); return mdb.insert(database_table, null, initialvalues); } when tried app crashed. think statements somehow faulty. ideas??? drawable drawable = mimageview.getdrawable(); if (drawable instanceof bitmapdrawable) { bitmapdrawable bitmapdrawable = (bitmapdrawable) drawable; bitmap bitmap = bitmapdrawable.getbitmap(); }

linux - What's wrong with my rc.local file (Ubuntu)? -

i have python daemon process gets started via rc.local. same script, same permissions, installed on few other ubuntu boxes have. runs without trouble on installations. is, after restarting box, daemon process running. with particular installation though, daemon process not running time log in , check existence of process. rc.local files between systems identical (or @ least close enough): localaccount@sosms:~$ cat /etc/rc.local #!/bin/sh -e # # rc.local # # script executed @ end of each multiuser runlevel. # make sure script "exit 0" on success or other # value on error. # # in order enable or disable script change execution # bits. # # default script nothing. python /var/www/mydaemon/main.py > /var/log/somelog.txt exit 0 the permissions are: localaccount@sosms:~$ ls -la /etc/rc.local -rwxr-xr-x 1 localaccount localaccount 370 jun 3 11:04 rc.local i tested if rc.local process getting executed using test rc.local: localaccount@sosms:/var/log/sosmsd$ cat /...

Codeigniter - Ordering active record alphabetically -

i wondering if me out something. i have bit of ajax calls function in model. but cant seem able order output 'model'. below function im having trouble with function get_models_by_brand($tree = null) { $this->db->select('id, model'); if($tree != null){ $this->db->where('brand_id', $tree); } $query = $this->db->get('models'); $models = array(); if($query->result()){ foreach ($query->result() $model) { $models[$model->id] = $model->model; } return $models; } else { return false; } } from documentation , $this->db->order_by(); lets set order clause. first parameter contains name of column order by. second parameter lets set direction of result. options asc or desc, or random. $this->db->order_by("title", "desc"); // produces: order title desc you can pass own string...

c - Optimization for recursive function required -

i want optimize function can give quick output input values (x = 300, y = 120, z = 10). thought of storing values in 3d array after successive calculation, unable implement that. please help. recursion hard understand! double p(int x, int y, int z) { double final; if (x >= 0 && (y <= 0 || z <= 0)) return 0; else if (x <= 0 && (y >= 0 || z >= 0) ) return 1; else { final = 0.1 * (p(x,y-1,z) + p(x-1,y-1,z) + p(x-2,y-1,z) + p(x-3,y-1,z) + p(x-4,y-1,z) + p(x-5,y-1,z) + p(x-6,y-1,z) + p(x-1,y,z) + p(x-1,y,z) + p(x,y-1,z-1)); return final; } } in order calculate p (300, 120, 10) function has calculate possible combinations of x, y, z such 0 <= x <= 300 , 0 <= y <=...

VB.Net / Acrobat - Acrobat hangs after user manually exits program -

i'm having issue vb.net , adobe acrobat. issue comes exiting acrobat windows taskbar still states there acrobat.exe process open. have tried using marshal.releasecomobject() , still hangs there. not want have rely on "end process" option on task bar in order remove it. below snippet of code try using: try 'tries close acrobat application acrobatapp.exit() system.runtime.interopservices.marshal.releasecomobject(javascriptobj) javascriptobj = nothing system.runtime.interopservices.marshal.releasecomobject(acropddoc) acropddoc = nothing system.runtime.interopservices.marshal.releasecomobject(acrobatavdoc) acrobatavdoc = nothing system.runtime.interopservices.marshal.releasecomobject(acrobatapp) acrobatapp = nothing 'below snippet of code found garbage collecting, did not work 'gc.collect() 'gc.waitforpendingfinalizers() catch ex exception 'a...

c# - Write file need to optimised for heavy traffic part 2 -

for interest see come can refer part 1, not necessary. write file need optimised heavy traffic below snippet of code have written capture financial tick data broker api. code run without error. need optimize code, because in peak hours zf_tickevent method call more 10000 times second. use memorystream hold data until reaches size, output text file. the broker api single threaded. void zf_tickevent(object sender, zenfire.tickeventargs e) { outputstring = string.format("{0},{1},{2},{3},{4}\r\n", e.timestamp.tostring(timefmt), e.product.tostring(), enum.getname(typeof(zenfire.ticktype), e.type), e.price, e.volume); fillbuffer(outputstring); } public class memorystreamclass { public static memorystream ms = new memorystream(); } void fillbuffer(string outputstring) { byte[] outputbyte = encoding.ascii.getbytes(outputstring); ...

database - Solr best practice: All data in Solr or periodically copy to Solr? -

solr supports updating, hence possible develop web app stores data within solr. idea? using solr, user update solr documents directly if change something. example, user might edit recipe document contain new tag. approach because app has 1 database. using 2 databases, user updates database needs to. then, periodically system updates solr index. approach allows use database technology keep data consistent , doesn't require slow rebuilding of solr indexes. for particular application, writes database infrequent. which approach makes sense , lead stable system? if updates in db infrequent, doing nightly delta import dih easy, , it's typical way people use solr (that is, not being primary store data). there people use solr primary store too, more infrequent, though when 4.0 released contained improvements makes easier use way.

c# - Combining XmlSerializer and XmlWriter? -

in addition list of objects serializing xml file using c#'s xmlserializer, store few more independent elements (mainly strings textboxes) in same xml. public static void savebehaviors(observablecollection<param> listparams) { xmlserializer _paramsserializer = new xmlserializer(listparams.gettype()); string path = environment.getfolderpath(environment.specialfolder.desktop); path += "\\test.xml"; using (textwriter writefilestream = new streamwriter(path)) { _paramsserializer.serialize(writefilestream, listparams); using (xmlwriter writer = xmlwriter.create(writefilestream)) { writer.writestartelement("foo"); //test entry... writer.writeattributestring("bar", "some & value"); writer.writeelementstring("nested", "data"); writer.writeendelement(); } ...

wrting integers as 4 bytes to file java -

i writing java program in have write integers file. make more efficient want write int 4 bytes(which think binary file kind of thing, not sure) , while reading file want read integers directly(i not want read bytes , convert them integer). there way that. i want write millions of integers file want method fast , efficient. i new please put me. use dataoutputstream class or randomaccessfile . both provide methods writing structured binary data, example "int 4 bytes" want.

time - Python timeit and program output -

is there way use timeit function output both function result , time took process @ same time? right using timer = timer('func()', 'from __main__ import func') print timer.timeit(1) but outputs time , not program output, returns @ end. want output funcoutputgoeshere 13.2897528935 on same line. ideally, i'd able take average of program running n times , outputting program result , average time (a total of 1 output overall) two options: include 'print' in timed code. ugly, hey. timer = timer('print func()', 'from __main__ import func') print timer.timeit(1) if run function once, dispense timeit module altogether , time code directly using same method: import sys import time if sys.platform == "win32": # on windows, best timer time.clock() default_timer = time.clock else: # on other platforms best timer time.time() default_timer = time.time t0 = default_timer() output = func() t1 = def...

xml - Passing parameters to testNG provider -

i'm new this, information not covered in testng docs, , understand few things, if can me. @dataprovider(name="test1") public object[][] providetestparam(itestcontext context){ string testparam = context.getcurrentxmltest().getparameter(test_param); return new object[][]{{ testparam }}; } @test(dataprovider="test1") public void testdata(string data){ //... } does know test_param ? file name, method parameter in testng.xml file? i looked @ javadoc itestcontext , don't understand how getparameter work. single hash map xml file data coming from? or key value pairs xml file data coming from? all want have xml file stored in project , use data xml file. feed dataprovider , run tests. there way this? can getparameter values within testng.xml <test> node or <class> node? no idea, test_param doesn't appear in code snippet. the parameters exposed in itestcontext ones found in testng.xml . sure, want parse o...

MongoDB - how to query for a nested item inside a collection? -

i have data looks this: [ { "_id" : objectid("4e2f2af16f1e7e4c2000000a"), "advertisers" : [ { "created_at" : isodate("2011-07-26t21:02:19z"), "category" : "infinity pro spin air brush", "updated_at" : isodate("2011-07-26t21:02:19z"), "lowered_name" : "conair", "twitter_name" : "", "facebook_page_url" : "", "website_url" : "", "user_ids" : [ ], "blog_url" : "", }, and thinking query give id of advertiser: var start = new date(2011, 1, 1); > var end = new date(2011, 12, 12); > db.agencies.find( { "created_at" : {$gte : start , $lt : end} } , { _id : 1 , program_ids : 1 , advertis...

php - Search mysql database using multiple terms utilizing drop menu for some -

i have multi field database, variables constant, selected using drop menu, variables free entry. want search database , find count of rows containing combination of selected terms, works part if use more 2 drop menus selection seems stop working: form search: <form action="search2.php" method="post"> <p> name: <input type="text" name="term1" style="background-color:#ffff11"> <br /> <br /> dept.: &nbsp;<input type="text" name="term4" style="background-color:#ffff11"> <br /> <br /> month: <select name="term2" style="width:65px; color: black;background-color:#ffff11"> <option value="" style="background-color: #ffff11;">...</option> <option value="jan" style="background-color: #ffff11;" >jan</option> <option value="feb" style="background-color:...

javascript - How can I display most of an html page quickly, then load the slow things last? -

i've got jsp page this: <html><body> <div id="maincontainer"> <div id="firstdisplaystuff">...</div> <% out.flush(); %> <div id="slowstuff"> <mytaglib:abc name='slowboat'>...</mytaglib> </div> </div> <div id="floatrightcontainer> <div id="endingdisplaystuff">...</div> <div> </body></html> when hits taglib, takes forever, , delay can not avoided. so using out.flush(); can @ least display firstdisplaystuff , user sits there looking @ half page while taglib stuff runs. after that's done user see endingdisplaystuff . i want firstdisplaystuff , endingdisplaystuff both display right away. but figured using jquery, there way leave <div id="slowstuff"> blank, , load later. what jquery code load <div id="slowstuff"> after both display stuff divs showing? ...

Write a python script that goes through the links on a page recursively -

i'm doing project school in compare scam mails. found website: http://www.419scam.org/emails/ save every scam in apart documents later on can analyse them. here code far: import beautifulsoup, urllib2 address='http://www.419scam.org/emails/' html = urllib2.urlopen(address).read() f = open('test.txt', 'wb') f.write(html) f.close() this saves me whole html file in text format, strip file , save content of html links scams: <a href="2011-12/01/index.htm">01</a> <a href="2011-12/02/index.htm">02</a> <a href="2011-12/03/index.htm">03</a> etc. if that, still need go step further , open save href. idea how do in 1 python code? thank you! you picked right tool in beautifulsoup. technically in 1 script, might want segment it, because looks you'll dealing tens of thousands of e-mails, of seperate requests - , take while. this page gonna lot, here's little code sn...

mysql - How to handle ambiguous field in my SQL -

select tb.id, latitude, longitude, 111151.29341326 * sqrt( pow( -6 - `latitude` , 2 ) + pow( 106 - `longitude` , 2 ) * cos( -6 * 0.017453292519943 ) * cos( `latitude` * 0.017453292519943 ) ) distance `tablebusiness` tb join `tablecity` tc on tb.city = tc.city join `businessestag` bc on bc.businessid = tb.id join `businessesdistricts` bd on bd.businessid = tb.id join `tabledistrict` td on td.id = bd.district ( `title` '%restaurant%' or `street` '%restaurant%' or tb.city '%restaurant%' or bc.tag '%restaurant%' or td.district '%restaurant%' ) , ( - 6.0917668133836 < `latitude` , `latitude` < - 5.9082331866164 , 105.90823318662 < `longitude` , `longitude` < 106.09176681338 ) order distance limit 0, 100 this mysql went through then want based on building too. so did, suggested do select tb.id, latitude, longitude, 111151.29341326 * sqrt(pow(-6 - `tb.latitude`, 2) + pow(106 - `tb.longitude`, 2) * cos(-6 * 0.0174532925199...

javascript - Generate a google map using latitude and longitude code script -

i need generate google map marker. i have latitude , longitude code. there's lots of scripts around quickest way display map on web page using latitude , longitude codes have? this current code: - no map being displayed <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <script> $(document).ready(function (){ var mylatlng = new google.maps.latlng(-25.363882,131.044922); var myoptions = { zoom: 4, center: mylatlng, maptypeid: google.maps.maptypeid.roadmap } map = new google.maps.map($('#map'), myoption...

kindle - Is it possible to create .mobi files with python? if so, how? -

i want able create .mobi files python, haven't found after hour of searching. don't want use calibre or softwares it, plain python. i'd recommend take @ this repo , if don't want use calibre (which great , has cli). while this script has created creating .mobi guardian, can modify taste.

google maps - api key, daily limit, free vs. pricing model for javascript v3 -

i have 300 domains use google maps. each has separate api key. 1 of them gave me error saying incorrect key, following understand v3 has no key , api limit of 25k maps per day. is 25k per account or per website? thanks mike some parts of google api require api key , others not when using javascript api. parts not require key limit per client ip unless use api key. otherwise, believe usage limits per key if each website has different key, should ok. https://developers.google.com/maps/faq#usagelimits

jquery - Invalid Assignment Left-Hand Side -

i trying assign class tag via jquery, resulting in error through firebug says "invalid assignment left-hand side" on fourth line below. <cfoutput> $('.pngfix a').each(function(index) { var hreflink = $(this).attr("href"); if (hreflink.tolowercase() = '../audio.cfm') { $(this).addclass('audioimg'); } }); </cfoutput> looking around online, looks syntax problem, don't seem see it... any tips? thanks if (hreflink.tolowercase() = '../audio.cfm') that attempts assign value, rather check equality. change = operator == .

html - CSS: Vertical column layout without <table> -

ok, leaned html & css in 2001. used (to create website "vertical-column" layout): <html> <head> <title>vertical-column layout</title> </head> <body> <table id="doc" > <!-- header --> <tr> <td id="header" colspan="3"><!-- header code/php include --></td> </tr> <!-- / header --> <!-- / content --> <tr> <td id="col1" name="menu"><!-- content code/php include --></td> <td id="col2" name="content_left"><!-- content code/php include --></td> <td id="col3" name="content_right"><!-- content code/php include --></td> </tr> <!-- / content --> <!-- footer --> <tr> <td id="footer" colspan="3"><!-- header code/php include --></td> ...

breadth first search - SPOJ WATER : Developing a BFS algorithm -

i attempting solve following question spoj : on rectangular mesh comprising n m fields, n m cuboids put, 1 cuboid on each field. base of each cuboid covers 1 field , surface equals 1 square inch. cuboids on adjacent fields adhere 1 close there no gaps between them. heavy rain pelted on construction in areas puddles of water appeared. task write program which: reads standard input size of chessboard , heights of cuboids put on fields computes maximal water volume, may gather in puddles after rain writes results in standard output. input the number of test cases t in first line of input, t test cases follow separated empty line. in first line of each test case 2 positive integers 1 <= n <= 100, 1 <= m <= 100 written. size of mesh. in each of following n lines there m integers interval [1..10000]; i-th number in j-th line denotes height of cuboid given in inches put on field in i-th column , j-th raw of c...

Attaching type hints to a Clojure delayed call -

i'm attempting put handles on java objects aren't available @ compile time, available @ runtime, in vars follows: (def component-manager (delay (somejavaobject/gethandle))) (if better mechanism delays available, welcome). when these objects used, reflection warning generated. these frequent, i've tried avoid following: (def my-handle ^somejavaobject (delay (somejavaobject/gethandle))) unfortunately, reflection warning still generated in case. modifying references works: (.foo ^somejavaobject @my-handle) ...but uglifies code substantially. wrapping in macro adds type hints seems obvious approach: (def my-handle' (delay (somejavaobject/gethandle))) (defmacro my-handle [] (with-meta '(deref my-handle') {:tag somejavaobject})) ...and looks should right thing: => (set! *print-meta* true) => (macroexpand '(my-handle)) ^somejavaobject (deref my-handle') ...but doesn't hold true when rubber hits road: ...

c# - How to list all printers on network computer -

Image
as shown below in picture, when tried retrieve printers, got 2 printers. is there way return printers using either powershell wmi or c#(so can translate in powershell)? i have tried system.drawing.printing.printersettings.installedprinters (refer how list of printers in computer - c# winform ) displays 2 entries. simply, via system.drawing.printing foreach (string printer in printersettings.installedprinters) { console.writeline(printer.tostring()+environment.newline); } via wmi public static void availableprinters() { omanagementscope = new managementscope(managementpath.defaultpath); omanagementscope.connect(); selectquery oselectquery = new selectquery(); oselectquery.querystring = @"select name win32_printer"; managementobjectsearcher oobjectsearcher = new managementobjectsearcher(omanagementscope, @oselectquery); managementobjectcollection oobjectcollection = oobjectsearcher.get(); foreach (managementobject oitem in oobject...

dotnetnuke - DNN Radeditor - hyperlink manager -

since updated version 06.02.00 hyperlink manager displays pages portal 0 rather new parent portal creating. have searched on google last few days , couldnt find anything. effecting new portals , not existing portals created prior install. can please help? the hyperlink manager developer , supported dnn folks. can ask them directly in forums http://www.dotnetnuke.com/community/forums/tabid/795/forumid/108/threadid/364908/scope/posts/default.aspx

javascript - Preserving URL fragment through CAS sign-on -

i maintain single-page application uses yui 2.8 history module retain local options in url fragment. i've put behind cas authentication, , i'm finding fragment gets lost during cas authentication. retained in signon url, not when redirected application page. true after session timeouts, users bumped default options after re-authentication. any suggested strategies hanging on fragment (or underlying javascript state) though cas roundtrip? you can store in cookie, sessionstorage , or value of window.name if there no security implications: //cookie document.cookie = "fragid=" + window.location.hash + ";path=/"; //session storage window.sessionstorage.setitem("fragid",window.location.hash); //window window.name = window.location.hash references url fragments , redirects – ieinternals

Flex/AIR SQLite: Multiple Inserts, Unknown Number of Rows in 1 SQL Statement -

i creating mobile app in flex/adobe air. using sqlite store , retrieve data. have situation need insert unknown number of rows table. there way single statement in sqlite? know can done using loop in as3, wanted see if it's possible single sql statement. have found references using unions , select, however, examples weren't clear nor sure applicable situation. examples appreciated. thanks. you should able like: insert sometable values ('column 1 row 1', 'column 2 row 1'), ('column 1 row 2', 'column 2 row 2'), ('column 1 row 3', 'column 2 row 3'); you'll still need loop in build sql statement, though. note there seems some confusion whether syntax supported sqllite.

jquery - Catch all scroll events on page -

i need little help. have created own context menu right click , want behave classic 1 - dissapear after scroll. problem have more scrollbars in layout, question is, how catch scroll events on page? have tried examle $(document).scroll() works main scrollbar, have tried use .on("scroll", function(){}); on main container, doesn't work @ :( so ideas please? thanks, david i suggest adding classes scrollable elements, such class="scrollable", , selector on class. requires dirty work in adding class, efficiently job done. $(document).add('.scrollable').on('scroll', function() { alert("action here"); });

android: how to detect horizontal and vertical gesture lines -

i have objects want connect lines. user should able simple line-gesture. use gestureoverlayview , read article http://developer.android.com/resources/articles/gestures.html , says following orientation: indicates scroll orientation of views underneath. in case list scrolls vertically, means horizontal gestures (like action_delete) can recognized gesture. gestures start vertical stroke must contain @ least 1 horizontal component recognized. in other words, simple vertical line cannot recognized gesture since conflict list's scrolling. and problem - want draw lines horizontal , vertical now have ongestureperfomedlistener, normal gesture recognition , additionally gestureoverlayview.ongesturelistener, in detect lines. want draw dashed line - vertical , horizontal. easier, if complete gesture in ongestureperformedlistener, instead of every single stroke of dashed line, in ongesturelistener. any ideas how can solve ? there method, called when gesturing done, if not recog...

php - Alternative Way to write string with Quotations -

how make work in php: $string = "<div id="widget14" class="widget widget-124"> <a href="http://website.com/page.php?id={$pageurl}"><p><span class="hotspot" onmouseover="tooltip.show('<strong>about us</strong><br/>learn us!');" onmouseout="tooltip.hide();"><img class="images_button" alt="about image" src="{$image_url}" width="172px"/><br/>about us</span></p></a> </div>"; $string = "<div id=\"widget14\" class=\"widget widget-124\"> <a href=\"http://website.com/cgames/\"><p><span class=\"hotspot\" onmouseover=\"tooltip.show('<strong>about us</strong><br/>learn us!');\" onmouseout=\"tooltip.hide();\"><img class=\"images_button\" alt=\"abo...

methods - Objective-C, how to display determinate progress bar? -

i show progress bar in app determinate rather indeterminate. doesn't work though when setting determinate (works fine indeterminate). i've read some of other answers this, although haven't worked. appreciated - thanks! @interface appdelegate : nsobject <nsapplicationdelegate> { iboutlet nsprogressindicator *showprogress; } - (ibaction)somemethod:(id)sender { [showprogress setusesthreadedanimation:yes]; // works [showprogress startanimation:self]; // works [showprogress setdoublevalue:(0.1)]; // not work [showprogress setindeterminate:no]; // not work [self dosomething]; [self dosomethingelse]; [self dosomethingmore]; .... [barprogress setdoublevalue:(1.0)]; // not work [barprogress stopanimation:self]; // works } updated code [working]: - (ibaction)somemethod:(id)sender { [showprogress setusesthreadedanimation:yes]; [showprogress startani...

compiler construction - ANTLR return group of lexical rules? -

Image
can replace indent_loop[3] in following grammar the group of 3 indent ? indent lexical rule indentation. i want write number of indent based on number. match_node : match_node_name (tree_operator) (new_line (indent_loop[3]) ( modulecall | literals ))* { match_node_list.push($match_node_name.text); } | single_quote pointe single_quote ; match_node_name : ident_small_letters ; indent_loop[int scope] : {scope == 3}? indent indent indent | {scope == 4}? indent indent indent indent ; indent : '\t'; when did not able come calling rule , not able return group of indentation? means, ( modulecall | literals ))* not called. where wrong? begining. or there other way this? you can using semantic predicate 1 : grammar t; parse : digit[1] digit[2] digit[3] eof ; digit[int amount] : ({amount > 0}?=> digit {amount--;})* ; digit : '0'.....

iphone - Custom compass calibration view like Compass app has -

Image
i want make compass native compass app has such calibration view. method tell need calibrate hardware - (bool)locationmanagershoulddisplayheadingcalibration:(cllocationmanager *)manager how notification calibration complete? you can monitor headingaccuracy of subsequent location updates see if accuracy did increase. apple has say: the alert remains visible until calibration complete or until explicitly dismiss calling dismissheadingcalibrationdisplay method. in latter case, can use method set timer , dismiss interface after specified amount of time has elapsed. so setting timer , dismissing if accurac increased should work you?

javascript - content not loading in facebox -

i'm having trouble facebox , can't seem find solution. anyways, have displayed , images work content not load. when click link rel="facebox" tag shows box displays loading.gif , none of content. know causing this? extremely simple can't seem find in code. here link page: http://www.mcallaro.com/smc/contact.html . have content being display:block can see there once close , click contact button see issue. thanks i haven't used facebox before, problem: <li><a href="#" rel="facebox">contact us</a></li> your contact link directing no because has # symbol no additional text. link facebox works anchor linking . make work must direct link div within page. example: your link this: <a href="#contact" rel="facebox">contact us</a><!-- #contact id of div linking --> your div within same page this: <div id="contact"> <!-- content here --> ...

android - programmatically set PreferenceScreen -

i have preferncescreen page showing of data , not saving setting the code below <?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android"> <preferencecategory android:title="member subscription status"> <preferencescreen android:title="subscription status" android:summary="active"> </preferencescreen> <preferencescreen android:title="next payment date" android:summary="2012-06-21 18:00:00s"> </preferencescreen> <preferencescreen android:title="plan type" android:summary="family"> </preferencescreen> </preferencecategory> </preferencescreen> right wondering how should set summary of preferncescreen show on screen? you can preference findpreference() , set summary setsummary() . ...

c# - How to map a related table with no primary key with fluent-NHibernate -

looks common situation me: have 2 tables: documents: did (pk, int), dname(varchar) and document_options: did (int), otype(int), ovalue(varchar) i have class document property options (a list of documentoption class) since document_options has no pk cannot use hasmany, , rows table don't seem 'real' entities anyway... i see way generate auto-number key document options , map hasmany, or maybe create composite id, i'd know if there better option don't know about. in case, documentoptions value object, since has no identity of own , has no meaning outside of document belongs to. so, use component map collection properties value object. public class document : entity // don't worry entity; it's base type created contains id property { public virtual string name { get; set; } public virtual ilist<documentoptions> options { get; protected set; } public document() { options = new list<documentoptions>()...

java - Getting different random strings from string array -

hi have string array 50 strings , want select 10 randon results , display them on table layout right except shows 1 result. heres code: private string[] list; private static final random rgenerator = new random(); @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); this.setrequestedorientation(activityinfo.screen_orientation_landscape); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.layout1); resources res = getresources(); list = res.getstringarray(r.array.names); string q = list[rgenerator.nextint(list.length)]; int total = 10; (int current = 0; current < total; current++) { // create tablerow , give id tablerow tr = new tablerow(this); tr.setid(100 + current); tr.setlayoutparams(...

php - What is this encoding called? -

i see in wordpress in database , see similar in cookie. kind of parser parses this: a:4:{s:14:"clientsorderby";s:9:"firstname";s:12:"clientsorder";s:4:"desc";s:13:"ordersorderby";s:2:"id";s:11:"ordersorder";s:4:"desc";} i it, a=array:x=number of children s=string:x=number of characters. is there parser built php kind of thing? why use method? it's php's built-in serialize() , can "decoded" unserialize() here example: $serialized = 'a:4:{s:14:"clientsorderby";s:9:"firstname";s:12:"clientsorder";s:4:"desc";s:13:"ordersorderby";s:2:"id";s:11:"ordersorder";s:4:"desc";}'; $unserialized = unserialize( $serialized); var_dump( $unserialized); output: array(4) { ["clientsorderby"]=> string(9) "firstname" ["clientsorder"]=> string(4) "de...

Store settings in database to decide whether to force login? -

i'd mange website dynamically. built database storing user level , check access pages successfully. want decide whether force login. store pages in database along "needlogin" boolean field, each time user access page, database decide whether force login? confused decide whether force login in frontend or backend? there better way?

c++ - Is it desirable to clear STL vector -

a quick question - possibly of style. desirable clear/empty vector when it's no longer required, or can rely on stl clean after when container no longer required. i'm talking in case basic vectors don't contain pointers or other objects require delete eg. std::vector<double> myvector; // use // finished // use clear? myvector.clear(); there's no benefit clearing vector, since it's not guaranteed give storage. see capacity() . if you're concerned memory used vector, can use little trick substitute empty vector: std::vector<double>().swap(myvector); of course easiest method let vector go out of scope , destroyed automatically , storage freed.

arrays - JavaScript: Why do I keep getting this error with a literal object custom method? -

ctx predefined along other canvas properties. didn't want bombard page huge chunk of code. i'm building array of literal objects , have 1 method. when try call method says it's undefined, this: var enemiesarray = []; function createenemy(ene) { (e = 0; e <= ene; e++) { var t = math.floor(math.random() * 291) var p = math.floor(math.random() * 101) var enemies = { x: t, y: p, hp: 20, dir: 0, damageimage: function () { return "bomber4.png"; } } enemiesarray.push(enemies); } } //an interval set call following function: function drawenemey() { (zdp in enemiesarray) { img = new image(); img.src = "images/" + enemiesarray[zdp].damageimage(); //this error. img.style.width = "20px"; ctx.drawimage(img, enemiesarray[zdp].x, enemiesarray[zdp].y); //move side side...

How to emulate Android Multiple Screen? -

how handle android multiple screen? confusing... i read here , here i'm confused range small, normal, large , xlarge. tried app on galaxy note works on real device. strangely not on emulator. tried use custom avd specific define galaxy note e.g. 800 x 1280 285 density. result looks ugly on emulator. i have problems other devices too. sgs 2, hd devices , other devices...all reference here seems invalid , inaccurate. how emulate perfectly? you can download galaxy note avd skin this link, see this article , reference.

iphone - warning : wait_fences: failed to receive reply: 10004003 -

i getting warning " wait_fences: failed receive reply: 10004003 ", not know why coming, i not have viewdidiappear method in code, have uialert in view, code uialertview *alert = [[uialertview alloc] initwithtitle:@"start" message:[nsstring stringwithformat:@"hi %@,",[user objectatindex:0] ] delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alert show]; [alert release]; this due ui actions on view controller on not currently,i.e. screen of accessing ui, not visible currently.

removed url from Google webmaster tool, now Google don't show my website in search -

i developed site, , removed url google webmaster tool " http://example.com \". i did because google show in search under construction title, previous page. when completed website, removed url there, , added sitemap etc have new copy of site. see in webmaster tools, pages indexed, still no success. yahoo , bing showing page when searched. in case try submitting sitemap & use fetch googlebot option , see happens.

How to convert Cyrillic letters to English latin in Java String? -

i have string a= "l1-23Миграција од vpn и промена на брзина actelis agregator alternativna 8-/208" ; i every string check if there cyrillic letters in string , convert them english: output should look: l1-23migracija od vpn promena na brzina actelis agregator alternativna 8-/208 thanks!

java - getting keytyped from the keycode -

i have send key code in hexadecimal function job tell key's code that. example key code in java control key in hexadecimal form 0x11 . there way can directly key typed ? otherwise have use switch statement. don't want consider it.i think not smart way this. use java.awt.event.keyevent.getkeytext(int keycode) . according javadoc: it returns string describing keycode, such "home", "f1" or "a".