Skip to content

Instantly share code, notes, and snippets.

View r3b's full-sized avatar

ryan bridges r3b

  • Atlanta, Georgia
View GitHub Profile
@r3b
r3b / KeyStore.html
Created February 4, 2014 21:27
Playing with IndexedDB
<html>
<head>
<meta charset="utf-8">
<title>IndexedDB Tests</title>
<script>
function isFunction(f) {
return (f && f !== null && typeof(f) === 'function');
}
</script>
<script src="KeyStore.js"></script>
@r3b
r3b / defib.js
Created February 12, 2014 06:01
Turn a constant, erratic method execution into a nice, steady pace.
function defib(fn, space, scope) {
space || (space = 1000);
var queue = [], timer;
function start() {
if (queue.length) {
var exec = queue.shift(),
context = exec.context,
args = exec.args;
fn.apply(context, args);
} else {
@r3b
r3b / module.js
Created February 12, 2014 06:04
A nice, simple module container for the browser or Node.
//noinspection ThisExpressionReferencesGlobalObjectJS
(function (global) {
var name = 'MyModule',
short = '_m',
_name = global[name],
_short = (short !== undefined) ? global[short] : undefined;
function Module() {
/* put code in here */
@r3b
r3b / cassandra-install.sh
Last active July 3, 2017 18:59
install cassandra test instance
//Adapted from https://www.digitalocean.com/community/articles/how-to-install-cassandra-and-run-a-single-node-cluster-on-a-ubuntu-vps
USER=cassandra
GROUP=cassandra
mkdir ~/temp
cd ~/temp
wget http://www.us.apache.org/dist/cassandra/1.2.16/apache-cassandra-1.2.16-bin.tar.gz
tar -xvzf apache-cassandra-1.2.16-bin.tar.gz
mv apache-cassandra-1.2.16 ~/cassandra
sudo mkdir /var/lib/cassandra
sudo mkdir /var/log/cassandra
@r3b
r3b / partial.js
Last active January 4, 2021 16:11
A simple, tiny partial application function
/*
takes as parameters a method and any number of static arguments.
returns a function that will call the original function with these
arguments, plus any new arguments given
example:
function pow(exponent, base){
return Math.pow(base, exponent);
}
var square=partial(pow, 2);
@r3b
r3b / complement.js
Created April 24, 2014 15:31
Find the complement of two arrays
// returns things in array 'a' that are not in array 'b'
// > ['a','b','c','1', '2', '3'].complement(['b', 'c', 'd', 'e']);
// ['a', '1', '2', '3']
function complement(a, b){
(b)||(b=a, a=this);
return (Array.isArray(a) && Array.isArray(b))
? a.filter(function(x){return b.indexOf(x)===-1;})
: undefined;
}
Array.prototype.complement=complement;
@r3b
r3b / provision_docker.sh
Last active August 29, 2015 14:00
Script to provision Docker on an ubuntu VM
sudo apt-get install linux-image-extra-$(uname -r) -y
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:dotcloud/lxc-docker
sudo apt-get update
sudo apt-get install lxc-docker -y
@r3b
r3b / .bashrc
Created May 15, 2014 18:22
Prettifying the bash shell
alias vb="VBoxManage"
alias ls='ls -GFh'
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
fill="--- "
reset_style='\[\033[00m\]'
red_style='\[\033[00;31m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
@r3b
r3b / y.js
Created June 19, 2014 05:34
A Javascript Y-Combinator, with proper symbols.
var Y = function(ƒ) {
return (function(x) {
return ƒ(function λ(y) {
return (x(x))(y);
});
})
(function λ(x) {
return ƒ(function λ(y) {
return (x(x))(y);
});
@r3b
r3b / oracle_jdk_install.sh
Created July 17, 2014 16:28
non-interactive install for Oracle JDK
# Add the Oracle JDK Repos
UBUNTU_VERSION=precise
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu ${UBUNTU_VERSION} main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu ${UBUNTU_VERSION} main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
DEBIAN_FRONTEND="noninteractive" apt-get update
# Accept the Oracle License
echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" > /tmp/oracle-license-debconf
/usr/bin/debconf-set-selections /tmp/oracle-license-debconf