Skip to content

Instantly share code, notes, and snippets.

View samuelcolvin's full-sized avatar

Samuel Colvin samuelcolvin

View GitHub Profile
#!/usr/bin/env python
# This is an example Git server. http://blog.nerds.kr/post/106956608369/implementing-a-git-http-server-in-python
# Stewart Park <stewartpark92@gmail.com>
from flask import Flask, make_response, request, abort
from StringIO import StringIO
from dulwich.pack import PackStreamReader
import subprocess, os.path
from flask.ext.httpauth import HTTPBasicAuth
@nolanlawson
nolanlawson / Dexie.min.js
Created February 7, 2015 18:01
IndexedDB+Dexie+Lunr MTG full-text search demo
(function(n,t,i,r){"use strict";function h(n,t){return typeof t!="object"&&(t=t()),Object.keys(t).forEach(function(i){n[i]=t[i]}),n}function y(n){return{from:function(t){return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,{extend:function(i){h(n.prototype,typeof i!="object"?i(t.prototype):i)}}}}}function p(n,t){return t(n)}function f(t){function or(){if(i)w.on("versionchange",function(t){w.close();t.newVersion&&n.location.reload(!0)})}function ki(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null};this.stores({})}function sr(n,t,i,r){var e,f,o,h,l,c;if(n==0)Object.keys(pt).forEach(function(n){di(t,n,pt[n].primKey,pt[n].indexes)}),e=w._createTransaction(kt,ri,pt),e.idbtrans=t,e.idbtrans.onerror=s(i,["populating database"]),e.on("error").subscribe(i),u.newPSD(function(){u.PSD.trans=e;try{w.on("populate").fire(e)}catch(n){r.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(f){}t.db.close();i(n)}});else{if(f=[],o=ii.filter(function(t){return
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@azimidev
azimidev / disposable_email_addresses
Last active December 22, 2022 06:51
Notify me of any update
0815.ru
0815.ru0clickemail.com
0815.ry
0815.su
0845.ru
0clickemail.com
0-mail.com
0wnd.net
0wnd.org
10mail.com
@KodrAus
KodrAus / Profile Rust on Linux.md
Last active November 14, 2023 17:19
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

@samuelcolvin
samuelcolvin / datetime_toolbox.py
Created March 24, 2017 17:13
toolbox of useful methods for working with datetimes in python
"""
Useful utilities when working with datetimes, written for and tested with python 3.6
With other versions of python you're on your own.
(should work find with at least 3.5 though)
"""
from datetime import datetime, date, timedelta, timezone, tzinfo
def set_timezone(dt: datetime, tz: tzinfo) -> datetime:
@samuelcolvin
samuelcolvin / nunjucks-precompile
Last active August 4, 2017 10:49
nunjucks-precompile with jinja compat (modified from `v3.0.1`), see https://stackoverflow.com/a/45440732/949890
#!/usr/bin/env node
var path = require('path');
var precompile = require('nunjucks/src/precompile').precompile;
var Environment = require('nunjucks/src/environment').Environment;
var lib = require('nunjucks/src/lib');
var nunjucks = require('nunjucks');
nunjucks.installJinjaCompat();
var yargs = require('yargs')
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active June 1, 2024 08:46
set -e, -u, -o, -x pipefail explanation
@samuelcolvin
samuelcolvin / pull_pull_request.py
Last active August 4, 2022 09:12
Pull from and pushing to other people's pull requests
#!/usr/bin/env python3
"""
pull from and pushing to other people's pull requests
(might require an auth key for private repos)
"""
import os
import re
import sys
import requests
@samuelcolvin
samuelcolvin / heroku_release_github_action.yml
Created November 3, 2020 12:32
push to heroku to deploy when you create a release in github
deploy:
needs:
- test
- lint
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP: <heroku app name>