- Unlike a lot of pre-commit scripts, it uses only the changes you've staged for commit, and doesn't touch your working tree (stash etc.).
- I use
skip 'slow' if ENV['FAST_TESTS'] == '1'
in tests that needlessly slow down everydayrake test
ing, but this runs them all before commit. - Written in 10 minutes. Barely tested. YMMV.
- See https://github.com/wisq/autocrew/blob/master/Rakefile for the latest version (e.g. if I find any bugs in this).
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
diff -ruN a/bash/shell.c b/bash/shell.c | |
--- a/bash/shell.c 2011-01-02 21:04:51.000000000 +0000 | |
+++ b/bash/shell.c 2014-09-25 21:20:24.656725026 +0000 | |
@@ -1703,13 +1703,8 @@ | |
tilde_initialize (); | |
/* Initialize internal and environment variables. Don't import shell | |
- functions from the environment if we are running in privileged or | |
- restricted mode or if the shell is running setuid. */ | |
-#if defined (RESTRICTED_SHELL) |
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 | |
Entry = Struct.new(:duration, :rows, :data) | |
def trim(array, limit, &block) | |
too_many = array.count - limit | |
if too_many > 0 | |
array.sort_by!(&block) | |
array.shift(too_many) | |
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
#!/usr/bin/env ruby | |
require 'digest/md5' | |
def random_hex(length) | |
bytes_needed = (length + 1) / 2 | |
bytes = $urandom.read(bytes_needed) | |
hex = ("%02x" * bytes_needed) % bytes.bytes | |
return hex[0,length] |
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/sh | |
ORIGIN=`basename "$0"` | |
BRANCH=${1:-master} | |
set -e | |
git fetch "$ORIGIN" | |
REV1=`git rev-parse "$ORIGIN/$BRANCH"` | |
REV2=`git rev-parse "$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
#!/usr/bin/ruby | |
require 'pathname' | |
file, project = ARGV.take(2).collect do |p| | |
if p.empty? | |
nil | |
else | |
Pathname.new(p) | |
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
class ObjectSocket | |
BLOCK_SIZE = 4096 | |
def self.pair | |
Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM, 0).map { |s| new(s) } | |
end | |
def initialize(socket) | |
@socket = socket | |
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
#!/usr/bin/ruby | |
require 'tempfile' | |
APPLESCRIPT = <<EOF | |
tell application "iTerm" | |
activate | |
tell the first terminal | |
set new_session to (make new session at the end of sessions) |
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 | |
# Optional: Force a particular Ruby version & gemset. | |
if ENV['BUNDLE_GEMFILE'].nil? | |
ENV['RBENV_VERSION'] = '1.9.3' | |
ENV['BUNDLE_GEMFILE'] = "#{ENV['HOME']}/ops/kitchen/Gemfile" | |
exec('bundle', 'exec', $0, *ARGV) | |
end | |
# Suppress iconv deprecation warning. |
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
% ls | |
cache-fm/ crawl/ git-up/ misc/ ruby-build/ ssh-ride/ zsh-completions/ | |
% ruby -e 'p IO.popen("echo *", &:read)' | |
"cache-fm crawl git-up misc ruby-build ssh-ride zsh-completions\n" | |
% ruby -e 'p IO.popen(["echo", "*"], &:read)' | |
"*\n" |
OlderNewer