Skip to content

Instantly share code, notes, and snippets.

@olslash
olslash / gist:25ca5be554fca1689762
Created August 10, 2014 23:23
T9 blogpost - 1
var keys = {
'a': 2, 'b': 2, 'c': 2,
'd': 3, 'e': 3, 'f': 3,
'g': 4, 'h': 4, 'i': 4,
'j': 5, 'k': 5, 'l': 5,
'm': 6, 'n': 6, 'o': 6,
'p': 7, 'q': 7, 'r': 7, 's': 7,
't': 8, 'u': 8, 'v': 8,
'w': 9, 'x': 9, 'y': 9, 'z': 9
};
@olslash
olslash / gist:dd52c242a74f0daaa108
Last active August 29, 2015 14:04
budget observable
var createObservedObject = function(callback) {
var obj = {};
var args = [].slice.call(arguments, 1);
obj.addObservedProperty = function(propertyName) {
obj['_' + propertyName] = undefined;
Object.defineProperty(obj, propertyName, {
get: function() {
return obj['_' + propertyName];
var mergeSort = function(array) {
function merge(left, right) {
// merge two lists, which are assumed to be sorted.
left || (left = []);
right || (right = []);
var result = [];
while (left.length > 0 || right.length > 0) {
if (left.length > 0 && right.length > 0) {
// if both lists have values
@olslash
olslash / generatedtables
Last active August 29, 2015 14:03
fml chatroom schema
ysql> describe users;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| created_at | datetime | NO | | NULL | |
| updated_at | datetime | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
@olslash
olslash / LinkedList.py
Created June 19, 2014 17:43
babby's first linked list
class Node:
def __init__(self, val = None):
self.value = val
self.next = None
def printValues(self):
n = self
values = [n.value]
while n.next:
@olslash
olslash / console
Created June 16, 2014 21:11
Testing the console's representation of data
var externalObj = {key: 'value'};
var items = {
obj: {
'string prop': 'string val',
5: 10,
nested: [[3, [5, 2]]],
'function': function(){return true;},
reference: externalObj
},