This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby -r pp -r charlock_holmes -e ' | |
contents = ARGF.read | |
detection = CharlockHolmes::EncodingDetector.detect(contents) | |
pp detection ' "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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#*/}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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")" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Last activity</h1> | |
<% for day, messages in @messages_by_day -%> | |
<h2><%= day %></h2> | |
<ol> | |
<%- for message in messages -%> | |
<li><%= link_to message.title, message %></li> | |
<%- end -%> | |
</ol> | |
<% end -%> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem "minitest" | |
gem "rspec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: license-audit [<project-dir>] | |
# | |
# Scans gems from the current project's bundle, Bower components and npm | |
# packages, and prints their license. | |
# | |
# Requires: | |
# - licensee >= 4.5.0 | |
# - ruby with Bundler (for Gemfiles) | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# for each git repo in a subdirectory ... | |
dirs = Dir['**/.git'].map { |gd| File.dirname(gd) } | |
def prompt | |
print ">> " | |
gets | |
end | |
# ... execute a command given on STDIN |
OlderNewer