Posts

node.js - StackOverflow API not returning JSON -

i using node.js script gather data stackoverflow. know responses gzipped, put code in should take care of that. script follows: var request = require('request'); var zlib = require('zlib'); function getstackoverflowresponse(url, callback){ request(url, {encoding: null}, function(err, response, body){ if(response.headers['content-encoding'] == 'gzip'){ zlib.gunzip(body, function(err, dezipped) { callback(dezipped); }); } else { callback(body); } }); } var url = "https://api.stackexchange.com/docs/questions#pagesize=2&order=desc&min=2014-01-04&max=2014-02-02&sort=activity&tagged=apigee&filter=default&site=stackoverflow&run=true"; getstackoverflowresponse(url, function(questions) { console.log(questions); }); instead of getting json output, i'm getting following response: buffer 0d 0a 0d 0a 0d 0a 0d 0a 3c 21 44 4f 43 54 59 50 45 20 48...

ios - Apple Push Notifications + TestFlight + Enterprise wildcard provisioning profile -

i work in organization have apple enterprise provisioning profile. developing ios application makes use of apple push notifications, , use testflight distribute many users in organizations without having register device ids in testflight. can use enterprise wildcard provisioning profile distribute via testflight application uses apple push notifications? or can use explicit provisioning profile distribute app via testflight without having register employees devices in testflight beforehand? thanks in advance, ido it should work! what enterprise apps? if registered apple's enterprise program , making enterprise apps, no worries...testflight works too. testflight supports enterprise apps , works ad hoc apps distribution. upload enterprise signed app , distribute team , approved members of team have access application installation. source: http://help.testflightapp.com/customer/portal/articles/402851-testflight-faq

linked list - Move value to end of queue in C -

