Skip to content

Instantly share code, notes, and snippets.

View caoer's full-sized avatar
🎯
Focusing as always

Zitao Xiong caoer

🎯
Focusing as always
View GitHub Profile
@caoer
caoer / ARCHelper.h
Created July 16, 2012 22:15 — forked from nicklockwood/ARCHelper.h
Objective-C: ARC Helper
//
// ARC Helper
//
// Version 2.1
//
// Created by Nick Lockwood on 05/01/2012.
// Copyright 2012 Charcoal Design
//
// Distributed under the permissive zlib license
// Get the latest version from here:
@caoer
caoer / gist:3214527
Created July 31, 2012 07:33 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

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".

@caoer
caoer / NSUserDefault.m
Created October 13, 2012 10:13
Objective-C: Save object to NSUserDefault.m
- (MyCustomObject *)getObject {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *MyCustomObjectEncodedObject = [defaults objectForKey:kMyCustomObjectKEY];
MyCustomObject *MyCustomObject = (MyCustomObject *)[NSKeyedUnarchiver unarchiveObjectWithData: MyCustomObjectEncodedObject];
return MyCustomObject;
}
- (void)setMyCustomObject:(MyCustomObject *)MyCustomObject {
NSData *MyCustomObjectEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:MyCustomObject];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@caoer
caoer / unicorn
Created February 8, 2013 00:40 — forked from shapeshed/unicorn
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@caoer
caoer / unicorn_nginx.conf
Created February 8, 2013 00:58
nginx config for unicorn
# This is example contains the bare mininum to get nginx going with
# Unicorn or Rainbows! servers. Generally these configuration settings
# are applicable to other HTTP application servers (and not just Ruby
# ones), so if you have one working well for proxying another app
# server, feel free to continue using it.
#
# The only setting we feel strongly about is the fail_timeout=0
# directive in the "upstream" block. max_fails=0 also has the same
# effect as fail_timeout=0 for current versions of nginx and may be
# used in its place.
@caoer
caoer / unicorn.conf.rb
Created February 8, 2013 00:59
uncorn config file
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
@caoer
caoer / unicorn_init.sh
Created February 8, 2013 00:59
unicorn startup script
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/u/apps/the_app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="/usr/bin/unicorn -D -c $APP_ROOT/config/unicorn.rb"
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@caoer
caoer / gist:5178242
Created March 16, 2013 20:42
redis
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@caoer
caoer / deploy.rb
Created June 14, 2013 05:05 — forked from stas/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)