Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Epictetus / gist:1031108
Created June 17, 2011 09:14 — forked from WizardOfOgz/gist:1012107
Save Base64-encoded images with Paperclip
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#',
@Epictetus
Epictetus / gist:1031117
Created June 17, 2011 09:24 — forked from WizardOfOgz/gist:1012107
Save Base64-encoded images with Paperclip
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#',
@Epictetus
Epictetus / gist:1047412
Created June 26, 2011 08:38 — forked from tmaeda/gist:1047385
View Source for Ruby
# 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
@Epictetus
Epictetus / README.md
Created June 27, 2011 12:13 — forked from wtnabe/README.md
import seed data from .csv or .yml for Rails 2.3.4+

Rails SeedImporter

  1. Put this code at #{Rails.root}/db/seeds.rb
  2. type rake db:setup

Limitation

It supports only `id' primary key.

@Epictetus
Epictetus / passgen.rb
Created June 28, 2011 07:06 — forked from rummelonp/passgen.rb
Thorを使ったパスワード生成Rubyスクリプトサンプル
# -*- 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
@Epictetus
Epictetus / Gemfile
Created June 29, 2011 17:24 — forked from tinomen/Gemfile
goliath demo
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'
@Epictetus
Epictetus / haml.rake
Created July 6, 2011 12:52 — forked from bmarini/haml.rake
Drop this in lib/tasks/haml.rake and run rake haml:assimilate
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}"
@Epictetus
Epictetus / test
Created July 7, 2011 19:53
test desu
aiueo
@Epictetus
Epictetus / unicorn.sh
Created July 12, 2011 06:03 — forked from rrrodrigo/unicorn.sh
init.d script for starting multiple unicorn-based apps
#!/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
@Epictetus
Epictetus / README.rdoc
Created July 15, 2011 07:34 — forked from udzura/README.rdoc
rack-rewrite README in japanese