Skip to content

Instantly share code, notes, and snippets.

from sentry.app import tsdb
from datetime import timedelta
end = timezone.now()
month_event_total = tsdb.get_sums(
model=tsdb.models.internal,
keys=['events.total'],
start=end - timedelta(days=30),
end=end
)['events.total']
@ehfeng
ehfeng / contributor_count.py
Created April 28, 2017 01:21
Sentry OSS Contributors
import requests
usernames = set()
repos = set(['sentry', 'sentry-plugins' , 'sentry-docs', 'sentry-php', 'raven-python', 'raven-java', 'symbolserver', 'sentry-swift', 'raven-js', 'sentry-symfony', 'react-native-sentry', 'raven-node', 'sentry-elixir', 'raven-ruby', 'sentry-cli', 'fastlane-plugin-sentry', 'homebrew-tools', 'raven-csharp', 'sentry-laravel', 'sentry-auth-github', 'sentry-relay', 'sentry-rust', 'raven-aiohttp', 'sentry-gitlab', 'raven-swift', 'sentry-objc', 'sentry-irc', 'perl-raven', 'sentry-auth-google', 'sentry-orbital', 'sentry-trello', 'sentry-youtrack', 'sentry-zendesk-app', 'sentry-bitbucket', 'sentry-jira', 'sentry-pushover', 'sentry-github', 'sentry-pivotal', 'sentry-hipchat-ac', 'sentry-pagerduty', 'sentry-teamwork', 'raven-objc', 'sentry-redmine', 'raven-php', 'sentry-phabricator', 'sentry-flowdock', 'raven-django', 'sentry-webhooks'])
for repo in repos:
for contrib in requests.get('https://api.github.com/repos/getsentry/%s/contributors' % repo).json():
usernames.add(contrib['lo
from threading import Thread
import time
def stuff():
print('in thread')
time.sleep(0.5)
print('ending thread')
t = Thread(target=stuff)
t.setDaemon(True)
@ehfeng
ehfeng / app.py
Created July 30, 2018 22:52
Scrubbing sensitive data with Sentry's Python SDK
from flask import Flask
from raven.contrib.flask import Sentry
app = Flask(__name__)
# To remove all client-side processors
# app.config['SENTRY_PROCESSORS'] = tuple()
# To specify which processors you'd like to use (because the raven flask plugin does not allow for a `processor` arg)
# app.config['SENTRY_PROCESSORS'] = ('raven.processors.SanitizePasswordsProcessor', )
{"code": "var Raven = require('raven');\nRaven.config('https://[email protected]/1257305').install();\ntry {\n doAnotherThing(a[0]);\n} catch (e) {\n Raven.captureException(e);\n}"}
echo "{\"filename\": \"main.py\", \"code\": \"from raven import Client\n\nclient = Client('https://c3a66f7b59044173b7f0e7cf8367a6a5:[email protected]/1257305')\n\ntry:\n 1 / 0\nexcept ZeroDivisionError:\n client.captureException()\n\nprint('testing print')\n\"}" | http POST https://us-central1-hackweek-fastrack.cloudfunctions.net/python-eval
package main
import (
"fmt"
"time"
"github.com/ry/v8worker2"
)
var script string = `
package main
import (
"fmt"
"log"
"math/rand"
"time"
v8 "rogchap.com/v8go"
)
@ehfeng
ehfeng / nginx.conf
Created July 10, 2022 21:11
Mapping requests to localhost servers based on Accept header
events {
worker_connections 1024;
}
http {
map $http_accept $accept {
default app;
~text/html web;
}
@ehfeng
ehfeng / bigint.go
Created October 15, 2022 21:40
BigInt
package bigint
import (
"encoding/json"
"errors"
"strconv"
"gopkg.in/guregu/null.v4"
)