Webkit's Array.sort()
is implemented in c++ as selectionsort. For some variety (and a better time complexity in big arrays), I wrote up an implementation of quicksort:
(function(window){
function quicksort(func){
/** | |
* Sometimes you're working with a script hosted on a server that you can't be sure is going to ever return/you don't know when | |
* this script lets you make calls to the object it is eventually going to add to the window object before it's there. | |
* this is (probably) very similar to the code behind google analytic's _gaq.push() | |
*/ | |
(function(watch_list,future_obj,interval){ | |
var noop = function(){}, _func_ = 'function'; | |
var __asynch = function(list,obj,intr){ | |
this.intr=(typeof intr==='number') ? intr : 500;this.loop=null;this.obj = obj; this.calls = [];var self = this; list = list || []; | |
for(var i=0,l=list.length;i <l;i++) this.calls[i] = list[i]; |
<?php | |
/** | |
* Simple File server for php | |
* this is in response to this: | |
* http://stackoverflow.com/questions/8792871/using-custom-url-rewrite-in-drupal-for-static-files | |
* --- | |
* in the process of using it I found a lot of places to refactor/clean it up, and correct some things | |
*/ | |
define('CHUNK_SIZE',1048576); |
// App.js | |
// the main logic of the application. | |
// this handles pretty much everything that goes on | |
// author: nickjacob | |
// generate faux-guid | |
function S4() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); }; | |
function guid() { return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); }; | |
// actual app | |
var Express = require('express') |
#!/bin/bash | |
# author: nbjacob | |
OUTLINE="===========================================" | |
echo $OUTLINE | |
echo $OUTLINE | |
echo "STARTING AUTO TEST" | |
for a in ${@}; do | |
echo "TESTING DIR: $a" | |
for f in $(ls $a/*.bl); do | |
# read header of test |
def toBin(s): | |
# removes space characters, puts each ascii code on a new line | |
print "\n".join(filter(lambda x:x!="100000",[bin(ord(c))[2:] for c in s])) | |
if __name__ == "__main__": | |
s = input("enter a string: \n") | |
toBin(s) | |
# or: |