This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE pgbench_accounts | |
ADD created_on timestamptz, | |
DROP CONSTRAINT pgbench_accounts_pkey; | |
CREATE UNIQUE INDEX ON pgbench_accounts(aid, created_on DESC); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import re | |
import json | |
import time | |
import uuid | |
import email | |
import types | |
import socket | |
import logging | |
import datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include "src/uthash.h" | |
struct my_struct { | |
int id; /* we'll use this field as the key */ | |
char *name; | |
UT_hash_handle hh; /* makes this structure hashable */ | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
define([ | |
'react', | |
'modernizr', | |
'punycode' | |
], function(React, Modernizr, punycode) { | |
/** | |
* Replaces the emojis in a text string with <img> tags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dl(url) { | |
var imageUrl = url + "?n=" + Math.random(); | |
var startTime, endTime; | |
var download = new Image(); | |
download.onload = function () { | |
endTime = (new Date()).getTime(); | |
var duration = (endTime - startTime); | |
console.log(url+" >"+ duration); | |
_gaq.push(['_trackEvent', 'Speedtest','CDN', url, duration]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
export APP_NAME=$1 | |
export PGHOST=$(< $HOME/predeploy.d/postgres_host) | |
export PGUSER=admin | |
if [ -f $HOME/$APP_NAME/DATABASE_URL ]; then | |
# Database URL is already set - DB must exist | |
DATABASE_URL=$(cat $HOME/$APP_NAME/DATABASE_URL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_chpwd() | |
{ | |
if [[ -s "$PWD/set_env" ]] ; then | |
source "$PWD/set_env" | |
echo '(automatically sourced set_env)' | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.production? | |
PAYPAL_ACCOUNT = '[email protected]' | |
else | |
PAYPAL_ACCOUNT = '[email protected]' | |
ActiveMerchant::Billing::Base.mode = :test | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
# The hidden singleton lurks behind everyone | |
def metaclass; class << self; self; end; end | |
def meta_eval &blk; metaclass.instance_eval &blk; end | |
# Adds methods to a metaclass | |
def meta_def name, &blk | |
meta_eval { define_method name, &blk } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APP_NAME="your-app-name-goes-here" | |
APP_PATH=/home/deploy/${APP_NAME} | |
# Production environment | |
export RAILS_ENV="production" | |
# This loads RVM into a shell session. Uncomment if you're using RVM system wide. | |
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm" |
NewerOlder