Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

David Cramer dcramer

I may be slow to respond.
Block or report user

Report or block dcramer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gulpfile.js
'use strict';
var gulp = require('gulp'),
gp_changed = require('gulp-changed'),
gp_clean = require('gulp-clean'),
gp_concat = require('gulp-concat'),
gp_filesize = require('gulp-filesize'),
gp_less = require('gulp-less'),
gp_rename = require('gulp-rename'),
gp_uglify = require('gulp-uglify'),
dcramer / pgbouncer.rb
Created Dec 16, 2014
Scout pgbouncer plugin
View pgbouncer.rb
class PgbouncerStats < Scout::Plugin
# need the ruby-pg gem
needs 'pg'
name: Pgbouncer username
notes: Specify the username to connect with
name: Pgbouncer password
dcramer / time-series-ring-buffer.js
Last active Aug 29, 2015
JavaScript time-series ring buffer
View time-series-ring-buffer.js
var TimeSeriesRingBuffer = function(size) {
this._lastTS = 0;
this._size = size;
TimeSeriesRingBuffer.prototype.reset = function(){
this._buffer = new Array(this._size);
for (var i = 0; i < this._size; i++) {
this._buffer[i] = 0;
dcramer / gist:7728286
Created Dec 1, 2013
find oldest file in directory
View gist:7728286
find -type f -printf '%T+ %p\n' | sort -r | head -1
View responses.rst
import responses

def test_my_api():
    responses.add(responses.GET, '',
                  body='{"error": "not found"}', status=404,
View gist:7330744
# supervisor
command=uwsgi --addr=
# when you restart it does them in batches, instead of one at a time
$ sudo supervisorctl restart sentry
- stops all 10 procs
View gist:6775018
var Changes = angular.module('Changes', ['ngAnimate', 'ngRoute']).
config(['$routeProvider', function($routeProvider) {
when('/', {
templateUrl: 'partials/change-list.html',
resolve: {
initialData: function($http) {
return $http.get('/api/0/changes/');
View gist:6774625
<section ng-controller="ChangeListCtrl">
<table class="change-list table table-striped">
<tr class="status-{{}} result-{{}}"
ng-repeat="change in changes | orderBy:dateModified:true" ng-animate="'animate-fade'">
<div class="indicator" title="{{}}">
<div data-result="{{}}"
data-value="{{change.lastBuild.progress}}" ng-radial-progress-bar>&nbsp;</div>
dcramer / gist:6682862
Created Sep 24, 2013
TIL use 'while 1' instead of 'while True'
View gist:6682862
dcramer:buildbox in ~/Development/buildbox on git:master
$ python -m timeit '(True and "pass")'
10000000 loops, best of 3: 0.0512 usec per loop
dcramer:buildbox in ~/Development/buildbox on git:master
$ python -m timeit '(True and "pass")'
10000000 loops, best of 3: 0.049 usec per loop
dcramer:buildbox in ~/Development/buildbox on git:master
$ python -m timeit '(True and "pass")'
View gist:6568624
$ pip install --help
pip install [options] <requirement specifier> ...
pip install [options] -r <requirements file> ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...
You can’t perform that action at this time.