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
## Basic Method | |
def say_hello | |
puts “Hello” | |
end | |
hello # => Hello | |
## Method with an argument | |
def say_hello_to(name) | |
puts “Hello, #{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
names = ["Michael", "John", "Paul", "George"] | |
names.each do |name| | |
puts "Hi, my name is #{name}" | |
end | |
# Result: | |
# Hi, my name is Michael | |
# Hi, my name is John | |
# Hi, my name is Paul |
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
# Basic Array | |
my_array = [1, 2, 3, 4, 5] | |
# Ruby arrays are zero-based arrays, | |
# meaning the first element is at index 0 | |
my_array[1] # => 2 | |
my_array[0] # => 1 | |
# Except when you do negative indexes | |
my_array[-2] # => 4 |
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
# Double Quotes | |
double_quotes = "Here be double quotes" | |
# Single Quotes | |
single_quotes = 'Here be single quotes' | |
# Intermixing Quotes | |
'Sam said, "Never give up, never surrender"' | |
"Sam told me to read the book, 'Brave New World'" |
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
1 + 1 # => 2 | |
x = 2 | |
x * 2 # => 4 | |
x *= 2# => 4 | |
x = x * 2 # => 8 | |
pi = 3.14 | |
pi * (5 * 5) # => 78.5 |
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 + 2 # => 4 | |
puts "Hello, World!" # => "Hello, World" | |
my_array = [1, 2, 3, 4, 5] # => [1,2,3,4,5] |
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
#!/bin/bash | |
# This shell script will process & encode a single video file, and output 3 | |
# seperate files in the following formats: WebM, Ogg Theora, & h.264 for | |
# streaming via an HTML5 player. | |
# | |
# You'll need ffmpeg, ffmpeg2theora, & HandbrakeCLI installed to run this | |
# script. ffmpeg and ffmpeg2theora can be installed via Homebrew on a Mac. | |
# If you're using Ubuntu, use the PPA at | |
# https://launchpad.net/~jon-severinsson/+archive/ffmpeg |
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
// If value is falsy and not a string, return | |
// undefined. Otherwise, return 'good input!' | |
// Note that this means that the empty string ('') | |
// should return 'good input!'. | |
function detectGoodInput(value) { | |
if( typeof(value) === 'string' ) | |
return 'good input!'; | |
} |
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
#Goes in APP_FOLDER/test/functional | |
require 'test_helper' | |
class BandsControllerTest < ActionController::TestCase | |
setup :activate_authlogic | |
def setup | |
@host = bands(:one).subdomain + ".localhost" | |
UserSession.create(users(:one)) | |
ActionMailer::Base.deliveries.clear |
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
total 167080 | |
-rwxr-xr-x 1 root wheel 18800 Jul 15 12:52 BuildStrings | |
-rwxr-xr-x 1 root wheel 25408 Jul 15 12:52 CpMac | |
-rwxr-xr-x 1 root wheel 100880 Jul 15 12:52 DeRez | |
-rwxrwxr-x 1 root admin 44480 Jul 25 10:31 DevToolsSecurity | |
-rwxr-xr-x 1 root wheel 18624 Jul 15 12:52 GetFileInfo | |
-rwxrwxr-x 1 root admin 70256 Apr 6 21:38 ImageUnitAnalyzer | |
-rwxr-xr-x 1 root wheel 62592 Jul 15 12:52 MergePef | |
-rwxr-xr-x 1 root wheel 19104 Jul 15 12:52 MvMac | |
-rwxr-xr-x 1 root wheel 59824 Jul 15 12:52 PPCExplain |