Skip to content

Instantly share code, notes, and snippets.

View alexec's full-sized avatar
😀

Alex Collins alexec

😀
View GitHub Profile
import java.io.IOException;
import java.io.InputStream;
/**
* @author alex.collins
*/
public class SearchAndReplaceInputStream extends InputStream {
private final InputStream is;
@alexec
alexec / csv_example.rb
Created August 3, 2013 10:21
Example of reading and writing a CSV file
# suitable for small files only
require 'csv'
f='a.csv'
headers=['x','y']
csv=[]
if File.exists?(f)
CSV.foreach(f, {:headers => :first_row, :converters => [:numeric]}) do |row|
@alexec
alexec / history.rb
Created August 3, 2013 10:33
A class to keep a short, persistent history of some values.
require 'csv'
class History
def initialize(name, cols, size)
@f=name
@headers=cols
@size=size
read
write
end
@alexec
alexec / stopwatch.sh
Created September 4, 2013 18:04
Run a command with as stopwatch, print the seconds as they pass. So you can track the progress of a command that lacks it's own progress bar.
#!/bin/bash
set -ue
BEGIN=$(date +%s)
BACK="\b\b\b\b"
($* ; touch /tmp/$$.done) &
OLDDIFF=0
while true; do
@alexec
alexec / reveal-passwords.js
Last active December 29, 2015 04:39
Reveal Passwords
var is=document.getElementsByTagName('input');for (var i=0;i<is.length;i++){var x=is[i];if (x.type=='password') {x.type='text'}}
#! /bin/sh
set -eux
cd docker-java
git pull
mvn clean deploy
git push
rm -R ~/.m2/repository/com/alexecollins/docker-java
cd ..
apt-get install nginx git ruby maven bundler
git clone https://github.com/alexec/www.alexecollins.com.git
cd www.alexecollins.com
bundler install
middleman build
mv /usr/share/nginx/html /usr/share/nginx/html.1
cp -R build /usr/share/nginx/html
apt-get install docker.io
vi /etc/init.d/docker.io
@alexec
alexec / mvncolor.sh
Last active August 29, 2015 14:04 — forked from katta/mvncolor.sh
#!/usr/bin/env bash
# Formatting constants
export BOLD=`tput bold`
export UNDERLINE_ON=`tput smul`
export UNDERLINE_OFF=`tput rmul`
export TEXT_BLACK=`tput setaf 0`
export TEXT_RED=`tput setaf 1`
export TEXT_GREEN=`tput setaf 2`
export TEXT_YELLOW=`tput setaf 3`
@alexec
alexec / changelog.sh
Last active August 29, 2015 14:09
Create a CHANGELOG.md from Git history on Github
#! /bin/sh
# Creates a markdown formatted change log based the git history
set -eu
read -p "Enter your username:" USER > /dev/stderr
read -s -p "Please enter $USER's password:" PASS > /dev/stderr
OWNER=$(git remote show origin|grep "Fetch URL"|sed 's/.*https:...*\/\(.*\)\/\(.*\).git/\1/')
REPO=$(git remote show origin|grep "Fetch URL"|sed 's/.*https:...*\/\(.*\)\/\(.*\).git/\2/')
@alexec
alexec / commit-msg
Created November 22, 2014 13:09
.git/hooks/commit-msg
#! /bin/sh
set -eu
if [ $(cat $1|grep -c '^[A-Z]*-[0-9]* \|Merge\|release') -eq 0 ]; then
echo "non-merge/release commit messages must start with a ticket ID" > /dev/stderr
exit 1
fi