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
// Mixin that allows to specify arbitrary CSS properties with | |
// unitless numbers. The output has rem unit with pixel fallback. | |
// Shorthand assignments are supported too! | |
$base_line: 10; | |
@mixin rem($property, $values, $important:"") | |
{ | |
// Placeholder variables | |
$shorthand_px: ""; | |
$shorthand_rem: ""; |
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
Architecture description | |
- | |
Aggregator | |
Orchestrates the overall process from fetching to updating the db, | |
scheduling and managing aggregator jobs and their stages for different modules | |
does: | |
fetch :all | latest - accepts a block with strategy to determine latest | |
jobs :all | :current - AggreagationJob - status, stop, pause, resume |
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
# Redefines const value during block execution. | |
# | |
# Usage example: | |
# SOMECONST = 1 # SOMECONST == 1 | |
# redefine_const(:SOMECONST, 'hello') do | |
# puts SOMECONST # SOMECONST == 'hello' | |
# end | |
# # SOMECONST == 1 | |
def redefine_const(const, value, &block) | |
if const_defined = Object.const_defined?(const) |
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
Creating a Multi Page Form in Rails | |
Creating a multi-step wizard-like form is pretty difficult in Rails. | |
Especially when trying to apply REST and validations. There are many | |
different approaches to this problem, and the right one depends largely | |
on your application details. Here are four options, and then my final | |
recommendation. Skip to that if you're in a hurry. | |
1. Create the model at the beginning on the first page of the form, and | |
have each successive page update the model. Validations are tricky |
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
before "deploy:rollback:revision", "deploy:rollback_database" | |
desc "Rolls back database to migration level of the previously deployed release" | |
task :rollback_database, :roles => :db, :only => { :primary => true } do | |
if releases.length < 2 | |
abort "could not rollback the code because there is no prior release" | |
else | |
rake = fetch(:rake, "rake") | |
rails_env = fetch(:rails_env, "production") | |
migrate_env = fetch(:migrate_env, "") |
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
set :sync_directories, ["assets", "galleries"] | |
set :sync_backups, 3 |
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 Rack | |
class LocaleSetter | |
def initialize app | |
@app = app | |
end | |
def call env | |
locale = env["HTTP_HOST"].match(/^[a-z]{2}(?=\.)/) | |
I18n.locale = locale ? locale.to_s : 'es' | |
@app.call env |
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
Rails CMS alternatives | |
====================== | |
Note: project activity was checked on 11/26/09 for most of these projects, and the "last update" field has not been kept up to date since then. | |
Active projects: | |
--------------- | |
adva-cms | |
repo: http://github.com/svenfuchs/adva_cms/ | |
site: http://adva-cms.org/ | |
Last update: 11/24/09 |
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
# Run rake db:size to get a print of your database size in bytes. | |
# Run rake db:tables:size to get the sizes for individual tables | |
# Works for MySQL and PostgreSQL. Not tested elsewhere. | |
namespace :db do | |
desc 'Print data size for entire database' | |
task :size => :environment do | |
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database] | |
adapter = ActiveRecord::Base.connection.adapter_name.downcase |
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 Paperclip | |
class Attachment | |
class UploadedPath | |
attr_reader :original_filename, :content_type, :size, :path | |
def initialize(uploaded_file) | |
@original_filename = uploaded_file["name"].downcase | |
@content_type = uploaded_file["content_type"].to_s.strip | |
@file_size = uploaded_file["size"].to_i | |
@path = uploaded_file["path"] |
OlderNewer