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 -w | |
require 'date' | |
require 'find' | |
# TODO | |
# - make work with -p option | |
def main | |
logopts = "--color=always --since=#{Date.today - 3} #{ARGV.join(' ')}" |
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
function reentrant(f, opts) { | |
opts = $.extend({catchup: false}); | |
var state = { | |
running: false, | |
reentry: false | |
}; | |
var rf = function() { | |
if (state.running) { | |
state.reentry = true; | |
return; |
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 | |
# | |
# Save as /usr/local/sbin/try-to-sleep | |
# | |
# Have cron try it regularly. | |
# /etc/cron.d/try-to-sleep: | |
# 12,27,42,57 22-23,0-5 * * * root /usr/local/sbin/try-to-sleep | |
# |
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 -e | |
STATE=/var/local/exclaim-errors.state | |
now=$( date +'%Y-%m-%d %H:%M:%S' ) | |
since="$(head -n1 $STATE 2>/dev/null || echo 2000-01-01)" | |
echo "$now" > $STATE | |
journalctl --priority=err --since="$since" | tail -n+2 |
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
_yo() { | |
local cur prev words cword generators | |
_get_comp_words_by_ref -n : cur prev words cword | |
generators=$( \ | |
yo --help \ | |
| sed -n '/Please choose a generator below./{:a;n;/-----------------------------------------/b;p;ba}' \ | |
| sed -n '/^ /p' \ | |
) |
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 -e | |
# See | |
# http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/ | |
# https://github.com/jpetazzo/nsenter | |
case "$1" in | |
-h|--help) | |
echo "Usage: docker-enter CONTAINER" | |
exit 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
#! /bin/sh -e | |
# Requires https://github.com/profh/romanic | |
# gem install romanic | |
device="default:CARD=X20" | |
lock="/run/lock/mpd-announce" | |
dotlockfile -r 0 -p "$lock" || exit 0 | |
trap "dotlockfile -p -u \"$lock\"" EXIT TERM INT |
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
__snappercomp() { | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
COMPREPLY=( $( compgen -W "$1" -- "$cur" ) ) | |
} | |
# From http://github.com/jweslley/rails_completion | |
# @param $1 Name of variable to return result to | |
# @param $2 Command list | |
__snappercmd() { | |
any_command=$(echo $2 | sed -e 's/[[:space:]]/|/g') |
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 'benchmark' | |
require 'ascii_charts' | |
def measure | |
GC.disable | |
Benchmark.realtime do | |
yield | |
end | |
ensure | |
GC.enable |
NewerOlder