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
| sudo a2enmod rewrite | |
| in public/.htaccess | |
| RewriteEngine On | |
| RewriteCond %{THE_REQUEST} ^(GET|HEAD) | |
| RewriteCond %{REQUEST_URI} ^(.*)$ | |
| RewriteCond %{DOCUMENT_ROOT}/cache/$1.html -f | |
| RewriteRule ^(.*)$ /cache/$1.html |
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
| >>> import this | |
| The Zen of Python, by Tim Peters | |
| Beautiful is better than ugly. | |
| Explicit is better than implicit. | |
| Simple is better than complex. | |
| Complex is better than complicated. | |
| Flat is better than nested. | |
| Sparse is better than dense. | |
| Readability counts. |
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
| require 'spec/spec_helper' | |
| require 'logger' | |
| require 'benchmark' | |
| # Delayed::Worker.logger = Logger.new('/dev/null') | |
| Benchmark.bm(10) do |x| | |
| Delayed::Job.delete_all | |
| n = 3000*3 | |
| n.times { "foo".delay.length } |
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 Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
| def facebook | |
| # You need to implement the method below in your model | |
| @user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user) | |
| if @user.persisted? | |
| flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook" | |
| sign_in_and_redirect @user, :event => :authentication | |
| else | |
| session["devise.facebook_data"] = env["omniauth.auth"] |
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
| text = "7,3,s,1,1,2,y,4,2,r,2,4,1,o,2,3, ,1,R,1,1,1,b,5,3,c,5,4,k,2,u" | |
| decoded = [] | |
| text.split(",").inject(0) do |sum, char| | |
| unless char.to_i.zero? | |
| sum + char.to_i | |
| else | |
| decoded[sum] = char | |
| sum = 0 |
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
| first: brew install highlight | |
| second: add to your .zshrc (or .bashrc) | |
| function hlr { | |
| filename=`echo $1 | cut -d . -f 1` | |
| highlight --syntax ruby -k Menlo -K 20 -O rtf -s edit-xcode $1 > $filename.rtf | |
| } | |
| third: it will generate a .rtf file. just open and copy the highlighted code and add to your Keynote talk. |
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
| desc "Run all tests" | |
| task :build do | |
| system "rm rerun.txt" | |
| raise 'Error on rspec. Fix it, bro' unless system "bundle exec rspec spec" | |
| raise 'Error on cucumber plain. Fix it, bro' unless system "bundle exec cucumber" | |
| end |
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
| $(window).konami(function(){ | |
| $(".goku").show(); | |
| $(".goku").delay(2000).fadeOut(); | |
| }); |
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 Foo | |
| def do_something | |
| ... | |
| Rails.application.routes.url_helpers.my_awesome_routing_path | |
| Rails.application.routes.url_helpers.my_awesome_routing_url(:host => 'http://your-domain.com') | |
| ... | |
| end | |
| end |
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
| sed -i.bkp s/Factory\(\:/FactoryGirl.create\(\:/g spec/**/*.rb | |
| sed -i.bkp s/Factory\ \:/FactoryGirl.create\ \:/g spec/**/*.rb | |
| sed -i.bkp s/Factory\.build\ \:/FactoryGirl.build\ \:/g spec/**/*.rb | |
| sed -i.bkp s/Factory\.build\(\:/FactoryGirl.build\(\:/g spec/**/*.rb | |
| sed -i.bkp s/Factory\.next/FactoryGirl\.generate/g spec/**/*.rb | |
| rm -rf spec/**/*.bkp |
OlderNewer