Posts

Showing posts from May, 2013

objective c - How to work with plist in several threads -

i have simple multithread application 2 tabs. each tab table view number of items, information them saved in plist file structure this: <key>items</key> <array> <dict> <key>name</key> <string>bosch kgn36x45</string> <key>price</key> <string>18890</string> <key>quantity</key> <real>33</real> </dict> i need work file in several threads, example in 1 thread can remove item code: - (void)removeitematrow:(int)row { [items removeobjectatindex:row]; nsmutabledictionary *plistdict = [nsdictionary dictionarywithobject:items forkey:@"items"]; [self saveappfile:plistdict]; } and can open item in other view controller edit: - (void) updateviews { nsdictionary *item = [[[datacontroller sharedinstance] getitems] objectatindex:itemrow]; nslog(@"%@", item); self.namelabel.text = [item obje

html - How to centralize div crossbrowser -

i know way in css center div in without being dependent set margin-top , down, control height magic numbers. the forms have learned these disadvantages, better , worse, dependent on something, , permanent solution browser (at least ie8+). i want centralize horizontally , vertically div element without magical numbers. height of div grow dynamically , automatically calculated , centralized. to clarify, example of not want. use widht , height defined leaves no flexibility, , have manipulating height added each item using js. http://jsfiddle.net/qswfg/ <div id="container"></div> #container { position: absolute; width: 380px; height: 360px; left: 50%; top:50%; padding: 30px; margin-left: -220px; margin-top: -210px; background: #000; } like this? codepen example: http://cdpn.io/budlo html <div class='modal-overlay'> <div class='modal-box'></div> </div> css .modal-overlay { background: b

android - Shall I ignore this exception from user -

just got crash report exception stack trace: java.lang.nullpointerexception @ com.google.ads.internal.c$a.run(sourcefile:128) @ android.os.handler.handlecallback(handler.java:587) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:150) @ android.app.activitythread.main(activitythread.java:4385) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:507) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:849) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:607) @ dalvik.system.nativestart.main(native method) is ok ignore exception 1 off. in thread 1 eric l, developer @ admob, seems recognize crash bug in sw.

html - Internet Explorer Print Preview different results from same page -

