Skip to content

Instantly share code, notes, and snippets.

@kristm
kristm / amfufu.rb
Last active August 29, 2015 14:04
amfufu
#!/usr/bin/env ruby
require 'RMagick'
require 'fileutils'
#color parser from https://gist.github.com/edouard/1787879
TOP_N = 10 # Number of swatches
def sort_by_decreasing_frequency(img)
hist = img.color_histogram
sorted = hist.keys.sort_by {|p| -hist[p]}
new_img = Magick::Image.new(hist.size, 1)
@kristm
kristm / tarbecue
Last active December 17, 2015 13:49
tarbecue - when your git repo is unreachable from the network
#!/bin/bash
usage="Tarbecue\nUsage: $0 <tarfile> [commit id]"
if [ $# -lt 1 ]; then
echo -e $usage
exit
elif [ $# -lt 2 ]; then
commit=""
else
commit=$2
fi
@kristm
kristm / hhhh
Last active December 14, 2015 08:09
Print git log in harvest app ready format
#!/bin/bash
if [ $# -lt 3 ]; then
echo -e "hhhh v0.2\nUsage: hhhh <author> <from date> <to date>"
exit
fi
pretty="--pretty=%C(blue)%ad%Creset %C(yellow)%h%C(green)%d%Creset %C(blue)%s %C(magenta) [%an]%Creset"
fl=`git log "$pretty" --author "$1" --since "$2" --until "$3"|awk ' ORS="\n" { $4=$5=$6=$7=""; print $0}'`
echo "$fl"|awk 'FS=" " { gsub(/(\[[A-Za-z0-9&#\ ]+\] ?|Merge.*)/,"");\
if (a != $1){ print sep$1sep$2 } else { print $2 } }\
{ a=$1; sep="\n==========\n" }'
@kristm
kristm / dzt.php
Created March 22, 2011 09:24
php script for generating zend framework models. http://blog.dottystylecreative.com/metaprogramming-in-php/
#!/Applications/MAMP/bin/php5.2/bin/php
<?php
class dzt{
public $host = 'localhost';
public $user = 'dbuser';
public $pw = 'dbpassword';
public $db = 'dbname';
@kristm
kristm / magback.sh
Created March 22, 2011 09:20
bash script for adhoc deployment and backup to large systems. useful for deploying updates to systems without version control
#!/bin/bash
usage="Usage: magback.sh <tarball file> <deploy|restore|clear>"
writelog(){
echo $1 >> .magback.log
if [ $# -eq 2 ];
then
echo $1
fi