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 "rubygems" | |
require "benchmark" | |
params = {} | |
puts "with params = {}" | |
Benchmark.bm(16) do |x| | |
x.report("with if-inline: ") { 1_000_000.times { params[:page] ? params[:page].to_i : 1 } } | |
x.report("with max......: ") { 1_000_000.times { [params[:page].to_i, 1].max } } | |
x.report("with or.......: ") { 1_000_000.times { (params[:page] || 1).to_i } } | |
x.report("with fetch....: ") { 1_000_000.times { params.fetch(:page, 1).to_i } } |
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
dns - http://freedns.ws | |
google apps - http://google.com/a | |
yola, pra criar o site - http://www.yola.com/ | |
logonerds, logos por $50 - http://www.logonerds.com/ | |
wuffo, forms builder - http://wufoo.com/ | |
analytics, pra monitorar - http://www.google.com/analytics/ | |
blog (tumblr) | |
adwords |
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
# Benchmark: !!(value) or (value == expected) | |
require 'benchmark' | |
n = 5000000 | |
value = :value | |
Benchmark.bm do |x| | |
x.report { p( !!(1 < 0 || 1 > 0) ) } | |
x.report { p( (1 < 0 || 1 > 0) == true ) } | |
x.report { p( !!(nil || value) ) } |
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
<div style="width:400px;overflow:auto"> | |
<h2>This comes from ajax request</h2> | |
<p> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean non velit. Donec pharetra, felis ut tristique adipiscing, diam magna rhoncus neque, sit amet convallis nibh nibh vel libero. Nulla facilisi. In eleifend nisl quis lorem. Duis semper fringilla justo. Proin imperdiet sapien sed lectus. Integer quis nisl et est elementum tempor. Morbi quis tellus nec turpis suscipit molestie. Praesent sed pede. Pellentesque ac orci. Sed sit amet urna eget tellus hendrerit aliquet. Nulla consectetur, pede aliquam ornare placerat, nunc augue commodo leo, sit amet elementum dolor est eleifend magna. | |
</p> | |
</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
1,Grixis Panorama,Land | |
1,Naya Panorama,Land | |
1,Bant Panorama,Land | |
1,Obelisk of Esper,3 | |
1,Obelisk of Bant,3 | |
1,Lush Growth,G | |
1,Elvish Visionary,1G | |
1,Elvish Visionary,1G | |
1,Cylian Elf,1G | |
1,Savage Hunger,2G |
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
#-- | |
# Copyright (c) 2006 Andrew Turner <geolocation@highearthorbit.com> | |
# | |
# Based on Geocoder - Copyright (c) 2006 Paul Smith <paul@cnt.org> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# "Software"), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, | |
# distribute, sublicense, and/or sell copies of the Software, and to |
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
$ whois ericfer.com | |
Whois Server Version 2.0 | |
Domain names in the .com and .net domains can now be registered | |
with many different competing registrars. Go to http://www.internic.net | |
for detailed information. | |
Domain Name: ERICFER.COM | |
Registrar: ENOM, INC. |
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
{ name = 'keyword.other.annotation.ruby'; | |
comment = ' everything being a method but having a special function is a..'; | |
match = '^\s*\b(private|public|protected)\b.*?$\n'; | |
}, |
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 Hash | |
def downcase_all_keys | |
result = self.map do |k,v| | |
[ | |
k.downcase, | |
case v.class.name | |
when "Hash" then v.downcase_all_keys | |
when "Array" then v.map {|i| i.downcase_all_keys } | |
else v | |
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
module Authentication | |
def logged_in? | |
current_user.is_a?(User) | |
end | |
def current_user | |
@current_user ||= User.find_by_id(session[:user_id]) || :false | |
end | |
def current_user=(new_user) |