View .gitconfig
1 2 3 4 5 6 7 8 9
[user]
name = Mislav Marohnić
email = mislav.marohnic@gmail.com
 
[color]
ui = true
 
[push]
default = simple
View fuzzy.coffee
1 2 3 4 5 6 7 8 9
# Get the shortest match (least distance between start and end index) for all
# the query characters in the given text.
#
# Returns an array in format [firstIndex, matchLength, [matchIndexes]]
shortestMatch = (text, queryChars) ->
starts = allIndexesOf(text, queryChars[0])
 
return if starts.length is 0
return [starts[0], 1, []] if queryChars.length is 1
View port-finder.rb
1 2 3 4 5 6 7 8 9 10
# ruby port-finder.rb | cut -f1 -d: | sort -n | uniq -c
#
# Verdict: it seems to be safe on Mac OS X, but it's *not safe* on Linux,
# where causal testing confirms that two subprocesses could pick the same port.
 
require 'socket'
 
module PortFinder
def self.call
server = TCPServer.new('127.0.0.1', 0)
View diff-gems.rb
1 2 3 4 5 6 7 8 9
#!/bin/bash
# Usage: diff-gems <branch>
#
# Shows diff between unpacked cached gems that changed on a branch.
set -e
 
branch="${1?}"
base_branch="origin/master"
merge_base="$(git merge-base "$base_branch" "$branch")"
View arch.md

Create the partition:

sgdisk --zap-all /dev/sda
cgdisk /dev/sda
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt

Edit the mirror list to bring the preferred mirror to the top:

View backfill-releases.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
# Usage: OAUTH_TOKEN="..." backfill-releases CHANGELOG.md [<project-title>]
 
set -e
 
log="${1?}"
project_name="${2}"
 
repo="$(git config remote.origin.url | grep -oE 'github\.com[/:][^/]+/[^/]+' | sed 's/\.git$//' | cut -d/ -f2-3)"
[ -n "${project_name}" ] || project_name="${repo#*/}"
View mac-randomize.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
set -e
 
current_mac() {
ifconfig en0 ether | awk '/ether / { print $2 }'
}
 
current_mac_wifi() {
networksetup -getmacaddress Wi-Fi | awk '{ print $3 }'
}
View h264.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
# Usage: h264 <infile> <HH:MM:SS-HH:MM:SS> [<outfile>]
set -e
 
infile="$1"
fromto="$2"
 
if [ -n "$3" ]; then
outfile="$3"
else
View watch.rb
1 2 3 4 5 6 7 8 9
require 'guard'
 
listener = Guard::Listener.select_and_init '/',
:relativize_paths => false,
:ignore_paths => ['Caches', 'Saved Application State']
 
listener.on_change do |files|
p files
end
View detect_encoding.sh
1 2 3 4
ruby -r pp -r charlock_holmes -e '
contents = ARGF.read
detection = CharlockHolmes::EncodingDetector.detect(contents)
pp detection ' "$@"
Something went wrong with that request. Please try again.