Posts

javascript - How to compare (contents of) color objects retrieved from HTML5 canvas via ctx.getImageData() -

i'd compare (a limited number of) color values retrieved html5 canvas. retrieve , store i'm interested in ctx.getimagedata(x, y, 1, 1).data; i tried use array.prototype.compare from: how compare arrays in javascript? by: // add same compare method uint8clampedarray uint8clampedarray.prototype.compare=array.prototype.compare; that works fine on recent firefox , chrome found not browsers return object of type uint8clampedarray. ie seems use object of canvaspixelarray , safari seems use simple 4-value array do have deal differences myself or there reliable generelized method (plain js or jquery) compare 2 such values retieved ctx.getimagedata() works on browsers? you can (probably?) use array compare method this: var comparisonresult = [].compare.call(yourpixels, colors); that code finds "compare" method array instance , invokes pixel array this value , other array (your colors) first parameter. this same thing: var comparisonresult = ...

ios - How can I verify that I am running on a given GCD queue without using dispatch_get_current_queue()? -

recently, had need function use guarantee synchronous execution of given block on particular serial dispatch queue. there possibility shared function called running on queue, needed check case in order prevent deadlock synchronous dispatch same queue. i used code following this: void runsynchronouslyonvideoprocessingqueue(void (^block)(void)) { dispatch_queue_t videoprocessingqueue = [gpuimageopenglescontext sharedopenglesqueue]; if (dispatch_get_current_queue() == videoprocessingqueue) { block(); } else { dispatch_sync(videoprocessingqueue, block); } } this function relies on use of dispatch_get_current_queue() determine identity of queue function running on , compares against target queue. if there's match, knows run block inline without dispatch queue, because function running on it. i've heard conflicting things whether or not proper use dispatch_get_current_queue() comparisons this, , see wording in headers: r...

Snap binary files upload -

i need understand file uploading process snap. given form: <form id="form" action="/files/upload" method="post" enctype="multipart/form-data"> <input type="file" id="files" name="files[]" multiple /> <button type="submit" onclick="handlefiles(e)">upload</button> </form> do use same functions getpostparams process binary files or use functions snap.util.fileuploads? i need upload , save binary files pdf in database. database driver accept bytestring store binary file. i went through snap.util.fileuploads not need. not sure how process in handler? thanks. edit with irc managed come below construct. think should close correct?? well, compiles , dumps file mongodb. can read back. although don't quite understand enumerators , iteratee stuff ... handlefiles :: apphandler () handlefiles = [file] <- handlemultipart defaultuploadpolicy $ \p...

gps - Why do I have to use cartesian coordinates in a perspective projection? -

in tutorial written, cartesian coordinates necessary perspective projection. let's have position of camera , object in spherical coordinates (longitude, latitude, altitude). why have transform them cartesian coordinates? possible calculate projection spherical coordinates? thanks

php - MySQL Query adding another condition -

Image
here query: select photos.* photos inner join follows on photos.userid=follows.followingid follows.followerid = $myid order photos.id desc limit 10 how add condition correctly can check photos user's id (using $myid variable)? update: added conditional in syntax provided in answer, shows images users you're following not own photos though. update 2: table structures: from question difficult gather how tables set up, may you're looking for: select photos.* photos left outer join follows on photos.userid=follows.followingid follows.followerid = $myid or photos.userid = $myid order photos.id desc limit 10 edit: see you're trying do, need left outer join include every result photos table, should work.

python - Numpy: Is it possible to display numbers in comma-separated form, like 1,000,000? -

this question has answer here: how print number commas thousands separators? 23 answers i have numpy array this: [ 1024 303 392 4847 7628 6303 8898 10546 11290 12489 19262 18710 20735 24553 24577 28010 31608 32196 32500 32809 37077 37647 44153 46045 47562 48642 50134 50030 52700 52628 51720 53844 56640 56856 57945 58639 57997 63326 64145 65734 67148 68086 68779 68697 70132 71014 72830 77288 77502 77537 78042 79623 81151 81584 81426 84030 86879 86171 89771 88367 90440 92640 93369 93818 97085 98787 98867 100471 101473 101788 102828 104558 105144 107242 107970 109785 111856 111643 113011 113454 116367 117602 117507 120910 121167 122150 123385 123079 125537 124702 130226 130943 133885 134308 ...

upload - Laravel 4 get image from url -

ok when want upload image. like: $file = input::file('image'); $destinationpath = 'whereever'; $filename = $file->getclientoriginalname(); $uploadsuccess = input::file('image')->move($destinationpath, $filename); if( $uploadsuccess ) { // save url } this works fine when user uploads image. how save image url??? if try like: $url = 'http://www.whereever.com/some/image'; $file = file_get_contents($url); and then: $filename = $file->getclientoriginalname(); $uploadsuccess = input::file('image')->move($destinationpath, $filename); i following error: call member function move() on non-object so, how upload image url laravel 4?? amy appreciated. i don't know if lot might want @ intervention library . it's intended used image manipulation library provides saving image url: $image = image::make('http://someurl.com/image.jpg')->save('/path/saveasimagename.jpg');