- Use UTF-8 as the source file encoding.
- Use 2 space indent, no tabs. (Your editor/IDE should have a setting to help you with that)
- Use Unix-style line endings. (Linux/OSX users are covered by default, Windows users have to be extra careful)
- if you're using Git you might want to do this
$ git config --global core.autocrlf true
to protect your project from Windows line endings creeping into your project
- if you're using Git you might want to do this
- Use spaces around operators, after commas, colons and semicolons, before { and }.
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
# config/initializers/facebooker.rb | |
module Facebooker | |
class << self | |
def fetch_config_for(api_key) | |
if app = Application.find_by_api_key(api_key) | |
{ | |
'api_key' => app.api_key, | |
'secret_key' => app.secret, | |
'canvas_page_name' => app.canvas_name, | |
'callback_url' => app.callback_url, |
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 the view | |
<% unless current_user.fan?(params[:fb_sig_app_id]) %> | |
<div style="width: 117px; height: 25px; margin-right: 10px; margin-bottom: 20px; float: right; overflow: hidden; position: relative;"> | |
<div style="position: absolute; top: -31px; left: -60px;"> | |
<fb:fan profile_id="<%= params[:fb_sig_app_id] %>" stream="1" connections="10" width="300"></fb:fan> | |
</div> | |
</div> | |
<% end %> | |
# in the model |
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
admin = Facebooker::Session.new.admin | |
properties = admin.get_app_properties :preload_fql | |
preload_fql = JSON.parse(properties.preload_fql) || {} | |
if preload_fql['online_friends'].blank? | |
if preload_fql['friends'].blank? | |
preload_fql['friends'] = { | |
:pattern => '.*', | |
:query => "SELECT uid2 FROM friend WHERE uid1 = {*user*}" | |
} |
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
# to create a new student | |
s1 = Sevis::Student.new( | |
:personal_info => { | |
:birth_date => '1986/12/01', | |
#... | |
}, | |
:educational_info => { | |
:edu_level => { | |
:level => '...' | |
#... |
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
" An example for a vimrc file. | |
" | |
" Maintainer: Bram Moolenaar <Bram@vim.org> | |
" Last change: 2002 Sep 19 | |
" | |
" To use it, copy it to | |
" for Unix and OS/2: ~/.vimrc | |
" for Amiga: s:.vimrc | |
" for MS-DOS and Win32: $VIM\_vimrc | |
" for OpenVMS: sys$login:.vimrc |
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 Proxy | |
instance_methods.each do |method| | |
undef_method(method) unless method =~ /(^__|^send$|^object_id$|^extend$)/ | |
end | |
def initialize(target) | |
@target = target | |
end | |
def method_missing(name, *args, &block) |
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 find_branches(name) | |
`git branch -r|grep '/#{name.gsub("'", '')}'`.to_s.split("\n").map(&:strip) | |
end | |
def last_commit_url(branch) | |
remote, name = branch.split('/') | |
sha = `git log -n 1 #{branch}|head -n 1|awk '{print $2}'`.strip | |
url = `git remote -v|grep #{remote}|grep '(push)'|awk '{print $2}'`.strip |
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
sudo tmutil disablelocal | |
ssh-keygen -t rsa -b 4096 -N "" | |
chsh -s /bin/zsh | |
# install dotfiles | |
rehash | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" | |
# echo 'export PATH="/usr/local/sbin:/usr/local/bin:$PATH"' >> .zshrc | |
rehash | |
fetch https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg | |
# fetch https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg |
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
/* | |
As of version 1.1.2, Propane will load and execute the contents of | |
~Library/Application Support/Propane/unsupported/caveatPatchor.js | |
immediately following the execution of its own enhancer.js file. | |
You can use this mechanism to add your own customizations to Campfire | |
in Propane. | |
Below you'll find two customization examples. |
OlderNewer