Think of a telescope. As it extends right, it gets smaller.
__
|| __
|| || __
|| || ||
|| || __
|| __
__
As you go right, the scope of the variable gets smaller.
$global_var
-> @@class_var
-> @instance_var
-> local_var
window.globalVar;
-> var functionVar;
As you go right, the scope of the User
s returned gets smaller.
User.all
-> User.all.where(active: true)
-> User.all.where(active: true).where(cohort: 5)
-> User.all.where(active: true).where(cohort: 5).limit(2)
Using named scopes
User.all
-> User.all.active
-> User.all.active.in_cohort(5)
-> User.all.active.in_cohort(5).limit(2)
As the URL grows longer, it becomes more specific.
- Show all users:
http://localhost:3000/users
- Show one user:
http://localhost:3000/users/1
- Show one user's articles:
http://localhost:3000/users/1/articles
The asterisk (*
) always matches everything.
The command will effect every file in the current directory.
ls *
rm *
cat *
Select every column from the users
table.
SELECT * FROM users;
The strategy of increasing productivity by optimizing keystrokes. This is usually creating convenient, short-named methods (or functions) for common operations, but it can be as simple as using nil
over null
.
Langauges that requires fewer keystrokes to generate a language that requires more.
- HAML, SLIM
- CoffeeScript
- SASS, SCSS
Shortcuts for longer BASH commands.
alias gd='git diff'
alias gc='git commit'
alias gco='git checkout'
alias gb='git branch'