Posts

Showing posts from August, 2010

java - Unmarshall single non-root node of a long XML file -

i have xml looks this: <root> <header> ... </header> <entries> ... </entries> </root> there single header node, lot of entries. there way extract node java bean, without reading whole xml file. if possible, there support in springbatch or xstream? i don't think using springbatch chunk-oriented tasklet staxeventitemreader appropriate since want read 1 item. you can write own itemreader extending staxeventitemreader (or, better, delegating it), redefine method itemreader.read() , change condition indicate reader "exhausted" returning null after first valid node read: when spring-batch found itemreader.read() method returning null stop processing file. can use chunk-oriented , avoid full file read.

performance - Hardware for a sharded + redundant MongoDB-environment -

i'm trying plan new database-environment scratch , i'm wondering how many servers needed , how performance should provide. since want fast, i'm considering using ssd-memory , loads of ram. however, flash-memory expensive , makes biggest part of cost of server. thus, entire system should set horizontal scaling start, can add more nodes when need more storage/performance. to started i'm thinking of using 2 shards, each consisting of master , replica-slave redundancy. mongodb-documentation suggests using 1 master , 2 slaves, i'm afraid won't in available budget, since each of these servers equipped 200 gb of ram , 6x400 gb ssd raid 10. when using shards, suggested using 3 config-servers failsafe/high-availability. same above, i'm thinking 1 master , 1 slave start. what sort of hardware recommend put config-servers on? should equally performant shard-nodes in terms of cpu/memory/harddisk? or can put them on virtualization or on cheaper hardware? do

ios - Different GADBannerView in TableView -

i want have uitableview contains admob banner every 13th cell. work, problem want show different banners (4 @ moment). @ cell 13 have banner 1 , @ cell 26 banner 2 , on. my problem is, don't know how realize that. receive first banner in every cell - - guess - means code loads 1 banner in every cell , says "yep. have ad. i'm happy" , not loads 2 banner in 26 cell. i did subclass "adcell" , have bool says "hasad" prevent every cell reloads when scrolling (but maybe part of problem?). maybe can me. the cell in table: adcell *cell = (adcell *)[tableview dequeuereusablecellwithidentifier:@"adcell"]; cell.tag = 4; if (cell == nil) { cell = [[adcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@"adcell"]; } if (![cell hasad]){ // create view of standard size @ bottom of screen. // available adsize constants explained in gadadsize.h. gadadsize custom

html - css : set the height of inner div just by using 'top' and 'bottom' propreties -

html code: <div class="container"> <div class="menu"> <div class="target"> </div> </div> <div class="main"></div> </div> the css code : .container{ position : absolute; height : 100%; width : 100%; background-color : green; } .menu{ position : absolute; top:0; left :0; height: 100%; width : 30%; background-color : orange; } .main{ position : absolute; top:0; left : 30%; height : 100%; width : 70%; background-color : blue; } .target{ position : relative; top : 20px; left : 10%; height: 70%; bottom : 100px; width : 80%; background-color : pink; overflow-y : auto; } the question: i want remove ' height ' property in ' .target ' div, ' height ' of div depends on ' top ' , ' bottom ' properties. my objective have fixed dist

php - Curl too slow with big files, known solutions don't work -

i upload files curl in php running on windows server 2008 (via post), uses 10% of possible speed. i've tried every solution find: -using http 1.0 -using curl version -another php version -using apache, use xampp, use wamp, use iis -changing buffer size -edit registry of windows (windows socket stack problem) -use server -use other files -use different scripts as said i've used different versions of can change. windows server 2008 seems problem, can't change because rented server paid year. try virtual apache system on server isn't solution. there solution problem?

php - Invalid controller specified (error) when trying Propel Query -

i've added propel orm zend framework project. following files under /application/configs folder: application.ini build.properties classmap-gentsefeesten-conf.php gentsefeesten-conf.php runtime-conf.xml schema.xml under /application/models have: gentsefeesten map om query's i work modules have modules folder 2 folders in (my modules). in "index.php" file i've added following: (third rule) set_include_path(implode(path_separator, array( realpath(application_path . '/../library'), realpath(application_path . '/models'),//propel get_include_path(), ))); so application gets models in models folder. but following error : fatal error: uncaught exception 'zend_controller_dispatcher_exception' message 'invalid controller specified (error)' in /applications/mamp/htdocs/gentsefeesten/library/zend/controller/dispatcher/standard.php:248 stack trace: #0 /application

When Google Maps API calls "mapsbackend.loadMap" method as reported in API console? -

