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
@jrichardlai
jrichardlai / ErrorManager.java
Last active Feb 7, 2018
Bugsnag integration with React Native
View ErrorManager.java
import android.util.Base64;
import android.util.Log;
import com.bugsnag.android.Bugsnag;
import com.bugsnag.android.MetaData;
import com.bugsnag.android.Severity;
import com.facebook.react.bridge.*;
import java.io.File;
import java.io.InputStream;
@cannikin
cannikin / deploy.rb
Last active Oct 22, 2018
Notify Sentry of a new release via Capistrano
View deploy.rb
# This task will notify Sentry via their API[1] that you have deployed
# a new release. It uses the release timestamp as the `version`
# (like 20151113182847) and the git ref as the optional `ref` value.
#
# This task requires several environment variables be set (or just
# hardcode the values in here if you like living on the edge):
#
# ENV['SENTRY_API_ENDPOINT'] : API endpoint, https://app.getsentry.com
# ENV['SENTRY_ORG'] : the organization for this app
# ENV['SENTRY_PROJECT'] : the project for this app
@eric
eric / README.md
Last active Dec 21, 2015
Steps to get Sentry working over SSL on the JVM
View README.md

Sentry and the JVM

Unfortunately Java's built-in cacerts do not include StartCom SSL root certificates.

Because of this, you must tell java to trust these certificates.

The easiest way I've found to do it is as follows:

1. Make a copy of the JRE cacerts

View gist:5960871
import django.db
import collections
all_models = django.db.models.get_models()
def find_deps(models):
""" return a dict of {model : [all dependent models] """
deps = collections.defaultdict(set)
name_to_model = {}
for model in models:
@karmi
karmi / .gitignore
Last active Jul 16, 2016
Elasticat makes Elasticsearch JSON responses pretty • http://git.io/elasticat
View .gitignore
.DS_Store
tmp/
@dcramer
dcramer / gist:5146800
Last active Dec 14, 2015
Code Review Quality/Performance Indicators
View gist:5146800

Questions to answer:

  • Is it a productivity hit?
  • What happens when only new hires are required to do code review?
  • How bad at large patches?
  • What about lack of automated tests?
  • Does a lot of back and forth (e.g. comments) indicate problems?
  • Does assigning more people (or less) to reviews improve anything?
  • How does a person spending more time committing (vs reviewing) affect the team?
@dcramer
dcramer / gist:5078280
Last active Dec 14, 2015
New Sentry Buffers
View gist:5078280
When an update comes into the system we fire off something like the following:
>>> app.buffer.incr(
>>> Group, # model class,
>>> {'times_seen': 1}, # counters
>>> {'id': group.id}, # filter restrictions, sometimes a composite key
>>> {'last_seen': now}, # metadata to update when buffer is processed
>>> )
This would get stored in a hash key as following:
View cramermath.py
"""
cramermath
~~~~~~~~~~
Usage:
>>> import cramermath
>>> cramermath.log(10)
0.014728067495500818
"""
@dcramer
dcramer / heapqueue.py
Last active Dec 11, 2015
Refined Heap Queue for Python (including capped and max heap implementation)
View heapqueue.py
import heapq
from threading import Lock
class HeapQueue(object):
def __init__(self, values=None, maxsize=None, reversed=False):
"""
Create a new heap queue.
- ``maxsize`` will create a capped queue.
@piscisaureus
piscisaureus / pr.md
Created Aug 13, 2012
Checkout github pull requests locally
View pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

You can’t perform that action at this time.