Skip to content

Instantly share code, notes, and snippets.

@mt3
mt3 / watcher.py
Created October 22, 2012 10:20 — forked from jonathansick/watcher.py
Run make whenever a LaTeX file is modified (using Python watchdog)
import subprocess
import os
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class ChangeHandler(FileSystemEventHandler):
"""React to modified .tex files."""
@mt3
mt3 / gist:3926205
Created October 21, 2012 07:01 — forked from irace/gist:3366283
Git cheat sheet
# Checkout remote branch
git checkout -t origin/<branch>
# Delete branch (local, remote)
git branch -d <branch>
git push origin --delete <branch>
# Submodules
git submodule init
git submodule update
@mt3
mt3 / gist:3926204
Created October 21, 2012 07:00 — forked from irace/gist:1041837
Simple bookmarklet template with jQuery
// Stripped down jQuerify for modern browsers: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
(function() {
var f = function() {
jQuery.noConflict()(function($) {
// Bookmarklet code goes here
});
};
if (typeof jQuery != 'undefined') {
@mt3
mt3 / gist:3888551
Created October 14, 2012 13:20 — forked from clintongormley/gist:3888120
Upgrading a running elasticsearch cluster

Yesterday I upgraded our running elasticsearch cluster on a site which serves a few million search requests a day, with zero downtime. I've been asked to describe the process, hence this blogpost.

To make it more complicated, the cluster was running elasticsearch version 0.17.8 (released 6 Oct 2011) and I upgraded it to the latest 0.19.10. There have been 21 releases between those two versions, with a lot of functional changes, so I needed to be ready to roll back if necessary.

Our setup:

  • elasticsearch

We run elasticsearch on two biggish boxes: 16 cores plus 32GB of RAM. All indices have 1 replica, so all data is stored on both boxes (about 45GB of data). The primary data for our main indices is also stored in our database. We have a few other indices whose data is stored only in elasticsearch, but are updated once daily only. Finally, we store our sessions in elasticsearch, but active sessions are cached in memcached.

@mt3
mt3 / gist:3888549
Created October 14, 2012 13:19 — forked from mattb/gist:1244665
Top 100 ascii-only 2-shingles on Twitter sample for the last 6 hours. Source at https://github.com/mattb/Storm-Try/
in the: ************************************* (3765)
i love: *************************** (2781)
to be: ************************** (2637)
of the: ********************* (2150)
if you: ********************* (2150)
on the: ******************** (2081)
i just: ****************** (1838)
i was: ****************** (1829)
i don't: ****************** (1825)
i have: ****************** (1802)
@mt3
mt3 / scrape.js
Created October 3, 2012 05:46 — forked from alexmcpherson/scrape.js
Casper.js vimrc scraper
var casper = require("casper").create();
var url = "https://github.com/search?langOverride=VimL&language=&q=vimrc&repo=&type=Repositories&start_value=" + casper.cli.get(0);
var repoLinks = [];
var fileLinks = [];
function getRepoLinks() {
var links = [];
$("div.results .result h2 a").each(function(i,el){
links.push(el.href);
});
@mt3
mt3 / git-branches-by-commit-date.sh
Created September 24, 2012 18:38 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@mt3
mt3 / .gitignore
Created September 21, 2012 12:44 — forked from karmi/.gitignore
Import your Gmail messages into ElasticSearch and search them with a simple web application.
.DS_Store
*.log
Gemfile.lock
@mt3
mt3 / flaskapp.py
Created September 17, 2012 04:36 — forked from kennethreitz/flaskapp.py
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
@mt3
mt3 / nonumberedcaptions.latex
Created September 12, 2012 15:24 — forked from rwst/nonumberedcaptions.latex
pandoc LaTeX template that removes "Figure #" automatic label from caption
\documentclass$if(fontsize)$[$fontsize$]$endif${article}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}