Skip to content

Instantly share code, notes, and snippets.

View mikeclarke's full-sized avatar

Mike Clarke mikeclarke

View GitHub Profile
@mikeclarke
mikeclarke / Install python2.6 from source
Created December 12, 2010 22:05
Installing python2.6 from source
# Create a directory to store all the sources we will need to compile/install
mkdir ~/src
cd ~/src
wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz
tar xzvf Python-2.6.4.tgz
cd Python-2.6.4
yum install apr-devel zlib-devel postfix mod_ssl openssl-devel sqlite sqlite-devel bzip2-devel
# These switches ensure python is compiled with threading, as a shared library, and reference zlib
./configure --with-threads --enable-shared --with-zlib=/usr/include
@mikeclarke
mikeclarke / sitemap-old.xml
Created December 12, 2010 22:18
Example old sitemap.xml
<url>
<loc>http://olddomain.com/2009/06/01/old-random--name.aspx</loc>
<changefreq>daily</changefreq>
</url>
@mikeclarke
mikeclarke / new-sitemap.xml
Created December 12, 2010 22:20
Example new sitemap.xml
<url>
<loc>http://newdomain.com/2009/06/old-random-name.html</loc>
<lastmod>2009-09-09T19:35:36-08:00</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
@mikeclarke
mikeclarke / migrate-sitemap.py
Created December 12, 2010 22:21
Script to use fuzzy matching to generate a new sitemap.xml
import re
from xml.dom import minidom
from difflib import get_close_matches
# The old sitemap.xml file
sourceXML = minidom.parse('sitemap-old.xml')
# sitemap.xml from the new site
targetXML = minidom.parse('sitemap-new.xml')
sourceNodes = sourceXML.getElementsByTagName('loc')
@mikeclarke
mikeclarke / .bash_history
Created October 28, 2011 18:21
Here's what happens when you set an awful default password for a simple username
ls
mkdir .ssh
chmod 600 .ssh/
cd ssh
vim .ssh/authorized_keys
cd .ssh/
ls
ls -al
chmod .ssh 700
chmod 700 .ssh
#!/bin/bash
#
# A git hook for automatically running commands
# based on the name of files modified in the
# previous changeset
#
# To install as a post-merge hook (on `git pull`):
# $ cp hook.sh .git/hooks/post-merge && chmod 755 $_
#
# To install as a post-checkout hook (changing branches):
@mikeclarke
mikeclarke / gist:2932816
Created June 14, 2012 20:41
VirtualBox / sshuttle kernel panic
Interval Since Last Panic Report: 1037400 sec
Panics Since Last Report: 5
Anonymous UUID: C0E2044C-7010-42EB-8653-592AF0EE242D
Thu Jun 14 13:39:49 2012
panic(cpu 0 caller 0xffffff80002c266d): Kernel trap at 0xffffff80003b5781, type 14=page fault, registers:
CR0: 0x000000008001003b, CR2: 0x000000000000017c, CR3: 0x0000000000100000, CR4: 0x00000000000206e0
RAX: 0x0000000000000000, RBX: 0x0000000000000000, RCX: 0x0000000000000130, RDX: 0xffffff80003b52e1
RSP: 0xffffff80e962ba00, RBP: 0xffffff80e962bc10, RSI: 0xffffff80e962bb0c, RDI: 0xffffff8020fa2a88
R8: 0x0000000000000000, R9: 0x0000000000000000, R10: 0x8000000000100000, R11: 0xffffff80002d8200
@mikeclarke
mikeclarke / Code.js
Created September 9, 2013 21:36
Create an Asana project task from the initial email sent to a mailing list. Emails from your company's domain are ignored. Configure this script to run based on an every minute trigger.
function forwardLabelToAsana() {
var asana_email = 'x+FirstNumber@mail.asana.com';
var domain = '@company.com';
var inbound_label = GmailApp.getUserLabelByName('recruiting/recruiting-inbound');
var destination_label = GmailApp.getUserLabelByName('recruiting');
var threads = inbound_label.getThreads();
for (var i = 0; i < threads.length; i++) {
// We only care about the first message in a thread
var messages = threads[i].getMessages();
@mikeclarke
mikeclarke / Dockerfile
Last active December 29, 2015 05:09
Simple base python Dockerfile (includes some basic OS packages, setuptools, pip, virtualenv, and uwsgi)
FROM ubuntu
MAINTAINER Mike Clarke <mike@standardtreasury.com>
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y language-pack-en
ENV LANGUAGE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
@mikeclarke
mikeclarke / Dockerfile
Last active December 29, 2015 05:09
Application-specific sample Dockerfile (inherits from a container generated via https://gist.github.com/mikeclarke/7620172)
FROM <your private Docker repository>/python-base
MAINTAINER Mike Clarke <mike@standardtreasury.com>
ADD . /opt/app
RUN virtualenv --no-site-packages /opt/app/venv
RUN /opt/app/venv/bin/pip install -r /opt/app/requirements.txt
WORKDIR /opt/app
ENTRYPOINT ["/opt/app/env.sh"]