Skip to content

Instantly share code, notes, and snippets.

View jasonkeene's full-sized avatar
:shipit:

Jason Keene jasonkeene

:shipit:
View GitHub Profile
@jasonkeene
jasonkeene / fizzbuzz.go
Created April 23, 2014 14:22
Playing around with go channels.
package main
import (
"fmt"
"strconv"
)
// sentinel value for channels
@jasonkeene
jasonkeene / calc_grade.py
Last active August 29, 2015 13:58
Script to calculate grade for CDA 3103 Spring 2014
#!/usr/bin/env python
# homework average is worth 15% of the grade and lowest will be thrown out
HOMEWORK = [
100, # hw1
100, # hw2
100, # hw3
100, # hw4
100, # hw5
]
@jasonkeene
jasonkeene / ff_branches.sh
Last active June 15, 2018 15:45
Automatically fetch remotes then fast forward to the new changes or launch a GUI.
# first update all remote branches
git fetch --all --prune
# loop over all local/remote pairs
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \
while read local remote
do
# make sure remote exists
[ -z "$remote" ] && continue
@jasonkeene
jasonkeene / calc.html
Last active August 29, 2015 13:56
Testing Calculator
<!DOCTYPE html>
<html>
<head>
<title>Testing Calculator</title>
<style type="text/css">
#display {
width: 180px;
border: 1px solid black;
padding: 5px 7px;
@jasonkeene
jasonkeene / counter.js
Created January 10, 2014 20:54
JavaScript Counter Implementation
function Counter() {
this.elements = {};
}
Counter.prototype.lookup = function (element) {
var el, i;
el = this.elements[element] || [];
for (i = 0; i < el.length; i++) {
if (el[i][0] === element) {
return el[i][1];
}
@jasonkeene
jasonkeene / alert.coffee
Last active December 30, 2015 20:39
A simple bookmarklet to add an alert feature to bitcoinwisdom.com :)
interval_id = high = low = null
ticker = $ '#price'
alert_url = 'http://www.angelfire.com/ut/jlpicard/images/picalert.wav'
start = ->
do nodes.stop.show
do nodes.start.hide
interval_id = setInterval ->
current_price = parseFloat do ticker.text
unless high > current_price > low
@jasonkeene
jasonkeene / notes.rst
Last active December 15, 2015 09:28
Getting started with testing in Python

Why Test

  • Tells you when your code is broken
  • Manual testing sucks
  • Prevent against regressions
    • Upgrading dependencies
    • Refactoring
  • Documentation
    • Other devs can read your tests to see how you intended your code to be used
@jasonkeene
jasonkeene / monte_carlo_pi.py
Created September 3, 2012 21:19
Naive Monte Carlo approximation of pi
#!/usr/bin/env python
"""Naive Monte Carlo approximation of pi."""
from __future__ import division
import math
from random import random
from itertools import repeat
@jasonkeene
jasonkeene / uber_pass.py
Last active October 7, 2015 20:08
Generate and check password hashes for Ubersmith DE (salted sha1)
r"""Generate and check password hashes for Ubersmith DE (salted sha1).
Example use:
>>> my_new_hash = generate_hash('my_new_pass', 'salt')
>>> my_new_hash # store this in the database
'{ssha1}W77amZWRUSWjDLh04P/dlfsCvYdzYWx0\n'
>>> check_password('my_new_pass', my_new_hash)
True
>>> check_password('not_my_new_pass', my_new_hash)
@jasonkeene
jasonkeene / gist:3019590
Created June 29, 2012 17:50 — forked from jglenes/gist:3018166
Bash Git Branch
function parse_git_dirty {
[[ `git status --porcelain` ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1="\n\[$BPurple\][\w]\n\[$BCyan\]\u@\h \[$BGreen\]\$(parse_git_branch)\n$\[$Color_Off\] "