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 / Vagrantfile
Last active August 29, 2015 14:08
Vagrant setup to run one cassandra and one elasticsearch server
# -*- mode: ruby -*-
# vi: set ft=ruby :
CFG_TZ = "US/Eastern"
# Provisioning script
node_script = <<SCRIPT
#!/bin/bash
dpkg -l oracle-java7-installer
[ $? -eq 0 ] && exit 0
<!DOCTYPE html>
<html>
<head>
<title>Update Test</title>
<script src="./js/usergrid.js"></script>
<script type="text/javascript">
var restaurants;
@r3b
r3b / longest_line.awk
Created August 14, 2014 16:28
Various file stats from the command line
awk '{ if ( length > x ) { x = length } }END{ print x }' $1
@r3b
r3b / Stringify.go
Created July 22, 2014 21:30
Turn any Go interface{} into a string
package stringify
import(
"fmt"
"reflect"
)
func Stringify(v reflect.Value) string {
var str string
switch v.Kind() {
case reflect.Func:
case reflect.Map:
@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
@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 / .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 / 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 / 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 / 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);