Skip to content

Instantly share code, notes, and snippets.

@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}'
@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
namespace :myapp do
desc 'Captures a heroku bundle and downloads it. The downloaded files are stored in backups/'
task :backup do
app_name = RAILS_ROOT.split('/').last
timestamp = `date -u '+%Y-%m-%d-%H-%M'`.chomp
bundle_name = "#{app_name}-#{timestamp}"
puts "Capturing bundle #{bundle_name}..."
`heroku bundles:capture --app #{app_name} '#{bundle_name}'`
# poll for completion (warning, a little hacky)
begin
@Epictetus
Epictetus / bootstrap.sh
Created September 19, 2011 16:47 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF