Skip to content

Instantly share code, notes, and snippets.

View Oshuma's full-sized avatar

Dale Campbell Oshuma

View GitHub Profile
# example of using rush to access files on multiple servers (as one collection)
nginx_confs = %w(www1 www2 www3).map { |n| Rush::Box.new(n)['/etc/nginx/nginx.conf'] }
nginx_confs.search(/access_log/)
@Oshuma
Oshuma / gist:14219
Created October 1, 2008 23:04
EndNote Export
%0 Journal Article
%T Spectacular Giant Magnetoresistance Effects in the Polycrystalline Perovskite Pr0. 7Sr0. 05Ca0. 25MnO3-d
%A Raveau, B
%A Maignan, A
%A Caignaert, V
%J Journal of Solid State Chemistry
%V 117
%N 2
%P 424-426
%D 1995
# app/helpers/application_helper.rb
# Sets the page title and outputs a container if passed in.
# ex. <%= title('Some Page', :h2) %> will return the following:
# <h2>Some Page</h2> as well as setting the page title.
def title(name, container = nil)
@page_title = name
content_tag(container, name) if container
end
h1. Things I Always Do
* Initialize git repository
* Move config/database.yml to config/database.yml.example
* rm -f log/*.log
* <code>find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;</code>
* git add . && git commit -m 'Initial commit.'
* Add top-level .gitignore
* Write AppConfig
* Install restful_authentication.
<% form_tag session_path, :class => 'some_class' do %>
<%= text_field_tag :openid_url, params[:openid_url] || params['openid.identity'], :class => 'another_class' %>
<%= submit_tag 'Use OpenID', :class => 'button grey' %>
<% end %>
# Just in case you can't make up your mind.
# Provide a string of choices separated by 'or'.
#
# p = Picker.new('tits or gtfo or OMFG')
# p.choice # => 'tits'
# p.choice # => 'OMFG'
#
#
# The second argument can be a separator:
#
# Passenger (mod_rails) Apache2 config.
<VirtualHost 1.2.3.4:80>
ServerAdmin admin@example.com
ServerName www.example.com
DocumentRoot /path/to/rails_root/public
</VirtualHost>
# Coin.flip # => 'heads' or 'tails'
class Coin
def self.flip
%w{heads tails}.sort_by {rand}.first
end
end
Flush DNS Cache
OSX (10.5)
----------
dscacheutil -flushcache
Windows
-------
C:\>ipconfig /flushdns
# tree = Node.new
# tree.branch.leaf.value = 'Hello World!'
class Node < Hash
attr_accessor :value
def method_missing(key)
self[key]==nil ? self[key]=Node.new : self[key]
end
end