Skip to content

Instantly share code, notes, and snippets.

namespace :figaro do
desc "SCP transfer figaro configuration to the shared folder"
task :setup do
transfer :up, "config/application.yml", "#{shared_path}/application.yml", :via => :scp
end
desc "Symlink application.yml to the release path"
task :finalize do
run "ln -sf #{shared_path}/application.yml #{release_path}/config/application.yml"
end
@tony612
tony612 / .travis.yml
Created March 15, 2014 18:09
travis.ci
# Notice:
# ci will fail when the coverage is less than the minimum coverage
bundler_args: --without development production
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- ruby-head
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
curb (0.6.2.1)
em-http-request (0.2.5)
eventmachine (0.12.10)
typhoeus (0.1.13)
user system total real Memory (Kb)
4kb std
0.000000 0.000000 3.010000 ( 22.408594) 24,484
@tony612
tony612 / new_server_setup.rb
Last active August 29, 2015 13:56
Setup a new server for rails
# login to server
$ ssh root@123.45.67.890
# change password
$ passwd
# add user
$ adduser user
@tony612
tony612 / gist:8554916
Created January 22, 2014 07:44
process status
$ ps #
$ ps aux
$ ps aux | ag ruby
$ ps aux | ag 9306
@tony612
tony612 / gist:8534170
Created January 21, 2014 03:46
Useful ag options
ag "^foo(bar)?"
ag -i "foo bar" # ignore case
ag --ignore "*.min.*" foo # ignore files/directory matching the pattern.
ag -G '.*.css' foo # Limit files to which match the pattern.
ag -l # Only print filenames that contain matches
# search and replace
ag --ignore "*.css" --ignore "*.min.js" -l 'halfings' | xargs perl -pi -E 's/halfings/halflings/g'
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
# username = "my_username"
# pwd = "my_password"
# target_path = "my_target_path"
# saving auth cookie
system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \
https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027}
(25..600).each do |i|
@tony612
tony612 / setup_env_on_mac.md
Last active December 22, 2015 08:30
Building development env for a ruby developer from 0 on Mac.

## Xcode

> In fact, Xcode is a compiler for iOS/OS X programs.But it provides many of the necessary compilers and libraries needed for your development environment.

You can install it from Mac App Store.

For xcode below 5.0 version, you must install the Command Line Tools in Preferences > Downloads.

If you use xcode5.0, you can check if you have it in Preferences > Locations > Command Line Tools

@tony612
tony612 / add_column_migration.rb
Created August 27, 2013 07:43
use Model.reset_column_information to let the modification work, and use say_with_time to explain the action..
class AddAddressToEvent < ActiveRecord::Migration
def up
add_column :events, :address, :string, :after => :lat
Event.reset_column_information
say_with_time "Update each event, which will result in all events to update their address" do
Event.find_each { |event| event.save! }
end
end