Lin Zhang marshluca

View gist:2308868

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

View defind-method-Wallpaper-upload.patch
1 2 3 4 5 6 7 8 9 10
From d3bb57d8e3974f2f6101184aafe4f4841b7af3f4 Mon Sep 17 00:00:00 2001
From: Lin Zhang <marshluca@gmail.com>
Date: Fri, 2 Mar 2012 11:36:06 +0800
Subject: [PATCH] defind method Wallpaper.upload
 
---
app/models/wallpaper.rb | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
 
diff --git a/app/models/wallpaper.rb b/app/models/wallpaper.rb
View explicit-vs-implicit-benchmark.rb
1 2 3 4 5 6 7 8 9
require 'benchmark'
 
def explicit
return "TEST"
end
 
def implicit
"TEST"
end
View MyAppDelegate.m
1 2 3 4 5 6 7 8 9 10
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
 
// Create a new window and assign directly to provided iVar
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Implementation of new init method
MyCustomNavigationBar *navigationBar = [[MyCustomNavigationBar alloc] initWithFrame:CGRectZero];
UINavigationController *navigationController = [[UINavigationController alloc] initWithCustomNavigationBar:navigationBar];
View rails3-mongoid-devise-template.rb
1 2 3 4 5 6 7 8 9
# Application Generator Template
# Modifies a Rails app to use Mongoid and Devise
# Usage: rails new APP_NAME -m https://raw.github.com/gist/1303515/4f661b5cbc2a6d3ed25e85c78fa8ac4f21eafa83/rails3-mongoid-devise-template.rb -T -O
 
# Information and a tutorial:
# http://github.com/RailsApps/rails3-mongoid-devise/
 
# Generated using the rails_apps_composer gem:
# https://github.com/RailsApps/rails_apps_composer/
View rails3-devise-rspec-cucumber-template.rb
1 2 3 4 5 6 7 8 9
# Application Generator Template
# Modifies a Rails app to use Devise with RSpec and Cucumber
# Usage: rails new APP_NAME -m https://gist.github.com/raw/1303508/f2c6643457fc246daf761a2488b10b28ba135538/rails3-devise-rspec-cucumber-template.rb -T
 
# Information and a tutorial:
# https://github.com/RailsApps/rails3-devise-rspec-cucumber
 
# Generated using the rails_apps_composer gem:
# https://github.com/RailsApps/rails_apps_composer/
View Delayed::Job daemon script for delayed_job
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
 
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true
View cropper_papaerclip
1 2 3 4 5 6 7 8 9
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ') # super returns an array like this: ["-resize", "100x", "-crop", "100x100+0+0", "+repage"]
else
super
end
end
View after.html
1 2 3 4 5 6 7 8 9 10
cache: [GET /intro] miss
 
 
Started GET "/intro" for 127.0.0.1 at Fri Aug 26 18:25:29 +0800 2011
Processing by HomeController#intro as HTML
==> Got Account:5343 from cache. (0.00065)
Rendered home/intro.html.erb within layouts/application (0.1ms)
Completed 200 OK in 233ms (Views: 4.1ms | ActiveRecord: 10.7ms | Mongo: 0.0ms | Sphinx: 0.0ms | Memcache: 0.0ms)
cache: [GET /assets/application-e808531739fb5e75ea9161663d738563.css] fresh
cache: [GET /assets/index-d16c1771b786ce3dc9730baa43e2fe87.css] fresh
View mongodb_restart.sh
1 2
sudo rm -rf /usr/local/mongodb_data/mongod.lock
sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist
Something went wrong with that request. Please try again.