This file contains 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
2.hours.ago # => Fri, 02 Mar 2012 20:04:47 JST +09:00 | |
1.day.from_now # => Fri, 03 Mar 2012 22:04:47 JST +09:00 | |
Date.today.to_time_in_current_zone # => Fri, 02 Mar 2012 22:04:47 JST +09:00 | |
Date.current # => Fri, 02 Mar | |
Time.zone.parse("2012-03-02 16:05:37") # => Fri, 02 Mar 2012 16:05:37 JST +09:00 | |
Time.zone.now # => Fri, 02 Mar 2012 22:04:47 JST +09:00 | |
Time.current # Same thing but shorter. (Thank you Lukas Sarnacki pointing this out.) | |
Time.zone.today # If you really can't have a Time or DateTime for some reason | |
Time.zone.now.utc.iso8601 # When supliyng an API (you can actually skip .zone here, but I find it better to always use it, than miss it when it's needed) | |
Time.strptime(time_string, '%Y-%m-%dT%H:%M:%S%z').in_time_zone(Time.zone) # If you can't use Time#parse |
This file contains 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
env CC=/usr/bin/gcc-4.2 rbenv install 1.9.3-p194 |
This file contains 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
require 'bundler/capistrano' | |
load 'deploy/assets' | |
# rbenv stuff | |
set :default_environment, { | |
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:/usr/local/git/bin:$PATH" | |
} | |
set :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec" | |
set :user, 'rails' |
This file contains 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
$(".country_selector").change( function(){ | |
if ($(".region_selector").length > 0){ | |
$.getJSON('/countries/'+$(this).val(), function(data) { | |
$(".region_selector").html($("<option></option>")); | |
$.each(data.country.regions, function(index, region){ | |
$(".region_selector"). | |
append($("<option></option>"). | |
attr("value",region.id). | |
text(region.name)); | |
}); |
This file contains 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
# using rvm with ruby-1.8.7-p249 | |
# latest version 2.7.7 2010-06-17 | |
brew install libxml2 | |
# installing libxslt from source code | |
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz | |
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7 | |
make | |
sudo make install |
This file contains 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
david$ env ARCHFLAGS="-arch x86_64" gem install mysql2 | |
ERROR: While executing gem ... (Errno::EACCES) | |
Permission denied - /Users/david/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/.gitignore | |
SilverBullet:ror david$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 | |
Password: | |
Building native extensions. This could take a while... | |
ERROR: Error installing mysql2: | |
ERROR: Failed to build gem native extension. | |
/Users/david/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb |
This file contains 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 MigrateUserToDevise < ActiveRecord::Migration | |
def self.up | |
change_table :users do |t| | |
t.string :encrypted_password, :null => false, :limit => 128 | |
# ... | |
end | |
end | |
def self.down | |
end |
This file contains 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
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH |
This file contains 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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/' | |
} | |
PS1='\[\033[01;37m\]\w\[\033[00;35m\]$(parse_git_branch)\[\033[00m\] \$ ' | |
alias r='rails' |