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
module AAA | |
def abc | |
"abc in AAA" | |
end | |
def not_in_common | |
"not_in_common in AAA" | |
end | |
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
class Duck | |
def quack | |
"Quack quack" | |
end | |
end | |
class Person | |
def quack | |
"Bad impression of Donald Duck" | |
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
# WheelType knows about the behavior of wheels | |
class WheelType | |
def diameter | |
#snip | |
end | |
def rim_size | |
#snip | |
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
arr = [] # => [] | |
arr = Array.new # => [] | |
arr = Array.new(5, "t") # => ["t", "t", "t", "t", "t"] | |
arr = Array.new(5) { |i| i **2 } # => [0, 1, 4, 9, 16] | |
arr[3] = 'replacement' # => "replacement" | |
arr # => [0, 1, 4, "replacement", 16] | |
arr.fetch 0 # => 0 | |
arr.first # => 0 | |
arr.last # => 16 |
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
h1 = Hash.new # => {} | |
h2 = Hash.new("a") # => {} | |
h3 = {} # => {} | |
h4 = {abc: "def"} # => {:abc=>"def"} | |
h5 = {:abc => "def"} # => {:abc=>"def"} | |
h6 = {"abc" => "def"} # => {"abc"=>"def"} | |
h1["abc"] # => nil | |
h1.fetch("abc", "kitty") # => "kitty" |
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
/* | |
Prerequisite: meteor add peerlibrary:aws-sdk | |
Terminology: | |
AWS: Amazon web services | |
S3: Simple storage service (one of the above.) | |
Create a bucket on S3. Use AWS Identity and Access Manager to create | |
a user that your app can log in as . Attach a policy to that user |
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
function doSumByGroup() { | |
var agg = [ | |
{$group: { | |
_id: "$columnObject", | |
total: {$sum: 1} | |
}} | |
]; | |
Snippet.aggregate(agg, function(err, logs){ | |
if (err) { |
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 CreateUsers < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :name | |
t.string :email | |
t.timestamps null: false | |
end | |
end | |
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
#Creating an app called my_great_app | |
rails new my_great_app -T -d postgresql --skip-turbolinks | |
cd my_great_app | |
git init | |
git add . | |
git commit -m "Initial commit. Rails boilerplate." | |
# Edit gemfile | |
# #Remove the reference to coffee-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
This is very well documented at https://devcenter.heroku.com/articles/getting-started-with-rails4 | |
Short version: | |
Download heroku tool belt and install it. Then in terminal, cd into the root folder of the app you want to deploy | |
In the Gemfile declare ruby version with a line like: | |
ruby "2.1.4" | |
Also add | |
gem 'rails_12factor', group: :production |
OlderNewer