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 Class | |
# Adds a initialize method, which takes attributes as a hash | |
# Optionally call with symbol-names, to additionally create attribute accessors with `attr_accessor` | |
def attr_initializer(*args) | |
attr_accessor *args unless args.empty? | |
module_eval <<-END | |
def initialize(attributes = {}) | |
initialize_attributes(attributes) | |
end | |
def initialize_attributes(attributes = {}) |
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 | |
def parse_missing_required(input) | |
matches = input.match(/Missing these required gems:([\s\S]*)You're running:/) | |
matches[1].strip.split("\n").map do |line| | |
m = line.match(/^\s*(\S+)\s+(\S+\s+[0-9.]+)/) | |
p line if m.nil? | |
{:name => m[1], :version => m[2]} | |
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
#!/bin/bash | |
LINE_COLOR=`echo -en '\e[92m'` | |
LINE_COLOR_RESET=`echo -en '\e[00m'` | |
MATCH_COLOR=`echo -en '\e[1m\e[33m'` | |
MATCH_COLOR_RESET=`echo -en '\e[22m\e[92m'` | |
PATTERN="" | |
if [ $# = 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/bash | |
svn diff "$@" | source-highlight --out-format=esc --src-lang=diff |
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 | |
TARGET=$1 | |
SVNROOT=`svn info | grep -h 'Repository Root: .*' | sed 's/Repository Root: //g'` | |
REVISION=`svn log --limit 1 --quiet $TARGET | grep -oh '^r.*' | sed 's/r\([0-9]*\).*/\1/g'` | |
svn log --limit 1 $TARGET | |
svn diff -c $REVISION $SVNROOT | source-highlight --out-format=esc --src-lang=diff |
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 sh | |
print_usage() { | |
printf "Usage: %s [-t=TESTFILE] [-w=WATCHDIR]\n" $(basename $0) | |
echo " TESTFILE Command to run test" | |
echo " WATCHDIR Dir to watch for changes" | |
exit 2 | |
} | |
# you need these dependencies: | |
# sudo apt-get install inotify-tools |
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 bash | |
# find and replace by regexp in many files | |
PRUNE="" | |
REPLACE="" | |
print_usage() { | |
echo "USAGE: $(basename $0) [--prune EXTENSIONS] [--replace REPLACE] SEARCH" | |
echo " EXTENSIONS Comma separated list of file extensions to ignore" | |
exit 1 | |
} | |
while true |
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
phpsh (c)2006 by Charlie Cheever and Dan Corson and Facebook, Inc. | |
type 'h' or 'help' to see instructions & features | |
New Feature: You can use the -c option to turn off coloring | |
php> var_dump(null > 10); | |
bool(false) | |
php> var_dump(null < 10); | |
bool(true) | |
php> var_dump(null == 10); | |
bool(false) | |
php> var_dump(null == null); |
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 | |
[ $# -eq 2 ] || echo "USAGE $0 REPOSITORY DESTINATION" && exit 1 | |
REPOSITORY=$1 | |
DESTINATION=$2 | |
TMPNAME="/tmp/$(basename $REPOSITORY).$$" | |
git clone $REPOSITORY $TMPNAME | |
rm -rf $TMPNAME/.git | |
mkdir -p $DESTINATION | |
cp -r $TMPNAME/* $DESTINATION | |
rm -rf $TMPNAME |
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 'uri' | |
require 'cgi' | |
require 'net/https' | |
cert_file = feed_source.certificate_absolute_path | |
raise "Cert file required" if cert_file.nil? || !(File.exists?(cert_file) && !File.directory?(cert_file)) | |
request = Net::HTTP.new(feed_source.url, 443) | |
request.use_ssl = true |
OlderNewer