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
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 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 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 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 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 |
NewerOlder