Skip to content

Instantly share code, notes, and snippets.

@stream7
stream7 / view_sql_in_rails_console
Created July 5, 2011 13:24
SQL logs from activerecord in rails console
For Rails 2:
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
For Rails 3:
ActiveRecord::Base.logger = Logger.new(STDOUT)
taken form http://stackoverflow.com/questions/1344232/how-can-i-see-the-sql-that-will-be-generated-by-a-given-activerecord-query-in-rub
@stream7
stream7 / README.markdown
Created August 13, 2011 11:33 — forked from ariera/README.markdown
Nestable, sortable and dragable categories

Nestable, sortable and dragable categories:

In the project I'm working on we wanted to have a Category model which we wanted to be nestable. But we also liked the user to have a draggable interface to manage and rearrange the order of his categories. So we chose awesome_nested_set for the model and jQuery.nestedSortable for the UI.

It took me some time to arrange things to work properly so I wanted to share my work in case it helps anybody.

Before beginning

you might want to take a look at a demo app

  1. go to: http://awesomenestedsortable.heroku.com/groups/
  2. click in show of any group
@stream7
stream7 / favorite_gems.md
Created August 29, 2011 18:07 — forked from ryanb/favorite_gems.md
A list of my favorite gems for various tasks.
@stream7
stream7 / Gemfile
Created September 1, 2011 05:40 — forked from chriseppstein/readme.md
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass', '~> 0.12.alpha'
end
@stream7
stream7 / index.html.slim
Created September 24, 2011 15:42 — forked from wlangstroth/index.html.slim
html5boilerplate in slim for rails
doctype html
/[if lt IE 7]
| <html class="no-js ie6 oldie" lang="en">
/[if IE 7]
| <html class="no-js ie7 oldie" lang="en">
/[if IE 8]
| <html class="no-js ie8 oldie" lang="en">
/[if gte IE 8]
| <html class="no-js" lang="en">
head
@stream7
stream7 / paperclip.rb
Created September 29, 2011 18:50 — forked from serek/paperclip.rb
Paperclip initializer for S3 Europe.
Paperclip.interpolates(:s3_eu_url) { |attachment, style|
"#{attachment.s3_protocol}://s3-eu-west-1.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
}
require 'aws/s3'
AWS::S3::DEFAULT_HOST = "s3-eu-west-1.amazonaws.com"
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
@stream7
stream7 / paperclip_migration.rake
Created October 26, 2011 16:16 — forked from louisgillies/paperclip_migration.rake
Quick and dirty one off migration task for paperclip plugin to move files from local filesystem to Amazon S3.
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:model_1, :model_2] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@stream7
stream7 / rails_symbolic_status_codes
Created September 28, 2012 10:15
Rails symbolic status codes
Status Code Status Message Symbol
1xx Informational
100 Continue :continue
101 Switching Protocols :switching_protocols
102 Processing :processing
2xx Success