Posts

Showing posts from January, 2013

Loop through keypress Jquery (case : 1; etc..) -

i have problem how maintain/continue loop if key pressed. figured animate page case 1 / case 2 / case 3 , case 4 know how continue loop if key pressed again (and again...). read loop here can't figure out. thanks in advance, here code : var counter = 0; $(document).bind('keydown', function(e) { if(e.which == 37 || e.which == 39) { counter++; switch(counter) { case 1: $('#maikeximu,#dossier').stop() .animate({ height: "toggle", }, 1200, function() { $('html,body').animate({ scrolltop: $("#maikeximu").next().offset().top }, 1000); }); break; case 2: $("#gal,#dossier, #viz").stop() .animate({ height: "toggle",

version control - Folding git commits -

i think there must commit per feature. however, 1 big feature consists of series of useful pieces. consider refactoring. though, others refactorins side effects of adding/modifying functionality , not deserve separate commit, consider couple of fixes in code. refactor different areas of codebase. not want commit big mess difficult untangle, changes related. therefore spawn more 1 refactoring commit. however, likely, people not want see tiny details. therefore want hide refactoring commits under 1 folder of commits. in history viewer, gitk, should able expand/collapse folder when desired. there solution issue, might solved in other versioning control? use feature branches. merge them mainline git merge --no-ff . mainline series of merge commits show 1 feature added another, if want see individual commits went feature, they're right there on branch.

Query to get count of distinct value in MySQL -

i have tried below query in mysql not working. select count(*) ( select count distinct(radl_request_msisdn) rbt_activation_details_log radl_active ='a' group radl_request_msisdn ); select count(distinct column_whose_distinct_values_you_want_to_count) rbt_activation_details_log radl_active ='a' group radl_request_msisdn you're grouping , counting on same column, give 1 result. edit: then omit group clause select count(distinct radl_request_msisdn) rbt_activation_details_log radl_active ='a'

ios - Two Controls Events on one UIButton -

in iphone app it's possible add 2 uicontrolevents on 1 unbutton? i want add touch inside , touch drag exit, tried add touch inside in ib in viewdidload add touch drag exit programmatically using following code: [btn addtarget:self action:@selector(method:) forcontrolevents:uicontroleventtouchdragexit]; it's work i'm wondering won't cause app crash?! thanks. you can add multiple events controls. if have overlapping events, of events might not fire wont crash application. more event programming: https://developer.apple.com/library/ios/documentation/eventhandling/conceptual/eventhandlingiphoneos/introduction/introduction.html

bash - parsing a csv file $INPUT, write to $OUTPUT, and prompt for user input all in a while loop - user NOT prompted -

