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 local copy of edge rails | |
# inside('vendor') { run 'ln -s ~/dev/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
#run "rm -f public/javascripts/*" | |
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
# This is a trivial HTTP proxy server, intended for use as a troubleshooting tool | |
# ONLY (not for real, actual, production use). I wrote this because I couldn't find | |
# a simple HTTP proxy that I could use to test HTTP proxy support in Net::SSH. | |
# | |
# This code is in the public domain, so do with it what you will! | |
require 'socket' | |
server = TCPServer.new('127.0.0.1', 8080) | |
client = server.accept |
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
#Rails 2.3 features | |
User.admins.first.try(:address).try(:reset) | |
#-------------------------------------------- | |
render :partial => 'articles/article', :locals => { :article => @article } | |
#---> | |
render @article | |
#------------------------------------------- | |
default_scope :order => 'created_at DESC' |
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 'feedzirra' | |
# fetching a single feed | |
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing") | |
# feed and entries accessors | |
feed.title # => "Paul Dix Explains Nothing" | |
feed.url # => "http://www.pauldix.net" | |
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing" | |
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0" |
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
# Measure the amount bloat you're adding by requiring libraries. | |
# | |
# Usage: | |
# | |
# Bloat.measure do | |
# require 'rubygems' | |
# require 'activesupport' | |
# end | |
# | |
# A report will be printed that tells you how many methods were |
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
You can use {TagsAsClasses} and tranform a tag in a CSS class: | |
A little example: | |
<div class="{TagsAsClasses}">....</div> | |
Add the tag test123 to a post and the relative output code will be: | |
<div class="test123">...</div> |
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 OpenStruct | |
def to_json | |
table.to_json | |
end | |
end | |
o = OpenStruct.new | |
o.foo = "foo" | |
o.bar = 1 | |
o.to_json |
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 User | |
def fullname(first, second) | |
"#{this.firstname} #{first} whatever" | |
end | |
def address(options) | |
"#{street} #{options[:hash_key]}" | |
end | |
def smth(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
7a8 | |
> @methods_params_hash = {} | |
29a31,37 | |
> def methods_with_params | |
> Array(options[:methods]).inject({}) do |method_attributes, method_array| | |
> method_attributes.merge!(method_array) if method_array.is_a?(Hash) | |
> method_attributes | |
> end | |
> 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
class Operation < ActiveRecord::Base | |
def best | |
created_at | |
end | |
def test(b) | |
"*#{b}*" | |
end | |
end |
OlderNewer