Skip to content

Instantly share code, notes, and snippets.

@nickjacob
nickjacob / str_to_bin.py
Created December 5, 2011 17:50
simple python script to convert string to binary ASCII with each character on a new line
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:
@nickjacob
nickjacob / autotest.sh
Created December 11, 2011 18:29
Shell script to automate testing of java compiler run w/ ant
#!/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
// 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')
@nickjacob
nickjacob / quicksortjs.md
Created July 13, 2012 17:36
Quicksort implemented in javascript

Quicksort in Javascript

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:

Source:

(function(window){

	function quicksort(func){
@nickjacob
nickjacob / FileServing.php
Created July 27, 2012 17:44
Simple Static PHP File Serving
<?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);
@nickjacob
nickjacob / asynchCaller.js
Created August 3, 2012 20:31
A little javascript that lets you setup calls to a script that you aren't sure has loaded yet. You could load this script in too
/**
* 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];
@nickjacob
nickjacob / lilball.js
Created August 22, 2012 02:18
I wrote this for something else because I realized I was using jQuery just for Ajax bc I was too lazy to learn the actual DOM API for XHR.. This is Smaller.
/***
* lil' ball
* this isn't even a library. I just realized that I'd been using jQuery *only* because
* I needed an easy way to do ajax. So I finally got my sh** together an just wrote smtng.
*
* author: @nickjacob
***/
;(function(window,undefined){
window._o_ = window._o_ || {};
@nickjacob
nickjacob / template.js
Created September 20, 2012 01:12
Basic Javascript Template
/**
* This is my own idea of how I wish all javascript files looked. I don't think it's probably the "best" way (is there a *best* way?), but I like it
* and I think everyone should have some kind of style.
*/
// name the IIFE for debugging/organization if you want to use a concatenation build tool
;(function this_module(window,undefined){
var _public = {}, _private = {}; // if only it were real!!! Fun fact -- "public" is reserved!
@nickjacob
nickjacob / x86_orgasm.s
Created October 22, 2012 01:54
Orgasm on 32-bit x86 Arch
# Lusty Data
# A Computer Orgasm
# @author nickjacob
#
.excitement
movl $1, %eax
.rising
cmpl $0, %eax
je .climax
@nickjacob
nickjacob / back_to_rockets.vim
Created October 22, 2012 23:40
vim regexp to convert 1.9 hash syntax to 1.8
:%s/\s\([_a-z]*\):\s/:\1 => /gi