- Put this code at #{Rails.root}/db/seeds.rb
- type
rake db:setup
It supports only `id' primary key.
| class Avatar < ActiveRecord::Base | |
| attr_accessor :content_type, :original_filename, :image_data | |
| before_save :decode_base64_image | |
| has_attached_file :image, | |
| PAPERCLIP_CONFIG.merge( | |
| :styles => { | |
| :thumb => '32x32#', | |
| :medium => '64x64#', |
| class Avatar < ActiveRecord::Base | |
| attr_accessor :content_type, :original_filename, :image_data | |
| before_save :decode_base64_image | |
| has_attached_file :image, | |
| PAPERCLIP_CONFIG.merge( | |
| :styles => { | |
| :thumb => '32x32#', | |
| :medium => '64x64#', |
| # Toss this in your ~/.irbrc file for a convenient way | |
| # to peruse Ruby source code in Emacs.app. This | |
| # only works in Ruby 1.9! | |
| # | |
| # Use it in irb like so: | |
| # | |
| # >> require 'active_record' | |
| # >> ActiveRecord::Base.source_for_method(:create) | |
| class Object |
| # -*- coding: utf-8 -*- | |
| require 'rubygems' | |
| require 'thor' | |
| class Passgen < Thor | |
| TABLE = { | |
| :number => (0x30...0x3A).map(&:chr), # 0123456789 | |
| :upper => (0x41...0x5b).map(&:chr), # ABCDEFGHIJKLMNOPQRSTUVWXYZ | |
| :lower => (0x61...0x7b).map(&:chr), # abcdefghijklmnopqrstuvwxyz |
| source 'http://rubygems.org' | |
| gem 'goliath', :git => 'https://github.com/postrank-labs/goliath.git' | |
| gem 'yajl-ruby' | |
| gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :require => 'eventmachine' | |
| gem 'em-http-request', :git => 'https://github.com/igrigorik/em-http-request.git' | |
| gem "em-synchrony", :git => 'https://github.com/igrigorik/em-synchrony.git' |
| namespace :haml do | |
| desc "Convert all .erb views to .haml" | |
| task :assimilate => :environment do | |
| git = File.exist?( Rails.root.join('.git') ) | |
| chdir Rails.root do | |
| Dir["app/views/**/*.erb"].map do |file| | |
| [ file, file.gsub(/\.erb$/, '.haml') ] | |
| end.each do |(erb, haml)| | |
| sh "bundle exec html2haml #{erb} #{haml}" |
| #!/bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: unicorn | |
| # Required-Start: $local_fs $remote_fs | |
| # Required-Stop: $local_fs $remote_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: S 0 1 6 |
rewriteルールを適用するための Rack ミドルウェアです。 Apache mod_rewrite ルールを書く代わりに使えます。
| module Termtter::Client | |
| # search replacement: | |
| # ADD: #[page] arg for list next pages | |
| register_command( | |
| :name => :search, :aliases => [:s], | |
| :exec_proc => lambda {|arg| | |
| search_option = config.search.option.empty? ? {} : config.search.option | |
| arg.gsub!(/\s*#(\d+)$/) { search_option[:page] = $1 ; ''} | |
| if arg.empty? && tags = public_storage[:hashtags] | |
| arg = tags.to_a.join(" ") |