i'm new c , i'm trying use function move value end of queue. works first 2 times, third time goes wrong regarding while loop , i'm not sure what's causing it. @ appreciated. :) void enqueue(queue q, int value) { if (q == null) { return; } // create new node node * newnode = (node *)malloc(sizeof(node)); if (newnode == null) { return; } // add node end of queue newnode->value = value; if (q->head == null) { newnode->next = q->head; q->head = newnode; } else { node * head = q->head; while (head->next != null) { head = head->next; } // update queue pointer head->next = newnode; } } if q->head non-null, never set newnode->next , leaving uninitialised. next code walk list follow uninitialised pointer, leading undefined behaviour , crash. to fix this, need initialis...

android - Drag and drop in ScrollView -

Image
i have imageviews inside horizontalscrollview. i able drag , drop imageviews somewhere else, still maintain scrolling capability. dragging should activated when user starts vertical motion finger. for now, have drag , drop activate on long-press, not solution. to illustrate: i had well. after reading http://techin-android.blogspot.in/2011/11/swipe-event-in-android-scrollview.html adapted code follows: class myontouchlistener implements view.ontouchlistener { static final int min_distance_y = 40; private float downy, upy; @override public boolean ontouch(view view, motionevent event) { switch (event.getaction()) { case motionevent.action_down: { downy = event.gety(); return true; } case motionevent.action_move: { upy = event.gety(); float deltay = downy - upy; // swipe vertical? if (math.abs(deltay) > min...

select - Joining the Column Outputs of Two or More Columns from a MySQL Query -

i trying join outputs of 2 or more mysql queries. if query 1 has n columns , query 2 has m columns, output should have n+m columns. example: select * (select 1,2,3) x, (select 4,5) y; the output here : 1 2 3 4 5 now issue second query may produce no results. case results in no output @ all: select * (select * table_0) x, (select * table_1) y; if table_1 returns no matches, combined output returns no rows. still entries of first table returned. while have workaround, involves individual queries each of m columns. not want create temporary tables , join them. a left join should it: select * (select * table_0) x left join (select * table_1) y on 1;

c++ - OpenCV findContours

i have c++ project using qt 5.1.1 , opencv 2.4.6. image processing algorithm runs in separate thread. works fine if call opencv function findcontours() program crashes stack overflow message (right in first time function called, not called several times before) "unhandled exception @ 0x56ec9a47 in sara.exe: 0xc00000fd: stack overflow." i found same problem in case matter of changing project visual studio 2010...but in case, project in vs2010. the algoritm runs fine if create separate console project, calls image processing algorithm, same code inside thread in qt project show stack overflow! if remove findcontours() function, woks should. in both projects use same libs , debug dlls (versioned xxx246d.dll), , compiling program debug. i tried make stack larger changing properties -> configuration properties -> linker -> system -> stack reserve size option, program still crashes, different message, saying "unhandled exception @ 0x76e5c41f in sara....

android - Passing current location to Marker -

i writing application opens maps app , able add marker object @ current location when opens. application correctly opens maps app , shows blue dot current location, having difficulty using current location in order create marker . here source code: import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.googleplayservicesclient; import com.google.android.gms.common.googleplayservicesutil; import com.google.android.gms.location.locationclient; import com.google.android.gms.location.locationlistener; import com.google.android.gms.location.locationrequest; import com.google.android.gms.maps.cameraupdate; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.markeroptions; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.supportmapfragment; import android.location.location; im...

c# - A straightforward answer to using session variables in MVC Views? -

i having difficulties utilizing session variables in mvc views. in example below, if condition in view not met when set isloggedin session variable true via controller. note: trimmed of irrelevant code easier reading. in advance! controller: public actionresult index(int id = 0) { jobsummarymodelhelper jobdetails = new jobsummarymodelhelper(); jobdetails.id = id; jobdetails.jdata = ..... return view(jobdetails); } public actionresult authenticate() { ..... int usercount = db.jobboardusers.where(u => u.userid.equals(un) && u.passcode.equals(pc)).select(u => new accountmodel() { uid = u.id }).count(); if (usercount > 0) { httpcontext.session["issignedin"].equals(true); } return redirecttoaction("index", jobdetails); view: ..... @if (convert.toboolean(session["issignedin"])) { <fie...

Invalid tag nesting configuration in ColdFusion 10? -

how around coldfusion error? i'm following this coldfusion tutorial. when tried implement code in coldfusion 10 got following error: invalid tag nesting configuration. query driven queryloop tag nested inside queryloop tag has query attribute. not allowed. nesting these tags implies want use grouped processing. however, top-level tag can specify query drives processing. the error occurred in line 76 74 : </cfloop> 75 : </tr> 76 : <cfoutput query="data" startrow="2"> 77 : <tr> 78 : <cfloop index="c" list="#collist here code: <cfset showform = true> <cfif structkeyexists(form, "xlsfile") , len(form.xlsfile)> <!--- destination outside of web root ---> <cfset dest = gettempdirectory()> <cffile action="upload" destination="#dest#" filefield="xlsfile" result="upload" nameconflic...

iphone - Client-side database in Actionscript 3 (built into the client, not read from a server database) -

i'm looking create way store items game i'm making using flash. there's going many items in game , want store them in database built client , doesn't require connecting server. i know write parser , import spreadsheet file game, i'd not reinvent wheel if don't have to. is there way or library that's created reading client side database? guess i'm looking way use database style system on client side without having build ground up. look @ sharedobjects : var savedata:sharedobject = sharedobject.getlocal("gamename"); savedata.data.test = 5; savedata.flush(); // ... restart application , then: trace(savedata.data.test); // 5

wso2 - API manager, upgrade from 1.4.0 to 1.60 -

we're running wso2 api manager 1.4 , upgrade latest version 1.6. can go directly 1.6 or have upgrade 1.5 first? i'm concerned regarding db migration, these scripts seem relevant single version increments. https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/products/apimgt/1.6.0/modules/distribution/resources/ thanks. as said, databases migrations, can execute migration-1.4.0_to_1.5.0 , migration-1.5.0_to_1.6.0 sqls sequentially. it's important note api manager 1.4.0 based carbon 4.1.x , api manager 1.6.0 based on carbon 4.2.0. see release matrix wso2 products . this means underlying clustering, registry , user-mgt have major changes. api manager related configurations has changed. therefore advice follows. backup existing database , api manager 1.4.0 deployment. migrate databases in incremental manner. re-do configurations in api manager 1.6.0 instances. i.e. direct migration 1.4.0 1.6.0. may compare api manager 1.4.0 repository/conf ...

c - Working on a Fibonnaci/mysequence code -

i working on code suppose calculate sequence: a(n+2)=-2(n+1)+3a(n) a(0)=2 a(1)= -1 unfortunately cannot figure out. i'm new @ (about month) , i'm going try best on own, need help. thank whoever decides me. #include <stdio.h> int mysequence(int n) { if (n==0) return 2; if (n==1) return -1; if (n==2) return 8; return (2 * mysequence(n+1) + mysequence(n+2))/3; } int main() { int n; printf("enter n = "); scanf("%d", &n); printf("%d\n",mysequence(n)); return 0; } look @ line return (2 * mysequence(n+1) + mysequence(n+2))/3 , compare know sequence: a(n+2)=-2(n+1)+3a(n) . they have nothing in common. what want return (-2*mysequence(n-1) + 3*mysequence(n-2)) . why, coefficients should clear enough, copied definition. reason call next level of recursion n-1 , n-2 quite simple, observe: a(n+2)=-2(n+1)+3a(n) -> substitute n n-2 -> a(n)=-2(n-1)+3a(n-2) .

c# - Image compression is not working -

i have operation on site takes crops image, resultant, cropped image coming out larger in terms of file size (original 24k , cropped image 650k). found need apply compression image before saving it. came following: public static system.drawing.image cropimage(system.drawing.image image, rectangle croprectangle, imageformat format) { var croppedimage = new bitmap(croprectangle.width, croprectangle.height); using (var g = graphics.fromimage(croppedimage)) { g.interpolationmode = interpolationmode.highqualitybicubic; g.drawimage( image, new rectangle(new point(0,0), new size(croprectangle.width, croprectangle.height)), croprectangle, graphicsunit.pixel); return compressimage(croppedimage, format); } } public static system.drawing.image compressimage(system.drawing.image image, imageformat imageformat) { var bmp = new bitmap(image); var codecinfo = encoderfactory.getencoderinfo(imagef...

jquery - PHP: Need advice on form validation on a server with PHP v5.1.3 -

i'm trying learn how server-side validation on web form using php. have client-side validation working through jquery. during studies read native validation filters added php v5.2 of grunt work form validation. unfortunately, learned office server running php v5.1.3. ouch! make long story short, can not upgrade php version. end of discussion. as newbie of this, are there other readily available functions out there me validate form input data older versions of php of job? read html_quickform2, have form built in html5 (using polyfill older browsers ie8 validate html5 forms). again, new , looking nudged right direction can form validated possible. as starter, suggest html5 -- default, have (very) basic validation field types ( email , tel , date ...). next, php's preg_match ; match inputs strings. first step start reading few articles on php validation. here's introductory article on subject. source, requires time , effort, go straight source @ php.net . ...

ruby on rails - Connect to Host MySQL Server on Vagrant -

it's possible connect host's mysql server inside vagrant box? i'm running ror vagrant box, need connect host database server. any help? there 2 thread 1 on stack overflow , on superuser might out doing this. links below. how connect host postgresql vagrant virtualbox machine https://superuser.com/questions/310697/connect-to-the-host-machine-from-a-virtualbox-guest-os/310745#310745 it possible trying achieve if settings correct.

javascript - Jasmine fixtures not cleaned up, tests not independent -

i'm using jasmine unit test table column sorting functionality. issue came noticed columns in wrong order (z-a instead of a-z) after first click. used browser's debugger examine html , confirm column in fact mis-sorted. test of independence, added click end of preceding it-block, , surprisingly fixed issue. reordering tests avoid other's click worked. this disproves the assertion "fixtures container automatically cleaned-up between tests". can verify bug or explain i'm misunderstanding? describe('gem bootstrap_sortable_rails', function() { var header; beforeeach(function() { setfixtures('<table class="sortable"><thead><tr><th data-sortkey="0">name</th></tr></thead>' + '<tbody><tr><td data-value="harrow baptist church"><a href="/organizations/1">harrow baptist church</td></tr>' + '<...

c++ - Run doesn't work in Eclipse with Cygwin toolchain -

i trying configure eclipse use cygwin toolchain. wrote simple c++ program check have setup things correctly. #include <fstream> using namespace std; int main() { ofstream fout("output.txt"); fout << "hi" << endl; fout.close(); return 0; } the build button compiles program , generates executable , can run it. however when click on run button in eclipse doesn't run program. rather confused since debug button runs program correctly (so issue should not not finding cygwin1.dll). the run button works if set toolchain mingw. i using eclipse kepler service release 1 , cygwin date. i search bit couldn't find answer how fix this. suggestion might cause of problem? the following solved problem me: add cygwin path in environment, e.g. c:\cygwin\bin\ add path mapping cygwin drives in window -> preferences -> c/c++ -> debug -> source lookup path , e.g. map \cygdrive\c c:\ .

Use Heroku config vars with PHP? -

i've been able find information on how use config vars in heroku python, node.js, , other languages, not php. can use them php, or not supported? this article shows how python, java, , ruby, not php. config vars on heroku manifest environment variables, should able access them php other environment variable, eg. using getenv . first, set variable console: heroku config:set my_var=somevalue then, access code: $my_env_var = getenv('my_var');

html - anchor tag div name -

i'm running trouble here, appreciated. i'm trying link section on page. i'm having trouble. check code: <a href="#h2">consulting</a> that's link, here's block i'm wanting link to: <div class="space" name="h2"> <h1 class="h2">consulting</h1> <p class="paragraph">blah</p> </div> now think have wrong, i'm trying not keep messy. have <a name="h2">blah</a> to make work, or can doing, , missing something? with url fragments want target id, not class. change to: <div class="space" name="h2"> <h1 id="h2" class="h2">consulting</h1> <p class="paragraph">blah</p> </div> per mdn: a url fragment name preceded hash mark (#), specifies internal target location ( an id ) within current document. see also: http://ww...

finding line number of file using grep command Linux -

i have find 250th line of txt file not have comma using grep command. file has more 250 lines, have find 250th line not. example: imagine had 10 line file , looking 3rd line did not contain comma lines 1 , 2 not have comma lines 3-7 have comma line 8 not contain comma answer file line 8. i used command : grep -vn "," test.txt and looked 250th line, did following command see if line numbers same, , were. grep -n "this text 250th line" test.txt i don't think should case because 250th line of file without comma should not same line 250th line of regular file because regular file has many lines commas in them, line number should less. what wrong here? thank you. unfortunately, posix disagrees: $ man grep # ... -n, --line-number prefix each line of output 1-based line number within input file. (-n specified posix.) # ... what toss awk on: $ grep -v , text.txt | awk '{ if (nr == 250) { print } }'