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
bitlbee | |
emacs | |
finch | |
freediameter | |
glib-networking | |
gnu-smalltalk | |
gst-plugins-bad | |
gwenhywfar | |
hamsterdb | |
inspircd |
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 | |
# Example: ./getopts.sh -b world -a hello one two three | |
# Output: A=hello B=world 1=one 2=two 3=three 4= | |
while getopts "a:b:" opt; do | |
case "$opt" in | |
"a") A="$OPTARG";; | |
"b") B="$OPTARG";; | |
esac |
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 | |
A=("$@") | |
X="$@" | |
echo; echo '"$@": <-- correct' | |
for arg in "$@"; do echo "$arg"; done | |
echo; echo '"${A[@]}": <-- correct' | |
for arg in "${A[@]}"; do echo "$arg"; done |
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
# A base class for implementing CLI scripts. | |
# ARGV and in/out IO's are injected, so can be mocked & tested. | |
# Basic signal handling by calling exit_on_signals inside work loops etc. | |
# Requires Ruby 2.0.0+ for keyword args etc. | |
class BaseScript | |
EXIT_SUCCESS = 0 | |
INDENT = " " | |
def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr) |
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 | |
set -euo pipefail | |
IFS=$'\n\t' | |
set -x | |
DEVICE_B="/dev/xvdb" | |
DEVICE_C="/dev/xvdc" | |
VG_NAME="ephemeral" | |
LV_NAME="ephemeral" | |
DEVICE_LV="/dev/$VG_NAME/$LV_NAME" |
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 "open-uri" | |
require "benchmark" | |
def main | |
urls = ARGV | |
results = Queue.new |
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 A | |
def with(&block) | |
instance_eval(&block) | |
end | |
private | |
def private_blarg | |
puts 'this is from a private method' | |
end | |
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 | |
# Contrived example of self-pipe preventing signal race condition prior to select() | |
# @see http://cr.yp.to/docs/selfpipe.html | |
# @author Paul Annesley | |
SELF_READ, SELF_WRITE = IO.pipe | |
@run = true | |
trap :INT do |
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 | |
# | |
# Are you one of the 10% of programmers who can write a binary search? | |
# http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/ | |
def bin_search(search, subject) | |
discarded_left = 0 | |
while subject.any? |
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 | |
# Attempts to fast-forward the current local branch to its remote tracked branch. | |
# Safely refuses if there is no remote tracking, or if a fast-forward is not possible. | |
# @author Paul Annesley | |
if [ -n "$(git merge --ff-only 2>&1 | grep 'unknown option')" ]; then | |
echo "Your git doesn't seem to support --ff-only... try git 1.7+" | |
exit 1 | |
fi |
OlderNewer