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
bronson@t500-jaunty:~$ ifconfig | |
eth0 Link encap:Ethernet HWaddr 00:1c:25:97:40:e0 | |
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 | |
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:1000 | |
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) | |
Memory:fc000000-fc020000 | |
lo Link encap:Local Loopback |
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
# download the command | |
cd /tmp | |
wget http://github.com/bronson/git-subtree/raw/6aa0e3e116daafd3292b862555b7a0da81352070/git-subtree | |
chmod a+x /tmp/git-subtree | |
# and put another git project as a subtree into myrepo | |
cd ~/myrepo/ | |
VERBOSE=1 /tmp/git-subtree clone git://blah/subproject.git | |
# (VERBOSE shows the git commands that it's using) |
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
<div class="list"> | |
<ul> | |
<% @items.each do |item| %> | |
<li class="<%= item_classes_for_user(item, @current_user) %>"> | |
<%= image_tag "/icons/#{item.state}.png" %> | |
<span class="name"> | |
<%= item.name %> | |
</span> | |
</li> | |
<% 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
<div class="list"> | |
<ul> | |
<% @items.each do |item| %> | |
<li class="<%= item_classes_for_user(item, @current_user) %>"> | |
<%= image_tag "/icons/#{item.state}.png" %> | |
<span class="name"> | |
<%= item.name %> | |
</span> | |
</li> | |
<% 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
# In reply to http://www.ultrasaurus.com/sarahblog/2009/08/ruby-unit-test-frameworks/ | |
# Put this in test_helper.rb to compare two arbitrarily nested structures. | |
# Usage: compare_objects(o1, o2). Raises an exception if it finds any differences. | |
# recursivly compare two objects. raise if a difference was found, return if not. | |
def compare_objects(wanted, actual, path=[]) | |
if wanted.kind_of?(Hash) | |
raise "Objects differ at #{path.join(".")}: extra keys in wanted: #{(wanted.keys - actual.keys).inspect}" if (wanted.keys - actual.keys).length > 0 | |
raise "Objects differ at #{path.join(".")}: extra keys in actual: #{(actual.keys - wanted.keys).inspect}" if (actual.keys - wanted.keys).length > 0 | |
wanted.keys.sort.each do |key| |
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
module RestClient | |
# Compatibility : make the Response act like a Net::HTTPResponse when needed | |
module ResponseForException | |
def method_missing symbol, *args | |
puts "called: #{:symbol}" | |
end | |
end | |
end | |
# produces: undefined method `whatev' for RestClient::ResponseForException:Module (NoMethodError) |
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
# minor improvement to http://blog.js.hu/2010/01/07/unobtrusive-jqgrid-on-rails-a-la-2dconcept-but-with-searchlogic/ | |
# (would have commented but blog.js.hu isn't sending me a registration email) | |
if params[:_search].present? | |
filters = {} | |
if params[:_search] == "true" | |
searchable_columns.each do |param| | |
filters["#{param}_like"] = params[param] if params[param].present? | |
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
Named scopes are great. You can compose huge queries by gluing | |
parts together. | |
u = User | |
u = u.employee if params[:employee] | |
u = u.unvested if params[:unvested] | |
... etc. | |
u.length -- returns the number of users matching the query. | |
Works great if you specify either parameter. You end up with one of: |
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
" Make \w toggle through the three wrapping modes. | |
" Add this to your vimrc: | |
:function ToggleWrap() | |
: if (&wrap == 1) | |
: if (&linebreak == 0) | |
: set linebreak | |
: else | |
: set nowrap | |
: endif |
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
My attempt (bad): | |
function s:FixWhitespace() range | |
for lineno in range(a:firstline, a:lastline) | |
call setline(lineno, substitute(getline(lineno), '\s\+$', '', '')) | |
endfor | |
endfunction | |
" Run :FixWhitespace to remove end of line white space. | |
command! -range=% FixWhitespace silent! <line1>,<line2>call <SID>FixWhitespace |
OlderNewer