brew update
rvm get stable
rvm requirements
rvm install 2.0.0
rvm use --default 2.0.0
rvm gemset create piron
rvm gemset use piron
gem install rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get External IP / local IPs | |
alias ip="curl ipinfo.io/ip" | |
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'" | |
## other get external ip methods | |
# dig +short myip.opendns.com @resolver1.opendns.com | |
# curl echoip.com | |
# curl ifconfig.me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if defined? Rails | |
$LOAD_PATH << "/Users/peng/.rvm/gems/ruby-1.9.3-p194@global/gems/awesome_print-1.1.0/lib" | |
end | |
begin | |
require 'awesome_print' | |
AwesomePrint.irb! | |
rescue LoadError | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sentence = "there is a wild rose" | |
letters = sentence.gsub(' ','').split(//) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_payment_token | |
# Simulate the JavaScript bridge we would use in production | |
params = { | |
'transaction.mode' => 'CONNECTOR_TEST', | |
'channel.id' => APP_CONFIG[:paymill_pub_key], | |
'jsonPFunction' => 'function', | |
'account.number' => '4111111111111111', | |
'account.expiry.month' => '02', | |
'account.expiry.year' => '2014', | |
'account.verification' => '111', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/ | |
./lsregister -kill -domain local -domain system -domain user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------------------------------------------------------------------------------------- | |
// PLACEHOLDER | |
//--------------------------------------------------------------------------------------------- | |
if(!Modernizr.input.placeholder){ | |
$('[placeholder]').focus(function() { | |
var input = $(this); | |
if (input.val() == input.attr('placeholder')) { | |
input.val(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CssCompressor | |
def compress(css) | |
#define formatting around the characters | |
colon = ':' | |
semicolon = ';' | |
comma = ',' | |
open_brace = '{' | |
close_brace = '}' | |
#one block per line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc 'Seed database from db/seed.sql file instead of the traditional db/seed.rb' | |
namespace :seed do | |
config = Rails::Configuration.new.database_configuration[RAILS_ENV] | |
seed_sql = File.expand_path(File.dirname(__FILE__) + '/../../db/seed.sql') | |
if !File.exists?(seed_sql) | |
puts "Missing RAILS_ROOT/db/seed.sql" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ## Backbone model caching | |
# This is a simple solution to the problem "how do I make less requests to | |
# my server?". | |
# | |
# Whenever you need a model instance, this will check first if the same thing | |
# has been fetched before, and gives you the same instance instead of fetching | |
# the same data from the server again. | |
# | |
# Reusing the same instance also has the great side-effect of making your | |
# model changeable from one part of your code, with your changes being available |