someone explain me when gmap javascript api calls mapsbackend.loadmap method reported in google api console? is called when first script google using " http://maps.googleapis.com/maps/api/js?key= ..." url? called when gmap objects dynamically loaded google server? or called when map rendered on screen? (in case, method never called if map container tag display: hidden or display: none ?) thanks in advance each time create google.maps.map -instance map-load counted. from docs : a map load counted when map initialized on web page i've tested little bit, seems map-load counted first time when tilesloaded-event of map fires. this event fire when map hidden, when map-div isn't part of document @ all. it not fire when 1 of required arguments constructor missing(e.g. zoom), set required property tilesloaded-event fire , load counted.

google app engine - GAE and JPA persistence exception -

i've created gae 1.8.2 project using jpa 2.0. when try launch junit tests throws following exception: java.lang.exceptionininitializererror @ it.bfm.dbutility.dbaccess.<init>(dbaccess.java:10) @ it.bfm.businesslogic.utenteimpl.<init>(utenteimpl.java:16) @ it.bfm.test.utentetest.testcreautente(utentetest.java:13) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:47) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:44) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:1

sql - jpql select into select -

it possible use 1 select's results table another(in other word: upper) select statement. there equivalent in jpql here sample sql statements select x.name, sls.total benefit (select * person) x inner join salesman sls on sls.person_id = x.id what equivalant statement in jpql? no, not possible. subqueries can used in , having clauses, told in jpa 2.0 specification: subqueries may used in or having clause.[58] ... [58] subqueries restricted , having clauses in release. support subqueries in clause considered in later release of specification. also in jpa 2.1 has not been changed.

java - Trying to rename a folder in extSdCard in my android device using code -

i trying develop , application 2 buttons (show,hide) when click show rename folder .pics pics and hide button rename pics .pics , run media scanner on every click. here code dont know error, made alot of searches in here non solved problem button btnshow = (button) findviewbyid(r.id.btnshow); //rename folder vids string sdcard = new string("/storage/sdcard1/"); file = new file(sdcard, (".pics")); file = new file(sdcard, ("pics")); from.renameto(to); //create on click trigger media scan btnshow.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { //broadcast media scanner intent trigger sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); //send message toast toast = toast.maketext(getapplicationcontext(), "media scanner triggered....", toast.length_short); toas

python - How do I make the C# constructor syntax more pythonic? -

i have background in python initializer (essentially python object constructor syntax), , syntax instantiate object in python follows: class account: def __init__(self,name=none,address="not supplied",balance=0.0): this.name = name this.address=address this.balance=balance why it, in c#, have provide defaults in body of constructor method, when in python can declare them optional, , default values passed in (see __init__ 's signature): public class account { private string name; private string address; private decimal balance; public account (string inname, string inaddress, decimal inbalance) { name = inname; address = inaddress; balance = inbalance; } public account (string inname, string inaddress) { name = inname; address = inaddress; balance = 0; } public account (string inname) { name = inname; address = &

Vector of structs c++ -

