Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Busy

Robert T. McGibbon rmcgibbo

💭
Busy
View GitHub Profile
@rmcgibbo
rmcgibbo / github_comment_on_commit.py
Created Aug 23, 2012
Jenkins setup to automatically comment on github commits with build status
View github_comment_on_commit.py
// 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 Oct 9, 2015
Install Python / numpy / scipy / ipython / matplotlib / umfpack / pytables from source
View install.sh
#!/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 Aug 27, 2012
Execute command on remote server which is mounted via sshfs to open remote file on desktop
View gist:3484766
#!/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 Sep 11, 2012
Milestoning With MSMBuilder/OpenMM :: Initial Sketch
View milestone.py
#!/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 Oct 18, 2012
Rectify a 1d binary signal with an HMM
View hmm.py
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 Oct 19, 2012
Viterbi algorithm for a simple class of HMMs
View viterbi.py
"""
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 Oct 30, 2012
linear regression mixture model (weighted linear regression) with E-M
View wls-em.py
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 Oct 30, 2012
Follow all of the top writers on Quora with a python/selenium/chrome hack
View quora_follow.py
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 Nov 1, 2012 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

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:

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