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 'singleton' | |
class State | |
attr_accessor :machine | |
STATES = {:ready => "Ready", :listen => "Listen", :processing => "Processing"} | |
def initialize(machine) | |
@machine = machine | |
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 'singleton' | |
class State | |
attr_accessor :machine | |
STATES = {:ready => "Ready", :listen => "Listen", :processing => "Processing"} | |
def initialize(machine) | |
@machine = machine | |
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
*sponsor.txt* For Vim version 7.1. Last change: 2007 Jan 05 | |
VIM REFERENCE MANUAL by Bram Moolenaar | |
SPONSOR VIM DEVELOPMENT *sponsor* | |
Fixing bugs and adding new features takes a lot of time and effort. To show |
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
# bootstrapper.rb | |
# Rails Bootstrapper using rails template | |
# Based on Extended Bort -http://github.com/laktek/extended-bort/tree/master | |
# Ideal to use when building a comprehensive web app | |
# Uses Braid to track remote repos. | |
# by Lakshan Perera | |
# Use Braid to track remote git or svn repos. | |
def braid(command, repo, options={}) | |
other_params = "" |
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
function parse_git_dirty { | |
git diff --quiet HEAD &>/dev/null | |
[[ $? == 1 ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ ' |
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
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |
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
link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }}, { :class => "fine" }) | |
#Currently renders: | |
<a class="fine" href="#" onclick="new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;">Remote outauthor</a> | |
#suggested view render: | |
<a class="fine" data-rails-remote="true" href="http://www.example.com/whatnot">Remote outauthor</a> | |
#Method implemented by jquery.rails.js helper | |
$(a["data-rails-remote=true"]).($.ajax({ |
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
link_to_function("Show me more", nil, :id => "more_link") do |page| | |
page[:details].visual_effect :toggle_blind | |
page[:more_link].replace_html "Show me less" | |
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
#without :ujs option | |
link_to_function("Greeting", "alert('Hello world!')") | |
# <a href="#" onclick="alert('Hello world!'); return false;">Greeting</a> | |
#with :ujs and :id option | |
link_to_function("Greeting", "alert('Hello world!')", :id => "greeting_link", :ujs => true) | |
# <a href="#" id="greeting_link">Greeting</a> | |
# <script type="text/javascript"> | |
# //assuming users JS framework of choice is jQuery | |
# $(\"#greeting_link\").click( function(){ alert('Hello world!'); return false } ); |
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 Student < ActiveRecord::Base | |
has_many :rating | |
has_many :books, :through => :ratings | |
end | |
class Book < ActiveRecord::Base | |
has_many :ratings | |
has_many :students, :through => :ratings | |
end | |