Skip to content

Instantly share code, notes, and snippets.

View rmcgibbo's full-sized avatar

Robert T. McGibbon rmcgibbo

View GitHub Profile
@rmcgibbo
rmcgibbo / github_comment_on_commit.py
Created August 23, 2012 07:22
Jenkins setup to automatically comment on github commits with build status
// Using the Jenkins Groovy Post build plugin to execute the following after every build
// https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin
// It would be nice not to have to specify these here... the repo name should be available within the hudson
// api somehow, but I didn't know how to get it. The access token should maybe be saved in a config file, and
// read in at runtime?
GITHUB_REPO_NAME = 'myusername/myreponame'
GITHUB_ACCESS_TOKEN = 'my_github_api_v3_access_token'
@rmcgibbo
rmcgibbo / install.sh
Last active October 9, 2015 03:48
Install Python / numpy / scipy / ipython / matplotlib / umfpack / pytables from source
#!/bin/bash
# =================================================================
# Install a full scientific python stack from source, for Ubuntu, with
# python 2.7.3 (tested on a totally fresh Ubuntu12.04-amd64). Requires
# sudo for apt-getting dependencies like libatlas, Tk, etc
# =================================================================
# packages pulled from PyPI are currently
# scipy 0.10.1
@rmcgibbo
rmcgibbo / gist:3484766
Created August 27, 2012 00:56
Execute command on remote server which is mounted via sshfs to open remote file on desktop
#!/usr/bin/env python
import os, sys
import subprocess
HOST_MOUNT_DIR = '\$HOME/ubuntu'
# get the ip of the host
host = os.environ['SSH_CLIENT'].split(' ')[0]
# get the path from $HOME to the file
@rmcgibbo
rmcgibbo / milestone.py
Created September 11, 2012 20:43
Milestoning With MSMBuilder/OpenMM :: Initial Sketch
#!/usr/bin/env python
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
from msmbuilder import Trajectory
import msmbuilder.metrics
#interface to the msmbuilder fast RMSD calculator
rmsd_calculator = msmbuilder.metrics.RMSD()
@rmcgibbo
rmcgibbo / hmm.py
Created October 18, 2012 22:35
Rectify a 1d binary signal with an HMM
import numpy as np
from sklearn.hmm import MultinomialHMM
import matplotlib.pyplot as pp
# sample run lengths from exponential distribution
run_lengths = np.array(np.random.exponential(100, size=10), dtype=np.int)
# make the signal from the run lengths
signal = []
for i, l in enumerate(run_lengths):
signal.extend([i % 2] * l)
@rmcgibbo
rmcgibbo / viterbi.py
Created October 19, 2012 02:55
Viterbi algorithm for a simple class of HMMs
"""
Viterbi algorithm for finding the most likely state sequence of a simple
hidden markov model.
# https://en.wikipedia.org/wiki/Viterbi_algorithm
The Model
---------
The HMMs considered in this code are extremely simple. Every hidden state
is uniquely associated with an output symbol, but the link is "fuzzy". That is,
@rmcgibbo
rmcgibbo / wls-em.py
Created October 30, 2012 08:37
linear regression mixture model (weighted linear regression) with E-M
import numpy as np
import matplotlib.pyplot as pp
from matplotlib import cm
def maximization(X, y, weights):
"""Calculate the beta that maximize the likelihood, given the weights (fuzzy assignment)
Parameters
----------
X : np.array, shape=[n_cases, n_features]
@rmcgibbo
rmcgibbo / quora_follow.py
Created October 30, 2012 10:29
Follow all of the top writers on Quora with a python/selenium/chrome hack
from selenium import webdriver
import time
import random
import numpy as np
browser = webdriver.Chrome()
browser.get('https://www.quora.com/login')
raw_input('You need to log in in the browser window. Hit enter here when finished...')
@rmcgibbo
rmcgibbo / pr.md
Created November 1, 2012 02:57 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

{
"metadata": {
"name": "Rpush bug example"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{