Skip to content

Instantly share code, notes, and snippets.

def empty?(s)
return s.size == 0
end
class B
def ==(s)
"not boolean"
end
end
@cutalion
cutalion / notes_for_rails_meetup_feb_2013.md
Created January 28, 2013 13:29
Notes for Rails Meetup - Feb 2013

Nice gems

  • racksh - console for Rack apps, like rails c or merb -i
Rails.application.config.database_configuration
Rails.application.load_generators
Rails.application.load_seed
Rails.application.paths['db/migrate'].to_a
Rails.application.railties.all
Rails::Engine.find(ENGINE_PATH)
Rails.env
Rails.env.development?
Rails::Generators::SessionMigrationGenerator.start [ ENV['MIGRATION'] || 'add_sessions_table' ]
Rails.root

Notes for Rails Meetup - Jan 2013

Rerun/Reload app

  • hot-key
  • hook on save
  • watch
  • Rack::Reloader
  • guard/autotest/shotgun/etc
@cutalion
cutalion / Gemfile
Created November 28, 2012 00:38
Gemfile with alphabetically sorted gems
source :gemcutter
source 'http://gems.github.com'
gem 'rails', '3.2.7'
gem 'rake', '0.9.2.2'
gem 'foreman'
gem 'sidekiq', '= 2.4.0'
gem 'sinatra', require: false
# Database and data related [Putting pg to the end because of a weird bug with Lion, pg and openssl]
@cutalion
cutalion / carrierwave.rb
Created November 13, 2012 16:23
CarrierWave test configuration
# spec/support/carrierwave.rb
class TestStorage < CarrierWave::Storage::File
def store!(file)
end
def retrieve!(identifier)
identifier
end
end
@cutalion
cutalion / gaz.rb
Created October 26, 2012 12:00 — forked from alg/communal.rb
# encoding: utf-8
def gas(name = "", acct = "")
url = "http://sevgaz.com.ua/index.php?option=com_content&view=article&id=52"
data = `curl -F "afam=#{name}" -F "peracc=#{acct}" "#{url}" 2>/dev/null`
data.scan(%r{Адрес.*?<tr><td>(.*?)</td>\s*<td>\s*<strong>(.*?)</strong>}).flatten
end
def water(name = "", acct = "")
@cutalion
cutalion / first_controller.rb
Created October 26, 2012 11:55
Call action from action. Is it good?
class FirstController < ApplicationController
def edit
prepare_model_for_form
end
def update
current_user.attributes = params[:user]
current_user.validates_email!
if current_user.save
@cutalion
cutalion / another_controller_spec.rb
Created October 25, 2012 13:23
Similar controller specs
describe SomeController do
context "if user is not logged in" do
specify "GET 'show' should redirect to login page" do
get :show
response.should redirect_to login_path
end
specify "PUT 'update' should redirect to login page" do
put :update
response.should redirect_to login_path
@cutalion
cutalion / gist:2889295
Created June 7, 2012 15:06
Rails Meetup - June 2012. Notes

Вопросы от Ивана Линько.

  1. Интересно было бы послушать чем отличается переезд с хероку от обычного деплоя на новый сервер, если чем-то отличается.
  • перенос БД (mongodump/mongorestore)
  • изменение способа хранения настроек
  • настройка почты (Google Apps)