Get it from the App Store.
In XCode's Preferences > Downloads you can install command line tools.
| # Simple Car class. Nothing special here... | |
| class Car | |
| attr_accessor :brand | |
| attr_accessor :model | |
| attr_accessor :year | |
| def initialize(brand, model, year=2011) | |
| @brand, @model, @year = brand, model, year | |
| end | |
| #!/usr/bin/env ruby | |
| # | |
| # $ ./wth_mysql.rb | |
| # user system total real | |
| # mysql 0.020000 0.010000 0.030000 ( 0.617876) | |
| # sqlite 0.000000 0.000000 0.000000 ( 0.001234) | |
| # postgresql 0.000000 0.000000 0.000000 ( 0.002423) | |
| srand 123456789 | |
| require 'active_record' |
| upstream app { | |
| server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
| } | |
| server { | |
| listen 80; | |
| server_name www.app.com; | |
| rewrite ^/(.*) http://app.com/$1 permanent; | |
| } | |
| server { |
| after "deploy:symlink", "deploy:restart_workers" | |
| after "deploy:restart_workers", "deploy:restart_scheduler" | |
| ## | |
| # Rake helper task. | |
| # http://pastie.org/255489 | |
| # http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/ | |
| # http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/ | |
| def run_remote_rake(rake_cmd) | |
| rake_args = ENV['RAKE_ARGS'].to_s.split(',') |
| cd ~ | |
| sudo yum update | |
| sudo yum install java-1.7.0-openjdk.i686 -y | |
| wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz | |
| tar -xf elasticsearch.tar.gz | |
| rm elasticsearch.tar.gz | |
| mv elasticsearch-* elasticsearch | |
| sudo mv elasticsearch /usr/local/share |
| class PostsController < ActionController::Base | |
| def create | |
| Post.create(post_params) | |
| end | |
| def update | |
| Post.find(params[:id]).update_attributes!(post_params) | |
| end | |
| private |
| class ActionDispatch::Routing::Mapper | |
| def draw(routes_name) | |
| instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
| end | |
| end | |
| BCX::Application.routes.draw do | |
| draw :api | |
| draw :account | |
| draw :session |
| var ajax = function (url, callback) { | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open('GET', url, true); | |
| xhr.send(); | |
| xhr.onreadystatechange = function (e) { | |
| if (e.target.status === 200 && e.target.readyState === 4) { | |
| callback(JSON.parse(e.target.response)); | |
| } | |
| }; | |
| }; |
| # Here's a contrived example of a LEFT JOIN using ARel. This is an example of | |
| # the mechanics, not a real-world use case. | |
| # NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord | |
| # extension that works for any named association. That's what I really wanted! | |
| # Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446 | |
| # == DEFINITIONS | |
| # - A Taxi is a car for hire. A taxi has_many :passengers. | |
| # - A Passenger records one person riding in one taxi one time. It belongs_to :taxi. |