Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Epictetus / default_replace.rb
Created July 24, 2011 12:19 — forked from melborne/default_replace.rb
Termtter plugins
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(" ")
@Epictetus
Epictetus / deploy.rb
Created July 28, 2011 07:29 — forked from bradly/deploy.rake
Simple Rails Deployments with Net/SSH
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
commands = [
@Epictetus
Epictetus / deploy.rb
Created July 28, 2011 17:30 — forked from bradly/deploy.rake
Simple Rails Deployments with Net/SSH
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
commands = [
@Epictetus
Epictetus / deploy-with-capistrano.md
Created July 29, 2011 09:55
Random, unorganized presentation notes / guide

Presentation Notes

Setting Up the Server

(Slightly) Hardening OpenSSH Server

Copy your key to the server then SSH into it:

user@workstation ~$ scp .ssh/id_rsa.pub server:~/.ssh/authorized_keys
user@workstation ~$ ssh server
@Epictetus
Epictetus / rails31init.md
Created July 30, 2011 22:55 — forked from jraines/rails31init.md
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.

@Epictetus
Epictetus / benchmark.sh
Created August 10, 2011 20:22 — forked from emersonmoretto/benchmark.sh
Apache bench + Gnuplot Script
#!/bin/bash
echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n"
## Gnuplot settings
echo "set terminal png
set output 'benchmark_${1}_${2}.png'
set title 'Benchmark: ${1} ${2}'
# rails blog -m https://gist.github.com/1155984.txt
# rails blog -m ~/template.rb
# rake rails:template LOCATION=~/template.rb
# template.rb
run "rm public/index.html"
generate(:scaffold, "person name:string")
route "map.root :controller => 'people'"
rake("db:migrate")
git :init
@Epictetus
Epictetus / Authlogic.v.2.1.3.README.ja.rdoc
Created August 24, 2011 13:54 — forked from eitoball/Authlogic.v.2.1.3.README.ja.rdoc
この文書はAuthlogic バージョン2.1.3時点のREADME.rdocを日本語に訳した文書です。This is Japanese-translation of README.rdoc of Authlogic as of version 2.1.3.

Authlogic

Authlogicは、簡潔で柔軟なRubyで記述された認証ソリューションです。

コードで例示して説明した方がいいでしょう…

Authlogicでは新しい型のモデルを提供しています。他のモデルのようにいくつでもどんな名前で必要なだけ作成することができます。この例では、クラス名から分かるようにUserモデルを使って認証を行おうとしています。

class UserSession < Authlogic::Session::Base
  # ここでは以下のように設定項目を記述します:
@Epictetus
Epictetus / rails_template_for_3.1.rb
Created September 1, 2011 17:19 — forked from willnet/rails_template_for_3.1.rb
rails template for 3.1
#
# Usage
#
# rails new yourapp -m https://raw.github.com/gist/1178242/3c77cfffeb99f32d19333de986ff41283aa9eb26/rails_template_for_3.1.rb -T --skip-bundle
#
git :init
append_file '.gitignore', <<-END
.rvmrc