Posts

Showing posts from May, 2012

mysql - Python: How to use a generator to avoid sql memory issue -

i have following method access mysql database , query executed in server don't have access change on regarding increasing memory. new generators , started read more , thought convert use generator. def getunames(self): globaluserquery = ur'''select gu_name globaluser gu_locked = 0''' global_user_list = [] try: self.gdbcursor.execute(globaluserquery) rows = self.gdbcursor.fetchall() row in rows: uname = unicode(row['gu_name'], 'utf-8') global_user_list.append(uname) return global_user_list except exception, e: traceback.print_exc() and use code follow: for user_name in getunames(): ... this error getting server side: ^gout of memory (needed 725528 bytes) traceback (most recent call last): ... packages/mysqldb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue operationalerror: (2008, 'mysql client ran out of mem

extjs - ActiveItemChange and Dataview.Dataview display -

Image
here subview i reworking ui. @ first button real button in titlebar. logic of button worked , mvced. have linked tab send proper signal controller. controller receive , navigate threw tree structure correctly. the problem dataview.dataview in project tab not displaying after tap on button. here code onsubviewactiveitemchange: function(container, value, oldvalue, eopts) { var me = container; switch(value.getitemid()) { case 'back_innertab': me.fireevent('goback'); break; case 'exit_innertab': me.fireevent('exit'); break; case 'project_innertab': me.fireevent('reloadchildren') break; case 'chart_innertab' : me.fireevent('categorydisplay',me.getcomponent('chart_innertab').getcomponent('pie')); break; } } with code, when tab tapped, controller job has intented, , tabpanel send me tab. if go project tab, displa

c++ - Not expected constructor called -

i'm looking c++11 move constructors doesn't work. in fact issue before started writing such constructor. here's code snipped: #include <iostream> #include <string> #include <sstream> class object { static std::ostream& log(object &obj) { std::cout << "object::id = " << obj.mid << "::"; return std::cout; } unsigned mid = 0; std::string *mtext = nullptr; unsigned nextuniqueid() const { static unsigned id = 0; return ++id; } const std::string textinfo() const { std::ostringstream oss; oss << "mtext @ " << &mtext; if (mtext) oss << " = " << *mtext; return oss.str(); } public: object() = delete; object& operator= (const object&) = delete; explicit object(const std::string& str) : mid(this->nextuniqueid()), mtext(new std::string(str)

python - How can I stop a loop with a Toggle Button -

i´ve made gui wx.slider , wx.togglebutton. goal use slider kind of timeline plot , toggle button start/stop button. ideia is: when press toggle button slider value starts increasing , when press toggle button again stops. i'm using following code , can make slider value increase once starts moving can't stop loop until reaches end of slider. there way stop increase when press toggle button again? def m_togglebtn1ontogglebutton( self, event ): value = self.m_togglebtn1.getvalue() if value == true: self.m_togglebtn1.setlabel("pause") in xrange(100): if == 100: self.m_slider1.setvalue(100) else: self.m_slider1.setvalue(i) time.sleep(0.1) else: self.m_togglebtn1.setlabel("start") slider_value = self.m_slider1.getvalue() self.m_slider1.setvalue(slider_value) thanks help. kind regards ivo. i wrote quick script think want: i

codeigniter - Pagination and controller methods arguments -

here problem. i'm using pagination library of code igniter paginate results model return. thing i've need pass arguments controller method url this: localhost/index.php/controller/paginationnum and need this localhost/index.php/controller/paginationnum/arg1/arg2/arg3 how can ignore paginationnumber in url can user arguments in controller? i not entirely sure since using pagination combined ajax lot in codeigniter can't go with: $this->uri->segment(n); so filter out unwanted parts of uri?

com.sun.crypto.provider.SunJCE is not supported by Google App Engine's Java runtime environment -

tried use aes functionality in sunjce got error saying com.sun.crypto.provider.sunjce not supported google app engine's java runtime environment anyone familiar this? appengine's java runtime environment has whitelist of classes jre can used. https://developers.google.com/appengine/docs/java/jrewhitelist the code sample in email thread shows 1 way of doing aes encryption on appengine. place start. https://groups.google.com/forum/#!topic/google-appengine/ym8axlulthg

How to call a custom JSON request, then build a collection of models from that, using Backbone.js? -

i'm new backbone.js , have been trying understand 3 things: 1) how , call custom json request? 2) how translate json request model? 3) how create collection of models? my json looks this: {"flavor": "vanilla", "message": "ok", "count": 10, "rows": [{"data":["this", "is", "123", "something"], "moredata": "more stuff here", "moreinfo": "more info here"}, {"data":["even", "more", "456", "something"], "moredata": "even more stuff here", "moreinfo": "even more info here"}, {"data":["it", "doesn't", "123", "end"], "moredata": "more , more stuff here", "moreinfo": "mor

scheme - DrRacket : How to get the position of a value in a list -

i trying list of positions of value in list in intermediate student language. for instance wish list of positions value "a" in following list (list false false false false false false false false ) the output must (list 1 6) i'll give hints solve problem, it's better if reach solution own means. fill-in blanks: ; position procedure ; lst: input list ; ele: searched element ; idx: initial index, starts in 0 (define (position lst ele idx) (cond (<???> ; if input list empty <???>) ; we're done, return empty list (<???> ; if current element equals 1 we're looking (cons <???> ; build output list, cons index found (position <???> ele <???>))) ; , advance recursion (else ; otherwise (position <???> ele <???>)))) ; advance recursion notice idx parameter necessary keep track of

objective c - How to hide a section in a table view controller with static cells? -

i have uitableviewcontroller static cells, 3 sections, , segmented control 2 buttons. achieve following behavior: when button 1 pressed hide section 2 when button 2 pressed hied section 3 i cannot find solution this. tip useful. thanks. simple, make sure set uitableviewdelegate, , can use heightforrowatindexpath: (and similar headers , footers) show/hide cells setting height 0. - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { if (indexpath.section == 2) { if (self.shouldshowsection2) { return 44.0f; }else{ return 0.0f; } }else if (indexpath.section == 3) { if (self.shouldshowsection3) { return 44.0f; }else{ return 0.0f; } }else{ return 44.0f; } } then define logic within ibaction change these bools around in between tableview's begin/end updates, , table show/hide sections want. - (ibactio

Use jQuery's .load() to load page fragments but only get contents of selector -

i using jquery's .load() page fragments method reload piece of page: $("#submit").click(function() { $("#box").load('/ajax/box/ #box'); }); it works, causing error because after contents loaded. since function uses .innerhtml replacing code on inside of div . html result looks like: <div id="box"> <div id="box"> <!-- page --> </div> </div> i have tried using .parent() removes other div s in parent. $("#submit").click(function() { $("#box").parent().load('/ajax/box/ #box'); }); essentially trying (i know code below invalid, represents trying accomplish): $("#submit").click(function() { $("#box").load('/ajax/box/ $('#box').html()'); }); is there way can make #box replaced #box ? 1 thing keep in mind cannot edit html, needs happen jquery only. just add > * after #box $("#s

asp.net - Azure: access RoleEnvironment from a website -

i have cloud service project web role (asp.net) , worker roles. in default.aspx.cs file tried access worker role: var role = roleenvironment.roles["myworkerrole"]; but got "role discovery data unavailable" exception. is there way accsess it? are trying debug locally or running azure? if locally, try switch visual studio webserver. if running on vs webserver, try iis express instead. hth

css - How can i remove large white areas of mobile site? -

i rid of large gaps of wasted white space between 2 shaded lines pages of mobile site. im using #pagewrapper { margin-top: 30px; } spacing on desktop version, maybe not ideal way? asked delete it, messed spacing desktop view. my site http://jeffreydowellphotography.com (im sorry if frowned upon post site link, dont know how show otherwise) i'm noob. you need apply mobile styling within media query: @media screen , (max-width: 800px) { #pagewrapper { margin: 0; padding: 0 20px; } .sqs-layout .sqs-row .sqs-block:last-child { padding-bottom: 0; } }

Jquery: Click event doesn't work after append. (Don't know how to use .ON) -

i have 2 click events. 1 appends img includes click event. doesn't work obviously. know have use jquery's .on, can't figure out how , where. my code: $( document ).ready(function() { // 1 below (.choimh) isn't triggered anymore $('.choimg').click(function(){ }); // switch chosen color $('.color').click(function(){ $(".thumbs").append('<a href="#"><img id="image'+u+'" class="choimg" src="/img/products/mini/'+colnumber+'-'+ + '.jpg" />'); }); }); the .color div on different place .choimg. i can't figure out how use .on. it used live or delegate functions did kind of thing. can this: $(document).on('click', '.choimg', function(e) { //do whatever });

java - What are consequences of having GCM SENDER ID being exposed? -

scenario: suppose reverse engineering .apk file, attacker obtains sender id push registration service used in app. attacker develops similar fake application has same/different package name , has been uploaded on different app store google play. my question: can he/she use same sender id app? implications of user installs fake application? related questions: google cloud messaging security question seems bit similar. answer of android gcm: same sender id more application question provides valuable information. reading both accepted answers conclusion seems absolutely possible , that's why recommended not have sensitive data in push messages. but doesn't seem solution problem. unable understand effect of above security lapse. a sender id (aka google api project id) not tied unique application package name. in fact, multiple apps can register gcm using same sender id, allow same api key used sending gcm messages of these apps. of course each app have dif

javascript - How to detect if Jquery syntax highlighting is applicable to a source file -

i'm implementing script detect if jquery being used within javascript source file (for sublime text plugin). right (aside obvious javascript extension test) solution checks if of following substrings appears within file: jquery_idioms = [ '$(function', '$(document)', '$(window)', '$(this)' '$.fn', '$.ajax', '$.noconflict', 'jquery.noconflict' ] i don't think 100% certanity achievable (because of similar libraries using replicating jquery's api, etc), i'm trying build list of substrings avoids false positives. as not huge jquery expert, question is: am missing used jquery idioms? ps: (i don't think it's possible but) alternative non substring searching ideas?

c++ - Generate a unique type or id for each template instantiation? ( example observer pattern ) -

is there way or technique generate unique types or ids each template instantiation @ compile time? for example observer pattern: #include <set> #include <iostream> template <typename t> struct type2type {}; // maybe int2type template<class t, class t_unique> struct observer_base { virtual void notify ( t, type2type< t_unique > ) = 0; }; template<class t, class t_unique> struct subject_base { // without t_unique parameter typedef t_unique unique_type; std::set< observer_base< t, unique_type >* > my_observer{}; void do_notify () { ( auto obs : my_observer ) obs->notify ( t{}, type2type< unique_type >{} ); } }; class x {}; class y {}; // manual unique required? class subject_a : public subject_base< x, subject_a > {}; class subject_b : public subject_base< x, subject_b > {}; class subject_c : public subject_base< y, subject_c > {};

sql - Deleting a record with child items and a self-referencing constraint -

so have following tables (with irrelevant columns omitted): create table [dbo].[step] ( [stepid] int not null primary key identity, [parentstepid] int null, constraint [fk_step_parentstep] foreign key ([parentstepid]) references [step]([stepid]) ) create table [dbo].[stepinput] ( [stepinputid] int not null primary key identity, [stepid] int not null, [childstepid] int null, constraint [fk_stepinput_step] foreign key ([stepid]) references [step]([stepid]), constraint [fk_stepinput_childstep] foreign key ([childstepid]) references [step]([stepid]), ) there step, has zero-to-many stepinputs. stepinput has optional child step, , step has optional parent step (self referencing). this works expected. want able delete step, , have of stepinputs associated step deleted, child steps , inputs. i using entity framework 5. there convenient way ef, or need create stored procedure, set cascade options on fk constraints, or there else better solution? i di

sql - MySQL COUNT() to return 0 -

i have query looks this: select app.application_id, j.job_number, j.job_id, j.job_title, j.job_city, j.job_state, p.person_id candidate_id, p.first_name, p.last_name, app.start_date, ope1.percent_complete, max(case when r.role_display_name = 'eng - recruiter' (select case when count(last_name) = 0 'unassigned' else count(last_name) end uname users join job_roles on job_roles.user_id = users.user_id job_id = j.job_id , role_id = r.role_id ) else '' end) role_3 my problem count(last_name) not return 0, because there no records returned, there no value of null . makes sense, have tried wrapping in ifnull() , isnull() , none of them seem fix problem. how can return 0 when there no records? need another subquery inside count() aggregate? not use subquery.... if understand correctl

c# - Error at BFS search .Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index -

i have function create bfs . have 1 function , code , : static void breadth_first_search(queue<int> q, list<int > trace, int[,] grid, int start, int nodes) { int u; list<int> visited = new list<int>(220000); q.enqueue(start); trace[start] = -1; visited[start] = 1; { u = q.peek(); q.dequeue(); (int v = 1; v <= nodes; ++v) { if ((grid[u, v] == 1) && visited[v] == 0) { q.enqueue(v); trace[v] = u; visited[v] = 1; } } } while (q.count != 0); } the problem don't work. have error : index out of range. must non-negative , less size of collection. parameter name: index at here : tr

eclipse - Lambda Expressions java 8 exception : java.lang.NoSuchMethodError: java.lang.invoke.LambdaMetafactory.metaFactory -

i have problem running following code: public class lambdatesting { public static void main(string[] args){ new lambdatesting(); } public lambdatesting(){ test1(); } private void test1(){ runnable x = () -> system.out.println("ok"); //error } } which causing following exception: *exception in thread "main" java.lang.incompatibleclasschangeerror @ java.lang.invoke.methodhandlenatives.linkmethodhandleconstant(methodhandlenatives.java:383) @ lambdatesting.test1(lambdatesting.java:24) @ lambdatesting.<init>(lambdatesting.java:20) @ lambdatesting.main(lambdatesting.java:15) caused by: java.lang.nosuchmethodexception: no such method: java.lang.invoke.lambdametafactory.metafactory(lookup,string,methodtype,methodhandle,methodhandle,methodtype)callsite/invokestatic @ java.lang.invoke.membername.makeaccessexception(membername.java:765) @ jav

Changing background colour without increasing GPU overdraw - Android -

i know using android:background change background colour adds layer gpu has draw app. wondering whether there way change set background style without adding layer of gpu overdraw. perhaps done style of sort have tried styles seems redraw on top of normal light theme background. in res/values folder create file , name it. example theme.xml <resources> <style name="theme.nobackground" parent="android:theme"> <item name="android:windowbackground">@null</item> </style> </resources> for parent, use whatever theme using in application manifest. logic that, extending parent theme , setting background attribute. in manifest file, set new style application theme between application tags. android:theme="@style/theme.nobackground" this remove theme background, have set background each activity in layouts. if want set 1 background application, instead of null assign whatever drawabl

python - Incorrect Content-Length for a file (Request Entity Too Large 413) -

a server receives file succesfuly if it's small enough. otherwise, returns error of " request entity large error 413 ". not mine server, i'm unable deal directly. i'm pretty sure depends of content-length http header (in fact, https connection if matters). conn = httplib.httpsconnection("www.site.com") conn.connect() conn.putrequest("post", path) conn.putheader("content-type", "some type") conn.putheader("content-length", str(os.path.getsize(file_name))) conn.endheaders() even if try send file chunk chunk big file (too big) chunk_size = 1024 while true: try: chunk = f.read(chunk_size) if not chunk: break conn.send(chunk) except exception e: break it failed, while on small files worked well. if manually make content-type smaller, seems(!) work, @ least error of " request entity large error 413 " server disappers. doesn't work because, probably, format of fil

Configuring middleware using Ruby on Rails 4 -

i interested in using omniauth cas in ruby on rails 4 project. particular gem i'm looking @ one: https://github.com/dlindahl/omniauth-cas the documentation says configure cas excerpt looks following: rails.application.config.middleware.use omniauth::builder provider :cas, host: 'cas.yourdomain.com' end my question go in context of ruby on rails 4 application? file config placed in? additional need done use middleware in ruby on rails 4? tried adding following in application.rb , getting complaints no route matches [get] "/cas_login": config.middleware.use omniauth::builder provider :cas, login_url: 'http://localhost:3000/cas_login', host: 'localhost', port: 3000 end this code should placed in initializer @ config/initializers/cas_middleware.rb . alternatively, put syntax inside class of config/application.rb block: config.middleware.use omniauth::builder provider :cas, host: 'cas.yourdomain.com' end

sql - PostgreSQL, min, max and count of dates in range -

this question based of 2 previous here , here . i trying hard 2 queries: select min(to_date(nullif(mydatetext,''), 'dd.mm.yyyy')) dmin, max(to_date(nullif(mydatetxt,''), 'dd.mm.yyyy')) dmax mytable and select count(*) mytable to_date(nullif(mydatetxt,'')) 'error here between max(to_date(nullif(mydatetxt,''), 'dd.mm.yyyy')) , min(to_date(nullif(mydatetxt,''), 'dd.mm.yyyy')) in single 1 can read result minimal date, maximal date, count of dates between , including min , max dates. here few problems. second query don't work expected or don't work @ have improved. if 2 queries can writen in single query (?) can use dmin , dmax variables first part variables in second part? this: select count(*) mytable to_date(nullif(mydatetxt,'')) 'error here between dmin , dmax please solve situation finally. workable code: using cmd new npgsqlcommand("select my_id, myd

asp.net - how can i get Total like From A post in Facebook with Graph Api? -

how total likes post graph api url ? here this link return: array of objects containing id , name fields. requesting summary=1 return summary object containing total_count of likes. in fb api explorer try fetching likes post, used 700182169998352 the "/700182169998352/likes" return: { "data": [ { "id": "663945278", "name": "irene olsson wikler" }, { "id": "100002437916716", "name": "frida braxell" }, { "id": "1135121633", "name": "rex leopold olsson" } ], "paging": { "cursors": { "after": "mteznteymtyzmw==", "before": "njyzotq1mjc4" } } } the "/700182169998352/likes?summary=1" return: { "data": [ { "id": "663945278", &

regex - Java - regular expression finding comments in code -

a little fun java time. want write program reads code standard input (line line, example), like: // comment class main { /* blah */ // /* foo foo(); // foo */ foo2(); /* // foo2 */ } finds comments in , removes them. i'm trying use regular expressions, , i've done this: private static string parsecode(string pcode) { string mycommentsregex = "(?://.*)|(/\\*(?:.|[\\n\\r])*?\\*/)"; return pcode.replaceall(mycommentsregex, " "); } but seems not work cases, e.g.: system.out.print("we can use /* comments */ inside string of course, shouldn't start comment"); any advice or ideas different regex? in advance. you may have given on intrigued problem. i believe partial solution... native regex: //.*|("(?:\\[^"]|\\"|.)*?")|(?s)/\*.*?\*/ in java: string clean = original.replaceall( "//.*|(\"(?:\\\\[^\"]|\\\\\"|.)*?\")|(?s)/\\*.*?\\*/", &quo

bash selective filename expansion to pass to daemon -

i want define function or alias starts process daemon can still grok filenames passed it. think: function emacs() { daemon /usr/bin/emacs $* } this should work for emacs localfile.txt /tmp/anotherfile.txt i need function changes localfile.txt $pwd/localfile.txt , not /tmp/anotherfile.txt. there bash-elegant way this? advice appreciated. if not, thinking of writing in perl. /iaw first, if weren't changing arguments, you'd want use "$@" , not $* . otherwise spaces cause argument list re-split. but sure. try this. function emacs() { local args=() in "$@"; case "$a" in [/-]*) args+=("$a");; # pass options , absolute filenames as-is *) args+=("$pwd/$a");; # absolutify else esac done daemon "$(type -p emacs)" "${args[@]}" } this still breaks option arguments aren't files, it's start. however, assumes emacs works daemon, doesn&#

java - BubbleSort -my code returns random addresses -

i have implemented code bubblesort algorithm returns weird error please tell me problem is? public class bubblesort { public static int[] unsorted = new int[5]; public void assignrandom(){ for(int = 0; < unsorted.length; i++){ unsorted[i] = (int)(math.random()*10) + 10; } } public void swapvalues(int first, int second){ int temp = unsorted[first]; unsorted[first] = unsorted[second]; unsorted[second] = temp; } public void bubblesort() { for(int = unsorted.length - 1; >= 0; i--){ for(int j = 0; j < i; j++){ if(unsorted[j] > unsorted[j+1]) swapvalues(j,j+1); } } system.out.print(unsorted); } public static void main(string[] args){ bubblesort newbubble = new bubblesort(); newbubble.assignrandom(); newbubble.bubblesort(); } } this code bubblesort (assignmrandom assign

macros - Autoit Recorder with Sleep -

there many autoit recorders out there none of i've seen track timing. put mouse movements/keystrokes 1 after other. note: want record far long manually add sleep() values. is there way solve this? other question: there way detect if user pressing mouse button? thanks. no existing tool in knowledge, have develop own. did same thing years ago cant manage fint it. just 1 advice, use _timer_getidletime() instead of timerinit() , timerdiff() http://www.autoitscript.com/forum/topic/69993-timer-getidletime/#entry513337

winforms - Producing a progress bar while loading in C# -

i have below code shows message text box while loading: private void button3_click_1(object sender, eventargs e) { int i; backgroundworker bw = new backgroundworker(); bw.workerreportsprogress = true; bw.workersupportscancellation = true; bw.dowork += new doworkeventhandler(bw_dowork); bw.progresschanged += new progresschangedeventhandler(bw_progresschanged); bw.runworkercompleted += new runworkercompletedeventhandler(bw_runworkercompleted); msgform = new form2(); //form2 showing message "please wait..." try { bw.runworkerasync(combobox15.text); msgform.startposition = formstartposition.centerparent; msgform.showdialog(); } catch (exception ex) { messagebox.show(ex.message); } } void bw_dowork(object sender, doworkeventargs e) { string prtadd = e.argument.tostring();

asp.net mvc 4 - unobtrusive ajax form prevent cancel button from posting -

question: why cancel button posting controller submit? i have form below loaded partial view. submit works fine. thing i've been struggling why cancel doesn't dismiss form. i've tried variety of things capturing click event. looked @ http://jimmylarkin.net/post/2012/05/16/broken-validation-on-cancel-buttons-with-unobtrusive-validation-ajax.aspx possible solution i'm not sure problem it's intended address. no doubt it's ignorance on part. bonehead thing missing? //click event loading form. <script> $(document).ready(function () { $('#editbtn').click(function () { var url = "/quiz/editquiz?id=@id"; $.get(url, function (data) { $('#formdiv').html(data); $("#formdiv").show(); }); }); </script> //form inside partial view. @using (ajax.beginform("editquiz", "quiz", formmethod.post,

php - json api graph call does not return anything? -

i fetching users fb newfeed , wanted check wether user has liked post or not using user_likes , problem following code wont return : $getlike = $facebook->api("/fql?q=select like_info stream post_id=" . $id); $checklike = $getlike['data'][0]['like_info']['user_likes']; here complete file: testone.php problem fql , calling user_likes wont return anything. want check wether user has liked post or how can value user_likes. json fb : { "data": [ { "like_info": { "can_like": true, "like_count": 70, "user_likes": false } } ] } is technique right?do need access code or something? if getting value of $getlike , can check value of user_likes (since of type boolean)- if($getlike['data'][0]['like_info']['user_likes']) { echo "true"; } else { echo "false"; }

ms access 2007 - How can I prevent ListBox from unselecting items after right click -

i have form there list box inside that. after selection of items (usually 20 items) , right click mouse on items should open pop form,the problem after right click selected items unselected except 1 item there mouse on that. how can prevent list box deselecting items after right click . the code mouse right click below: private sub itemlist_mousedown(button integer, shift integer, x single, y single) const rightbutton = 2 dim udtpos pointapi dim frm access.form if button = rightbutton set mp = new [*clsmouseposition] getcursorpos udtpos docmd.openform "frmshortcut" docmd.movesize udtpos.x * mp.twipsperpixelx, udtpos.y * mp.twipsperpixely forms!frmshortcut!txtparameter = me.itemlist.value end if end sub if multi select property set simple should not happening. i assuming mutli select set extended , in case should press ctrl button while right clicking item mouse keep existing selections left clicking. in nutshell: right click same left cli

javascript - If jQuery has Class do this action -

i trying check whether or not particular element has been clicked having trouble doing so. here html: <div id="my_special_id" class="switch switch-small has-switch" data-on="success" data-off="danger"> <div class="switch-on switch-animate"><input type="checkbox" checked="" class="toggle"> <span class="switch-left switch-small switch-success">on</span> <label class="switch-small">&nbsp;</label> <span class="switch-right switch-small switch-danger">off</span> </div> </div> here jquery: <script type="text/javascript"> $(document).ready(function() { $('#my_special_id').click(function() { if ($('#my_special_id div:first-child').hasclass('switch-on')) { window.alert('on!'); } }); }); </sc

sql - Select subsets of collection type values -

using cql3 collection types , how can select parts of collection? there examples given update , set collection types, doesn't seem possible query subsets of values in such type. you can't select specific element within collection (yet). docs can retrieve collection in entirety. , while may (or may not) relax rule bit in future, still means collections not meant excessively large. not replacement proper modelisation tables.

Using sed , awk to extract lines of data between a pattern till the beginning of a line with a special character -

i have following xml ## 13 aug 2013 14:53:44, 390 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:53:44, 390 [info] orderid 105 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:55:45, 490 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:53:44, 390 [info] orderid 105 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> i want search particular line orderid "example orderid 100" , print both line , below till next order line starting doulbe hash(##) if search orderid 100 should following ## 13 aug 2013 14:53:44, 390 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>det

jquery mobile - Phonegap android project works on emulator and in some devices but not in a 2.2 android device -

im making phonegap application (phonegap 2.9 + jquery 1.8.3 + jquery mobile 1.3.1) works in: -4.3 android device. -4.0 android device. -2.2 android virtual device. the problem im having issues when install in android 2.2.2 device. of api calls work , others dont. for example, call works: $.ajax({ data: {museum_id:'1'}, url: url+'index.php?r=api/listallcuriosities', type: 'get', success: function (response) { var resultado = response['data']; var listadohtml = ''; (var i=0;i<resultado.length;i++){ listadohtml += '<ul data-role="listview" data-theme="b" class="titulos"><li>'+resultado[i]['title']+'</li></ul>' +' <p>'+ resultado[i]['description']+'</p>'; } $('#listcuriosities').html(listadohtml); $('#lis

jquery - JavaScript <div> .class Extraction -

i writing javascript retrieves webpage site, , displays 'notices' site. fortunately, 'notices' div elements of class 'event'. want extract these divs returned code can re-format , display them. code have far working, i'm not sure on how extract 'event' divs source code. ideas? function getnotices(){ // date form var str = document.getelementbyid('formdate').value; var year = str.slice(1,4); // extract year var month = str.slice(6,7); // extract month var day = str.slice(9,10); // extract day // inject correct date url var link = "<a href=\"http://ilearn.stpauls.school.nz/calendar/view.php?view=day&course=1&cal_d=" + day + "&cal_m=" + month + "&cal_y=" + year + "\">raw link</a>"; // write raw link div debugging document.getelementbyid('rawlink').innerhtml = link; (debugging) // bounce off anyorigin.com sourc

javascript - jquery relative a href="#" remove display block -

<li><a href="#section17"><b>arbeiten</b></a></li> this link. when click change id of div(#section17) display none block. <li><a href="#section15"><b>feiern</b></a></li> now if click on other link(#section15) should change display:block #section17 display:none again , link(#section15) display block the page doesnt reload url change little bit. can me? <script type="text/javascript"> $("a").click(function () { var addressvalue = $(this).attr("href"); $(addressvalue).css("display","block"); }); </script>; demo: http://jsfiddle.net/gvee/qba7e/ html <ul> <li><a href="#section17"><b>section 17</b></a> </li> <li><a href="#section18"><b>section 18</b></a> </li> <li><a href=

apple push notifications - iOS APNs badge update issue -

say, have app apns on. app icon badge number badge property of apns json payload, right ? means if app icon badge 1, when new push notification arrives, app icon badge changed badge value of json payload, not auto increase 1, if right ? if so, there approach auto increase. or there way total notification count app in notification center? thanks. with json payload you're setting badge number. solution manage server side notifying server each time "notification" read. you should add "read" flag objects in database sent notifications. chat app example: when send notification new message, badge number should total of conversations unread flags user. , each time user reads conversation, should make api call mark read in server , of course decrement badge number locally.

MS Excel macro for not counting weekends? -

Image
q: how can create macro (any ideas?) "overdue" column? it should "y" if the: created column+days column younger current date. it should "n" if not. but: weekends not needed counted.. so if ex.: the "created" "8/10/2013 22:38" - saturday weekend , "days" 2, addition of 2 should be: 8/13/2013 24:00 if "created" "8/16/2013 11:26" - friday, weekday , "days" 2, addition of 2 should be: 8/20/2013 13:34 example: today is: 8/13/2013 10:25 created days overdue 8/10/2013 22:38 2 y 8/12/2013 11:26 2 n because: 8/10/2013 22:38 + 2 days younger 8/13/2013 10:25, "overdue" needs "y" 8/12/2013 11:26 + 2 days older 8/13/2013 10:25, "overdue" needs "n" what using if , compare date now() ? =if( (a2+b2)<now(),"y","n") (okey, check updated question , make new inputs here...) used formulas: =

X-PHP-Response-Code Headers -

i saw header(x-php-response-code) here in answer , wondering. what function , there other x-php-* headers? if there function , usage (as info possible)? if 1 (in doubt) ignore 2. in example given, header nothing, point. http headers starting x- precisely not standardized, can set such header knowing doesn't mean specific. point in case cite use header function set response code. that, some header needs supplied. user chose use otherwise meaningless header x-php-response-code , able give some header header() in order use third argument set response code. in other words: it's hack.

python - Parse value to None in ndb custom property -

i have custom ndb property subclass should parse empty string none. when return none in _validate function, none value ignored , empty string still used. can somehow cast input values none? class booleanproperty(ndb.booleanproperty): def _validate(self, value): v = unicode(value).lower() # '' should casted none somehow. if v == '': return none if v in ['1', 't', 'true', 'y', 'yes']: return true if v in ['0', 'f', 'false', 'n', 'no']: return false raise typeerror('unable parse value %r boolean value.' % value) maybe looking ndb.computedproperty ? class yourbool(ndb.model): my_input = stringproperty() val = ndb.computedproperty( lambda self: true if self.my_input in ["1","t","true","y","yes"] else false)

sql - Why order of the result varies on using extra brackets in select query -

select distinct (upper(cd)) table end_date > '08-12-2013' and select distinct upper(cd) table end_date > '08-12-2013' the results of both queries same order varies. there explanation ? as understand there no default 'order' of results unless order clause specified. this may dependent on rdbms afaik standard sql.

angularjs - Progressive loading in ng-repeat for images, angular js -

i hope can help, been on internet looking solutions , cannot find.. do of know how implement progressive loaded of content scroll down page? otherwise 1000 images load @ same times. thanks much. use infinite scrolling directive. nginfinitescroll demo html <div ng-app='myapp' ng-controller='democontroller'> <div infinite-scroll='loadmore()' infinite-scroll-distance='2'> <img ng-repeat='image in images' ng-src='http://placehold.it/225x250&text={{image}}'> </div> </div> js var myapp = angular.module('myapp', ['infinite-scroll']); myapp.controller('democontroller', function($scope) { $scope.images = [1, 2, 3, 4, 5, 6, 7, 8]; $scope.loadmore = function() { var last = $scope.images[$scope.images.length - 1]; for(var = 1; <= 8; i++) { $scope.images.push(last + i); } }; });

jquery - Open a fancybox link with ajax -

i use fancybox on site show content after click on link. code use this: js in : $(document).ready(function() { $('.fancybox').fancybox(); }); link opens fancybox window: <a rel="nofollow" target="_blank" class="fancybox" href="#show_code_8">show code</a> code opens in fanctbox window (just example): <div id="show_code_8" class="inline"> content here </div> it works correct, instead of want load content via ajax. tried lot, can't work correctly. i've managed open ajax page via ajax, thats without right id (the 8 variable href="#show_code_8"). can please tell me how can open ajax page right id? how pass variable ajax page? i can think of several possibilities. one using php file returns specific code (section) when call file parameter <a class="fancybox" href="allcodecontent.php?code=show_code_8" ... another jquery using .

Save or update in Groovy -

usually in java execute select statement , check size of resultset. if 0 issue insert , otherwise update. since groovy provides syntactic sugar on top of jdbc, i'm wondering if provides way ease process? there easier way save or update record? note: know hibernate offers this, i'd rather stick groovy api. there's lightweight orm called gstorm here i've had on list of things investigate has no dependencies, doesn't handle related domain objects and library leverage grails gorm here (which pulls gorm out of grails has quite few dependencies including hibernate) other (and other examples i've missed), there's nothing know of you're trying do. guess you'd have write own (you switch between insert or update depending on whether pass primary key -- assuming primary keys auto-generated db)

Javascript. document.create -

is if statement saying if placeholder not in document.create(input)? why using document.create. <input type="text" placeholder="john doe"> <input type="email"> <script> if( !'placeholder' in document.createelement('input'){ // } </script> it's seems trying perform feature detection determine support placeholder properties on <input> elements, new html5 . the document.createelement('input') used create unmodified <input> element test. , in operator tests presence of property on dom element. though, doesn't quite achieve seems trying. ! act before in , ends testing whether such elements have false properties, don't. it'll need group of parenthesis ensure in evaluated first ! can negate result condition. if (!('placeholder' in document.createelement('input'))) { // `<input>` elements don't have `placeholder` properti

ios - What is NSRunLoop? -

this question has answer here: understanding nsrunloop 4 answers i have been reading documents run loop, still can not understand exactly. ios not open source, while nsrunloop special ios/mac os x platform, real implementation inside? if have kind of user interface, or other code needs listen events (like network ports), need run loop. every nsthread automatically gets own run loop, , have concern them directly. run loop in charge of creating , releasing autorelease pools. for more information : what basic difference between nstimer, nstask, nsthread , nsrunloop?

split the string of a row of datatable in asp.net -

i using asp.net. trying split data in datatable. have code sample this: { dt=objerrorloggingdataaccess.geterrordetails(errorid); string[] stringseparators = new string[] { "message" }; string error = dt.rows[0]["message"].tostring(); string[] test = error.split(stringseparators, stringsplitoptions.none); string pagename = test[0].tostring(); pagenamelabel.text = pagename; stringseparators=new string[] {httpcontext.current.request.url.tostring()}; error = dt.rows[0]["message"].tostring(); test = error.split(stringseparators, stringsplitoptions.none); string message = test[0].tostring(); messagelabel.text = message;} in datatable following data there: {....id.......message....................................................................................................................... ....1........http://localhost:10489/images/categoryicon/images messa

php - jquery ajax return duplicate result (twice) -

i'm trying use jquery ajax catch form vars > send them php > result > update iframe. but reason i'm getting result twice, example php should return: "hello world" but i'm getting: "hello worldhello world" $('#purchaseform').submit(function() { var serializeddata = $("#purchaseform").serialize(); $.ajax({ type: "post", url: "checkout.php", data: serializeddata }).done(function( result ) { alert(result); var $iframe = $('#plimus'); if ( $iframe.length ) { $iframe.attr('src',result); return false; } }); return false; }); thanks shai

AngularJS Scope Object Inheritance -

hi need angularjs wiz point me in right direction been trying head around angularjs scope , inheritance. have child scope add parent scope want add new object parent scope via array.push(); i'm not sure why child scope inherits new value. see fiddle here http://jsfiddle.net/sjmcpherso/efxuz/ first example using ng-repeat , objects causes child update: $scope.childarr = [{'name':'peter'},{'name':'paul'},{'name':'perry'}]; $scope.parentarr = $scope.childarr; $scope.parentarr.push({'name':'why in in child array?'}) whereas second example using variable not: $scope.childvar = "confused muchly"; $scope.test.parentvar = $scope.childvar; $scope.test.parentvar = "this wont change child variable"; ideally make changes child scope update parent scope not other way around. i have read of https://github.com/angular/angular.js/wiki/understanding-scopes while not understanding issue seems mystery

passenger - Failed to integrate the git into Redmine 2.3.2 -

i had install bitnami redmine on ubuntu server 12.04 lts. works well! but want integrate git redmine , follow offices tutorial how_to_configure_redmine_for_advanced_integration_with_git step 3.a success and step 4, copy , add the script /usr/local/share/redmine/apache2/conf/httpd.conf , restart redmine here part of httpd.conf loadmodule passenger_module /usr/local/share/redmine/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.2/libout/apache2/mod_passenger.so passengerroot /usr/local/share/redmine/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.2 passengerruby /usr/local/share/redmine/ruby/bin/ruby <virtualhost *:8088> documentroot "/usr/local/share/redmine/apache2/htdocs/grack/public" <directory "/usr/local/share/redmine/apache2/htdocs/grack/public"> options none allowoverride none order allow,deny allow </directory> </virtualhost> and test on mac , got below info hseecoms-imac:githsee ithsee$ git clone http://1