i'm developing web site, 1 of pages it's collection of divs. each div must printed 1 per page. i'm setting width/height of each div this: body .htmltemplate{ height:1140px; padding:0px; margin:auto; width:840px; } it seems work. before 1140px, had 1098px, divs jumped pages, changed 1140px the problem every once in while (let 1 of 6), printpreview shows half (or so) of width, , portion of height goes next page, have double pages print. in example, if have 40 divs, 80 pages. i've noticed when problem occurs, cpu usage in task manager jumps 100% do have idea of causing problem??? missing css attribute (i've tried page-break no luck)??? thanks in advance

Target certain words with CSS? -

this kind of theory question wonder whether possible or not. so if have div content like... <div>£100.00 - buy</div> can target "£100.00" without targeting rest? so can increase font size of £100.00? you target wrapping in span element: jsfiddle example <div><span class="price">$100.00</span> - buy</div

pass javascript variables into grails params -

so need pass javascript variables grails parameters build , download file. did ajax learn ajax doesn't downloads. worked so: <script type="text/javascript" charset="utf-8"> function myfunction() { jquery.ajax({ url: "search/download", type: "post", data: {facets: visualsearch.searchquery.facets()} }); } </script> <input type="button" onclick="myfunction()" value="download"> while passed mapping correctly, didn't downloads. so want similar g:link <g:link controller="search" action="test" params="[facets: '\$(visualsearch.searchquery.facets())']" >test grails</g:link> but in params in controller are facets=$(visualsearch.searchquery.facets()) action=test controller=search how can fix pass facets (whether parsed or unparsed) controller. thanks! adding jav

ruby on rails - Efficient way to Add/Update or Delete with RoR -

i need loop through series of updates either involve adding / updating record, or removing it. updates need carried out in order, couldn't bulk delete @ end. is there efficient / quick way achieve through rails. currently i'm envisaging looping through updates. if it's delete request, deleting it. if it's not, searching it. if exists, updating. if doesn't, adding. i don't think, when dealing thousands of updates, going pleasant wondering if there more efficient way go process? you can try destroy_all delete_all update_all conditions/scopes like: user.where(:active => false).destroy_all

jquery - .remove event triggers .blur event - how to escape that? -

i have .blur() event bound element. whenever remove element $(elem).remove() method, .blur event triggered same element. here jsfiddle - see case click on blue div , press key. here code: html: <div id="container"></div> <ul id="tr"></ul> css: #container { width:100px; height:100px; background:blue; position:relative; cursor:pointer; } js: $("#tr").on('keydown', '#ti', function() { $(this).remove(); }); $("#tr").on('blur', '#ti', function() { alert('blur triggered'); }); $('#container').on('click', function() { var item = '<li id="ti" contenteditable="true"></li>'; $("#tr").append(item); $("#ti").last().focus(); }); how can prevent .blur event if element removed? or maybe how can know event triggered element's deletion? remove blur event before

Unload/Reload javascript or better solution for lots of ajax content? -

i have page several tabs on it. i'll use 2 example. (products, services) instead of having content in these tabs load @ run-time, have them load specific tab content when tab clicked. have lot of tabs lot of content , it's way have reasonable initial page/load speed. each 1 of these tabs used have own javascript file loaded after content loaded. javascript file huge , needed come universal script file universal tokens in data use same script file of tabs... example, instead of class .viewproductcomments, .viewservicecomments, etc. have .viewelementcomments of them. this have accomplished, created problem. is there simple way "unload actions" created script file when tab clicked, can reloaded after new elements sent page via ajax? go through , .on every little thing hierarchy level of .on capture static element quite bit ladder. basically have lot of script needs recognized "after" content loads, , don't want reload same script file every ta

What is the correct failure mode for Modbus (0x10) Write Multiple Registers (if any)? -

how should modbus device fail if error encountered after write multiple register (0x10) request has been validated before writes have been completed? specification (6.12) seems vague on point , web searches have not proven fruitful. see 3 possibilities: attempt write each register in turn. if error occurs give up/send exception. treat request atomic transaction either data should written or none of it. attempt write data sending exception @ end if failure observed. is there conventional or proper way fail here or way device fails implementation specific requiring documented in manual? according figure 22: write multiple registers state diagram on page 31 of specification exception code 4 should returned protocol not specify how application layer should work. the way device fails must consider constraints , possible side effects. example if accept control commands (set point value or setting multiple outputs assigned different registers) practice never assign s

jquery - How to get simple XSocket.Net example up and running -

Image
trying follow tutorials on how set simple sample application. error when running sample: websocket connection 'ws://127.0.0.1:41589/generic' failed: unexpected response code: 404 not sure if it's project or if it's chrome failed. created project: runned in nuget: install-package xsockets and added html file following code: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="scripts/jquery-1.9.1.js" type="text/javascript"></script> <script type="text/javascript" src="scripts/xsockets.latest.js"></script> <script> $( document ).ready(function() { var url = "ws://127.0.0.1:41589/"; var controller = "generic";

javascript - jQuery event listener fires before selector applied? -

i'm stuck on event listeners. when 1 element clicked want create listener clicks. reason both firing. here's code , jsbin: http://jsbin.com/uhiyigi/2/edit html <div class="wrap"> <button>click me</button> </div> js $('button').on('click', function(event){ $('body').append('<p>button clicked</p>'); $('.wrap').addclass('clicked'); $('body').on('click', '.clicked', function(e){ $('body').append('<p>.clicked clicked</p>'); $('.wrap').removeclass('clicked'); $('body').off('click', '.clicked'); }); }); from understand event listeners, second 1 should not fire until '.clicked' element has complete click event (a mouse down , mouse up), fires on first click, meaning event fired though element doesn't have trigger class until after event. i'm seeing even

java - Jackson @JsonProperty(required=true) doesn't throw an exception -

i using jackson 2.2 annotation @jsonproperty required set true. while deserializing json file doesn't contain property via objectmapper readvalue() method no exception being thrown. supposed work in different way or did missed something? my dto class: public class user { public enum gender {male, female} ; public static class name { private string _first, _last; public string getfirst() { return _first; } public string getlast() { return _last; } public void setfirst(string s) { _first = s; } public void setlast(string s) { _last = s; } } private gender _gender; private name _name; private boolean _isverified; private byte[] _userimage; @jsonproperty(value ="naame",required = true) public name getname() { return _name; } @jsonproperty("verified") public boolean isverif

python - Looking for recommendation on how to convert PDF into structured format -

Image
i analysis on properties listed in upcoming auction. unfortunately, city running auction not publish information in structured format instead provides 700+ page pdf of properties going auction. i'm wondering if community has thoughts how can approach parsing said pdf structured format insertion db or create spreadsheet of properties. here's image of each page represents: and here's page lists properties: i'm comfortable python , ruby don't have issues scripting solution, because "columns" , data in said columns aren't necessary tied together, seems dubious proposition. any ideas appreciated. convert text xpdf using command pdftotext . i converted file following: pdftottext.exe -layout -f 23 -l 510 auctionbook2013.pdf auctionbook2013.txt this conversion leaves text exactly in original layout (due -layout option). options -f , -l indicate first , last page numbers of range of pages extract. from there, parsing should

get elasticsearch schema via commandline tool -

i trying speed on elasticsearch implementation on project. how can see data on cluster? there commandline tool gives me information on schema? to schema: curl -xget 'http://loadtest-appserver1:9200/myindex/_mapping' see elasticsearch api doc

Read and search text file in Python? -

i need write python script reads flat text file, searches string, , rewrites new text file. i have (example) script: import re read = open("file.txt", "r") data = file.read() print data newfile = open("newfile.txt", "w") line in read: if re.match("(.*)dst="+str_var"(.*)", line): print newfile, line, file.close() is there easier or more correct way? (i know pretty nothing python. code derived i've found in tutorials, google, etc.) thanks! this may trick read_file = open("file.txt", "r") data = read_file.read() read_file.close() file_content = re.sub("\d+", "", data) word = your_word if word in file_content: newfile = open("newfile.txt", "w") print >> newfile, word newfile.close()

linux - synchronization issues of github project with local server -

i running apache server on localhost (mac). there project on github tried pull in local folder. git pull up-to-date. but, problem can't see updates when check on browser, localhost/directoryname. i tried change ssh key. global file git. git config --edit --global everything fine. reason ? did try clone repository clone git@github.com:blabla.git

spring - Mantain long Transaction Session in Spring3 and Hibernate4 -

i lazyinitializationexception shop.events collection in below scenario. i know problem might transaction session closed before call shop.getevents executed. i learning opensessioninviewfilter, think no idea mantain every transaction sessions in every calls life server. , fetchtype.eager not neither. i need solve question. thank in advance. @entity @table(name = "shop") public class shop implements serializable { // class attributes. @onetomany(mappedby = "shop", fetch=fetchtype.lazy) private set<event> events; // getters , setters. } @entity @table(name = "event") public class event implements serializable { // class attributes. @manytoone(fetch = fetchtype.lazy) @joincolumn(name = "shop_id", nullable = false) private shop shop; // getters , setters. } persistence layer implementation. public interface abstractdao<e, extends serializable> { e finduniquebycriteri

redhawksdr - /sbin/service omniNames status -

/sbin/service omninames status returns omninames (pid 2529) running... . ok? processes see after start waveform are: aug16 ? 00:00:00 networkmanager --pid-file=/var/run/networkmanager/networkmanager.pid aug16 ? 00:00:00 /usr/sbin/modem-manager 14:06 pts/1 00:00:00 domainmanager debug_level 3 dmd_file /domain/domainmanager.dmd.xml domain_name redhawk_dev force_rebind false persistence false sdrroot /home/me/redhawk/sdr 14:06 pts/1 00:00:00 devicemanager dcd_file /nodes/devmgr_host.mycom.com/devicemanager.dcd.xml debug_level 3 domain_name redhawk_dev sdrcache /home/me/redhawk/sdr/dev sdrroot /home/me/redhawk/sdr am missing processes though waveform seems run fine? everything looks fine. further verify domains/nodes/waveforms/etc running via nameclt list [domain] command. an example be: nameclt list redhawk_dev this list like: redhawk_dev waveform1 waveform2 node1 ... if wanted see component(s) inside of waveform running in r

javascript - How to test that a function has been called after an event was fired? -

there custom event fired in fooview .. // views/foo_view.js this.trigger("something:happened"); the associated foocontroller binds handler take care of event ... // controller/foo_controller.js initialize: function() { this.fooview = new fooview(); this.fooview.bind("something:happened", this.onsomethinghappened, this); } onsomethinghappened: function(event) { // else. } to test event handling write following test jasmine : it("should else when happens", function() { var foocontroller = new foocontroller(); spyon(foocontroller, "onsomethinghappened"); foocontroller.fooview.trigger("something:happened"); expect(foocontroller.onsomethinghappened).tohavebeencalled(); }); though, test fails .. fooview should else when happens. expected spy onsomethinghappened have been called. error: expected spy onsomethinghappened have been called. @ new jasmine.expectationresult (http://localhost:8888/__jasmine_ro

c++ - Why is my Linked List assignment not working as it should? -

so made linked list class: class node { public: string name; node *next; node(string init) {name = init; next = nullptr; }; and in main created node pointer , initialized name of node points to. node *root; root->name = "hello"; //error the compiler doesn't call error, when run program stops working @ line of code. know why? you need allocate node object root point to. node* root = new node; but careful, have make sure call delete on root @ right moment. coudl simplify things using smart pointer, or automatic storage object node root; root.name = "hello";

java - Rewriting parts of a string -

i have string rewrite. string contains substrings "ddt" plus 4 digits. i'll call these blocks. contains connectives "&" , "|", | represents "or", parentheses. now rewrite string such blocks separated &s should written "min(x(block1), x(block2), etc.)", whereas blocks separated |s should written "max(x(block1), x(block2), etc.)". looking @ example should help: public class test{ public static void main(string[] arg) throws exception { string str = "(ddt1453 & ddt1454) | (ddt3524 & ddt3523 & ddt3522 & ddt3520)"; system.out.println(str.replaceall("ddt\\d+","x($0)")); } } my desired output is: max(min(x(ddt1453),x(ddt1454)),min(x(ddt3524),x(ddt3523),x(ddt3522),x(ddt3520))) as can see, performed initial substitution include x(block) part of output, cannot rest. ideas on how achieve desired output? just doing string substitution wrong way go

android - Device Phone Number -

i need way capture android device's phone number in order send web api processing. i've read issues , inconsistencies getline1number function question this, there programmatic alternatives getline1number or available method retrieve device phone number? to clear, not looking uuid, mobile phone application , require users phone number data association. you can use getline1number () this. returns phone number string line 1, example, msisdn gsm phone. return null if unavailable. here example: telephonymanager tm = (telephonymanager)getsystemservice(telephony_service); string number = tm.getline1number(); it requires read_phone_state permission added on androidmanifest.xml file.

angularjs - Phonegap.js on second html page -

i have 2 pages in phonegap application building pgb (index.html , main.html), both use angular.js. index.html login app, redirects main.html afterwards. plugins , phonegap.js being injected fine main, none of inline js (alerts on doc ready, device ready, window load) firing, let alone phonegap.js being loaded well. any advice appreciated. script includes: <script src="phonegap.js"></script> <script src="cdv-plugin-fb-connect.js"></script> <script src="facebook-js-sdk.js"></script> <script>alert("inside pg");</script> <script src="childbrowser.js"></script> <script src="js/jquery.js"></script> <script src="js/angular.min.js"></script> <script>alert("here");</script> <script src="js/controllers.js"></script> <script src="js/klass.min.js"></script> <script src

visual studio 2012 - Is there a way to change the color of my code based on my criteria? -

i know can change dark/light, etc. but if want this: properties purple. classes blue. etc. is possible? it seems bit of hassle, option: http://www.hanselman.com/blog/yourcolorfulvisualstudio2012withthecolorthemeeditorvs2010colorstoo.aspx

node.js - Path of the requiring script inside the required script -

i have 2 scripts: first requiring second. 1st script main.js: ... var = require(second); ... 2d. script second.js path = path/of/the/main/script i want access path of first script within second script without passing argument. way achieve it? module.parent.filename holds file name of calling script. see here more information.

java - Cookie troubles with Spring MVC -

i trying cookie value using @cookie . 400 error if cookie value null. what's wrong? controller: public string listcontacts(map<string, object> map, httpservletresponse response, @cookievalue("flag") string flag) { response.addcookie(new cookie("flag", "in use")); ... try setting required = false in @cookievalue annotation: public string listcontacts(map<string, object> map, httpservletresponse response, @cookievalue(value = "flag", required = false) string flag) { by default spring expects cookie header present , throws exception otherwise: default true, leading exception being thrown in case header missing in request. switch false if prefer null in case of missing header. alternatively, provide defaultvalue, implicitly sets flag false.

Matlab clc command -

i checking original 'clc.m' file in matlab. apparently function written p-code , see description placed in: ..\matlab\r2013a\toolbox\matlab\iofun\clc.m how can take @ original code?; not main question, fun. the main point looking way reverse clc process, after clean screen. there way reverse clc process. same question goes clear all well. try using home instead of clc . whereas clc removes text command window , moves cursor top left giving blank window, home moves cursor top left , gives blank window - text still there, , can scroll see it. use home time rather clc . in either case, text remains in command history window, , can retrieved in command window using up/down arrows. the reason can't see code behind clc not it's p-coded, it's it's built-in function (i.e. not implemented in matlab language). same true clear , , many math functions such svd , eig etc. there's no way modify them change (such reversing process). edit

javascript - Scroll to Top in iframe without reloading -

i tried scroll top of iframe without reloading. have form within iframe. when click submit button, should moved top of iframe without reloading. i tried following codes, top.location.href = '#top'; window.parent.location.hash = "#top"; but reloading. should not reload page. because, when loads , validation error message javascript becomes invalid.please helpful achieve one. thanks in advance use function window.scrollto(xpos, ypos) window.scrollto(0,0) if want animated, can use jquery's animate function, , set scrolltop 0 , this: $('iframe').animate({ scrolltop: 0 });

delphi - Show the window shadow when using VCL styles -

Image
is there way show window shadow, per normal windows 7 forms, when using vcl style? i understand bitmap , settings in style replaces form borders, isn't shadow sort of alpha blend / aero thing outside area affected style? adding cs_dropshadow windowclass.style seems have no effect. using cs_dropshadow style works fine type tmyform = class(tform) protected procedure createparams(var params: tcreateparams); override; end; procedure tmyform.createparams(var params: tcreateparams); begin inherited; params windowclass.style := windowclass.style or cs_dropshadow; end;

vtk - Error: "No memory left on the GPU even for a minimal block" -

i using vtksmartvolumewrapper volume rendering , have been running on computer ati gpu , has been running fine. i running amd (ati) firepro m8900 (firegl) mobility pro graphics a new person coming on project started , has new dell laptop nvidia quadro pro in it, , running software, gets following error: i've checked , computer seems running latest drivers dell (311.44) the version of vtk running activiz 5.8.0 (i'm running c#.net client), latest version. any suggestions? ok, figured out going on... the computer nvidia card had 4gb of gpu memory. default mapper uses 75% of available gpu memory. unfortunately, appears max memory stored "signed int", (i'm not sure if in c# wrapper or in c++ based code), being set unsigned value of 3gb, represented -1gb signed int. so, temporary measure, set max memory 1.9 gb, , works long gpu has @ least 1.9 gb of memory (i need put check in that). i report issue vtk folks...thanks

javascript - Handling Backbone.model.destroy with server-side authentication -

what common practice when dealing backbone.js , server-side permission based restful interactions. for example if user wants remove model view, needs permissions, given how model.destroy() works (even wait option set true). in order stop model being removed / delete have make sure {wait: true} option set , throw non 200 status code server destroy({error: function(){}) callback used. is there way around missing? you understand correctly. when passing {wait:true} trigger destroy event in success callback. is there way around it...? if wanted change behavior of destroy method, sure.

ios - How to display overlay on Apple TV via AirPlay -

i developing ios app displays video, e.g., football game, on apple tv via airplay. want display additional information, e.g., player stats, on big screen while video playing. i aware of redfin approach, require user turn on airplay mirroring first. unfortunately, not acceptable us. want obvious users on how show video. we presenting airplay route button before displaying video allow user set using following code. self.airplaypicker = [[mpvolumeview alloc] initwithframe:cgrectmake(0, 0, 50, 50)]; self.airplaypicker.showsvolumeslider = no; self.airplaypicker.showsroutebutton = yes; [self.view addsubview:self.airplaypicker]; the route button show when there apple tv around, allowing user turn on. present video mpmovieplayercontroller. when airplay turned on , video playing, in code, see 1 uiscreen, 2 uiwindows. both uiwindows have same dimensions iphone. when add subview either uiwindow, subview shows on iphone. has figured out how present overlay on top of video on apple

messaging - Can I use MQTT for my use case? -

so, have bunch of mobile devices (millions) , have backend system. needs/use case are:- 1. collect data devices , send backend. 2. send push messages backend system individual or groups of devices. so, given scenario, make sense use mqtt communication between backend , devices? 1 of confusions, have in use case #1, devices publishers , system in backend subscribers, whereas use case #2, devices subscribers push messages , backend system publisher. possible? or thinking wrong way? having worked on number of examples (e.g. mobile telemetry system push notification) fit usage pattern can mqtt can fit perfectly. mqtt client can act both publisher , consumer, there no distinction. you need design topic structure suit data sending in either direction, should not difficult.

c# - Can't use SQL Server CE in VS2012 -

Image
i'm developing web application , trying use local database file store information. however, when add .sdf file, error. below screenshots detailing problem. i've been trying figure what's wrong several hours. i've seen similar issues, have yet find fix. used able use sqlserverce connections before .sdf files, though different development environment. have tried reinstalling sql several times, including downloading find on msdn. can me out? below solution explorer view. i've added database1.sdf project. i error add it: if try open .sdf file, error: here list of references: and, finally, of relevant sql-related installations on local machine: sql server compact 4.0 supported vs 2012, requires ddex provider isntalled. sounds vs install somehow broken. can install toolbox add-in, , go dialog in toolbox check if ddex provider , sql server ce 4.0 installed.

Using jQuery for responsive .resize() -

i've searched topic awhile, , answer may have been in front of me wasn't able put together. trying resize custom slider section area. i using bootstrap framework, jquery works best here because contents inside container using absolute positioning , have random top/left values generated in admin panel jquerys own .draggable function. id keep basic possible, , figure take math. example fiddle var h = $(window).height(); var w = $(window).width(); var static_h = $('.static-area').height(); if((h/w) > 800) { $('#main').css({'margin-top': w/1.2}); } else { $('#main').css({'margin-top': w/1.2, 'width':w}); $('.static-area div').css({'width': w/2, 'left':0}); } this kind of sorta works, , can divide css properties, top/left width/height, have no clue how math here content adjusts browser resize. i made quick fiddle visual demo fiddle i not trying rec

Android Service, Keeping Track of Objects -

this kind of convoluted, please bear me. have object has imageview instance variable. image need attach object stored on server, , vary instance instance. therefore, need dynamically. each object gets instantiated through oncreate() method of listactivity class. retrieve appropriate image, right after instantiation, have service role download correct image file server. stores image on sd card. far, good. file gets downloaded correctly. here stuck. when service completes, need able link object intending file, file itself. accomplish this, trying pass along object service , broadcastreceiver . problem approach, have discovered, whenever pass along object, gets passed value, not reference. thus, new object created , trail destroyed. i'm sure confusing. here relevant code. can post more if help. i'm open ideas how keep track of object or better ideas how accomplish this. thanks in advance. know strange question. hope i've explained enough. from oncreate() in li

jquery - Passing autocomplete value to ajax not working -

i want show mysql result html table.my problem come here, variable value not sending ajax data (empty). <form id="oqcform"> ..... <input type="text" id="fittest"/> <input type="text" id="nik"/> <button id="inputbutton">input</button> </form> <div id="qtycheck"></div> $("#inputbutton").click(function() { //ajax show mysql result html table var idnum = $("#nik").val(); $.ajax({ type:"post", url:"process2.php", data:"no="+idnum+"&action=personalqty", //problem here no = empty cache:false, async:false, success: function(result){ $('#qtycheck').html(result); //echo html table & mysql result } }); }); at console log: no: --> empty action:personalqty upda

Bulk update in rails with mongodb -

i have scenario need update 7k records in mongodb. query document.all.each |d| d.pages_enabled_count = d.pages.where(:disabled => false).count d.pages_enabled_to_query_count = d.pages.where(:disabled => false , :to_query => true).count d.pages_enabled_to_rescan_count = d.pages.where(:disabled => false , :to_rescan => true).count d.pages_enabled_to_retag_count = d.pages.where(:disabled => false , :to_retag => true).count d.save end it looks query take more 2 hrs!! 1 update takes around 1.6 sec. way optimize this? mongodb (388.3ms) test['$cmd'].find({"count"=>"pages", "query"=>{:deleted_at=>nil, "document_id"=>bson::objectid('51cd1c435329b64899000035'), :disabled=>false}, "fields"=>nil}).limit(-1) mongodb (388.5ms) test['$cmd'].find({"count"=>"pages", "query"=>{:deleted_at=>nil, "document_id"=>bson::objectid('5

python - I don't know how to use statement driver.find_element(By.LINK_TEXT, -

i tried writing driver.find_element(by.link_text, value='10').click() and following command line feedback: uname = driver.find_element(by.link_text, '10').click() file "c:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l ine 680, in find_element {'using': by, 'value': value})['value'] file "c:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l ine 165, in execute self.error_handler.check_response(response) file "c:\python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py" , line 164, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.nosuchelementexception: message: u'no such element\n (session info: chrome=28.0.1500.95)\n (driver info: chromedriver=2.2,platform= windows nt 6.1 sp1 x86_64)' other permutations of statement produce similar looking feedback. (the '10' i

c# - Exception in Add Parameter To DbCommand -

i need update command parameters, , reasons can't use stored procedures, generate update command depend on database, table , columns, following forms use: string constr = "provider=sqlncli10;server=.\\sql2008;database=mydatabase;trusted_connection=true;"; dbproviderfactory dbfactory = dbproviderfactories.getfactory("system.data.oledb"); dbconnection dbconnection = dbfactory.createconnection(); dbconnection.connectionstring = constr; dbcommand dbcommand = dbfactory.createcommand(); dbcommand.commandtext = "update [student] set name = @name id = @id"; dbparameter param1 = dbcommand.createparameter(); param1.parametername = "@name"; param1.value = "lol"; dbparameter param2 = dbcommand.createparameter(); param2.parametername = "@id"; param2.value = 5; dbcommand.parameters.add(param1); dbcommand.parameters.a

ruby on rails - Can I get a symbol for a member from an argument name? -

i validating child objects of parent this: validate :overdue_tasks_valid validate :created_overdue_tasks_valid i have methods this: private def overdue_tasks_valid validate_notification(overdue_tasks, :overdue_tasks) end def created_overdue_tasks_valid validate_notification(created_overdue_tasks, :created_overdue_tasks) end def validate_notification(notification, key) return if notification.valid? notification.errors.full_messages.each |message| errors.add key, message end end what want know, is, can pass 1 argument validate_notfication , somehow determine symbol in method? so validate notification called this: validate_notification(overdue_tasks) and method this: def validate_notification(notification) return if notification.valid? notification.errors.full_messages.each |message| errors.add [somehow symbol], message end end no, can send symbol instead: def overdue_tasks_valid validate_notification :overdue_tasks end def cre

printing - Simulate Printer Errors / Printed Pages Signals -

i'm testing software sends jobs printer queue , rises flag when printed. needs detect how many pages printed correctly in failed job. although there many "virtual printers" out there, process jobs perfectly... , that's problem. is there printer simulator can provide control on signals sends windows spooler, such printed pages, out of paper errors, paper jams, etc? i'm not interested in raw output printer driver handles printer, rather signals driver passes windows' spooler.

Which is better way of handling callback in iOS -

i have created custom network handler managing server calls application. internally uses nsurlconnection , callback function block once data fetch complete. current can set callback method or callback codeblock. wanted understand 1 better , why. option 1 : basenetworkhelper * helper = [[basenetworkhelper alloc] initwithurl:@"request/url/as/string" action:@"action/for/request" params:params]; [helper addfinishaction:self sel:@selector(markreadfinished:)]; is way arc warning when call callback method once action complete. bellow. if (_target) { if ([_target respondstoselector:selector]) { [_target performselector:selector withobject:rdata]; } } option 2: basenetworkhelper * helper = [[basenetworkhelper alloc] initwithurl:@"request/url/as/string" action:@"action/for/request" params:params]; [helper startdownload:^(nsdata *data, nserror *error) { // business logic response handling / error h

gcc - arm-linux-gnueabi compiler options -

i using, arm-linux-gnueabi-gcc compile c programs arm processor in linux. however, not sure default arm mode compiles. for example, c code: test.c unsigned int main() { return 0x1ffff; } arm-linux-gnueabi-gcc -o test test.c now, when @ disassembly of main() function objdump, can see: arm-linux-gnueabi-objdump -d test <main>: push {r7} add r7, sp, #0 movw r3, #65535 ; 0xffff movt r3, #1 mov r0, r3 mov sp, r7 pop {r7} bx lr it appears disassembly thumb mode of arm (because of push instruction). how can display disassembly follows: .sect ".text" .global _fn _fn: movw a1,#65535 movt a1,#1 bx lr or this .sect ".text" .global _fn _fn: ldr a1, con1 bx lr .sect ".text" .align 4 con1: .word 0x1ffff i saw example here: http://e2e.ti.com/support/development_tools/compiler/f/343/t/40580.aspx however, unable view disassembly w

c# - Problems after merging Fluent into main.exe -

my question fluent , merged program.exe in 1 merged.exe code: public class program { [stathreadattribute] public static void main() { appdomain.currentdomain.assemblyresolve += onresolveassembly; app.main(); } private static assembly onresolveassembly(object sender, resolveeventargs args) { //we dont' care system assemblies , on... //if (!args.name.tolower().startswith("wpfcontrol")) return null; assembly thisassembly = assembly.getexecutingassembly(); //get name of assemblyfile var name = args.name.substring(0, args.name.indexof(',')) + ".dll"; //load form embedded resources - function not called if assembly in application folder var resources = thisassembly.getmanifestresourcenames().where(s => s.endswith(name)); if (resources.count() > 0) {

checkbox - Adding checked items in a custom list view to array list in android -

hi writing program using custom listview checkbox. intention start new activity when clicking button ( add ) , new activity displays selected values listview.i getting error when try add values the error occuring line is selecteditems.add(adapter.getitem(position)); if comment line can check box shows eror when click "add" button. here complete code. my mainactivity homepage.java public class homepage extends activity { private listview listview1; listadapter adapter; button btn; sparsebooleanarray checkedvalue; arraylist<list> selecteditems; string name; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_home_page); list device_data[] = new list[] { new list(r.drawable.ic_pic , "actvity1"), new list(r.drawable.ic_pic, "actvity2"), new list(r.drawable.ic_pic, "actvity3"), new l

asp.net - Login with Jquery Colorbox Plugin -

i used jquery colorbox lightbox plugin in order let users login site ,this plugin use signin.aspx page (which made) in order evaluate user's credentials, problem when try signin ,i'm facing error: blocked frame origin " http://www.example.com " accessing frame origin " https://www.example.com ". frame requesting access has protocol of "http", frame being accessed has protocol of "https". protocols must match. idea(s)? appreciate the page frame on , page loading lightbox (signin.aspx) must both on same domain (including protocol). called same origin policy . if want popup same protocol, use protocol-less url: //example.com/signin.aspx this use protocol of parent document (http or https)

mvvm - Injecting Instantiated ViewModel to View with AvalonDock -

i have observable collection of viewmodels bound avalondock's layoutitemtempate. when user opens problem fetched list, creates new viewmodel in observable collection. new document created result, new , not use viewmodel collection. i tried use converter, doesn't seem use converter @ all. know alternative? perhaps code-behind solution? here main xaml snippet . . . <window.resources> <pconv:iprobleminfotofreeresponsevmconverter x:key="freeresponsetovm" /> </window.resources> . . . { lines down } . . . <dock:dockingmanager.layoutitemtemplateselector> <selector:layoutitem> <selector:layoutitem.problemeditviewtemplate> <datatemplate> <problem:freeresponseedit datacontext="{binding selectedproblem, converter={staticresource freeresponsetovm}}" /> </datatemplate> </selector:layoutitem.pr

django - DetailView template not displaying model data -

i have model want display detail view, have created list view has link leads detailed view. dont errors template doesn't render of models detail link detailview <a href="../ancillaries/{{ ancillary.id }}" > product </a> model from django.db import models django.core.urlresolvers import reverse class ancillary(models.model): product_code = models.charfield(max_length=60, null=true) type = models.charfield(max_length=120, null=true) product = models.charfield(max_length=120, null=true) standard = models.charfield(max_length=120, null=true) measurement = models.charfield(max_length=120, null=true) brand = models.charfield(max_length=120, null=true) class meta: verbose_name_plural = "ancillaries" def get_absolute_url(self): return reverse('ancillaries') def __unicode__(self): return u'%s %s %s %s %s %s %s' % (self.id, self.product_code, self.type,

batch file - dated dir structure, multi depth -

i new here, neither programmer or computer professional i amateur photographer , create folder structure photos below , use bat file automate every new shoot. 2013-21-31_enter photo shoot info manually 2013-21-31_info above/2013-21-31_info above_jpg 2013-21-31_info above/2013-21-31_info above_tif 2013-21-31_info above/2013-21-31_info above_raw 2013-21-31_info above/2013-21-31_info above_bw 2013-21-31_info above/2013-21-31_info above_rejects i appreciate help, dettki give whirl: if don't want current date date enter remove rem below. @echo off /f "delims=" %%a in ('wmic os localdatetime ^| find "."') set "dt=%%a" set "yyyy=%dt:~0,4%" set "mm=%dt:~4,2%" set "dd=%dt:~6,2%" set "hh=%dt:~8,2%" set "min=%dt:~10,2%" set "sec=%dt:~12,2%" set datestamp=%yyyy%-%mm%-%dd% rem set /p "datestamp=enter date in yyyy-mm-dd format: " set /p "var=enter descri

ios - getting error when calling objectFromJSONString using JSONKit -

i use following code create dictionary based on json string received server. (i have downloaded jsonkit , embedded project). code below returns legal json string server (parsed on android) crashes when try convert dictionary. - (ibaction)submit { bool usessl = true; char *c_url="http://(rest of url)"; nsstring* url = [nsstring stringwithformat:@"%s" , c_url]; url = [nsstring stringwithformat:@"%@%@%s", url, self.label.text, "/keys"]; nsstring * response = [self getdatafrom:url]; nsdictionary *dict = [response objectfromjsonstring]; //generates sigabrt!! nslog(@"%@",dict); nsstring *success = [dict valueforkey:@"success"]; } - (nsstring *) getdatafrom:(nsstring *)url{ nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request sethttpmethod:@"get"]; [request seturl:[nsurl urlwithstring:url]]; nserror *error = [[nserror alloc] init]; nshttpurlresponse *responsecode = nil; nsdata *ores

java - to display one image after the another by using on click method -

i having many images in drawable folder mickey1 , mickey 2 , mickey 3 , mickey 4;i want draw 1 image after 1 form complete mickey mouse . here code public class displaymessageactivity extends activity implements onclicklistener { button next; imageview fullimage; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_display_message); next=(button)findviewbyid(r.id.button1); next.setonclicklistener(this); fullimage = (imageview) findviewbyid(r.id.fullimage); } @override public void onclick(view v) { int click =1; if (click == 1) { fullimage.setimageresource(r.drawable.mickey1); { if(click==2); fullimage.setimageresource(r.drawable.mickey2); } } } } you can this fullimage.settag("1"); in oncr