Skip to content

Instantly share code, notes, and snippets.

View jleeothon's full-sized avatar

Johnny Lee-Othon jleeothon

  • Wunderflats
  • Berlin
View GitHub Profile
@jleeothon
jleeothon / min.rb
Created March 31, 2015 19:28
Minimum distance between clusters of nodes
class Node
def distance_to cluster
self.reduce(nil) do |min, i|
cluster.reduce(min) do |min, j|
d = i.distance_to j
min = if min.nil? or min > d then d else min end
end
end
end
end
@jleeothon
jleeothon / repeatexperiment.vb
Created April 17, 2015 13:43
Repeat a certain experiment for queue models
Sub RepeatExperiment()
'
' RepeatExperiment Macro
'
'
For i=0 To 40
Sheets("Simulación").Select
Sheets("Simulación").Copy After:=Sheets(Sheets.Count)
Range("B2").Select
@jleeothon
jleeothon / methodmissinghash.rb
Created April 19, 2015 23:59
Ruby dynamically resolve names from a hash
def respond_to? method_sym, include_private = false
if @a.has_key? method_sym
true
else
super method_sym, include_private
end
end
def method_missing method_sym, *arguments, &block
if @a.has_key? method_sym
@jleeothon
jleeothon / cortobootstrap.sh
Last active December 30, 2015 19:56
Set up Corto playground
workspaceparent="$HOME"
cd $workspaceparent
mkdir cortoproject
cd cortoproject
git clone https://github.com/cortoproject/corto
git clone https://github.com/cortoproject/c-binding
git clone https://github.com/cortoproject/xml
git clone https://github.com/cortoproject/corto-language
git clone https://github.com/cortoproject/io
@jleeothon
jleeothon / pyvenv-ubuntu.sh
Created December 12, 2015 23:29
pyvenv for ubuntu (apparently it's broken in 14.04) in cloud9
# I use this script in cloud9
/usr/bin/python3 -m venv --without-pip env
source env/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source env/bin/activate
workspaceparent="$HOME"
# needs to be run after cortobootstrap.sh
cd "$workspaceparent/cortoproject"
git clone https://github.com/cortoproject/python-binding
cd python-binding
# virtual environment
python3 -m venv --without-pip env
source env/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
@jleeothon
jleeothon / todaysentry.sh
Created May 13, 2016 09:24
Create a markdown file with today's date
touch `date +"%Y.%m.%d.md"`
# Rake Quick Reference
# by Greg Houston
# http://ghouston.blogspot.com/2008/07/rake-quick-reference.html
# -----------------------------------------------------------------------------
# Running Rake
# -----------------------------------------------------------------------------
# running rake from the command-line:
# rake --help
@jleeothon
jleeothon / project-manager.coffee
Created August 23, 2016 19:35
project-manager.coffee
default_template:
title: "Default"
settings:
"*":
"editor.tabLength": 4
".source.coffee":
"editor.tabLength": 2
".source.ruby":
"editor.tabLength": 2
alfiebox:
#!/bin/bash
# tip: run with `./hashes.sh | column -t`
set -eu
for g in `find . -name .git`
do
d=$(basename $(dirname $g))
h=$(git --git-dir $g rev-parse HEAD)