Skip to content

Instantly share code, notes, and snippets.

@weargoggles
weargoggles / gist:b71ea58342640e544f6e
Created October 23, 2014 11:55
Install dependencies for Sentry
sudo apt-get update
sudo apt-get install libpq-dev redis-server python-dev build-essential python-psycopg2 python-virtualenv postgresql-9.1 supervisor
import os
import tornado.httpserver
import tornado.ioloop
import tornado.wsgi
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
def main():
# Bind to PORT if defined, otherwise default to 5000.
from functools import update_wrapper
from django.conf.urls import patterns, url, include
from django.contrib import admin
# Register your models here.
from django.contrib.admin.utils import quote
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.admin import csrf_protect_m
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwbkJky1DezPNw6mCN4MXb4sz7kq5Jjh0+RamokaRIR7PGZQ8lL/F2ZR+tjdc/RMm60442cz8yuM7LBC1ys9nJzexl50WuaX2jq8T+LhQIXaUWPWjlpMV/LKbKN3wCztEJIgXH/ZwpPwe4AgmC9hLe7wL1p4RBlqzyargill4TlAO3xBgEHlGNoJH08BLoIyj4s7wXnWaEtb/yqkH3VEfL1+PrI6f3NLvqSxPO2JockqrnywLAXhq7/Xu9ENfDGS0kCQn1v/VMfGJm7gnX53Tw/2liL/+r06AhHAJLvO+otbZu9MT1F8EmTFfmFemrewGW6T8Ypkco/nQBKfGLUHwYw== pete
coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
# uncomment the following line and replace it with your discovery URL
# discovery: SOME_DISCOVERY_URL
# Source Debian/Ubuntu bash completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Source Apple-style bash completion and prompting
if [ -f /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash ]; then
. /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
. /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
fi
@weargoggles
weargoggles / gist:0e8d2753a709e91b1fd9
Last active August 29, 2015 14:17
profiling python with cprofile
# I'm pretty sure this would work without writing to any files,
# but you'd need somewhere to stream the output.
try:
import cProfile as profile
except ImportError:
import profile
import pstats
import time
@weargoggles
weargoggles / lcm.js
Created September 15, 2015 14:30
lowest common multiple of numbers less than another number
function gcd(a, b) {
var a_ = a;
var b_ = b;
while (a_ != 0 && b_ != 0) {
if (a_ > b_) {
a_ = a_ % b_;
} else {
b_ = b_ % a_;
}
}
@weargoggles
weargoggles / gist:da537305078b7161018a
Created December 9, 2015 11:59
csv from postgres
[pete@cassandra 11:58:11]
[/home/pete/]$ psql minor_planets -c 'copy (select * from orbits limit 100) to stdout csv header' | head
designation_raw,magnitude,slope,epoch_raw,mean_anomaly,argument_of_perihelion,longitude_ascending,inclination,eccentricity,mean_daily_motion,semimajor_axis,uncertainty,reference,observations,oppositions,year_first_obs_or_arc_length,year_last_obs_or_days,residual,coarse_perturbers,precise_perturbers,computer,readable
00001 ,3.34,0.12,K14C9,95.98921,72.52200,80.32927,10.59338,0.0758228,0.21407760,2.7675059,0,MPO309141,6532,107,1802,2014,0.60,M-v,30h,MPCLINUX , (1) Ceres
00002 ,4.13,0.11,K14C9,78.22871,309.93032,173.09624,34.84100,0.2312737,0.21360273,2.7716062,0,MPO319080,7712,103,1821,2014,0.58,M-v,28h,MPCLINUX , (2) Pallas
00003 ,5.33,0.32,K14C9,33.07717,248.40995,169.87117,12.98166,0.2554482,0.22582205,2.6707003,0,MPO319080,6660,101,1821,2014,0.60,M-v,38h,MPCLINUX , (3) Juno
00004 ,3.20,0.32,K14C9,20.86389,151.19843,103
const (action_type, delay) => store => next => {
let last = performance.now() - delay;
return action => {
let now;
if (action.type === action_type) {
now = performance.now();
if (now - last > delay) {
last = now;
return next(action);