Posts

Showing posts from January, 2014

java - call to Bitmap.compress does not return - and NO exception -

on android following image. it never gets past bitmappicture.compress line - seems sit there , hang. the line above byte count returns 40000. i never see compress done, or other output after 'compress'. try { final int compression_quality = 100; string encodedimage; bytearrayoutputstream bytearraybitmapstream = new bytearrayoutputstream(); log.e("error","compress" + bitmappicture.getbytecount()); bitmappicture.compress(bitmap.compressformat.png, compression_quality, bytearraybitmapstream); log.e("error","compress done"); byte[] b = bytearraybitmapstream.tobytearray(); log.e("error","bytear"); encodedimage = base64.encodetostring(b, base64.default); log.e("error","jsondata encodedimage returned"); return encodedimage; } catch (exception e) { errorlogger.adderror(e.getmessage(), 199); log.e("error","

javascript - preventing screen redraw on resizing -

is there way prevent redrawing of screen while resizing responsive website? i want have responsive website, don't cheap animations involved when resizing screen (media breaks, instant disappears, text wraps (really ugly)) i hope there way tell browser redraw screen when resizing has stopped or similar solution.. is there? no. when change size of dom element, including body , browsers "reflow" (i.e. redraw) page. when include img element without explicit size, page reflow when image loaded. you may read more details here: when reflow happen in dom environment?

file - Remove lines from a .txt with a certain character in MATLAB -

i working on project data of magnitude of variable stars , have come across problem: the data have in .txt document has lot of comments marked symbol # , know if there way read whole text , take lines not include particular character, have read whole text , put array: fid=fopen('000006+2553.txt','r'); i=1; while 1 tline=fgetl(fid); if ~ischar(tline), break, end a{i}=tline; i=i+1; end but there don't know how follow. just add a if tline(1)=='#', continue, end to loop. that's quite standard snippet. note check first character on purpose, have come across data files contain comments after data in same line. (valid) string fields might include character.

javascript - jquery reduce flicker effect for page load -

i had side bar replacing new_sidebar url , while doing first see old br loading , new contents .its kind of flicker effect.is there way can reduce flickering effect. $(document).ready(function(event){ $(".bar").empty(); $(".bar").load("{% url 'get_bar' %}"); }); try : css : <style> .sidebar { display: none; } </style> jquery $(document).ready(function(event){ $(".bar").empty(); $(".bar").load("{% url 'get_bar' %}"); $(".bar").show(); });

jQuery.getJSON read data -

why code below not working? can see in firebug data variable contains reply data expect: "[{"nextid":"stk000022"}]" but when try , access value "undefined". jquery.post( get_data_url, formdata, function(data) { sessionstorage.ticket_id = data[0].nextid; <--- undefined here }) .done(function(data) { showpopupmsg(successclass, false, "new ticket created!<br/>new ticket number: <strong>" + sessionstorage.ticket_id); // reset form jquery( '#partnernewticketform' ).reset(); }) .fail(function(jqxhr, textstatus, error ) { var syserror = textstatus + ", " + error; showpopupmsg(errorclass, logoutflag, "the application has failed create new ticket. error: " + syserror); }) .always(function(data) { }); since server returning json, need tell jquery it, giving 4th argument $.post : jquery.post( get_data_url, formdata, function(data) { sessionstorage

eclipse - Javascript : Syntax error on token "delete", StringLiteral? -

var testfunction = function () { return { delete: function() { // line 1 // } }; } getting below error on line 1 in eclipse syntax error on token "delete", stringliteral as changed "delete" "delete1" , error goes away . delete reserved keyword ? yes, delete reserved keyword, used remove property in object, not iterable anymore. thus, given: var = { b: 5 }; delete a.b; console.log(a); // logs {} it can used remove "global variables" properties of global object too, is: delete a; // in browsers equal delete window.a; notice can use delete property name too, need quote it: var obj = { 'delete': function() { // line 1 // } }; obj['delete']();

python - What is the purpose of Py_DECREF and PY_INCREF? -

i going through tutorial defining 'new types' in python, https://docs.python.org/2/extending/newtypes.html , , did not understand purpose of using py_decref in piece of code. static pyobject * noddy_new(pytypeobject *type, pyobject *args, pyobject *kwds) { noddy *self; self = (noddy *)type->tp_alloc(type, 0); if (self != null) { self->first = pystring_fromstring(""); if (self->first == null) { py_decref(self); return null; } self->last = pystring_fromstring(""); if (self->last == null) { py_decref(self); return null; } self->number = 0; } return (pyobject *)self; } my understanding of reference counting patchy , appreciated. in case, py_decref free memory allocated tp->alloc. tp->alloc sets ref count 1. py_decref decreases ref count 1 0; finds ref count 0, calls ap

jquery - Android and iOS webview not loading HTML, using AJAX, after playing embedded video -

i have ebook web app jquery carousel plugin (royalslider) preloads html component files(image, html, css), using ajax, in succeeding page containers when user swipes next page. ebook web app loaded in native app webview, both ios , android. in of pages, place video triggers play video overlay (youtube, movideo). i'm testing in mobile devices (iphone , android phones) the pre loading of html components work fine until play embedded video in page container. example, play embedded video in page 2, mobile video player loads, plays , close video. however, when swipe succeeding pages, preloading of html components doesn't occur end empty pages in page containers of carousel. issue occurs in webview of native app. tried on external mobile browser , doesn't happen. is there mime-type or data-type need set again after loading video? why won't ajax fetch of html contents work after playing video? "origin" issue after loading videos? i'm not familiar androi

javascript - how to get all select option values using jquery -

i have select list <select name="select-choice-min" id="mainmenu" data-mini="true"> <option value="10">10</option> <option value="11">11</option> ... </select> i tried var arr = new array(); var sval = $("#mainmenu option").val(); arr.push(sval); but on alerting arr variable i'm getting first value 10, 10, 10, ... so, how select option values? try this loop through #mainmenu option using .each() appropraite values using $(this).val() push using arr.push($(this).val()); var arr = new array(); $('#mainmenu option').each(function(){ arr.push($(this).val()); }); console.log(arr) working demo

How to get color dialog in eclipse during page editing? -

i working on website involves lot of colors , combinations. during page designing in eclipse whenever write color attribute inside style tag or in css file , limited color list, can custom color dialog box or hexadecimal values small preview of colors, helpful during page designing save lot of time. note: have set preferences of colors , fonts java editor, , believe has nothing it. thanks.

ios - Do I need to declare a method prior to the first use of the method in same class? -

i new in objective c, , working in c/c++ till now. in c/c++, if function not know prototype of function, not call function, if in same file. either use header file, or write prototype before using it. like, void proto(void); void somefun() { proto(); //call function } but in objective c, have function in same file, can call without giving prototype. following code compiling correctly. //calling before declaring/defining, works fine. [self processresponse:responseobject]; -(void)processresponse:(id)responseobject { } can objective c calls functions without knowing prototype if in same class? should prefer? please note processresponse internal function. not want expose other class. can objective c calls functions without knowing prototype if in same class? yes try call it. what should prefer? it better declare function in private extention part of implementation file(.m) since dont want expose function other class. advandtages: 1.other peer ca

c++ - MongoDB bson_date_t to local time -

i appended date mongodb this bson_append_date(b,"uploaddate",(bson_date_t)1000*time(null)); do remember append "milliseconds since epoch utc" , saved 2014-06-27 06:11:56 now reading out , giving milliseconds ( 1403852029 ) right. want convert local time. tried use localtime function of c++ did success time returned mongodb in int64_t. if(bson_iterator_type(&it)==bson_date) bson_date_t date_it = bson_iterator_date( &it ); where bson_date_t typedef int64_t bson_date_t; . can tell me how can local time milliseconds. getting valid time_t work localtime should opposite of doing in forward conversion: bson_append_date(b,"uploaddate",(bson_date_t)1000*time(null)); to have workable time_t, should following: time_t rawtime = (time_t)(bson_iterator_date( &it ) / 1000); struct tm * timeinfo = localtime (&rawtime);

.net - How to build the project with different configuration setting on TeamCity -

Image
i have been compiling project solution have different configuration settings building project. this. now have specific settings on project uses "debug envers" , want build project on command line msbuild. when uses default debug settings , project need envers built through debug configuration. can specify build project based on envers ? the command line : msbuild yoursolution.sln /p:configuration=debug(or preferred conf) why build command line when teamcity has visual studio solution type designed , can specify configuration type build

java - OpenLdap server, Spring ldap user bind (inetOrgPerson) No such object -

i installed openldap server , trying connect, add, users,groups on it. since 'm new on ldap nice if share tutorials spring-ldap :/ so here's bind code: user class: public class user implements serializable{ private string id; private string username; private string firstname; private string lastname; private string email; private string password; private string department; private string groups[]; } save method: public user save( final user user ){ init(); name dn = builddn( user ); attributes attributes = buildattributes( user ); logger.info( "trying save dn " + dn + " , attributes " + attributes ); ldaptemplate.bind( dn, null, attributes ); // update groups for( string group : user.getgroups() ){ try{ distinguishedname groupdn = new distinguishedname(); groupdn.add( "ou", "groups" );

Passing Image using Ajax to PHP -

i trying pass image , title field value php, process file uploads straight php using $_files array, not sure how create/pass array using ajax php. form: <form role="form" name="updateproductform" id="updateproductform" method="post" enctype="multipart/form-data"> <input name="imgone" id="imgone" type="file" title="add image"> <a class="btn btn-primary" name="updateproduct" id="updateproduct">update product</a></div> </form> and trying use pass php: $('#updateproduct').on('click', function() { try { ajaxrequest = new xmlhttprequest(); } catch (e) { try { ajaxrequest = new activexobject("msxml2.xmlhttp"); } catch (e) { try { ajaxrequest = new activexobject("microsoft.xmlhttp"); } catch (e) {

apache - deploying django, error : /mysite.fcgi/ was not found on this server, in shared hosting -

/home/public_html/.htaccess .htaccess addhandler fastcgi-script .fcgi rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(.*)$ /mysite.fcgi/$1 [qsa,l] mysite.fcgi path : /home/public_html/mysite.fcgi i changed permission 755(mysite.fcgi) after executing not found the requested url /mysite.fcgi/ not found on server. additionally, 404 not found error encountered while trying use errordocument handle request. addhandler fastcgi-script .fcgi <ifmodule mod_fcgid.c> addhandler fcgid-script .fcgi <files ~ (\.fcgi)> sethandler fcgid-script options +followsymlinks +execcgi </files> </ifmodule> rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(.*)$ /mysite.fcgi/$1 [qsa,l] this works me

python - How the return result like this , What is the lambda function do in this code? -

this question has answer here: local variables in python nested functions 3 answers flist = [] in range(3): flist.append(lambda: i) f in flist: print f() i don't know why returning 2,2,2 in last iteration through first loop, i value 2 , hence i values in each element of list 2. because have created live reference i variable. here simplified demonstration: a = 5 c = lambda: a += 5 >>> c() 10

datetime - Navigating to date time settings screen from my Windows Phone Application -

i want modify system time in windows phone if doesn't matches server time, want prompt user change date time redirecting them date time settings screen. this code have used android new intent(android.provider.settings.actiondatesettings); suggest me way same in windows phone. i don't think you'll able access date , time settings panel thought access settings page application. connectionsettingstask connectionsettingstask = new connectionsettingstask(); connectionsettingstask.connectionsettingstype = connectionsettingstype.wifi; connectionsettingstask.show(); have @ these: how link specific system-setting in windows phone app? http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662937(v=vs.105).aspx http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394011(v=vs.105).aspx hope helps!

How to resize activity listview in android? -

hi want resize listview in android. i have other source previous topics. .xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="3dp" > <textview android:id="@+id/currentdirectorytextview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="current directory:" /> <listview android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margintop="5dp" android:textsize="30sp" android:layout_weight="1" /> </linearlayout> .class arrayadapter adapter = new arrayadapter(

regex - Using multiple regexes to capture matching nested xml tags -

suppose have xml file contains tags nested inside themselves, eg <tag>one<tag>two</tag>one</tag> from this page , have 2 examples of regex expressions don't match string, eg get <tag>one<tag>two</tag> which not balanced. according google, it's not possible find regex parse html correctly, eg here or here . entire html parsing not possible regular expressions, since depends on matching opening , closing tag not possible regexps. regular expressions can match regular languages html context-free language. thing can regexps on html heuristics not work on every condition. should possible present html file matched wrongly regular expression. that's nice clear-cut theoretical answer, got me thinking: would possible programmatically, using multiple regexes and/or loops? here's simple recursive descent xml parser, i'm making right rough , ready, writing in ruby didn't specify language. not use

cordova - Phonegap : How to make every page load -

i building app in phonegap framework , want on each page need load upon call other function. let's have homepage menu. when user enter on 'page2' call page2_function(),on enter 'page3' call page3_function(); markup structure : <div data-role="page" id="page1" data-theme="c"> <!-- header --> <div data-role="header" id="wrap-header"> <img src="img/logo.png" class="logo"/> <a href="page2" class="menu" data-transition="slide">page2</a> <a href="page3" class="menu" data-transition="slide">page3</a> </div> <!-- /header --> <!-- content --> <div data-role="content" id="content"> <ul data-role="listview"

java - Update ListView items from another class -

i have issue when try update listview values. have custom adapter composed edit text. when click on edit text show dialog (that in class) , pass him same values position, arralist , other. in dialog class i've method public void updatevalue(string newvalue) { myobject object = arraylist.get(position); object.valuefile = newvalue; arraylist.set(position, object); myadapter adapter = new myadapter(context, 0, arraylist); adapter.notifydatasetchanged(); } this method works because new values correctly insert array list text of edit text not updated updates when scroll, , go editt text. why? how can fix? problem? you cannot new() adapter @ second time. adapter can new() 1 time. if want update listview, need update data in arraylist arraylist<yourtype> arraylist = new arraylist<yourtype>(); //init data arraylist //... //init adapter myadapter adapter = new myadapter(context, 0, arraylist); //update item of listview public void

javascript - Error in switch() case; -

while i'm trying write simple function need iterate through classes of event.target , depending of class name, i've encountered unknown error (as me). function tpager() { var lc = $(event.target).attr('class'); swith(lc) { case ('slow'): console.log('slowclicked'); break; case ('page'): console.log('pageclicked'); break; } }; this testing purposes, console "unexpected token", there error in line 3, "{". can't what's wrong. jsfiddle: http://jsfiddle.net/2cjhc/ wouldn't code this switch(lc) { // note keyword switch case 'slow': console.log('slowclicked'); break; case 'page': console.log('pageclicked'); break; } you're having this swith(lc) { // not switch keyword. the mistake actual, @ keyword usage. having wrong keyword triggering mis

android - ConvertView items partially updated -

Image
i have custom listview in activity , uses convertview pattern , viewholder. works fine, text in items cuted off. seen on screenshots: it looks reuse old view , don't update text length. here part of adapter code: if (convertview == null) { viewholder = new viewholderitembool(); layoutinflater inflater = (layoutinflater) context.getsystemservice (context.layout_inflater_service); if (changeable) { convertview = inflater.inflate(r.layout.sensor_bool_e, null, true); } else { convertview = inflater.inflate(r.layout.sensor_bool, null, true); } viewholder.txtname = (textview) convertview.findviewbyid(r.id.txtname); viewholder.txtdesc = (textview) convertview.findviewbyid(r.id.txtdescript); viewholder.imgstate = (imageview) convertview.findviewbyid(r.id.img); convertview.settag(viewholder); } else { viewholder = (viewholderitembool) convertview.gettag(); } viewholder.txtname.settext(name); if (isimportant()) v

java - JFrame not presenting any Components -

i using following code create simple jframe , reason doesn't show components, blank frame. why happening? created frames bunch of times , can't figure out wrong. code is: main(){ jframe frame = new jframe("colorizer | by: nonamesl"); frame.setsize(400,200); frame.setlocationrelativeto(null); frame.setvisible(true); frame.setdefaultcloseoperation(jframe.exit_on_close); jpanel panel = new jpanel(); frame.setcontentpane(panel); textfield=new jtextfield("enter name!"); textfield.setbounds(0,0,40,200); textfield.setvisible(true); frame.getcontentpane().add(textfield); button=new jbutton("go!"); button.setbounds(0, 200, 40, 200); button.setvisible(true); frame.getcontentpane().add(button); rectangle=new recshape(color.white); rectangle.setbounds(0,40,400,160); rectangle.setvisible(false); frame.getcontentpane().add(rectangle); main.frame=frame; registerbutton(); }

java - android download Bitmap from url ran into out of memory exception -

i`m building app loads images url , when user scroll down app download more images. after 30 downloads out of memory exception. read here , in android developer not find way make run. this code download image: for (int k = 0; k < pictureary.length(); k++) { try { url url = new url(picurl + pictureary.getstring(k) + "/230"); httpurlconnection connection = (httpurlconnection) url .openconnection(); connection.setdoinput(true); connection.connect(); inputstream input = connection.getinputstream(); bitmap mybitmap = bitmapfactory.decodestream(input); picarraylist.add(mybitmap); break; } catch (ioexception e) { bitmap mybitmap = bitmapfactory.decoderes

Bars not displaying in jqplot bar chart -

my problem bars not displaying @ in bar chart, using jqplot. here code: var line = [['clients' , 15] , ['prospects' , 8]]; var plot4 = jquery.jqplot('chartdiv4', [line] , { seriesdefaults:{ renderer:jquery.jqplot.barrenderer, rendereroptions: { varybarcolor: true } }, axes:{ xaxis:{ renderer: jquery.jqplot.categoryaxisrenderer, } } }); see example @ http://jsfiddle.net/bpek2/3/ shows bars being drawn on screen. make sure @ included dependencies (external resources) you'll need of them. in essence, n

android - Calling method of another activity from Asynctask -

Image
i getting syntax error - "no enclosing instance of type mainfragmentactivity accessible in scope" in method buildreport - buildreport method - public void buildreport(view v) { //syntax error here new verifydialogue(mainfragmentactivity.this).execute(daterange); } this asynctask class - class verifydialogue extends asynctask<string, string, string> { public mainfragmentactivity activity; public verifydialogue(mainfragmentactivity a) { //this how getting instance of activity this.activity = a; } @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(getactivity()); pdialog.setmessage("initializing please wait"); pdialog.settitle("loading"); pdialog.setcancelable(true); pdialog.show(); } protected string doinbackground(string... args) { return ""; } protected void onpostexecute(string result) { //there records in sync queue alertd

php - Does save() method works of update in Yii -

i have message model class. want check weather particular entry exist in db table. if doesn't exist save new entry in db table , if exists update current entry. now problem when entry exists (update) in db table, save() method gives exception. 'chttpexception' message 'your request invalid.' can use save() method instead of update() method updating records? $message = message::model()->find($criteriamessage); if (!isset($message)){ $message = new message(); $message->id = $tagmessage->id; $message->language = $language; $message->translation = $translation; } else $message->translation = $translation; if(!$message->save()){ return false; } you do: $message = message::model()->find($criteriamessage); $message->your_field = $somevalue; $message->save();

sql - How can I sort a field in numerical order after FORMAT() in MySQL? -

after using format() strip unnecessary decimal places result, i'm unable correctly order field, field string rather number. what practice order results , remove decimal places (or vice versa) ordered in correct numerical order? results before format order `field` asc *---------* | 1000.06 | | 2000.17 | | 3000.12 | | 10000.4 | | 20000.1 | | 30000.2 | *---------* results sorted numerically there unneeded decimal places need removed. results after format() order `field` asc *---------* | 1,000 | | 10,000 | | 2,000 | | 20,000 | | 3,000 | | 30,000 | *---------* results have had decimal places removed format() has made field string not sorting numerically require, alphabetically. required results *---------* | 1,000 | | 2,000 | | 3,000 | | 10,000 | | 20,000 | | 30,000 | *---------* the required result results sorted numerically , have decimal places removed. just select formatted value , order unformatted one. select f

android - GestureOverlayView not working perfectly on layout -

i working on project include gestures. it's work want put padding or margin on gesture not layout change want. how put padding or margin in gestures? my xml code: <framelayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1.50" android:layout_margintop="5dp" android:layout_gravity="center" > <imageview android:id="@+id/imageview3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_alpha" android:layout_gravity="center" android:contentdescription="@string/app_name" > </imageview> <android.gesture.gestureoverlayview android:id="@+id/draw_on_gesture&

PHP dynamic HTML table using SQL -

background i using below code generate html table based on sql results. code $stid = oci_parse($conn, " select * ( select orders.order_no, orders.porder_no, orders.date, order_totals.value orders, order_totals orders.order_no = order_totals.order_no , orders.account_no = '" . $_session['session_account'] . "' order orders.order_no desc ) rownum <= 15 "); oci_execute($stid); echo "<table class='table'> <thread> <tr> <th>order no</th> <th>purchase order no</th> <th>date</th> <th>value</th> </tr> </thread> <tbody>"; while ($row = oci_fetch_array($stid, oci_num)) { echo "<tr>"; echo '<td><a href="view.php?id=' . $row['0'] . '">' .

scalability - Node.js slow broadcast -

i'm programming node.js server clients can connect server through /read?id=45 (where client id 45 in example). server stores connection in object , call res.end(message) on when message arrives client #45. alternatively, after 60 seconds, connection closed , idea client calls /read again. the connection stored so: var openconn = {}; function handlereadreq(req, res) { var id = input.returnfromget(req, 'id'); // fetches ?id value // save connection openconn openconn[id] = new array(); openconn[id].push(res); openconn[id].push( settimeout(function() { openconn[id][0].end(''); delete openconn[id]; } }, 60 * 1000) ); } if send message /bcast, broadcast connections in openconn so: function dobcast(req, res) { var message = input.getpost('message'); // akin input.returnfromget var knownclients = 0 var stealopenconn = openconn; // 'steal' openconn openconn = {}; for(var client in stea

c++ - How do you create the "Shader" folder in Visual Studio interface -

i have seen several projects "shader" folder in solution explorer. however, when create 1 myself, can see "header files", "source files", "resource files", , "external dependencies" folder. is there way tell visual studio need "shader" folder because i'm going use shaders? if not, how can create manually? visual studio has virtual folders called "filters". these can map real folders in file system or can use them define logical/conceptual groups of items inside projects. to create filter under project in visual studio, right-click mouse on project in solution explorer, expand "add" , click "new filter". new filter ("newfilter1") created under project can rename like. you can drag items project inside in order group them "logically" or can right-click on new filter , choose add>existing item or add>new item. can nest multiple filters inside each ot

java - Can an Android activity call itself? -

when creating new intent start new activity, possible activity call , program technique. example, let's have template activity , avoid making 10 different activities, handy have same activity call itself? yes is. if requirement there no harm in doing that. if use dont forget call finish(). finish() remove activity backstack when press dont return previous instance of same activity. startactivity(new intent(myclass.this,myclass.class)); finish();

Not able to understand how select_tag working in rails 4? -

i have following code in rails, <%= select_tag 'profile', (options_from_collection_for_select(@profiles, :id, :name, @dealer.profileid.to_i))%> and generating following html, <select id="profile" name="profile"> <option value="cm profile">cm profile</option> <option value="admin profile">admin profile</option> </select> but want value in option tag should "id" of profiles object. assigining name of @profile object . and schema of profile table is, id ==> int(11) ==> auto_increment name ==> varchar(20) ==> primary key type ==> int(11) how can ?? according syntax <%= select_tag 'profile', (options_from_collection_for_select(@profiles, :id, :name, @dealer.profileid.to_i))%> is right, should work intend to. unless syntax this options_from_collection_for_select(@profiles, :name, :na

C# - Override the Standard Windows Close Button to Pop-up my Custom Form -

yes, noob question. apologies. when users click on red x button on window, want pop message asking if want quit. found similar question on site: override standard close (x) button in windows form . the thing is, want customize font , messageboxicon messagebox, , sadly can't done (or take lot of effort done). so, i've decided make own form. protected override void onformclosing(formclosingeventargs e) { if (txtid.text != "" || txtpassword.text != "") { base.onformclosing(e); if (e.closereason == closereason.windowsshutdown) return; // confirm user wants close new formconfirmexit().showdialog(); } } i added code under main form. however, when run code , click on standard close button, pop (the custom form did) doesn't it's job. suppose click "no" button, terminates entire program. "yes" button, pop-up shows again, , kinda stops (on visua

python - How to unit test this lambda code? -

say, have following python code: try: fabulous.color import fg256 format_info = lambda x: fg256(63, unicode(x, 'utf-8')).as_utf8 except importerror: format_info = lambda x: '\033[1;30m' + x + '\033[0m' how can unit test this? is worth testing? there need mock import statement both branches excised. trivial -- example, mock fg256 have side effect of raise importerror . matching returned string has right control characters fine feels brittle. what want test? seem have 2 unrelated cases here; importing fails lambda returns correct info it's not responsibility check not using code fails; if want test nevertheless (perhaps because code has posted on popular forum) separate 2 distinct tests. we don't know lambda supposed return, looks of it, should return string similar assign in except branch?

ios - How to discover which friends accepted invites with Facebook API? -

facebook api v2.0 introduced invitable_friends edge . an example response request edge is: { "data": [ { "id": "avkgk9flfxasdvxnbdv_gyogr6lxa9sklnh...", "name": "anita sujarit", "picture": { "data": { "is_silhouette": false, "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t1.0-1/c0.0.50.50/p50x50/1470158_10201991701127909_302023572_t.jpg" } } } } looking closely @ id, it's not normal facebook user id. instead it's invite token ; token passed requests dialog value to parameter. the invite token, returned on each of friend objects value of field named id, unique (per user , per game) string of variable length. invite token subject expiration, , may change between game sessions. therefore not advisable cache these results, or try assign them given person. the friends edge

Chrome Extension - injecting javascript fails after download -

i trying download series of files on website using chrome extension. however, after first download, javascript injection fails work. the following code stripped down version of extension, downloads file page: http://spreadsheetpage.com/index.php/file/word_clock/ the manifest.json file: { "manifest_version": 2, "name": "file downloader", "description": "file downloader", "version": "1.0", "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" }, "permissions": [ "tabs", "activetab", "http://*/*", "https://*/*" ], "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" } the popup.html file: <!doctype html> <html> <head> <title>file download

php - Single Page WP Theme -

so i'm building wp 1 page theme , want each page display on static front-page. user able add/edit content of page in dashboard versus markup. when view page template the_content() working advertised, when require page template on static front-page, else shows the_content() blank. ideas?? thanks! work.php file // work template page -- the_content() works <!-- works --> <section id="works"> <!-- container --> <div class="container"> <!-- row --> <div class="row"> <!-- head --> <div class="head big wow bouncein"> <h3>our <span class="blue">works</span> </h3> <div class="head-break-line"> <span class="head-line-blue"></span> </div> <?ph

ruby on rails - "englify" string, get rid off special symbols -

i wanted ask question converting string. i using rails 4.0.4 and in database have values in native language rīga or jēkabpils. wondering if there kind of function or other way convert words english symbols/characters riga or jekabpils. i wondering because compare them like: "jēkabpils".convert == "jekabpils" i asking purely based on own interest, wondering if possible? you can this: require "i18n" i18n.enforce_available_locales = false s = "jēkabpils" puts s puts i18n.transliterate(s) output: jēkabpils jekabpils

azure web sites - WebJobs Not Retrying Failed Queue Message -

i have following logic in webjob using new 0.3.0-beta webjobs sdk. when code fails processing message, azure dashboard shows aggregate exception (which makes sense since async). however, not retry processing message. the little documentation i've been able find indicates message should retried within 10 minutes of failure. not case new sdk? public static task processmymessageasync( [queuetrigger(config.my_queue)] string msg, int dequeuecount, cancellationtoken cancellationtoken) { var processor = config.container.getinstance<imessageprocessor>(); return processor.handlejobasync(msg, dequeuecount, cancellationtoken); } the exception stems sql timeout exception (its db query against sql azure in code): system.aggregateexception: system.aggregateexception: 1 or more errors occurred. ---> system.data.entity.core.entitycommandexecutionexception: error occurred while executing command definition. see inner exception details. ---&

javascript - Redirect to WebForm with JSON -

i have situation dont want use querystrings pass data redirect page. current implementation, source page: window.location = "invaliduser.aspx?u=" + encodeuri(username); i looking @ using ajax methodology not sure redirect page. landing page: <%@ page language="c#" autoeventwireup="true" codebehind="invaliduser.aspx.cs" inherits="itask.organizer.invaliduser" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>invalid user</title> <script type="text/javascript" src="scripts/jquery-2.1.0.js"></script> <script src="scripts/app.utility.js"></script> <script src="scripts/invaliduser.js"></script> </head> <body> <h1>invalid user account:</h1> <p>your user account ( <span id="pusername"></span> ) not setup ap

Concat several arrays in JavaScript (nodejs) -

what more concise way concat ar arrays in following object: var obj = { field1: { ar: [...] }, field2: { ar: [...] }, ... fieldn: { ar: [...] } } i found this: object.keys(obj).reduce(function(array, entry) { return array.concat(obj[entry].files); }, []); you may try this: [].concat.apply([], [array1, array2, ...])

g wan - GWAN query string length issue -

i using gwan (v4.3.14) , facing strange issue. trying pass long text in query string. have figured out gwan not allow me pass query parameters beyond total request size of 537 characters. it responds 400 bad request an example string : http://xxx.xxx.xxx.xxx:yyyy/?t.cpp&c=dbe9kdojgmm9yr7aypglqby1a9rzuiamdaantjsbobrjzo45yhbpao5venla6icmlsadzntucpkbkb0e0g15pfhcgb4onxqq3m1k0cx8k15rqkawb8mthuoihkp02vk9wwjfu5nkbjtwu80onudokwwpuigxkkcjiswjjncgdy1lqij1gnvgrggomthoxppsz1cl7zxif5cjwggzsbunaddtq5w4pbxvevnugobhryqdtylhi4tudeae2junswezxtqm1qkg3ezgkm2dn68r7yxpcefz2n1nxggukydgn6em7veq5g5lptvrdexn0fsozgbenfhxs2oljwghffcedgeu1dfknfxnac6ietbiivvtjv55wczi7wbita0r60kjkuzynn59w6xhnawtk0zcyn2rq8lraojhzjxhjcyl9sk6jw4d9k0wwlsizhdftolnpr9jyp2sesyhlujschpihor4fcbvwqmwh5yoddcpl2kbr6cjsjwabaac the code in c++ file is: # include "gwan.h" # include <iostream> using namespace std; int main (int argc, char * argv[]) { if(argc) { cout<<argv[0]; xbuf_cat(g

php - How to integrate Avangate webservice? -

i need source code or example integrate avangate webservices php application. does have sample source code or can me on how integrate api using php. i had gone through document lengthy , bit confusing. need guidance have worked on this. how add new products. can add control panel or need use it's api. how parse notification data received response avangate.

visual studio - how to use c# snippet prop? -

just got know c# snippet. unable use them in code. me out please, messed set , how work. here test class named "myclass" namespace windowsformsapplication1 { class myclass { public string getmessage(string givenname) { return "hb "+givenname; } private string bmessage; public string myproperty { { return bmessage; } set { bmessage = value; } } } } in button code form. unable use these set. ll great if clears how can use these set. "myproperty" here? know not method. purpose? thanks snippets not executable statements. short-cuts in writing executable statements. for e.g. if write prop , press enter, give auto-generated property. have change datatype , property name. similarly propfull give property , set parts. in case myproperty property name , string datatype. bmessage backing field property.

html - Jquery - Get the highest height out of three different divs -

i'm working on pinterest based grid system, everything's fine , dandy , working except 1 thing. problem being because i'm using absolute positioning container wraps them has set actual pixels, came code:- $(document).ready(function(){ $('.newspagemain').css({height:(($('#newsentry:nth-child(1)').height()) + ($('#newsentry:nth-child(4)').height()) + ($('#newsentry:nth-child(7)').height()) + 141)}); // id 9 }); it works degree problem is, if row longer, longest 1 cropped off, want able work out highest of nth-chlds 1,2,3 4,5,6 7,8,9 can add highest container wrap correctly i hope makes sense, appreciated thank you ~matt if understand correctly want tallest element every group of 3 elements in collection: var $els = $('#newsentry div'), height = 0; (var = 0; < $els.length; += 3) { height += math.max.apply(null, $divs.slice(i, i+3).map(function() { return $(this).height(); }).get()); }

python - Writing files to directories in a round robin pattern -

i'm looking solution, within python, write generated files in round robin fashion set of target directories, such files evenly distributed. so if there 5 target directories: d1, d2, d3, d4 , d5 and constant stream of generated files (f1 .... fn), directories written follows:- d1: f1, f6, f11 ... etc d2: f2, f7, f12 ... etc d3: f3, f8, f13 ... etc d4: f4, f9, f14 ... etc d5: f5, f10, f15 ... etc ideally there may python lib out there allows ... thanks use itertools.cycle next directory next file: it = itertools.cycle( ['d1', 'd2', 'd3'] ) print next(it) print next(it) print next(it) print next(it) print next(it) print next(it) result d1 d2 d3 d1 d2 d3 it = itertools.cycle( ['d1', 'd2', 'd3'] ) x in ['f1', 'f2', 'f3', 'f4' , 'f5', 'f6']: print x, 'write in', next(it) result f1 write in d1 f2 write in d2 f3 write in d

javascript - requireJs can not find modules when running on travis -

i trying use requirejs first time in javascript project. have written test cases in jasmine , using grunt run them. working fine on local machine when deploy same on travis. requirejs not able resolve module dependencies , throwing errors. error: scripterror: illegal path or script error: ['listmodel'] project url: https://github.com/metanitesh/js.jquery.metalist travis build: https://travis-ci.org/metanitesh/js.jquery.metalist i using mac development, , named files in camelcase notation. guess problem case insensitive nature of mac osx, travis not able read these files. i renamed files in lowercase , it's working fine.

mysql - Merge results of single JSON output with PHP -

i have json array per below: { "aadata": [ { "date_time": "23", "traffic": "22", "direction": "sent" }, { "date_time": "24", "traffic": "55", "direction": "sent" }, { "date_time": "25", "traffic": "60", "direction": "sent" }, { "date_time": "26", "traffic": "43", "direction": "sent" }, { "date_time": "27", "traffic": "50", "direction": "sent" }, { "date_time": "23", "traffic": "50", "direction": "received" }, { "