Skip to content

Instantly share code, notes, and snippets.

View AlexChien's full-sized avatar

Boombastic AlexChien

View GitHub Profile

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@AlexChien
AlexChien / gist:4148863
Created November 26, 2012 15:44
TextMate 2 .tm_properties

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

@AlexChien
AlexChien / gist:4072519
Created November 14, 2012 14:45 — forked from mutru/gist:3505849
config/god/resque.god
rails_env = ENV['RAILS_ENV']
raise "Please specify RAILS_ENV." unless rails_env
rails_root = ENV['RAILS_ROOT'] || File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
RESQUE_PROCESSORS = [
[1, "foo,bar"],
[2, "baz"],
[3, "demo"]
]
@AlexChien
AlexChien / gist:4072518
Created November 14, 2012 14:45 — forked from mutru/gist:3505854
config/god/resque_scheduler.god
rails_env = ENV['RAILS_ENV']
raise "Please specify RAILS_ENV." unless rails_env
rails_root = ENV['RAILS_ROOT'] || File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
God.watch do |w|
w.dir = "#{rails_root}"
w.name = "resque-scheduler"
w.group = 'resque'
w.interval = 30.seconds
w.env = {"RAILS_ENV"=>rails_env, "BUNDLE_GEMFILE"=>"#{rails_root}/Gemfile"}
@AlexChien
AlexChien / sencha_touch_app_helpers.js
Created April 17, 2012 14:32 — forked from jeffreyiacono/sencha_touch_app_helpers.js
js helper to "railsify" param keys so sencha touch 2 and rails controllers play nice
/**
* Application helpers
* requires Underscore.js
*/
var ApplicationHelpers = {
/**
* Railsify object's keys to play nice with default Rails controller setup.
* Rails default controller setup expects params submitted via PUT / POST as:
*
* (POST) {'my_model[attr1]' : 'value1', ... etc. }
@AlexChien
AlexChien / mysql-install.sh
Created November 18, 2011 15:13 — forked from hdemon/mysql-install.sh
MySQL5.5 install
#!/bin/bash
# http://namakesugi.blog42.fc2.com/blog-entry-98.htmlを参考に。
#
sudo aptitude install -y \
cmake \
paco \
bison \
g++ \
libncurses5-dev \
@AlexChien
AlexChien / ruby-install.sh
Created November 18, 2011 15:10 — forked from hdemon/ruby-install.sh
REE install script
#!/bin/bash
### rvm
# rvmをシングルユーザで入れることがオフィシャルで推奨されているので、sudoは付けない。
# 以下全て同様。
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.zshrc
### REE
sudo aptitude -y install \
@AlexChien
AlexChien / nginx.conf
Created October 31, 2011 14:57 — forked from huacnlee/nginx.conf
Nginx http proxy cache to mirror of Rubygems.org
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度
# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装
# 做这个起什么作用?
# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。
# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外
proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10m
inactive=24h max_size=1g;
server {
listen 80;
@AlexChien
AlexChien / database.yml.thor.rb
Created October 28, 2011 04:40 — forked from mikehale/database.yml.thor.rb
Generate your database.yml file with thor
class DatabaseYml < Thor
FILE = 'config/database.yml'
desc "mysql db_name", "create a database.yml for the named mysql database"
method_options :force => :boolean
def mysql(name)
yml = %(
env: &env
adapter: mysql
encoding: utf8
@AlexChien
AlexChien / sftp.thor.rb
Created October 28, 2011 04:39 — forked from mattmccray/sftp.thor.rb
Thor task for sftp syncing
# module: sftp
# A generic Thor module for sftp syncing.
#
# 1. Call `thor sftp:setup` to create config file.
# 2. Edit the config file
# 3. Call `tor sftp:sync` start the sync
#
# Ze end.