View trie.py
class Node:
def __init__(self, label=None, data=None):
self.label = label
self.data = data
self.children = dict()
def addChild(self, key, data=None):
if not isinstance(key, Node):
self.children[key] = Node(key, data)
else:
View lightsail-docker.sh
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install -y docker-engine
sudo service docker start
sudo docker pull php:5.6-apache
View .gitconfig
[alias]
dt = difftool
mt = mergetool
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
cmd = \"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\"
[difftool "p4"]
View getCommandLineArgumentsInNode.js
/* Example: Say you run this from the command line:
node myscript.js -color blue -names joe jenny -month september
You can get the arguments in your script by calling the following method as such:
var color = getCmdLineArgument("-color") //returns "blue"
var names = getCmdLineArgument("-names", 2) //returns ["joe", "jenny"]
var month = getCmdLineArgument("-month") //returns "september"
var ghost = getCmdLineArgument("-ghost") //returns null
View AddParametersToThis.html
<html>
<head>
<script>
"use strict";
class BaseClass {
//Adds the parameters of a method to the context (this)
addParametersToThis() {
var parameters = this.getFunctionParameterNames(this.constructor);
View mongoGroupAggregateHelper.js
let Group = {
/*
* Description:
* Creates a $group object for Mongo aggregate that adds all the properties
* of a Model object and any other additions.
*
* Sample usage:
* MyCoolModel.aggregate({$match:{..}, {$group:Group.withModel(MyCoolModel, {count: { $sum: 1 }})} })
*
* Parameters:
View bash-cheatsheet.sh
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
View killprocs.sh
#!/bin/bash
# ex: ./killprocs.sh Process1,Process2,Process3
# set the "internal field separator" variable (delimiter)
IFS=','
# read the delimited line into an array
read -ra PROCS <<< "$1"
# loop through the array
for i in "${PROCS[@]}"; do
# get the PID of the process
View zsh_on_ubuntu.md

Prereq:

apt-get install zsh
apt-get install git-core

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | zsh
View Diff Backup Drives.sh
#Step One: Get the raw diffs... usually takes me an hour
grep -rq dir1 dir2 > rawdiffs.txt
#Step Two: Filter out the junk
grep Only rawdiffs.txt | grep -v '.Spotlight' | grep -v '.fseventsd' | grep -v '.DocumentRevisions' | grep -v '.DS_Store' | grep -v '.TemporaryItems' | sort > filteredDiffs.txt