Posts

algorithm - Compress an ordered sequence of uint32 -

given array of unique uint32 ordered fixed-width'ed sequence , size can vary thousand million, what's options there compress minimal size? start replacing note of first value , array of differences between successive values. easiest thing run general purpose compression algorithm zip on array of differences. if wanted scratch might try encoding differences http://en.wikipedia.org/wiki/elias_omega_coding , using http://en.wikipedia.org/wiki/huffman_coding on result, treated byte stream or perhaps stream of 16-bit values.

sql - How can you expand a "condensed" PostgreSQL row into separate columns? -

i have function returns table. if run select * some_function(12345) result is: object_id | name ---------------- 12345 | "b" if run select some_function(12345) result is: some_function ------------- (12345,"b") the problem want original form (so can access individual column values), have argument some_function() come column in table. can execute select some_function(thing_id) things returns: some_function ------------- (12345,"b") (12346,"c") (12347,"d") whereas want returned is: object_id | name ---------------- 12345 | "b" 12346 | "c" 12347 | "d" so how can 1 "unnest" or "expand" such condensed row? in postgresql 9.3 or newer use implicit lateral query: select f.* things t, some_function(t.thing_id) f; prior versions, causes multiple-evaluation of some_function : select (some_function(thing_id)).* things;

Perforce: Deleting Multiple Workspaces Through Command LIne -

is there command line option, in perforce, delete multiple workspaces @ once? i have many workspaces not in use anymore. run command can delete workspaces - workspace name can input string txt file. possible? being new p4, have tried (and failed) far is: p4 -x client -d -f c.txt "c.txt" text file contains list of workspaces deleted. thanks. the -x flag says read perforce commands file line line. in case you're asking read commands file named "client". i think intended change c.txt list of clients deleted bunch of lines saying: client -d -f client1 client -d -f client2 ... that allow use command p4 -x c.txt

ios - Azure Notification Hub Registered Device list -

Image
i following this post work azure notification hub. trying creating web api registers devices azure notification hub. when send request registering device shown in article hits azure notification hub. below screen shot of azure portal. shows there request registration. but when try details of registered devices using following code 0. var registrationscount = await hub.getallregistrationsasync(int32.maxvalue); return registrationscount.count().tostring(); now have few questions : 1 ) how can explore registered device details ? 2 ) how can send test notification ios devices end. below code using send test notifications. var payload = string.format(toasttemplate, message); hub.sendapplenativenotificationasync(payload, "worldnews"); 3 ) if using web api end necessary configure ios app details in azure notification hub ? i.e uploading certificate , other details on azure portal ? your first problem how calling getallregistrationsasync . parame...

javascript - How to find the name of variable where object is created? -

i have object called 2 different variables. there way find out - inside object function - variable calling it? sp = new selectedplaylists("tableselectedplaylists"); sa = new selectedplaylists("tableselectedalbums"); these 2 variables i think create variable inside selectedplaylists class determine type of playlists , pass trhough constructor: sp = new selectedplaylists("tableselectedplaylists", "p"); sa = new selectedplaylists("tableselectedalbums", "a"); in consctructor: function selectedplaylists(id, type) { // ... code ... var managetype=type; var buttonlabel=''; switch(type) { case 'p': // playlist mode this.buttonlabel='remove playlist'; case 'a': // album mode this.buttonlabel='remove album'; } } store second param in variable (for example managetype ) , use when needed (tak...

javascript - Revert getElementsByClassName to original browser version -

i'm working on existing web page has sorts of javascript i'm not able edit. have access part of page stuff. problem using jquery. previous developer had modified getelementsbyclassname method custom version, i'm assuming kind of polyfill ie. breaks jquery uses getelementsbyclassname on supported browsers. now how may revert getelementsbyclassname original version before code executed. can't find original method anywhere online. not using jquery not option i'm trying integrate big piece of code written jquery. thanks. since prototype chain of document wasn't altered, restore deleting current implementation, mentioned in comments: delete document.getelementsbyclassname; demo that make implementation available again via prototype chain. old answer you try restore hack: document.getelementsbyclassname = document.documentelement.getelementsbyclassname .bind(document.documentelement); i'm not whether has downsides, though. ...

javascript - typeahead.js : How to remove value when value not in suggestion -

i use typeahead.js autocomplete textbox. at first, when input , select value suggestions, textbox sets value correctly. then, input value not in suggestions , press tab , value of textbox doesn't clear. how clear value of textbox when input value not in suggestions. i ran same situation , way solved using events of typeahead.js . record selection on typeahead:select , check on typeahead:change if selection made. if no selection made, reset input original value. // initialize typeahead ususal var $mytypeahead = $("#my-typeahead"); $mytypeahead.typeahead(/* set-up typeahead here */); // set variables store selection , original // value. var selected = null; var originalval = null; // when typeahead becomes active reset these values. $mytypeahead.on("typeahead:active", function(aevent) { selected = null; originalval = $mytypeahead.typeahead("val"); }) // when suggestion gets selected save $mytypeahead.on(...