Skip to content

Instantly share code, notes, and snippets.

View dcramer's full-sized avatar
💭
I may be slow to respond.

David Cramer dcramer

💭
I may be slow to respond.
View GitHub Profile
@primaryobjects
primaryobjects / hotspot-keep-alive.ps1
Last active April 13, 2024 15:53
Script to Enable Windows 10 Mobile Hotspot Automatically After Reboot
# https://superuser.com/a/1434648
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
@jrichardlai
jrichardlai / ErrorManager.java
Last active February 7, 2018 20:44
Bugsnag integration with React Native
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 October 22, 2018 09:02
Notify Sentry of a new release via Capistrano
# 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 December 21, 2015 20:39
Steps to get Sentry working over SSL on the JVM

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

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 August 24, 2020 09:25
Elasticat makes Elasticsearch JSON responses pretty • http://git.io/elasticat
.DS_Store
tmp/
@dcramer
dcramer / gist:5146800
Last active December 14, 2015 20:49
Code Review Quality/Performance Indicators

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 December 14, 2015 11:19
New Sentry Buffers
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:
@mattrobenolt
mattrobenolt / cramermath.py
Created February 28, 2013 02:23
David Cramer math
"""
cramermath
~~~~~~~~~~
Usage:
>>> import cramermath
>>> cramermath.log(10)
0.014728067495500818
"""
@dcramer
dcramer / heapqueue.py
Last active December 11, 2015 04:09
Refined Heap Queue for Python (including capped and max heap implementation)
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.