Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Epictetus / README.md
Created October 7, 2011 05:53 — 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 / load.c.patch
Created October 10, 2011 08:08 — forked from funny-falcon/load.c.patch
Patch against ruby-1.9.3-rc1 to futher improve load.c
diff --git a/load.c b/load.c
index 0ff4b60..34fd8ca 100644
--- a/load.c
+++ b/load.c
@@ -130,11 +130,18 @@ loaded_feature_path_i(st_data_t v, st_data_t b, st_data_t f)
}
static int
+rb_find_feature_left_place(VALUE features, const char *feature, long flen);
+static int
@Epictetus
Epictetus / classname2instance.rb
Created October 10, 2011 19:20 — forked from maraigue/classname2instance.rb
Rubyのクラス名を文字列で与えて(例:"Hoge::Piyo")そのクラスのインスタンスを生成する方法
#!/usr/bin/ruby
#
# = 元ネタ
#
# Kawaz - Pythonで文字列からクラスインスタンスを生成したりメソッドを呼ぶ方法
#
# http://www.kawaz.org/blogs/miiojp/2011/05/15/106/
#
# 上記ページでは、Pythonで "hogehoge.hogenoho.HogeClass" のような文字列に
@Epictetus
Epictetus / HelloDartTest.dart
Created October 11, 2011 05:30
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// VMOptions=--compile_all
class HelloDartTest {
static testMain() {
print("Hello, Darter!");
@Epictetus
Epictetus / tuningathon2_memo.txt
Created October 11, 2011 07:31 — forked from hamano/tuningathon2_memo.txt
hamano's gist: 第2回 Tuningathon チューニングメモ
# 第2回 Tuningathon チューニングメモ
このメモは @hamano が [第2回 Tuningathon][1] に参加した際に行ったチュー
ニングポイントと感想です。
[1]: http://www.zusaar.com/event/agZ6dXNhYXJyDQsSBUV2ZW50GLmFBgw "第2弾!いろいろチューニングしてパフォーマンスを競うバトルイベント開催!「Tuningathon」2!! #tuningathon"
今回のお題は MediaWiki への参照性能という事でまたPHPか! とは思いました
が2台構成可、Web Serverの入れ替え可、という条件でしたのでチューニングの
範囲が大きく広がった様に感じました。
@Epictetus
Epictetus / README.md
Created November 1, 2011 12:18 — forked from juno/README.md

Install rbenv and ruby-build to Amazon Linux (cloud-init).

  1. Copy & paste content of user-data.sh to EC2 RunInstances user-data
  2. Then, logging in to EC2 instance as ec2-user and run install-ruby.sh.
@Epictetus
Epictetus / fcgi_easy_install_for_sakura.sh
Created November 2, 2011 23:24 — forked from iwakou/fcgi_easy_install_for_sakura.sh
さくらの共有レンタルサーバにfcgiとfcgiのgemライブラリをインストールするコマンドまとめスクリプト
#!/bin/sh
#=============================
# make work directory
#=============================
mkdir -p $HOME/local/fcgi/src
cd $HOME/local/fcgi/src
#============================
# install fcgi
@Epictetus
Epictetus / google_analytics.rb
Created November 9, 2011 14:52 — forked from migrs/google_analytics.rb
Google Analytics Mobile for Rails Metal
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class GoogleAnalytics
extend Rack::Utils
G_COOKIE_NAME = '__utmmobile'
GIF_DATA = "GIF89a\001\000\001\000\200\000\000\377\377\377\377\377\377!\371\004\001\n\000\001\000,\000\000\000\000\001\000\001\000\000\002\002L\001\000;"
UTM_GIF_LOCATION = "http://www.google-analytics.com/__utm.gif";
@Epictetus
Epictetus / gist:1357697
Created November 11, 2011 10:32 — forked from trevorturk/gist:366598
Automated Heroku Backups
namespace :heroku do
desc "PostgreSQL database backups from Heroku to Amazon S3"
task :backup => :environment do
begin
require 'right_aws'
puts "[#{Time.now}] heroku:backup started"
name = "#{ENV['APP_NAME']}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}.dump"
db = ENV['DATABASE_URL'].match(/postgres:\/\/([^:]+):([^@]+)@([^\/]+)\/(.+)/)
system "PGPASSWORD=#{db[2]} pg_dump -Fc --username=#{db[1]} --host=#{db[3]} #{db[4]} > tmp/#{name}"
s3 = RightAws::S3.new(ENV['s3_access_key_id'], ENV['s3_secret_access_key'])
// This is my handler in the javascript
var uploadCompleteHandler = function(upload_options,event){
$.ajax({
url: '<%= notify_rails_of_successful_upload_path(:format => :js)%>',
global: false,
type: 'POST',
data: ({
'authenticity_token' : '<%= form_authenticity_token %>',
'upload' : {
'file_file_name' : upload_options.FileName,