Skip to content

Instantly share code, notes, and snippets.

View sente's full-sized avatar

Stuart Powers sente

View GitHub Profile
@sente
sente / gist:8665191
Created January 28, 2014 10:21 — forked from jeresig/gist:199298
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ];
then
GIT_AUTHOR_EMAIL="[email protected]";
GIT_COMMITTER_EMAIL="[email protected]";
git commit-tree "$@";

Flask + uWSGI + nginx Primer

I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

How this shit works

  • Flask is managed by uWSGI.
  • uWSGI talks to nginx.
@sente
sente / README.md
Last active December 19, 2015 07:28 — forked from mbostock/.block

This histogram shows the distribution of GitHub Gist API response times (in milliseconds) for a sample of 10,000 requests as observed by bl.ocks.org.

The distribution roughly follows a log-normal distribution, which is unsurprising for a complex process that has multiple independently-random sources of delay. The mode response time was in the range 120-140ms, while the median response time was 206ms. The middle 80% of requests were in the range 114-527ms. About 11% of requests took longer than 500ms, and 5% of requests took longer than one second. (The rightmost bin in the histogram includes these long requests.)

Since API endpoints vary dramatically in their computational cost, the distribution of response times is likely multimodal. In this dataset, 96% of requests were for a single gist (/gists/42), while the remaining 4% of requests were to list a user’s gist (/users/fred/gists). By separating the API requests for a single

@sente
sente / gmail_chat.py
Last active December 16, 2015 18:49 — forked from jleedev/gmail_chat.py
import email
import email.parser
import imaplib
import getpass
def imap_login(username=None, password=None):
"""
login and return the connection
"""
@sente
sente / ajaxify-html5.js
Created November 13, 2012 20:16 — forked from exonen/ajaxify-html5.js
Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
// https://gist.github.com/854622
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
$ = window.jQuery,
document = window.document;
// Check to see if History.js is enabled for our Browser
@sente
sente / object_keys_values.js
Created November 12, 2012 02:50 — forked from Cside/object_keys_values.js
Object.keys(), Object.values()
// changed the functions from .keys() -> ._keys(), likewise for .values()
// because .keys()/.values() breaks jQuery
Object.prototype._keys = function (i) {
var keys = Object.keys(this);
return (i >= 0) ? keys[i] : keys;
};
Object.prototype._values = function (i) {
var self = this;
@sente
sente / mixpanel.js
Created November 11, 2012 05:24 — forked from TooTallNate/mixpanel.js
Mixpanel JS Lib, Beautified
var MixpanelLib = function (j, n, m) {
function k(a, c, b) {
if (a.length) {
var e;
for (e = 0; e < a.length; e++) c.call(b || c, a[e], e)
} else if (typeof a == "object") for (e in a) Object.hasOwnProperty.call(a, e) && c.call(b || c, a[e], e)
}
function z(a, c) {
a.prototype = new c;
a.prototype.constructor = a;
@sente
sente / load.rb
Created October 25, 2012 07:14 — forked from igrigorik/load.rb
load githubarchive data into sqlite3 database
#
# $> ruby load.rb http://data.githubarchive.org/2012-04-01-15.json.gz
#
require 'yajl'
require 'zlib'
require 'sqlite3'
require 'open-uri'
input = ARGV.shift
@sente
sente / promises.md
Created October 25, 2012 02:06 — forked from domenic/promises.md
You're Missing the Point of Promises

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
});
@sente
sente / gist:3803222
Created September 29, 2012 04:57 — forked from anonymous/gist:3803147
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "twilight"