Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Epictetus / gist:1360956
Created November 12, 2011 19:02 — forked from sr3d/gist:441392
Paperclip - Factory_Girl for Rails 3 beta 4
Factory.define :contacts_short_csv, :class => 'CsvFile' do |f|
include ActionDispatch::TestProcess
f.csv { fixture_file_upload( 'files/contacts_short.csv.upload', 'text/csv') }
f.account_id { 1 }
end
My model is

最近のタイムライン保存事情

TwitterのタイムラインはJSONで流れてくるので、JSONぽい形式でデータを突っ込むMongoDBと相性が良い。
今まではtimeline.logとして書き出してたけど、GB単位に膨らんだテキストファイル重すぎて扱いづらいし最近は専らMongoDBに流し込んでます。
全部保存しとくと、誰がいつどのtweetを消したとか分かって異常に便利。こわい。
全文検索したいときがあるので、ツイイトはわかち書きでsplitして配列としても入れといてます。
MongoDBは配列で保存出来て、配列内にインデックスを貼れるので、簡単にいい感じの検索機能が作れて楽しいですね。
TLの全保存やってる人自体はそこら中に居るだろうし目新しいことは特にないでした。

@Epictetus
Epictetus / pony_sample.rb
Created November 29, 2011 15:21 — forked from koki-h/pony_sample.rb
pony_sample. A good wrapper of Net/SNMP + TMail
#ponyを使ってgmail経由でメールを送信
#pony : http://github.com/benprew/pony
#メールクライアントの設定-GMailヘルプ : http://mail.google.com/support/bin/answer.py?hl=jp&answer=13287
require 'rubygems'
require 'pony'
Pony.mail(:to => '[email protected]',
:body => "あああああああああああ", #bodyもsubjectも日本語OK(windows/cygwin)
:subject => "テストとととととt",
:via => :smtp,
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.
@Epictetus
Epictetus / heroku_autoscalling.rb
Created November 29, 2011 22:13 — forked from mataki/heroku_autoscalling.rb
Auto scalling dynos on heroku using NewRelic
=begin
Need to install gems heroku, newrelic_rpm
$ gem install heroku newrelic_rpm
Set your apps setting
app_name : heroku's app_name of auto scaling
license_key : NewRelic api key. You can get heroku's NewRelic admin console. "App setting" and "Agent configuration"
execute with cron every minutes
$ ruby ./adjust_dynos_with_newrelic.rb
ja:
errors:
messages:
not_found: "は見つかりませんでした"
# not_found: "not found"
already_confirmed: "は既に登録済みです"
# already_confirmed: "was already confirmed"
not_locked: "は凍結されていません"
# not_locked: "was not locked"
@Epictetus
Epictetus / heroku_autoscalling.rb
Created November 29, 2011 22:26 — forked from mataki/heroku_autoscalling.rb
Auto scalling dynos on heroku using NewRelic
=begin
Need to install gems heroku, newrelic_rpm
$ gem install heroku newrelic_rpm
Set your apps setting
app_name : heroku's app_name of auto scaling
license_key : NewRelic api key. You can get heroku's NewRelic admin console. "App setting" and "Agent configuration"
execute with cron every minutes
$ ruby ./adjust_dynos_with_newrelic.rb
@Epictetus
Epictetus / gist:1414084
Created December 1, 2011 05:50 — forked from newbamboo/gist:1261956
Linode Ubuntu 10.04 (Lucid) with passenger & nginx for rails hosting
#################################################################
# #
# A guide to setting up a linode Ubuntu VPS for #
# Ruby on Rails hosting with nginx & passenger #
# #
# Compiled by Chris Toomey [ctoomey.com] on Sept. 9 2011 #
# #
#################################################################
# Start with base 10.04 image. Setup the DNS for any domains you
<script type="text/javascript">
var queueBytesLoaded = 0;
var queueBytesTotal = 0;
var myQueue = null;
var queueChangeHandler = function(queue){
// alert('Uploading Started');
myQueue = queue;
// console.log("COLLECTION CHANGE!");
var list = document.getElementById('file_todo_list');