i having issue creating vector of structs. in function addapp unable "push_back" newly allocated struct vector. error message "invalid arguments". looked around see if had similar issue nothing helped. can point out whats flaw in logic? thx. class appholder { private: struct info { int refnumber; string name; string link; }; vector<info> database; public: void addapp(int ,string ,string ); }; void appholder::addapp(int r, string n, string l) { info *newapp = new info; newapp -> name = n; newapp -> link = l; newapp -> refnumber = r; database.push_back(newapp); } the reason code fails std::vector<info>::push_back requires pass object of type info , pass info* . we can solve using info objects directly instead of using pointers new ed variables: void appholder::addapp(int r, string n, string l) { info newapp; newapp.name = n; newapp.link = l; newapp.refnumber = r; database.pus

shell - Convert a file into CSV with newline as the delimiter -

i've got lot of data new line delimited, copied raw server. however, cannot convert csv replacing \n comma since need have fields. there 9 fields in occasion. how can convert data? keeping in mind last element doesn't need comma since need retain newline character. i horrible @ regular expression foo, since have loop being needed, assume need make shell script? any appreciated. example data: name logon user ip address version last login restart required foo1 foo2 foo3 jon weinraub jweinraub 10.18.66.10 3.1.1.1 2013-08-19 14:33:11 no bar1 bar2 bar3 homer simpson .... so should be name,logon user, ip,...foo3 jon weinraub,jweinraub,10.18.66.10,...bar3 homer simpson,.... a elaborate way (but it's easy understand , modify) using awk : create file makecsv.awk following script: begin { count = 0; } { count++; if (count == 9) { count = 0; printf "%s\n", $0; } else { printf "%s, ", $0; } } the

c# - How to add subview above the keyboard in monotouch/Xamarin.Ios? -

how can add uiview on top of keyboard in monotouch/xamarin.ios? i have tried following doesn't seem work. uiapplication.sharedapplication.delegate.window.addsubview (myview); uiapplication.sharedapplication.delegate.window.bringsubviewtofront (myview); the uiview added behind keyboard. in objective c able use following code , worked. [[[[uiapplication sharedapplication] windows] objectatindex:1] addsubview:myview]; thank you. you'll first need create new uiwindow @ same level status bar. can put code in viewdidload override: newwindow = new uiwindow (uiscreen.mainscreen.bounds); newwindow.windowlevel = uiwindow.levelstatusbar; and add view (in case button) new uiwindow: var uibutton = new uibutton (uibuttontype.infodark) { frame = new rectanglef (10, 400, 30, 30) }; newwindow.addsubview (uibutton); in uitextfield, add event listener editingdidbegin myinput.editingdidbegin += (object sender, eventargs e) => { newwindow.hidden = false

windows - Close all locally opened files in a given directory -

i'm trying add step batch process make sure local files have been closed in specific directory. everything can find keeps pointing me net files , openfiles, both of these options close open files accessed via share (not local). i've looked @ both taskkill , microsoft's handle tool, can tell isn't smartest way go task. is there equivalent net files close files opened locally? any appreciated. you might try handle on command line: for /f "tokens=2 delims=:" %a in ('handle "c:\folder"') @for /f %b in ("%~a") @echo handle -c %~b remove echo if output looks good.

Recoding over multiple data frames in R -

(edited reflect help...i'm not doing great formatting, appreciate feedback) i'm bit stuck on suspect easy enough problem. have multiple different data sets have loaded r, of have different numbers of observations, of have 2 variables named "a1," "a2," , "a3". want create new variable in each of 3 data frames contains value held in "a1" if a3 contains value greater zero, , value held in "a2" if a3 contains value less zero. seems simple enough, right? my attempt @ code uses faux-data: set.seed(1) a1=seq(1,100,length=100) a2=seq(-100,-1,length=100) a3=runif(100,-1,1) df1=cbind(a1,a2,a3) a3=runif(100,-1,1) df2=cbind(a1,a2,a3) i'm thousand percent sure r has functionality creating same named variable in multiple data frames, have tried doing lapply: mylist=list(df1,df2) lapply(mylist,function(x){ x$newvar=x$a1 x$newvar[x$a3>0]=x$a2[x$a3>0] return(x) }) but newvar not available me once leave lapply lo

usb - Android charging behavior when in use -

i'm working on hardware/firmware/android app project android (in case nexus 7 tablet) connects custom hardware platform via usb. android in accessory mode, means other end of wire (the host) supplies power android. hardware has dedicated 5v 2a switching supply usb connector there plenty of current available tablet. when android plugged in hardware, reports battery charging , requests 500ma usb connection (for don't know, usb protocol requires device inform host of current requirements). hardware provides current , 5v stays rock-solid. despite this, charge level never changes long device remains in use. application uses tablet in kiosk mode - display stays on @ full brightness continuously. sleep tablet , battery charges, leave on , there no reported change in battery level. the explanation can think of android's power supply circuitry cannot simultaneously handle current requirements of both full operation , battery charging. wonder if conscious decision based on

mysql - How to get error from preparedstatement for inserting from JDBC -

i using preparedstatement in jdbc insert records. set unique index on table. when run sql against mysql db console, got following error expected duplicate entry 'val1-val2' key 'some_unique_key_idx' but when run same jdbc. don't see error reported, although result returned "0" means nothing got inserted. there anyway duplicate entry error?

user interface - jQuery Masonry and UI Sortable -

there's website i'm developing can found here . it's photography website , client asked me implement allow move photos around , change order of appear. come mysql database , displayed jquery masonry. i thought instantly of jquery ui sortable, , i've been trying implement absolutely no luck @ all. how can achieve this? can point me in right direction, please? thanks in advance! i struggling same issue, far answer has been change classes jquery's sortable start, stop, change , sort events. so: $('#sortable').sortable({ start: function(event, ui) { console.log(ui); ui.item.removeclass('masonry'); ui.item.parent().masonry('reloaditems') }, change: function(event, ui) { ui.item.parent().masonry('reloaditems'); }, stop: function(event, ui) { ui.item.addclass('masonry');

sublimetext2 - Python: Program unexpectedly terminates -

i used sublime text 2 , ran program in terminal. here code: print("welcome quizwow!") while true: question = input("enter number of questions ask (up 10): ") ###program terminates after input: 'question' answered user. if question == '1': qonea = input("enter question here: ") qoneaa = input("enter answer here: ") print ("1: ", qonea) qoneaguess = input("enter guess here: ") if qoneaguess == qoneaa: print ("correct") else: print ("incorrect") input() tries execute user entered python code. according docs: this function not catch user errors. if input not syntactically valid, syntaxerror raised. other exceptions may raised if there error during evaluation. so it's raising exception , terminates program. i think want use raw_input() instead.

c# 4.0 - wpf mvvm datepicker textbox auto format -

is possible auto format user input date in textbox of datepicker? i have following code <style targettype="{x:type datepicker}"> <setter property="foreground" value="{dynamicresource textbrush}"/> <setter property="istodayhighlighted" value="true"/> <setter property="selecteddateformat" value="short"/> <setter property="padding" value="2"/> <setter property="calendarstyle" value="{dynamicresource datepickercalendarstyle}" /> </style> <style targettype="{x:type datepickertextbox}"> <setter property="foreground" value="{dynamicresource textbrush}"/> <setter property="padding" value="2"/> <setter property="control.template"> <setter.value> <controltemplate> <textbox

SQL Server Query for values within same Table -

i have data table (not structured) in have following clientid | parameter | value 111..........street..........evergreen 111..........zip................75244 111..........country.........usa 222..........street..........evergreen 222..........zip................75244 222..........country.........usa 333..........street..........evergreen 333..........zip................75240 333..........country.........usa 444..........street..........evergreen 444..........zip................75240 444..........country.........usa 555..........street..........evergreen 555..........zip................75240 555..........country.........usa 666..........street..........some street 666..........zip................75244 666..........country.........usa for want select client id on street = evergreen zip 75244, have on 700k rows so, exporting big issue. my idea was: select clientid (select clientid table1 value = 'evergreen') zip = '75244' but wont give me accurate results

Pass Variable (cookie) from local html to UILabel - iOS -

i wanted know how go passing variable (cookie) in local html file in ios app, , pass cookie says onto uilabel. here html code is. need pass message uilabel <script language="javascript">setcookie('test','you sir have succeeded. congratulations.', 300); </script> and here updated code ios app header file: import @interface viewcontroller : uiviewcontroller { iboutlet uiwebview *webview; iboutlet uilabel *mylabel; } @end main file #import "viewcontroller.h" @interface viewcontroller () @end @implementation viewcontroller - (void)viewdidload { [webview loadrequest:[nsurlrequest requestwithurl:[nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"dtpcontent/cookietest" oftype:@"html"]isdirectory:no]]]; [super viewdidload]; nsstring *mycookie = [self->webview stringbyevaluatingjavascriptfromstring:@"getcookie('test')"]; self->mylabel.text = myc

android - Refreshing fragments in FragmentActivity after sync service runs -

does have elegant solution refreshing views in fragments in fragmentactivity's viewpager after sync service syncadapter runs? i've tried calling notifydatasetchanged() , notifydatasetinvalidated() on adapter, refreshdrawablestate() on views ( gridviews ), no avail. perhaps i've been calling them wrong places -- i've tried doing @ setuservisiblehint isvisible =true, hoping trigger whenever fragment comes view, doesn't work. i've been using async calls sqlite database data needs, rather content provider , think have made bit easier. can think of couple of ways without content provider , neither nice. any ideas? can provide code if wished. thanks. i'll assume you're using asynctask loading cursor sake of explanation, work same if you're using loader, threadpool or whatever. from service, new data changed send localbroadcast . activity might there or not, broadcast way let know there's new data. service do: // th

three.js - Convert from string to hex code (0x000000) in Three 3dObject in JavaScript? -

i'm trying write large number of objects @ once , want color fade. however, after making string using .tostring(16) , doesn't read in code says, new three.meshbasicmaterial({ color: '0x' + color, wireframe: false, opacity: 0.5 }); here's code currently: (var = 0; < 10; i++) { (var j = 0; j < 10; j++) { (var k = 0; k < 10; k++) { geometry = new three.cubegeometry(50, 50, 50); colorr = 254 / 10 * k; colorr = math.round(colorr); colorr = colorr.tostring(16); colorg = 254 / 10 * k; colorg = math.round(colorg); colorg = colorg.tostring(16); colorb = 254 / 10 * k; colorb = math.round(colorb); colorb = colorb.tostring(16); color = '0x' + colorr + colorg + colorb; material[i] = new three.meshbasicmaterial({ color: color, wireframe: false

ruby - Are there any basic examples of Rack::Session::Cookie usage? -

i can't find simple examples using rack::session::cookie , able store information in cookie, , access on later requests , have expire. these examples i've been able find: how set/get session vars in rack app? http://rack.rubyforge.org/doc/classes/rack/session/cookie.html here's i'm getting: use rack::session::cookie, :key => 'rack.session', :domain => 'foo.com', :path => '/', :expire_after => 2592000, :secret => 'change_me' and setting/retrieving: env['rack.session'][:msg]="hello rack" i can't find other guides or examples setup of this. can help? you have setup cookie in question. not sure if means else "setup". instead of env['rack.session'] can use session[key] simplification. session[:key] = "vaue" # set value s

php - AngularJS proper/best practice in handling large amount of data -

i kind new in angularjs. ask advice in using scope temporary storage in requesting large amount of data server. here's scenario of app, in home page, accessing 45k+ data in server. write query on service pull 100 data initial display , handle others pagination or infinite scrolling thorugh serverside (means call service , push result existing scope). now, ask if doing correct? better make server side pagination using client side filtering of data angularjs built in filter. advice or techniques appreciated.. thanks in advance! you in right track. it's not better way filter data on frontend. because don't have fetch data , filtering on frontend. it's gonna slow hell. i'm working on same application have thousands of products in system , use pagination/infinitive scrolling fetch data bit bit.

javascript - Display message if close window in ASP.NET but not on PostBack -

i display message user if close asp.net web forms page or navigate away it. if click button, linkbutton, autopostback element, or else postback don't want show message. so far have following code: <script type="text/javascript"> var postback = false; addtopostback = function(func) { var old__dopostback = __dopostback; if (typeof __dopostback != "function") { __dopostback = func; } else { __dopostback = function(t, a) { if (func(t, a)) old__dopostback(t, a); } } }; $(document).ready(function() { addtopostback(function(t,a) { postback = true; }); }); $(window).bind("beforeunload", function() { if (!postback) { return "message"; } }); </script> this works partially seems stop autopostback events firing , still shows message linkbuttons etc. how can this? this take timestamp of when __dopostback called , carry out default behav

javascript - Date picker JS: how to have it work on multiple form fields -

i using plugin wp: http://wordpress.org/plugins/cf7-datepicker-alternative/ the .js file includes code: jquery(document).ready(function($) { $('#fieldname1').datepicker({ autoclose: true }); }); does know how doctor bit of code date picker function in multiple fields in same form, such fieldname2 , fieldname3 fieldname1? i thank in advance efforts. instead of using id attribute, assign meaningful class e.g. datepicker elements want datepicker on. update javascript use class selector. example: <!-- html --> <input type="text" id="fieldname1" class="datepicker" /> <input type="text" id="fieldname2" class="datepicker" /> // jquery jquery(document).ready(function($) { $('.datepicker').datepicker({ autoclose: true }); }); update: if don't want use class selectors , want use multiple id s, following: <!-- html --> <input type="t

javascript - how to attach an event listener using jQuery map v3? -

i trying load more markers when map dragged , i'm not sure how current bounds. var map = $('#map'); map.gmap().bind('init', function(evt, map) { $(map).dragend(function(){ console.log('a'); }); }); i need somehow current bounds inside dragend callback , load more markers.. notice using jquery ui map v3 , not google maps api v3 witch bit different in way calls different methods anyone has ideas, can't find in wiki ? thanks variant #1 (using addeventlistener -method of plugin) $(function() { $('#map_canvas') .gmap() .bind('init', function(evt, map) { $(map) .addeventlistener('dragend',function(){ console.log('a'); }); }); }); variant #2 (using addeventlistener -method of google-maps-api) $(function() { $('#map_canvas')

algorithm - abstract inplace mergesort for effective merge sort -

i reading merge sort in algorithms in c++ robert sedgewick , have following questions. static void mergeab(item[] c, int cl, item[] a, int al, int ar, item[] b, int bl, int br ) { int = al, j = bl; (int k = cl; k < cl+ar-al+br-bl+1; k++) { if (i > ar) { c[k] = b[j++]; continue; } if (j > br) { c[k] = a[i++]; continue; } c[k] = less(a[i], b[j]) ? a[i++] : b[j++]; } } the characteristic of basic merge worthy of note inner loop includes 2 tests determine whether ends of 2 input arrays have been reached. of course, these 2 tests fail, , situation cries out use of sentinel keys allow tests removed. is, if elements key value larger of other keys added ends of , aux arrays, tests can removed, because when (b) array exhausted, sentinel causes next elements c array taken b (a) array until merge complete. however, not easy use sentinels, either because might not easy know largest key value or because space might

android - Synchronised sound effects in libgdx ..? -

is there way synchronize sound effects sprite sheet animation (consisting 30 frames). all need play sound file (2 sec) synchronised explosion effects last 2 sec (i presume might change depending on devices, no way assign fixed time). thanks why duration of sound or duration of animation change depending on different devices? or did mean animation? the device shouldn't play soundfile more fast or more slow. if load asset before need play() , there shouldn't delay. @ same moment reset animation time 0 , add deltatime of last frame animationtime. way, when lagging, might skip frames of animation , keep sound , animation synchronized.

java - error after installation of netbeans 7.3.1 -

hello please start new java me....i download netbeans ide 7.3.1 yesterday after finish installation try run there sample java application got error message.. error - ant misconfigured , cannot run. java.io.ioexception: not load class org.netbeans.modules.javame.profiler.ant.openprofiler: java.lang.unsupportedclassversionerror: org/netbeans/modules/javame/profiler/ant/openprofiler : unsupported major.minor version 51.0 @ org.apache.tools.ant.module.bridge.antbridge.loaddefs(antbridge.java:561) @ org.apache.tools.ant.module.bridge.antbridge.createcustomdefs(antbridge.java:538) @ org.apache.tools.ant.module.bridge.antbridge.createantinstance(antbridge.java:326) @ org.apache.tools.ant.module.bridge.antbridge.getantinstance(antbridge.java:279) @ org.apache.tools.ant.module.bridge.antbridge.getinterface(antbridge.java:268) @ org.apache.tools.ant.module.run.targetexecutor.run(targetexecutor.java:541) @ org.netbeans.core.execution.runclassthread.run(runclasst

jquery - Unrecognized expression when using special ID -

i have following code in jquery mobile 1.2 project. working fine until upgraded jquery 1.7.2 jquery 1.8.3. <input type="text" id="a['val']" name="a['val']" /> when page loaded, throws syntax error, unrecognized expression: label[for='a['val']'] and page refuse load. although there's no label in code, error thrown asking label. problem occurs in jquery 1.8 , it's working fine 1.9 , versions prior 1.8. here's fiddle problem on 1.8.3 + jqm 1.2 here's fiddle without problem on 1.9.1 + jqm 1.2 i think bug or feature in jquery 1.8 + jqm 1.2, occurs when have id containing ' jquery can't transfer selector of label correctly , throw error, can modify id "a[val]" or 'a["val"]' , it's ok. <input type="text" id='a["val"]' name="a['val']" /> see fiddle

javascript - How do you prevent CSS div from dislocating or collapsing when resizing the browser? -

how prevent whole website resizing whenever minimize browser or maximize, webiste size adjust directly proportional resize. how prevent happening? without re-organizing everything? need site length still if resize or maximize please help. thank you. here's i've done far: markup: <div id="table"> <div class="tabs" id="content1"> <div class="tab"> <input type="radio" id="tab-1" name="tab-group-1" checked> <label for="tab-1">home</label> <div class="content"> <p></p> <!-- <div id="contentheader"></div> --> <div id="caption"> <p> title goes here</p> </div> <div id="nextcontent"> <p>words go here</p>

c# - How to overwrite a string with another string? -

how can overwrite string ? example: string text = "abcdefghijklmnopqrstuvwxyz".overwritewith("hello world", 3); // text == "abchello worldopqrstuvwxyz" of course method doesn't exist. but is there build in in .net framework ? if not, how can efficiently write string string ? short answer, cannot. strings immutable type. means once created, cannot modified. if want manipulated strings in memory, c++ way, should use stringbuilder.

algorithm - What is the time complexity of finding the cube of a matrix? -

i know complexity of multiplying 2 matrices directly axb o(n^3). holds when trying find square of matrix, because means axa. what complexity when trying find cube of matrix? it o(n 3 ) why? you can calculate cube 2 matrix multiplications. doing matrix multiplication of square matrices not change n. doing 2 o(n 3 ) operations in series o(n 3 ). see wikipedia formal definition.

file - F2 function key and same key in eclipse -

when press f2 on word such strtok in qtcreator ide open location of definition of strtok , need hotkey in eclipse ide , what's f2 in eclipse ? maybe one: f3 : open declaration. see this answer.

html - White Space in UIWebView -

Image
i working on app in using uiwebview . make uiwebview editable, have used html file , have set attribute contenteditable=true . perform operation, using javascript. i have set css in html file. below code. <style> #test { padding-left:5px; padding-right:5px; background-color:green; text-align:left; width:100%; font-family: "times new roman"; border-radius:5px; } </style> now, problem getting white margin of 10-15px top, bottom , left side between uiwebview , html file loaded in uiwebview . here attaching screenshot same. i have started working on html , javascript(no prior knowledge) , not getting problem is. as discussed use {position:absolute;top:0px;left:0px;} this take html file top left of webview.

python - How to get index of element in Set object -

i have this: numberlist = {} item in results: data = json.loads(item[0]) if data[key] in itemlist: numberlist[itemlist.index(data[key])] += 1 print numberlist where itemlist 'set' object. how can access index of single element in ? a set unordered collection of unique elements. so, element either in set or isn't. means no element in set has index. consider set {1, 2, 3} . set contains 3 elements: 1, 2, , 3. there's no concept of indices or order here; set contains 3 values. so, if data[key] in itemlist returns true , data[key] element of itemlist set, there's no index can obtain.

javascript - A website is crashing-closing the android default browser -

i have weird pb. client website (in developpment) crash/closed android default browser (tested on 2 tablets , genymotion virtual android). if disable js, browser stop crzsking. it's browser whiçth pb. of coul create ? website make joomla! 2.5 , classic omponents (sobipro etc). these using massively google api/map if help...

angularfire - Digest is not triggered when scope variable is updated in AngularJS -

i using angularjs , angularfire show list of tasks: <ul ng-repeat="tool in tools"> <li>{{tool.name}} {{ tool.description}}</li> </ul> var toolref = new firebase(dbref + "/tools/" + toolid); toolref.once('value', function(snapshot) { console.log(angular.tojson(snapshot.val())); $scope.tools.push(snapshot.val()); //$scope.$apply(); }); http://jsfiddle.net/oburakevych/5n9mj/11/ code simple: bind 'site' object firebase db. object contains list of id of relevant tools. load every tool in $scope.tools variable , use ng-repeat show them in ui. however, every time push new entry $scope.tools - dom not updated. have call $scope.$apply trigger digest after every push - see commented out line 18 , works. it's strange since sow several times , scope variables bound angularfire. can explain this? doing wrong? because change scope outside of angularjs, must use $scope.$apply() inform angula

Create jsp to generate Out Of Memory -

i want create war application generate out of memory in application server. see code. how can compile in jsp in war? thanks import java.util.arraylist; class testoome { public static void main(string[] args) { long start = system.currenttimemillis(); byte[] buffer = new byte[2^20]; arraylist<string> list = new arraylist<string>(); try { while (true) { list.add("lollygobblenlissbomb"); } } catch (throwable t) { long end = system.currenttimemillis(); buffer = null; system.err.println(t + " in " + (end-start) + " millis."); } } }

asp.net mvc 4 - How to add icon button beside dropdownlist globally using jquery -

Image
i working on mvc4 web application.everything working fine in end of project got 1 new requirement in have show plus icon beside of each dropdownlist present on 20 pages like. in above picture in item dropdownlist had added icon manually.but want add icon every dropdownlist present in full project. on clicking icon 1 pop-up open text box. user enter new item in , save. common structure of page : <div runat="server" id="divformlayout" class="formlayout"> <div class="tabsectionl" style="width: 99%"> <span class="tabsectionheader">item details</span> <table cellpadding="4" cellspacing="4"> <tr> <td> item </td> <td> @if (viewdata["itemdesc"] != null) { @html.dropdownlistfor(m =>

asp.net - Compressing a directory on the go using Xceed -

i have directory contains several files. want compress folder zip (using xceed third party dll library) , push user through http. @ same time create log of files inside folder , append part of compressed file. i using dotnetzip , working perfectly. need equivalant of in xceed. below code using dotnetzip imports ionic.zip ' tell browser we're sending zip file! dim downloadfilename string = string.format("yourdownload-{0}.zip", datetime.now.tostring("yyyy-mm-dd-hh_mm_ss")) response.contenttype = "application/zip" response.addheader("content-disposition", "filename=" & downloadfilename) ' zip contents of selected files using zip new zipfile() ' construct contents of readme.txt file included in zip dim readmemessage string = string.format("your zip file {0} contains following files:{1}{1}", downloadfilename, environment.newline) integer = 0 maindirs.length - 1 rea

plsql - select forall array in sql statement(PL/SQL) -

type tabarray table of table%rowtype; tablearray tabarray ; --fill array select * bulk collect tablearray table table.field = .... --work pos in 1..tablearray .count loop dbms_output.put_line(pos||' '||audarray(pos).field); end loop; --doesn't work select * table2 table2.field in (select filed forall tablearray ); main question: how can use array in sql statement (in) ? first have create type in sql can use given below create type fruit_tt table of varchar2(100) select column_value val table(fruit_tt('apple','banana','apricot')) column_value not 'a%'; here type fruit_tt created , using in sql query.

How do we implement comments in TypeScript so intellisense sees them -

we love typescript. makes our lives easier. intellisense part empowered web essentials. i'm not shure how implement correctly. we use comments like: /** function returns current user */ it shows when typing in typescript file references .ts file declares comment. but comment 'maintainselection' option not show up /** cttgrid options */ export interface cttgridoptions extends kendo.ui.gridoptions { /** true - rows scrolled out of view maintained */ maintainselection: boolean; } ... var activiteiteningrid : kendowrappers.cttgrid = $('#werkpakketactiviteiteningrid').kendocttgrid ({ navigatable: true, pageable: false, sortable: true, groupable: true, resizable: true, filterable: true, selectable: 'multiple', maintainselection: true, scrollable: { virtual: true }, editable: "incell", columns: activiteitencolumns }).data('kendocttgrid'); now when hover mouse on '

css - Link color in Firefox -

i'm changing color of link in web page. css: a:link, a:visited, a:active { color:#009900 !important; text-decoration:none; } a:hover { background-color:#009900; color:#ffffff !important; text-decoration:none; } .lemmas a:link, a:visited, a:active { color:#014e68 !important; text-decoration:none; } .lemmas a:hover { background-color:#014e68; color:#ffffff !important; text-decoration:none; } .feel a:link, a:visited, a:active { color:#ff3300; text-decoration:none; } .feel a:hover { background-color:#ff3300; color:#ffffff !important; text-decoration:none; } the link colored last color 1 assigned class feel in firefox. in explorer colors shown perfectly. know problem? thanks i think these selectors: .lemmas a:link, a:visited, a:active {} .feel a:link, a:visited, a:active {} should like: .lemmas a:link, .lemmas a:visited, .lemmas a:active {} .feel a:link, .feel a:visited, .feel a:active {} if not, :visited , :ac

CakePHP - Checking from which controller and action request came -

hi there way check request came in cakephp ? need check if user has registered or not. cheers maybe might help. here static class returns either controller name or action name: class customrouter extends object { public static function controller_name() { $url_string = router::url(); return ( !empty( $url_string ) && is_string( $url_string ) ) ? explode( '/', $url_string )['1'] : null ; } public static function action_name() { $url_string = router::url(); return ( !empty( $url_string ) && is_string( $url_string ) ) ? explode( '/', $url_string )['2'] : 'index' ; } }

imagemagick - rails: produce pdf and render it as image -

i'm trying produce pdf , send file, or, better, render image in browser, using imagemagick , wicked_pdf. i'm able send something, it's not recognized image os. pdf string generated correctly, suppose problem in image part this code of controller: format.jpg @format = :pdf pdfstr = render_to_string 'generated_graphics/tag.erb', :pdf => "tag", :layout => nil, :page_height => '38mm', :page_width => '129mm' file = tempfile.new('foo') file.write pdfstr file.close require 'rmagick' pdf = magick::imagelist.new(file.path) send_data pdf.write("myimage.jpg"), :type => 'image/jpg' end take @ imagemagick , rmagick plugin ruby. allows kinds of image conversions, including pdf jpeg. http://rmagick.rubyforge.org/ edit: untested sample code: require 'rmagick' pdf = magick::imagelist.new("doc.pdf") pdf.write("myimage

python - How to use scipy weave and sscanf to parse string to numpy array? -

i'm working on scientific python code speed up. 1 specific problem reading in lots data stored in text files using formated strings. figured out approach using split() , np.array() works nicely, slow if compared i'm used fortran. i'm wondering weather scipy.weave used here, unfortunately i'm no expert in c. here example: line =" 0.7711408e-01 0.7616138e-01 0.7521919e-01" arr = np.array(line.split(),dtype=np.float) print arr this works, far slow large data sets. this, bu working? line =" 0.7711408e-01 0.7616138e-01 0.7521919e-01" arr = np.zeros(3) weave.inline("""sscanf(std::string(line).c_str(),"%f %f %f",arr);""",['line','arr']) print arr

Django ModelForm - conditional validation -

i need add conditional piece of validation modelform. below listing model. listing_types = ( ('event', 'event'), ('release', 'release') ) class listing(models.model): title = models.charfield(max_length=255, verbose_name='listing title') type = models.charfield(max_length=255, choices=listing_types, verbose_name='listing type') slug = models.slugfield(max_length=100) content = models.textfield(verbose_name='listing overview') competition = models.textfield() date_start = models.datetimefield() time_start = models.charfield(max_length=255) date_end = models.datetimefield() time_end = models.charfield(max_length=255) pub_date = models.datetimefield('date published', auto_now_add=true) venue = models.foreignkey(venue) class listingform(modelform): date_start = forms.datefield(input_formats=date_input_formats) date_end = forms.datefield(input_formats=date_i