Skip to content

Instantly share code, notes, and snippets.

@tijn
tijn / install-ruby-shim.rb
Last active August 8, 2019 08:51
install-ruby-shim
#!/usr/bin/env ruby
require 'erb'
require 'optparse'
require 'pathname'
PROJECT_ROOT_FILES = %w(.ruby-version Gemfile .env)
$verbose = false
$force = false
$dry_run = false
@tijn
tijn / git-scrub
Created January 4, 2017 21:18
remove merged branches; could be generalized and cleaned up but it's already useful in its current form
#!/usr/bin/env ruby
if ARGV.include? '--help'
puts "git-scrub"
puts
puts "Remove all merged and stale branches."
puts
puts " merged = merged into master (the command will only run on the master branch)"
puts " stale = removed from the remote"
exit 0
@tijn
tijn / bitbucket-sort-pr-by-nr.user.js
Last active December 10, 2015 11:00
Sort pull requests by number
// ==UserScript==
// @name Bitbucket: sort pull requests by number
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Sort pull requests by number
// @author Victor Yap, changes by Tijn Schuurmans
// @match https://bitbucket.org/*/*/pull-requests/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
@tijn
tijn / dd-fast
Created October 24, 2014 11:10
OS X write a disk image faster with dd
sudo dd if=raspberrypi.dmg of=/dev/rdisk2 bs=1m
@tijn
tijn / rpi-id
Last active February 3, 2016 14:06
raspberry-pi ID
#!/bin/sh
cat /proc/cpuinfo | grep Serial | sha256sum | cut -f1 -d' '
@tijn
tijn / autostart.sh
Created October 24, 2014 09:05
pi-kiosk
chromium --incognito --kiosk --disable-translate http://status-manager.herokuapp.com/?id=`rpi-id`
@tijn
tijn / date_from_string.rb
Last active January 1, 2016 16:49
Trying to help Arjan
# this script proves that no matter how many bytes you leave out of the original string it won't result in a valid date that is in the specified range (within one year)
string = "\x04\x02R\xA6a\xC4M"
bytes = string.unpack("C*")
MIN = Time.new(2013,1,1)
MAX = Time.new(2013,12,31)
# equivalent to:
# string.bytes
@tijn
tijn / fucking.coffee
Created December 6, 2013 14:46
A script to make a hubot respond to foul language.
module.exports = (robot) ->
robot.hear /\bfucking\s+?(\w+)/i, (msg) ->
msg.send "fucking #{msg.match[1]} indeed".toUpperCase()
robot.hear /\bfuck(\s+?(?:my|your|this|those|these|our))?\s+?(\w+)/i, (msg) ->
pronoun = msg.match[1]
subject = msg.match[2]
pronoun = pronoun.trim().toLowerCase() if pronoun
@tijn
tijn / splitter.rb
Last active December 15, 2015 18:09 — forked from ChrisLundquist/splitter.rb
split off subdirectories of a git repo to their own repo.
#!/usr/bin/env ruby
# preliminary:
#
# git clone remote_repo repo
# cd repo
# for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done
def git_repo(subdir)
if File.directory?(subdir + "/.git")
@tijn
tijn / git-lines-per-author.sh
Last active January 31, 2019 19:18
Produce a histogram with lines of code per author.
#!/bin/sh
git ls-tree -r HEAD | sed -Ee 's/^.{53}//' | \
while read filename; do file "$filename"; done | \
grep -E ': .*text' | sed -E -e 's/: .*//' | \
while read filename; do git blame --line-porcelain "$filename"; done | \
sed -n 's/^author //p' | \
sort | uniq -c | sort -rn