For a much more elegant way, visit my blog.
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
<h1>Last activity</h1> | |
<% for day, messages in @messages_by_day -%> | |
<h2><%= day %></h2> | |
<ol> | |
<%- for message in messages -%> | |
<li><%= link_to message.title, message %></li> | |
<%- end -%> | |
</ol> | |
<% 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 | |
# for each git repo in a subdirectory ... | |
dirs = Dir['**/.git'].map { |gd| File.dirname(gd) } | |
def prompt | |
print ">> " | |
gets | |
end | |
# ... execute a command given on STDIN |
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
## Usage: | |
$ ruby git-scoreboard.rb | |
You can also specify a range of commits: | |
$ ruby git-scoreboard.rb v1.2..HEAD | |
## Outputs: |
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
## gets the latest Twitter update from a user | |
require 'rubygems' | |
require 'json' | |
require 'yaml' | |
require 'open-uri' | |
CONFIG_FILE = ENV["HOME"] + "/.twitter" | |
CACHE_FILE = "/tmp/.#{ENV["LOGNAME"]}_TwitterAdium.txt" | |
DEFAULTS = { 'interval' => 300, 'limit' => 3 } |
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
Xcode | |
http://developer.apple.com/technology/xcode.html | |
[OR] | |
Mac OS X install disc 2 | |
GNU wget | |
http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz | |
Git | |
http://code.google.com/p/git-osx-installer/ |
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
# nginx: redirect secondary domain names to primary | |
server { | |
listen 80; | |
server_name mislav.caboo.se mislavmarohnic.com mislavmarohnic.name mislav.name mislav.info mislav.biz; | |
# ... | |
if ($host != "mislav.caboo.se") { | |
rewrite .* http://mislav.caboo.se$uri permanent; | |
} |
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 ErbEngine < Haml::Engine | |
def push_script(text, preserve_script, in_tag = false, preserve_tag = false, | |
escape_html = false, nuke_inner_whitespace = false) | |
push_text "<%= #{text.strip} %>" | |
end | |
def push_silent(text, can_suppress = false) | |
push_text "<% #{text.strip} %>" | |
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
require 'haml' | |
module ImplicitTags | |
ALLOWED_NESTING = { | |
'tr' => %w(table thead tbody tfoot), | |
'td' => 'tr', | |
'li' => %w(ul ol), | |
'col' => 'colgroup', | |
'dd' => 'dl', | |
'option' => %w(select optgroup), |
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
YouTubeModel::SingletonMethods.class_eval do | |
include WillPaginate::Finders::Base | |
protected | |
def wp_query(options, pager, args) | |
# dup options and set limit | |
args << options.merge(:max_results => pager.per_page) | |
# carefully add start_index (YouTube goes nuts if it's zero) | |
args.last[:start_index] = pager.offset if pager.offset > 0 |
OlderNewer