Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@nesquena
nesquena / basic.sql
Created September 7, 2011 01:56
PostgreSQL Common Utility Queries
/* How to calculate postgreSQL database size in disk ? */
SELECT pg_size_pretty(pg_database_size('thedbname'));
/* Calculate size of a table including or excluding the index */
SELECT pg_size_pretty(pg_total_relation_size('big_table'));
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */
/* See indexes on a table with `\d tablename` */
@derwiki
derwiki / .gitconfig
Created November 22, 2011 06:35
Fancy .gitconfig you can grow into
[log]
decorate = short
[color]
ui = auto
[pager]
status = true
show-branch = true
[rebase]
autosquash = true
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
# ~/.gitconfig from @boblet
# initially based on http://rails.wincent.com/wiki/Git_quickstart
[core]
excludesfile = /Users/oli/.gitignore
legacyheaders = false # >git 1.5
quotepath = false
# http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
pager = less -r
# if ↑ doesn’t work, try: pager = less -+$LESS -FRX
@andrewle
andrewle / leader-election.md
Created April 16, 2012 02:06 — forked from ryandotsmith/process-partitioning.md
Leader Election With Ruby & PostgreSQL

Leader Election With Ruby & PostgreSQL

The Problem

I have a table with millions of rows that needs processing. The type of processing is not really important for this article. We simply need to process some data with Ruby --or any other user-space programming language.

A Solution

@tobyhede
tobyhede / postsql.sql
Created May 17, 2012 03:08
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@myrne
myrne / FSEventStreamCreateFlags
Created August 11, 2012 09:08
OS X FSEvent flags
kFSEventStreamCreateFlagNone = 0x00000000
kFSEventStreamCreateFlagUseCFTypes = 0x00000001
kFSEventStreamCreateFlagNoDefer = 0x00000002
kFSEventStreamCreateFlagWatchRoot = 0x00000004
kFSEventStreamCreateFlagIgnoreSelf = 0x00000008
kFSEventStreamCreateFlagFileEvents = 0x00000010
var Bacon = require('baconjs').Bacon,
_ = require('underscore'),
add = new Bacon.Bus,
remove = new Bacon.Bus,
compose = function(fn) {
return function (val) {
return function(ctx) {
return fn(ctx, val);
}
}
@elasticdog
elasticdog / gist:4660155
Last active December 11, 2015 21:09
AWS S3 Bucket Policy to Deny Hotlinking Images
{
"Version": "2008-10-17",
"Id": "http referer policy",
"Statement": [
{
"Sid": "Allow GET requests",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},