i have problem, , pretty new writing bash. parsing csv file, checking few things. if check true, change variable later written file. reading input file , outputting file well, , if argument checks true, want prompt user , pause script until user verifies information matches (manual verification). i have recent attempt not prompting. continues read , write output. pretty sure because output going directly output file, not know way direct prompt terminal window stuck. input=$tmpsave ifs=, [ ! -f $input ] && { echo "$input file not found"; exit 99; } while read cdwon cdwod manu_date hp_sn manu_sn wiped_by wiped_date checked_by disposition readonly in ${!allassigned[@]} if [[ -n $manu_sn ]] if echo ${allassigned[i]} | grep -q $manu_sn physicaldrive=${allassigned[i-1]} disk=$(hpacucli ctrl slot=${slot} show config detail | grep -b 4 ${phys

angularjs - Angular + Facebook JS SDK login: Not requesting my permissions -

fb.login() not working. fb popup not requesting right permissions. can see, in source code there's fn handler uses right parameters / parameters being set correctly. i'd understand why isn't working ? this code i've got far: http://jsbin.com/itey/1/ this i'm setting permissions list: facebook.login(function(response) { console.log(response); }, {scope: 'email,user_likes'}); in accordance docs ( https://developers.facebook.com/docs/reference/javascript/fb.login/ ) by doing console.log in fn handler login(), fn function(response){ ... } , {scope: 'email,user_likes'} i found other users reporting same issue using fb sdk here in so. tried tip use "perms" instead of "scope", get: oauth2 specification states 'perms' should called 'scope'. please update. not appearing problem. shows param being send there. go wonder why's not working ?! i've cleaned cache too originally i've repor

java - Implementing ScrollView Causes Fatal Exception -

i have relativelayout i'm attempting add ability scroll down on - when device in horizontal position. (currently - button disappears when flip horizontally - undesired.) current xml state: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:orientation="vertical" > <button android:id="@+id/go_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text" android:layout_centerhorizontal="true" android:layout_margintop="85dp" android:background="@drawable/apn_app_go_button" /> <imageview andr

c# - Scalable Solution for Splitting words in a document? -

i have document in words separated , extracted blank space. purpose used following code. string[] words = s.split(' '); now problem going use code parser of search engine. because of there hundreds of thousands if not millions of webpages needed split words. is concern right using above code process take long time or unfounded. if right suggestions on alternative scalable solution welcomed. write own implementation returns ienumerable<string> defers execution. example: private static ienumerable<string> createsplitdeferredenumerable( string str, char delimiter) { var buffer = new stringbuilder(); foreach (var ch in str) { if (ch == delimiter) { yield return buffer.tostring(); buffer.length = 0; } else { buffer.append(ch); } } if (buffer.length != 0) { yield return buffer.tostring(); } } public static ienumerable<string> splitdeferred(this s

Get user group id in Joomla with PHP -

to user group id in joomla 2.5.15, followed documentation in joomla documentation here my code looks this: $user = jfactory::getuser(); echo "<p>your group id {$user->gid}.</p>"; but code producing error: notice: undefined property: juser::$gid in without group id in output. try using this: $user = jfactory::getuser(); $groups = $user->get('groups'); foreach ($groups $group) { echo '<p>group = ' . $group . '</p>'; }

How to connect several jquery tabs? -

see example here - http://jsfiddle.net/d1st/kywqr/5/ <div id="tabs"> <ul> <li><a href="#tabs-1">nunc tincidunt</a></li> <li><a href="#tabs-2">proin dolor</a></li> <li><a href="#tabs-3">aenean lacinia</a></li> </ul> <div id="tabs-1"> <p><strong>click tab again close content pane.</strong></p> <p>proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. curabitur nec arcu. donec sollicitudin mi sit amet mauris. nam elementum quam ullamcorper ante. etiam aliquet massa et lorem. mauris dapibus lacus auctor risus. aenean tempor ullamcorper leo. vivamus sed magna quis ligula eleifend adipiscing. duis orci. aliquam sodales tortor vitae ipsum. aliquam nulla. duis aliquam molestie erat. ut et mauris vel pede varius sollicitudin. sed ut dolor nec orci tincidunt interdum. phasellus

regex - Java : Matcher.find using high cpu utilization -

Image
i using mod security rules https://github.com/spiderlabs/owasp-modsecurity-crs sanitize user input data. facing cpu shoot , delay in matching user input mod security rule regular expressions. overall contains 500+ regular expression check different types of attacks(xss , badrobots , generic , sql). each request , go through parameters , check against these 500 regular expressions. using matcher.find check parameters. in case parameters fall in infinite looping , tackled using below technique. cancelling long running regex match? . sanitize user request took around ~500 ms , cpu % shoots up. analyzed using visualvm.java.net test suite runner. cpu profile output please me reduce cpu usage % , load average? if possible, compile regexes once , keep them around, rather repeatedly (implicitly) compiling (especially inside loop). see java.util.regex - importance of pattern.compile()? more info.

R - How to draw an empty plot with no height? -

i can make empty plot in r using: plot.new() that create blank plot default width , height. i want create empty plot minimal height. tried png('z.png', height=1) , got me: > png('x.png', height=1) > plot.new() error in plot.new() : figure margins large how can create such plot? guess have 0 margins too. well... don't know why want this, here goes: # make png file png('x.png', height=1) # change margins of plot 0 on each side par(mar=rep(0,4)) # make empty plot plot.new() # close connection png file dev.off()

python - Validate a argument value based on another argument -

i want validate argument based on value of argument. samplescript.py def parse_args(): parser = argparse.argumentparser() parser.add_argument('-a', '--arg1', help="year-month or year") parser.add_argument('-b', '--arg2', help="needs month argument arg1", action="store_true") args = parser.parse_args() return args def main(): args = parse_args() if __name__ == "__main__": main() value arg1 can in format yyyy or yyyy-mm . however, when arg2 set, want make sure value arg1 passed in format 'yyyy-mm' , not 'yyyy'. i.e when run python samplescript.py -a 2011 , program should work fine. when run python samplescript.py -a 2011 -b , program should throw error since -a not in yyyy-mm format is possible such validation using argparse ?

three.js - ThreeJS object outlines and masking -

i have problem masking in three.js. i want have outline around object , did using tutorial http://www.codeproject.com/articles/8499/generating-outlines-in-opengl i wrote code; renderer.autoclear = false; ... renderer.render(scene, camera); ... var gl = this.world.renderer.domelement.getcontext('webgl') || this.world.renderer.domelement.getcontext('experimental-webgl'); gl.clearstencil(0); gl.clear(gl.stencil_buffer_bit); gl.enable(gl.stencil_test); gl.stencilfunc(gl.always, 1, 1); gl.stencilop(gl.keep, gl.replace, gl.replace); gl.colormask(0, 0, 0, 0); renderer.render(scenemask, camera); gl.colormask(1, 1, 1, 1); gl.stencilfunc(gl.notequal, 1, 1); gl.stencilop(gl.keep, gl.replace, gl.replace); renderer.render(sceneoutlines, camera); gl.disable(gl.stencil_test); and works charm. but want have outline more thicker. on windows, web browsers using angle , directx can render thicker lines. (i know can use scaled object vertex normals, in way create

javascript - Bing Map v7, Direct call vs Ajax Call. Delay on Callback Function -

i'm adding bing map page using call: var geocoderequest = "http://dev.virtualearth.net/rest/v1/locations?query=" + encodeuri(addressstring) + "&output=json&jsonp=geocodecallback&key=" + credentials; it's working fine when used directly in page javascript tag. want reuse in different pages i'm trying extract partial view , call on demand in different pages using ajax call. here controller public actionresult showmap(string address) { maphandlermodel model = new thelist20site.maphandlermodel { title = "address", address = address, originalheight = 400, originalwidth = 500, smallheight = 0, smallwidth = 500, speed = 500 }; return partialview("prtmap", model); } and call happen through ajax method: $.ajax({ url: "/project/showmap", type: "post", data: { address: addressstring }, success: function (data) {

python - package_data files with executable permissions -

i using distutils create python (2) package installer. in package couple of binary executable called python code. listing these package_data in setup.py file installed along package. however, distutils not copy executable permission bit on these files when installed. there way force distutils install package_data files executable permissions? figured out based on other answers - following works: class my_install_lib(distutils.command.install_lib.install_lib): def run(self): distutils.command.install_lib.install_lib.run(self) fn in self.get_outputs(): if <this 1 of binaries want executable>: # copied distutils source - make binaries executable mode = ((os.stat(fn).st_mode) | 0555) & 07777 distutils.log.info("changing mode of %s %o", fn, mode) os.chmod(fn, mode) and pass cmdclass={'install_lib':my_install_lib} setup .

php - Using SimpleXMLElement in an array -

so testing feed on page pulls wordpress site , worked locally reason on production server needs array. $xml variable used in foreach works locally not on server because it's not array. first time using simplexmlelement i'm not sure if using methods looked in manual turn $xml array via function json work have here. there away convert $xml array , use array results in foreach()? <?php $xml = simplexml_load_string($data, 'simplexmlelement', libxml_nocdata); ?> <?php $i = 0; foreach ($xml->channel->item $item) { $creator = $item->children('dc', true); echo '<h2>' . $item->title . '</h2>'; echo '<small>posted on '. date('l f d, y', strtotime($item->pubdate)) .' '.$creator.'</small> </p>'; echo '<p class="description">' . $item->description . '</p>'; if (++$i === 3) break; } ?>

c# - Get Selected Row On Button Click -

i have gridview following: protected override void render(system.web.ui.htmltextwriter textwriter) { foreach (gridviewrow gvrow in gvnotifications.rows) { if (gvrow.rowtype == datacontrolrowtype.datarow) { gvrow.attributes.add("onmouseover", "this.previous_color=this.style.backgroundcolor;this.style.backgroundcolor='#ffff99';this.style.cursor='hand';"); gvrow.attributes.add("onmouseout", "this.style.backgroundcolor=this.previous_color;"); gvrow.attributes["onclick"] = clientscript.getpostbackclienthyperlink(gvnotifications, "select$" + gvrow.rowindex,true); } } base.render(textwriter); } protected void gvnotifications_selectedindexchanged(object sender, eventargs e) { gvnotifications.selectedrowstyle.backcolor = color.lightblue; } i have button called btntest

printer control language - Is there a specific drawing order in PCL? -

i trying write pcl document, has several drawing objects (lines, rectangles, texts...) i found if draw rectangles before else, appear in right position , size. however, if draw them among rest of objects, drawn smaller , in wrong place. the pcl seems ok (although yet proven), has made me think perhaps graphic objects must drawn in particular order (i using hpgl/2, way). does know if so? have not been able find in pcl manual nor in internet (which leads me believe there not such drawing order). perhaps have written position or scale commands unintentionally affect rectangles.

audio - How to choose sound device in android -

i connected usb handsfree android device. need switch sound input between handfree , built-in microphone. in devices (like mk802 hdmi-tv-console) threre system menu sound input , output changed. i searching way change input , ouput console or code. i'm not aware of official way of doing want. rationale being like: if didn't want use handsfree wouldn't have plugged in in first place. there few things try, they're not guaranteed work across devices , android versions. for playback try audio routed loudspeaker instead of usb accessory: class audiosystemclass = class.forname("android.media.audiosystem"); method setforceuse = audiosystemclass.getmethod("setforceuse", int.class, int.class); // first 1 == for_media, second 1 == force_speaker. go default // behavior, use force_none (0). setforceuse.invoke(null, 1, 1); and recording try using voice_call or camcorder audiosource instead of mic or default .

python - Stylesheets with File Dialog -

i'd incorporate stylesheet python traits-based gui app. far i've been defining views in terms of qtview objects, because these allow more functionality including style_sheet property. has there been such modification file dialogs , other built-in ui dialogs? looking @ traitsui.file_dialog seems defines view rather qtview objects. thank you actually, there way can apply stylesheet file-dialog. default ui views may qdialog's , in case there exist ui method, called qfiledialog , documentation here . so if want set stylesheet on qfiledialog can this: qfiledialog dialog; dialog.setstylesheet("qpushbutton { background-color: red }"); dialog.exec_();

python - monit doesn't start the script -

i'm trying test monit . idea have python script prints out text, have shell script acts start/stop script. shell script redirects output file called fetch_output . what want make monit check timestamp of file , if didn't change in last minute restart script. here python script: test.py import time import sys in range(100): time.sleep(1) sys.stdout.write('a'*i) sys.stdout.flush() wrapper_test #! /bin/bash pidfile=/home/jhon/workspace/producer/wrapper_test.pid case $1 in start) echo $$ > ${pidfile}; exec /usr/bin/python /home/jhon/workspace/producer/test.py >> fetch_output.txt 2>&1 ;; stop) kill `cat ${pidfile}` ;; *) echo "usage: wrapper {start|stop}" ;; esac exit 0 /etc/monit/conf.d/test check process wrapper_test pidfile /home/jhon/workspace/producer/wrapper_test.pid start program = "/home/jhon/workspace/producer/wrapper_test start" st

Android handeling swipe gesture on an edittext -

i'm trying swipe gesture work on edittext. try tends buggy. when return false gesture works cursor moves when making swipe gesture. when return result gesturelistener (onfling) cursor stay's in place, on android 2.3.3 after gesture finished context menu text edit pops up, on 4.1.2 there no context menu, making gesture select whole word. here current code: package com.example.testmarkup; import android.content.context; import android.view.gesturedetector; import android.view.gesturedetector.simpleongesturelistener; import android.view.motionevent; import android.view.view; import android.view.view.ontouchlistener; public class onswipetouchlistener implements ontouchlistener { public interface onswipelistener { public void onswipe(); } private gesturedetector mgesturedetector = null; private onswipelistener monswipeleftlistener; private onswipelistener monswiperightlistener; private gesturelistener mgesturelistener = null; publ

How can i stop Solr without stopping the WebSphere Commerce Test Server (IBM RAD) -

i need test error handling use cases in event solr server shuts down or unreachable. on 1 of our testing servers can run stopserver script passing in indentifier solr server. have tried using same .bat version of script locally, seems there no separate profile solr. is there way stop solr (ie. wc instance still running apache) in rad, either through admin console, cli script, or other ui interface? in websphere commerce developer, don't believe can since it's not server deployment it's in it's own profile. nevertheless, haven't tried think can block communication ports (on server 3737).

A Fifo queue with fast insertion , deletion and get front element java -

which data structure should use in java implement queue fast insertion @ end , deletion front , , operation first element? wouldn't linkedlist fit bill? its implementation public e remove() { return removefirst(); } public boolean add(e e) { linklast(e); return true; } it has both first , last nodes, insertion fast @ end. can delete front method remove() . can first element well, ie. peek() returns first node. that's o(1) . source void linklast(e e) { final node<e> l = last; final node<e> newnode = new node<>(l, e, null); last = newnode; if (l == null) first = newnode; else l.next = newnode; size++; modcount++; }

Balanced Payments Account debit not working with Node.js -

i trying account credit request node.js using following example. fails when use sample code without change. https://docs.balancedpayments.com/current/overview.html?language=node#charge-a-credit-card balanced.accounts.get("/v1/marketplaces/test-mp60c88vnfhzgzeyzgcbmkic/accounts/ac1a77avbmvtut8pciwdlmjw/debits", function(err, result) { var user = balanced.accounts.nbalanced(result); user.debits.create({ amount: 1000 }, function(err, result) { /* . . . */ }); }); it fails after statement executed... var user = balanced.accounts.nbalanced(result); the error message is... the following properties required , missing or null (id). here full stack trace... c:\users\nabeel\groupfund\node\node_modules\balanced-official\lib\nbalanced\validate.js:112 if (!callback) throw error; ^ following properties required , missing or null (id). the original issue, yes, example supplied account debits uri when should have been account uri. these

regex - Regular expression to get all matches in string ends with -

please me develop regular expression return matches in string if end (&any character) eg. string a="abcd(&w)", matches should have value (&w) if a="abcd(&w), xhz(&d), there should 2 matches note: in place of comma (,) above can delimiter list [','':',';'.........] if abcd(&w)pqrsr, xhz(&d). matches should (&d) , not (&w) since not in end before delimiter something should work: \(&.\)(?=[,:;]|$) this match literal (& followed character, followed literal ) . requires next character 1 of , , : , or ; or match followed end of string.

Tuning Java 7 to match performance of Java 6 -

we have simple unit test part of our performance test suite use verify base system sane , performs before start testing our code. way verify machine suitable running actual performance tests. when compare java 6 , java 7 using test, java 7 takes considerably longer execute! see average of 22 seconds java 6 , 24 seconds java 7. test computes fibonacci, bytecode execution in single thread should relevant here , not i/o or else. currently run default settings on windows or without "-server", both 32 , 64 bit jvm, runs indicate similar degradation java 7. which tuning options may suitable here try match java 7 against java 6? public class baselineperformance { @before public void setup() throws exception{ fib(46); } @test public void testbaseline() throws exception { long start = system.currenttimemillis(); fib(46); fib(46); system.out.println("time: " + (system.currenttimemillis() - start));

html - getting URL of pages with ajax -

this webpage number of "subpages" embedded in ajax user reviews. http://www.goodreads.com/book/show/13636400-the-bone-season# i trying specific url particular pages (say ?page=4), can point people particular reviews directly instead of going page , clicking on page4. below snippet source code page: <a href="#" onclick="new ajax.request('/book/reviews/13636400-the-bone-season?page=4', {asynchronous:true, evalscripts:true, method:'get', parameters:'authenticity_token=' + encodeuricomponent('xsogyhac4p0tam8wgiqtqgy+pxgpdiei45ayry0nle4=')}); return false;"> when type http://www.goodreads.com/book/reviews/13636400-the-bone-season?page=4 , blank page. what need page show? thank you! you can url specific reviews, unable find anyway "page". if want direct specific review, can url "see review" link or date link on particular review.

Better file reference for typescript -

i’m new typescript , trying setup unit tests typescript code base. problem code depends on other's work , these references done in form of hard coded relative paths “......\somefile.d.ts”. when come unit test, want fake out of dependencies don’t know how make typescript take fakes instead of hard coded referenced files. my question is: there way not hard coding reference path in source code? there things preprocessor or macro in typescript, or use project system resolving dependency, rather hard coding them in source code? check out grunt-ts reference file generation : https://github.com/basarat/grunt-ts#reference-file-generation what can have seperate targets, 1 dev , 1 test : dev: { src: ["app/**/*.ts", "!app/**/*.spec.ts"], // exclude spec files reference: "./app/reference.ts", out: 'app/out.js', }, test: { src: [&quo

html - Bootstrap 3: Alignment of Close Icon -

Image
close icon acting weird. code <div class="well sidebar-nav"> <ul class="list-unstyled"> <li>file uploaded</li> <li><a href="#">file 1</a> <button type="button" class="close" aria-hidden="true">&times;</button></li> <li><a href="#">file 2</a> <button type="button" class="close" aria-hidden="true">&times;</button></li> <li><a href="#">file 3</a> <button type="button" class="close" aria-hidden="true">&times;</button></li> </ul> </div> it's appearing this: the image 21px tall, li 20px tall (due font) floats overlap. simple , unobtrusive fix set li height 21px. http://jsfiddle.net/px

jquery - How to find the input tags contained in a table -

i have question regarding find method. i want able identify cell contains input tag. my html like <table> <tr> <td> celll </td> <td> celll </td> <td> celll </td> </tr> <tr> <td> celll </td> <td> <span><input type='text'></span> </td> <td> <span><input type='text'></span> </td> </tr> </table> my jquery $('table').find('td').each(function(){ if($(this).find("input").length){ console.log('found') } }) my codes can't seem find it. tips? lot! rather using .find() twice, use once , .closest() cell: $('table').find('input').each(function(){ var parent = $(this).closest('td'); //do parent }); demo: http://jsfiddle.net/dirtyd77/kdl97/

Oracle SQL - Average Time Between Dates By Subject -

i'm working in oracle sql. have table ids , dates, , i'm trying find average time between dates subject. this. table subjectid date 1 8/01/2013 12:00:00 1 8/31/2013 12:00:00 1 9/10/2013 12:00:00 2 1/01/2010 12:00:00 2 1/21/2010 12:00:00 i need write query goes through table subjectid, records time between dates, , outputs average of averages, speak. in example, time between first , second rows (30 days) + time between second , third rows (10 days) / 2 (to average subject 1, = 20), , time between rows 4 , 5 (20 days) / 1 (to average subject 2), , output should average between (20 + 10) / 2 = 15. the average difference between min , max values, divided 1 less count. for data: select subjectid, (case when count(*) > 1 (max(date) - min(date))/(count(*) - 1) end) avgdifference t group subjectid; to overall average, use subquery: select avg(avgdifference) (selec

sql - MySQL Select First Day of Year and Month -

how find first day of year in select? select `date`,`somevalue1`,`somevalue2` `sometablename` (`date` >= [...first day of year in date format...]) i found month - don't quite have grasp enough year: (i looking separate query find data between beginning of month , now) where (`date` between date_format(now() ,'%y-%m-01') , now() ) i think need: where (`date` between date_format(now() ,'%y-01-01') , now() ) to honest, do: where (`date` between date_format(now() ,'%y') , now() )

javascript - zurb foundation and events on ajax loaded content -

i wondering if there possibility reinitialize foundation after content changed ajax. in case trying reinitialize foundations abide form validation on form passed ajax call. i tried call $(document).foundation() should reinit javascript ... nice, found out how reinitialize abide validation on form just call $(document).foundation('abide','events');

ember.js - Controller computed property is not showing new data additions immediately, where the data is not those returned from the route model -

summary: controller computed property issue: in 1 case, can see things getting added not see newly added things ( jsbin ), , in case can see newly added things added things don't show ( jsbin ). second update of aug 26: so thinking ... have these 2 complementary pieces of code. need combine them , achieve perfection, right? sadly, failed miserably, can see in jsbin , nothing shows @ all. :( this failed attempt combine 2 recordarrays: officelist: function(){ var allrecords = []; console.log("in oficelist"); // record array shows added records var a_recordarray = app.office.find({org_id: 'myorgid'}); a_recordarray.foreach(function(record){ allrecords.push(record); }); console.log(a_recordarray.tostring()); console.log(allrecords.length); // record array shows newly added records var b_recordarray = app.office.filter(function(office) { return office.get('org_id') === 'myorgid'; }); b_recordarray

How can I improve this code to call Google API less times -

Image
i have sync google contacts spreadsheet, have call api may time set values in google spreadsheet, how can overcome problem call google api less times or once ? var precontacts = group.getcontacts(); var rowno = 2; for(var y = 0; y < precontacts.length; y++) { var fnamecontact = precontacts[y].getgivenname(); var phonenoarray = precontacts[y].getphones(); var phonenocontact = getphonenumbers(phonenoarray); var emailarray = precontacts[y].getemails(); var emailadresscontact = getemailaddresses(emailarray); //var customfieldsarray = precontacts.getcustomfields(); sheettab_bulk_cdb.getrange("j"+rowno).setvalue(emailadresscontact); sheettab_bulk_cdb.getrange("g"+rowno).setvalue(emailadresscontact); sheettab_bulk_cdb.getrange("f"+rowno).setvalue(emailadresscontact); sheettab_bulk_cdb.getrange("a"+rowno).setvalue(emailadresscontact); rowno++; } the significant optimization available w

c# - PictureBox and HttpWebRequest -

i want use picturebox show user captcha image. know how set typical image url. need add captcha need cookies. this: https://konto.interia.pl/poczta/nowe-konto . i don't know how can hold cookie server, can use later display captcha, , after send special response create account. have ideas how can that? you need download image , put in picturebox; can't use built-in downloader cookies. use httpwebrequst download memorystream , call image.fromstream() .

sql - PHP: Time - "Today" - "Yesterday" by dates and not hours -

this question has answer here: php: date “yesterday”, “today” 6 answers i got figured out: $dates = date(" d-m-y",$forum_tid); if ($dates == date(' d-m-y')) { $day_name = 'this day'; } else if($dates === date(" d-m-y", strtotime("-1 day"))) { $day_name = 'yesterday'; } else { $day_name = 'another day'; } echo "$day_name"; now runs 24 hours clock-system. want work dates. (if time same day, says "this day", if date before f.ex 23-08-13, shows "yesterday") how do this? hope question more people wondering about! with datetime class: $date = new datetime(); $date->settimestamp($forum_tid); $today = new datetime(); $yesterday = new datetime('-1day'); switch(true) { case $today->format('m-d') === $date->format('m-d'

amazon web services - wget in AWS could formation -

i'm using wget fetch jar during deployment in ci process. wget command doesn't execute after executing cloudformation command aws service. before couldformation command works fine. if change wget curl, works fine. not sure issue. please give suggestions wget might not installed on instance default. make sure cloudformation template installs before trying use it.

R: likelihood ratio test comparing two models, however missing data made the two models not in the same dimension -

i'm trying likelihood ratio test between 2 models. glm.model1 <- glm(result ~ height + weight ) glm.model2 <- glm(result ~ hight + weight + speed + speed : height + speed : weight ) require(lmtest) <- lrtest(glm.model1, glm.model2) and got following error: error in lrtest.default(glm.model1, glm.model2) : models not fitted same size of dataset i know of "speed" data missing, none of height , weight data missing, since model 2 includes variable "speed" model 1 doesn't, model 2 has datapoints got deleted glm due missingness. when likelihood ratio test between model 2 , model 1, data dimension not equal, , end error message above. there way can datapoints deleted in model 2, in reduced model can include script delete same datapoint in order keep dimension of data same? here's i've tried: 1) add na.action = na.pass keep missing data in model 2, doesn't work. 2) tried: glm.model1 <- glm(result ~ height + weight +

regex - MongoDB avoid using the index -

my scenario same 1 described here: mongodb regular expression indexed field to summarise, when using index $regex query returns 700ms slower when not use index. unfortunately cannot use simple prefix queries optimise against index. i can't drop index because required queries not involve regex. is possible bypass index , mongodb scan table directly?

c# - DropDownList in fixed -

i have dropdownlists in particular screen , whenever value of same, comes first value. do solve this, dropdownlist in other pages work correctly , can select value of them, can not. i'm setting values ​​of dynamically, every time go file in server folder, upgraded, filling vector has name (in string) of items in directory. when select different value comes standard on it, quyando'll play value in database, if had not selected anything. i've tried solve autoporsback true , false, , nothing in page_load. how fix this? have no errors in code. note: drop down list loaded every time climb new file, not have in ispostback. every time climb new file, have method mostraimagenscarrefadas() updates , populates dropdownlist. method gets event of button. not using update panel , nothing of sort. all code component: //aspx header <%@ page title="" language="c#" masterpagefile="~/administrativo/masterpage.master" enableviewstate="fal

parsing - C# Importing CSV using OleDb -

i'm trying set code import .csv files .net. i've tried both microsoft.jet.oledb.4.0 , microsoft.ace.oledb.12.0 providers, including modifying extended properties , modifying corresponding registry keys each. have yet come solution attempting do: i import each field text, leave fields longer 255 characters un-truncated. what i've found far can have 1 or other, not both. if set importmixedtypes registry value majority type , leaves 255+ character text fields un-truncated, converts other fields unwanted types. if set importmixedtypes registry value text , truncates 255+ character text fields, leaves other field types text. how accomplish using oledb? additional info: i have "notes" column, can contain lengthy text. have "zip code" column, contains mixed zip-code formats (5-digit , 9-digit dash). typically, 5-digit zip-code format more popular, importer thinks column should integer type, leaving 9-digit zip-codes null values afte

Checking and Installing .net 4.0 before while installing my forms app in SharpSetup WIX -

i don't have lot (this first go of it) of experience wix, decided use sharpsetup template in vs 2012 , running quickly. problem need install .net on users machine them use app, answers i've found on here talk using 'chain'. again don't know i'd this. assume .net installer put in same folder .exe in i'm swinging @ @ moment. can see tried , failed solving problem including .net installer exe in same group project. if explain in code implement .net check/install i'd appreciate it! here's wix: <?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <?include product.defines.wxi ?> <fragment> <directory id="targetdir" name="sourcedir"> <directory id="programmenufolder" name="programs"> <directory id="programmenudir" name="!(loc.appname)"> <component id="pmd

javascript - Drag and drop takes me to a different website if false or restarts animation if true -

i've got animation: http://codepen.io/tiamat/pen/jrdvx when colored circle goes black 1 restarts animation. when not go it takes me circle.com website. can stop both of these actions? if successful, not restart animation, colored circle remain in black one. html: <div id="intreg" style="border:1px solid #000000; width:750px; height: 550px;" > <div id="jos"> <div id="square_drop"ondragenter="return dragenter(event)" ondrop="return dragdrop(event)" ondragover="return dragover(event)"></div> <div id="circle_drop"ondragenter="return dragenter(event)" ondrop="return dragdrop(event)" ondragover="return dragover(event)"></div> </div> <div id="sus"> <div id="triangle_drop"ondragenter="return dragenter(event)" ondrop="return dragdrop(event)" ondragover="return dragover(