Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

David Cramer dcramer

💭
I may be slow to respond.
View GitHub Profile
@dcramer
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;
this.reset();
};
TimeSeriesRingBuffer.prototype.reset = function(){
this._buffer = new Array(this._size);
for (var i = 0; i < this._size; i++) {
this._buffer[i] = 0;
@dcramer
dcramer / pgbouncer.rb
Created Dec 16, 2014
Scout pgbouncer plugin
View pgbouncer.rb
class PgbouncerStats < Scout::Plugin
# need the ruby-pg gem
needs 'pg'
OPTIONS=<<-EOS
user:
name: Pgbouncer username
notes: Specify the username to connect with
password:
name: Pgbouncer password
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'),
View foo.md

Item List => Item => ItemStatusSelector

  • Need to maintain certain state in ItemStatusSelector (specifically have we "saved" the change, this is to avoid passing useless properties all over the place like itemStatusIsSaving)
  • Currenlty Item List controls item via prop, which controls item status via prop. This means we pass an onStatusChange all the way back to Item List.
  • [Re]flux seems to resolve this by using some store/action combo, but unclear if "Item" is in an "item list" store or if each item should be its own store, or how "change item status" should actually flow
@dcramer
dcramer / cleanup_redis_tsdb.py
Last active Aug 29, 2015
clean up data that should have been expired but wasnt
View cleanup_redis_tsdb.py
#!/usr/bin/env python
from sentry.utils.runner import configure
configure()
from datetime import datetime, timedelta
from sentry.app import tsdb
def cleanup_connection(connection, epoch):
def delete(key):
View mailgun.py
import logging
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
from email_reply_parser import EmailReplyParser
from email.utils import parseaddr
from sentry.tasks.email import process_inbound_email
View gist:f825896f3acfea9b5b73
api.assign() =>
AssignAction(...)
this.request('...')
.success(() => AssignSuccessAction())
.error(() => AssignErrorAction())
ThingStore =>
onAssign:
// we want to emulate a Set() for this
View gist:099511a7a8f9efab7517
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'sentry': {
View gist:93a088759f532c3a398f
>>> import subprocess
>>> proc = subprocess.Popen(['git', 'clone', 'git@github.com:getsentry/sentry.git', '/tmp/ds-repo-1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>>> print(proc.communicate())
("Cloning into '/tmp/ds-repo-1'...\n", None)
View django_cookies.py
"""
A two-part middleware which modifies request.COOKIES and adds a set and delete method.
`set` matches django.http.HttpResponse.set_cookie
`delete` matches django.http.HttpResponse.delete_cookie
MIDDLEWARE_CLASSES = (
'django_cookies.CookiePreHandlerMiddleware',
...
'django_cookies.CookiePostHandlerMiddleware',
You can’t perform that action at this time.