Skip to content

Instantly share code, notes, and snippets.

View kevinslin's full-sized avatar

Kevin Lin kevinslin

View GitHub Profile
@kevinslin
kevinslin / instal.txt
Created March 4, 2013 19:52
#unsorted Install application into mac
cd /Applications && curl http://www.ninjamonkeysoftware.com/slate/versions/slate-latest.tar.gz | tar -xz
import random
def compare_with_ties(a, b):
diff = cmp(a, b)
return diff if diff else random.choice([-1, 1])
a = {'a': 1, 'b': 2, 'c': 1, 'd':2, 'e': 1}
print "Initial dictionary:\n", str(a.iteritems())
import random
def compare_with_ties(a, b):
diff = cmp(a, b)
return diff if diff else random.choice([-1, 1])
a = {'a': 1, 'b': 2, 'c': 1, 'd':2, 'e': 1}
print "Initial dictionary:\n", str(a.iteritems())
@kevinslin
kevinslin / hello.random.java
Created March 8, 2013 13:43
#java #cool "Random" Hello world
// source: http://stackoverflow.com/questions/15182496/why-does-this-code-print-hello-world?newsletter=1&nlcode=83359%7c512e
System.out.println(randomString(-229985452) + " " + randomString(-147909649));
public static String randomString(int i)
{
Random ran = new Random(i);
StringBuilder sb = new StringBuilder();
for (int n = 0; ; n++)
@kevinslin
kevinslin / reoder_fields.py
Created May 4, 2013 13:23
#django #form #cookbook Reorder fields on django form
def __init__(self, *args, **kw):
super(EditProfileForm, self).__init__(*args, **kw)
index = self.fields.keyOrder.index('about')
self.fields.keyOrder.remove('majors')
self.fields.keyOrder.insert(index, 'majors')
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'

Node syntax

=== Syntax 1

def build():
  nodes = {}
  node['a'] = Node(...)
  node['b'] = Node(...)
 ...
memory max_idle_in_min
128 27
256 27
512 27
1024 27
1152 27
1280 27
1408 27
1536 27
1792 27