##SELECT
Strings should be in 'single quotes'
Show the population of Germany
SELECT population
FROM world
WHERE name = 'Germany'
##SELECT
Strings should be in 'single quotes'
Show the population of Germany
SELECT population
FROM world
WHERE name = 'Germany'
#For Loops
##for A for loop, as mentioned above, is useful for looping with a given number of iterations. Use it when you want to do something x times, such as changing the values in an array or counting the number of vowels in a string.
The common and fundamental syntax for a for loop in JavaScript is as follows:
for (var i = 0; i < n; i++) {
// block of code
}
#puts vs. print vs. p ###The 'puts' (short for "put string") and 'print' commands are both used to display the results of evaluating Ruby code. ###Both 'puts' and 'print' call the 'to_s' method on the object AND return nil.
###The primary difference between them is that 'puts' adds a newline after executing, and 'print' does not. ###They don't RETURN anything so the RETURN value is nil. ###Using 'p' calls the 'inspect' method on the object.
print "Milan"
Milan => nil
#Faker
Usage is simple; first grab the gem using your gem program:
$sudo gem install faker
Now you can use it in your favorite ruby program or script. For now let's fire up irb and see what we can fake.
require 'rubygems'
#Sublime Text Shortcuts
CTRL-SHIFT-UP/DOWN => multiple cursors
CMD-D => select next occurences
CMD-CTRL-G => select all occurences of a word you can edit
OPT/ALT-ENTER = > find all
CTRL/TAB or CTRL/SHIFT/TAB => toggle tabs
FUNC-DELETE => delete forward
Ctrl + Windows + arrow will snap window into grid positons. |
// alt + r will get you <% _ %> | |
// shirt + alt + r will get you <%= _ %> | |
[ | |
{ "keys": ["alt+r"], | |
"command": "insert_snippet", | |
"args": { | |
"contents": "<% ${1:}$SELECTION %> ${0}" | |
} |
require 'spec_helper' | |
describe "Static pages" do | |
let(:base_title) {"Ruby on Rails Tutorial Sample App"} | |
subject { page } | |
describe "Home page" do |
Terminal shortcuts go in .bashrc in the home directory. | |
alias gs='git status ' | |
alias ga='git add ' | |
alias gb='git branch ' | |
alias gc='git commit' | |
alias gd='git diff' | |
alias go='git checkout ' | |
alias gk='gitk --all&' | |
alias gx='gitx --all' |
Two Forms of Functions | |
// function declaration | |
function square(x) { | |
return x * x; | |
} | |
// function expression | |
var square = function(x) { | |
return x * x; | |
}; |