Skip to content

Instantly share code, notes, and snippets.

View nicholaides's full-sized avatar

Mike Nicholaides nicholaides

View GitHub Profile
@nicholaides
nicholaides / osx-defaults.sh
Created September 12, 2014 02:13
OSX defaults
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@nicholaides
nicholaides / rake-prereqs-to-dot.rb
Created February 25, 2018 16:36
Visualize rake dependencies with Graphviz
# Usage: rake -P | ruby rake-prereqs-to-dot.rb | dot -Tpng | imgcat
require 'pp'
tasks = {}
dependencies = nil
ARGF.each_line.lazy.map(&:strip).each do |line|
if match = line.match(/^rake (.*)/)
dependencies = tasks[match[1]] ||= []
@nicholaides
nicholaides / sh_redirect.rb
Created February 25, 2018 18:59
Like FileUtils#sh but lets you specify a file to redirect output to. Helpful for building rake tasks.
# Like sh, but
# 1. lets you specify a file to redirect output to and
# 2. removes the file if there's an error
def sh_redirect(*args, out:)
sh(*args, { out: out }, {}) do |ok, status|
unless ok
rm_f out
raise "Command failed: `#{args.join(' ')}`\nDeleted `#{out}`"
end
end