Skip to content

Instantly share code, notes, and snippets.

View leigh-johnson's full-sized avatar

Leigh Johnson leigh-johnson

View GitHub Profile
hrldcpr /
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
andreyvit /
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

JeffPaine /
Created July 19, 2012 17:24
Make an issue on github using API V3 and Python
import json
import requests
# Authentication for user filing issue (must have read/write access to
# repository to add issue to)
# The repository to add this issue to
MrDys / gist:3512455
Created August 29, 2012 13:26
Link directly to an open modal window in Bootstrap
/* If you've ever had the need to link directly to an open modal window with Bootstrap, here's a quick and easy way to do it:
Make sure your modal has an id:
<div class="modal" id="myModal" ... >
Then stick this bit of Javascript at at the end of your document:
$(document).ready(function() {
paulkaplan / colorTempToRGB.js
Last active March 4, 2024 10:29
Color Temperature to RGB
// From
// Start with a temperature, in Kelvin, somewhere between 1000 and 40000. (Other values may work,
// but I can't make any promises about the quality of the algorithm's estimates above 40000 K.)
function colorTemperatureToRGB(kelvin){
var temp = kelvin / 100;
CMCDragonkai /
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
listochkin / node-command-line-options.txt
Created April 17, 2014 11:00
Node V8 GC-related options
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
rsmoorthy /
Created February 3, 2015 21:28
sails-hook-extmodel: Sails.js hook for extending Models

fw Extended Models

This hook extends the models, its definition and its behaviour.

For now, various features will get added in this hook. And we will migrate them to proper ones, as we go by.

Extended enum support

This feature extends the values of enum from other sources. Other sources could be:

garystafford /
Last active April 14, 2019 00:54
Use variables within your Docker Compose YAML file, using simple shell script and YAML template

For a small number of variables ('tokens'), I use a simple shell script along with a templated version of my YAML file. Here's an actual example: