Skip to content

Instantly share code, notes, and snippets.

View alexec's full-sized avatar
😀

Alex Collins alexec

😀
View GitHub Profile
skinparam shadowing false
skinparam defaultFontName "Futura"
skinparam activityArrowColor Black
skinparam activityBackgroundColor White
skinparam activityBorderColor Black
skinparam actorBackgroundColor White
skinparam actorBorderColor Black
skinparam monochrome true
skinparam shadowing false
skinparam handwritten false
autonumber
@alexec
alexec / dedup.sh
Created January 31, 2016 18:06
De-duplicate a directory of files
#! /bin/bash
set -eu
DB=~/.dedup
DUPS=dups
if [ ! -e $DB ]; then
mkdir $DB
fi
#! /bin/bash
set -eu
find . -mindepth 1 -maxdepth 1 -name '*.jpg' -or -name '*.JPG' | while read F ; do
echo $F
D=$(stat -f '%Sm' -t '%Y/%m/%d' "$F")
if [ ! -e $D ]; then
mkdir -p $D
fi
mv -v "$F" $D/
#! /bin/bash
set -eu
find "/Volumes/My Passport/Backups.backupdb/Alex Collins’s MacBook/2013-06-04-230142/Macintosh HD/Users/Shared/Pictures" -maxdepth 11 -path '*/Pictures/*' -type f \( -name '*.jpg' -or -name '*.JPG' -or -name '*.mov' -or -name '*.mov' \) | while read F ; do
D=$(stat -f '%Sm' -t '%Y/%m/%d' "$F")
if [ ! -e $D ]; then
echo "creating $D"
mkdir -p $D
fi
T="$D/$(basename "$F")"
@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'}}
@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 / 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 / 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|