Skip to content

Instantly share code, notes, and snippets.

[alias]
lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lg2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"
@staltz
staltz / _set_local_env_vars.py
Last active May 6, 2024 03:15
Call this from your Django settings file to import environment variables from '.env'. Useful if you use PyCharm and want an automatic solution to recognize your env variables.
import os
ENV_VARS_FILENAME = '.env'
def import_env_vars(project_root):
"""Imports some environment variables from a special .env file in the
project root directory.
"""
if len(project_root) > 0 and project_root[-1] != '/':
@staltz
staltz / .vimrc
Last active December 23, 2015 06:39
vim syntax highlighting for git-done TODO
" Append these to your .vimrc
syntax enable
au BufRead,BufNewFile *.todo setfiletype todo
au BufRead,BufNewFile TODO setfiletype todo
@staltz
staltz / gist:7473252
Last active May 6, 2024 03:15
Code glossary

Code glossary

A useful list of programming jargon to solve your naming problems.

Adapter: a design pattern that translates one interface for a class into a compatible interface.

Admin: short for 'administrator'; very commonly used in speech or online to refer to the systems person in charge on a computer. Common constructions on this include sysadmin and site admin (emphasizing the administrator's role as a site contact for email and news).

Counter: a variable or user interface that counts occurrences or repetitions of some phenomena or event.

@staltz
staltz / point-wise-err-handlers.js
Last active August 29, 2015 14:00
Q promises point-wise error handling
var Q = require('q');
function delaydo(x) {
var deferred = Q.defer();
setTimeout(function() {
if (x === 2) {
console.log("reject: "+x);
deferred.reject(x);
}
else {
@staltz
staltz / single-err-catcher.js
Created May 3, 2014 05:59
Q promises single error catcher
var Q = require('q');
function delaydo(x) {
var deferred = Q.defer();
setTimeout(function() {
if (x === 2) {
console.log("reject: "+x);
deferred.reject(x);
}
else {
@staltz
staltz / promises-pyramid.js
Created May 3, 2014 06:05
Q promises pyramid of doom
var Q = require('q');
function delaydo(x) {
var deferred = Q.defer();
setTimeout(function() {
if (x === 2) {
console.log("reject: "+x);
deferred.reject(x);
}
else {
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@staltz
staltz / delayUntil.xtend
Created September 24, 2014 17:10
.delayUntil() for RxJava
/**
* Delays all items from the source Observable up until when the other Observable
* emits its first item. After the other Observable emitted its first item,
* the source items are not delayed.
*
* source: ---s-s---s----------s---s----s---s---s--|>
* other: ------------o------o-------o------o-----|>
* result: ------------sss-----s---s----s---s---s--|>
*
* @param first
@staltz
staltz / gist:2f0704b1ecadc42fb0ab
Last active August 29, 2015 14:13
Cycle components decouple abstraction from implementation

Cycle custom elements decouple the component's abstraction from its implementation.

When you use a React component like

<div>
  <NewHotness />
</div>

You are pulling in that specific NewHotness component. You actually had to explicity import the NewHotness component before using it.