This file contains hidden or 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
#!/bin/sh | |
# runcocoa.sh - Run any Cocoa code from the command line | |
# | |
# Michael Tyson, A Tasty Pixel <[email protected]> | |
# | |
ccflags=""; | |
includes=""; | |
usegdb=; | |
ios=; | |
while [ "${1:0:1}" = "-" ]; do |
This file contains hidden or 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
set :rails_env, "production" | |
set :passenger_port, 9292 | |
set :passenger_cmd, "#{bundle_cmd} exec passenger" | |
namespace :deploy do | |
task :start, :roles => :app, :except => { :no_release => true } do | |
run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d" | |
end | |
task :stop, :roles => :app, :except => { :no_release => true } do |
This file contains hidden or 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
source ~/.vim/vimrc | |
set wrap nowrap | |
if has("gui_running") | |
set columns=180 | |
colorscheme railscasts2 | |
if has("gui_mac") || has("gui_macvim") | |
set guifont=Menlo:h12 |
This file contains hidden or 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
- (id)initWithStyle:(id)style | |
{ | |
... | |
} | |
or | |
- (id)initWithStyle:(id)style { | |
... | |
} |
This file contains hidden or 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 Post | |
extend Enumerable | |
def self.files | |
Dir["posts/*.markdown"].sort_by { |file| File.stat(file).ctime }.reverse | |
end | |
def self.each | |
files.each do |entry| | |
File.open(entry) { |file| yield Post.new(file.read) } |
This file contains hidden or 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
-A INPUT -i lo -j ACCEPT | |
-A OUTPUT -o lo -j ACCEPT | |
-A OUTPUT -p udp -o eth0 --dport 53 --sport 1024:65535 -j ACCEPT | |
-A INPUT -p udp -i eth0 --sport 53 --dport 1024:65535 -j ACCEPT | |
-A OUTPUT -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT | |
-A INPUT -p tcp -i eth0 --dport 22 --sport 1024:65535 -m state --state NEW -j ACCEPT | |
-A INPUT -p tcp -i eth0 --dport 80 --sport 1024:65535 -m state --state NEW -j ACCEPT | |
-A OUTPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -o eth0 -p tcp -m multiport --dport 80,443 -m multiport --sport 1024:65535 | |
-A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i eth0 -p tcp | |
-A INPUT -j DROP |
This file contains hidden or 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
root :to => "home#show", :constraints => UserLoggedConstraint.new(false) | |
root :to => "profile#show", :constraints => UserLoggedConstraint.new(true) |
This file contains hidden or 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 AttrEncryptedRelation | |
def self.included(base) | |
base.class_eval do | |
alias_method_chain :build_where, :attr_encrypted | |
end | |
end | |
private | |
def build_where_with_attr_encrypted(opts, other = []) |
This file contains hidden or 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 String | |
def encrypt(options = {}) | |
crypt :encrypt, options | |
end | |
def decrypt(options = {}) | |
crypt :decrypt, options | |
end | |
private |
This file contains hidden or 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 User | |
has_many :posts | |
end | |
class Post | |
belongs_to :user | |
has_many :comments | |
def self.search(comment_description) | |
joins(:comments).where(:comments => { :description => comment_description }) |