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 / 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_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 / fizzbuzz.go
Created April 23, 2014 14:22
Playing around with go channels.
package main
import (
"fmt"
"strconv"
)
// sentinel value for channels
@jasonkeene
jasonkeene / python_scripting.rst
Last active November 14, 2024 11:18
Get started with writing your own python scripts to automate system tasks.

Python for System Admins / Operators

Installing Python

Most Unix/Linux systems come with python pre-installed:

$ python -V
import pytest
class Fixture():
@property
def foo(self):
raise NotImplementedError
@pytest.fixture
// ==UserScript==
// @name Hipchat Click to View Images
// @version 0.2
// @match https://*.hipchat.com/chat
// @copyright 2014, Zach "theY4Kman" Kanzler
// @grant GM_unsafeWindow
// ==/UserScript==
// Add styles to initially disable images
@jasonkeene
jasonkeene / git-move.sh
Last active June 15, 2018 14:41
Moves commits from one repo to another preserving commit messages and author date.
# Usage:
# cd ~/my_old_repo
# git-move HEAD ~/my_new_repo
function git-move {
src=$(pwd)
commit=$1
dest=$2
git rev-list $commit --reverse |
while read hash; do
@jasonkeene
jasonkeene / settings.__init__.py
Last active August 29, 2015 14:12
Idea for class based settings.
from .local import config
config.render(globals())
// Excerpt from Practical Cryptography With Go
// https://leanpub.com/gocrypto/read#leanpub-auto-block-padding
// Pad applies the PKCS #7 padding scheme on the buffer.
func Pad(in []byte) []byte {
padding := 16 - (len(in) % 16)
if padding == 0 {
padding = 16
}
for i := 0; i < padding; i++ {
#!/usr/bin/env python
from itertools import chain
from random import SystemRandom
import sys
PLANTS = {
'Stinging Nettle': 3,
'Sorrel': 3,