Skip to content

Instantly share code, notes, and snippets.

View chrishiestand's full-sized avatar

Chris Hiestand chrishiestand

View GitHub Profile
@chrishiestand
chrishiestand / cf-cmd.rb
Last active December 12, 2015 05:58 — forked from zzamboni/cf-cmd.rb
cf-cmd
#!/usr/bin/env ruby
#
# CFengine command-line test utility.
#
# Diego Zamboni, December 27th, 2011
#
# Run as "cf-cmd help" to see usage information.
require 'readline'
require 'tmpdir'
@chrishiestand
chrishiestand / memtest.c
Last active December 21, 2015 23:29 — forked from tmbartol/memtest.c
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
main(argc,argv)
int argc;
char **argv;
{
char *array;
unsigned long long int n_bytes,t,i,j;
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
main(argc,argv)
int argc;
char **argv;
{
char *array;
unsigned int n_bytes,t,i,j;
@chrishiestand
chrishiestand / pdb-his-change.py
Created October 1, 2013 09:40
a quick and dirty python script to modify parts of an ATOM PDB file in a very domain-specific way
#!/usr/bin/env python3
import re, argparse
#NE2 HIS -> HSE
#standard fields = [ 'record', 'serial', 'name', 'altLoc', 'resName', 'chainID', 'resSeq',
# 'iCode', 'x', 'y', 'z', 'occupancy', 'tempFactor', 'element', 'charge' ]
parser = argparse.ArgumentParser(description='Changes HIS to HSE in PDB file where "NE2 HIS" found, outputs to sdout')
parser.add_argument("file", type=str)
@chrishiestand
chrishiestand / .bash_git.sh
Last active August 29, 2015 14:07
Bash PS1 for git
exists() {
if [ -z "$1" ]; then
return 99;
fi
type -t "$1" 2>&1 1>/dev/null
}
if ! exists _command && ! shopt -oq posix; then
if [ -f /etc/bash_completion ]; then
@chrishiestand
chrishiestand / monopoly-traffic
Last active October 6, 2017 22:08
finding monopoly (the board game) real estate frequency
#!/usr/bin/env python
from __future__ import division
# a bar plot with errorbars
import numpy as np
import matplotlib.pyplot as plt
import random
from collections import Counter
@chrishiestand
chrishiestand / gitify-dir
Last active August 29, 2015 14:16
Convert any directory into a git-based directory preserving original, non-intersecting, files
#!/bin/bash
# To backup a directory, and then replace it with a git version
# that is already available remotely
# Conflicting file versions will be overwritten with the remote version
# Files which existed locally but not in the git repo will be preserved (*not* removed)
set -e
PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:$PATH
@chrishiestand
chrishiestand / fw
Last active August 29, 2015 14:18
gulp or watch watcher (frog watch)
#!/bin/bash
#Notifies you when a watch/build script dies on OS X (easy to modify for linux though)
#Installation: put this into e.g. ~/bin/ (make sure your PATH variable points there)
#run e.g. `fw gulp`
trap exit SIGINT
while [ 0 ]; do
"$@"
@chrishiestand
chrishiestand / image-squash
Created June 25, 2015 01:20
Size Optimize Images for the web
find . -iname '*.png' -exec pngcrush -brute -reduce -ow {} \;
find . \( -iname '*.jpg' -o -iname '*.jpeg' \) -exec jpegoptim {} \;
@chrishiestand
chrishiestand / qla-add-tapedrives
Last active September 27, 2015 22:08
A workaround for Overland 2000 tape devices (via FC), /dev/sgx, /dev/nstx not being added automatically in RHEL4. This was my first python script, so feel free to LoL
#!/usr/bin/env python
#This is a workaround for Overland 2000 tape devices (via FC), /dev/sgx, /dev/nstx not being added automatically in RHEL4.
#For more information see notes at end of file
#
# chkconfig: 235 71 25
# description: Workaround for Overland 2000 tape devices (via FC) \
# being added as device nodes.
DEBUG = 9
import os, re, time
qla_search_path = '/proc/scsi/qla2xxx'