[site] = name of site [root dir] = path to site root [logs] = path to logs directory
Example: site = helloworld root dir = /Users/me/Sites/helloworld logs = /Users/me/Sites/logs
#!/usr/bin/env ruby -wKU | |
class Object | |
def destruct! | |
print "This message will self-destruct in..." | |
5.downto(0) {|i| print "#{i}..."; $stdout.flush; sleep(1)} | |
File.open(__FILE__, 'w') { } | |
end | |
end |
require 'formula' | |
class Thrift < Formula | |
homepage 'http://incubator.apache.org/thrift/' | |
head 'http://svn.apache.org/repos/asf/incubator/thrift/trunk' | |
url 'http://archive.apache.org/dist/incubator/thrift/0.5.0-incubating/thrift-0.5.0.tar.gz' | |
md5 '14c97adefb4efc209285f63b4c7f51f2' | |
depends_on 'boost' |
_,'| _.-''``-...___..--';)
/_ \'. __..-' , ,--...--'''
<\ .`--''' ` /'
`-';' ; ; ;
__...--'' ___...--_..' .;.'
(,__....----''' (,..--''
To enable cat cat
, place the above text in a file titled cat. Image by Felix Lee, from http://user.xmission.com/~emailbox/ascii_cats.htm
require 'formula' | |
class Thrift < Formula | |
homepage 'http://incubator.apache.org/thrift/' | |
head 'http://svn.apache.org/repos/asf/incubator/thrift/trunk' | |
url 'http://archive.apache.org/dist/incubator/thrift/0.5.0-incubating/thrift-0.5.0.tar.gz' | |
md5 '14c97adefb4efc209285f63b4c7f51f2' | |
depends_on 'pkg-config' => :build | |
depends_on 'boost' |
require 'date' | |
class ExpiredTodoError < StandardError; end | |
# Implementation # | |
def todo(what, by_date) | |
if production? || (Date.parse(by_date) >= Date.today) | |
yield | |
else | |
raise ExpiredTodoError, "TODO: #{what}" |
[ undefined, null, [], {}, NaN ].forEach(function(val){ | |
console.log("val =", val, "; val == val; //", val == val ); | |
}); | |
// Output | |
// val = undefined ; val == val; // true | |
// val = null ; val == val; // true | |
// val = [] ; val == val; // true | |
// val = {} ; val == val; // true | |
// val = NaN ; val == val; // false |
find . -type f | # find all normal files | |
grep -v "\.log$" | # skip files ending with .log | |
xargs wc -l | # run wc -l on each file | |
sort -r # sort descending |
ps axc -o pid | grep -v PID | ruby -e 'puts STDIN.read.split("\n").shuffle.join("\n")' | head -1 | xargs kill |
# How to read a file in Ruby | |
file_name = "example.txt" | |
# It's simple. | |
# Open the file in read mode ("r"), read it, and close it. | |
f = File.open(file_name, "r") | |
f.read | |
f.close | |
# Though "r" is the default mode, so you can remove that. |