04 Jun 2014
####Lambda Literals
succ = lambda {|x| x+1}
succ = ->(x){ x+1 }
succ = ->x { x+1 }
####Porc Equality
lambda {|x| x+1 } == lambda {|x| x+1 } # false
p = lambda {|x| x+1 }
q = p.dup
p == q #true
p.object_id == q.object_id #false
####Shorthand for string list
####Warning Mode
####Annotation
- TODO
- FIXME
-
OPTIMIZE
rake notes
####Hash
Basically use fetch instead of square brackets- it will raise error if it’s nil.
####String
Flexible quoting:
- $(string)
- %!string!
- %{string}
Shovel(«) operator modifies the original string, while += doesn’t
####Symbol
String.to_sym
I/O
$stdout.reopen 'filename' # redirect standard ouput to a file
$stdin.noecho &:gets # runs gets without echoing input to the screen
$stdin.reopen '/dev/tty' # redirect standard output to the terminal
####Questions?
arr = [1,2,3,4]
why arr[4..0] == []
but arr[5..0] == nil
what’s with single quotes sometimes interpret escape characters
@about_symbols.rb:34
@about_constants.rb:87
04 Jun 2014
update_attribute
Watch out for update_attribute
, it doesn’t run model validations. But update_attributes
does.
#count, #length and #size for ActiveRecord
- Use #size
- Use #length if you’ll need to load the real records immediately
14 May 2014
###1.1 The Elements of Programming
####1.1.1 Expressions
Prefix notation
####1.1.2 Naming and the Environment
Defines environment(global environment)
####1.1.3 Evaluating Combinations
####1.1.4 Compound Procedures
(define (square x) (* x x))
####1.1.5 The Substitution Model for Procedure Application
Applicative order versus normal order
- normal order: fully expand and then reduce(lazy approach?)
- applicative order: (eager approach?)
####1.1.6 Conditional Expressions and Predicates
(cond (<p1> <e1>)
(<p2> <e2>)
...
(<pn> <en>))
or
(cond (<p1> <e1>)
...
(else <en>))
if statement
(if <predicate> <consequent> <alternative>)
logical composition operations:
####1.1.7 Example: Square Roots by Newton’s Method
- In mathematics we are usually concerned with declarative (what is) descriptions
- In CS we are usually concerned with imperative (how to) descriptions
####1.1.8 Procedures as Black-Box Abstractions
- Each procedure accomplishes and identifiable task that can be used as a module in defining other procedures
- Block structure: to make procedures local and make proper variables free
###1.2 Procedures and the Processes They Generate
1.2.1 Linear Recursion and Iteration
###Questions
- Is normal order vs applicative order same as lazy evaluation vs eager evaluation
- Exercise 1.7
14 May 2014
####C and M
- C(Control)
ctrl
- M(Meta)
command
####Screen navigation
- Move forward
C-v
- Move backward
M-v
- Clear screen
C-l
####Cursor navigation
- Previous line
C-p
- Next line
C-n
- Backward one character
C-b
- Forward one character
C-f
- Backward one word
M-b
- Forward one word
M-f
- Line start
C-a
- Line end
C-e
- Sentence start
M-a
- Sentence end
M-e
- File start
M-<
- File end
M->
####Usually the Rule
- Meta commands are for English text
- Control commands are for basic textual units
####Repeat command
C-u <times> [command]
####Stopping Edwin
C-g
quit what it was doing
C-c C-c
cancel a Scheme evaluation
####Deletion
-
delete the character just before the cursor
C-d
delete the next character after the cursor
M-<Delete>
kill the word immediately before the cursor
M-d
kill the next word after the cursor
C-k
kill from the cursor position to end of line
M-k
kill to the end of the current sentence
####Yank
Use C-y
C-y
get the most recent kill
M-y
get the previous kill
####Evaluating Scheme Expressions
- get into an evaluation buffer
C-x b *scheme*
C-x C-e
evaluate the expression(point is after the closing parenthesis)
M-p
to access the history
C-x b TUTORIAL
####Undo
C-x u
or C-_
####Files
- Find a file
C-x C-f
- Save the file
C-x C-s
####Buffers
- List buffers
C-x C-b
- get rid of the buffer list
C-x 1
- Save all changed buffers
C-x s
####eXtend command
- C-x Character eXtend. Followed by one character
- M-x Named command eXtend. Followed by a long name
####C-x commands
- C-x C-f Find file
- C-x C-s Save file
- C-x C-b List buffers
- C-x C-c Quit Emacs
- C-x u Undo
####Named eXtended command(“functions”)
- M-x replace-string
- M-x scheme-mode
####Modes
- C-h m documentation on current mode
####Searching
- Forward search
C-s
- Reverse search
C-r
####Recursive editing levels
####Windows
####Getting help
- C-h
- C-h ?
- C-h c brief description
- C-h k documentation of the function
- C-h f describe a function
- C-h a Command Apropos
###Misc
- C-u C-v to bring current line up
13 May 2014
The final turned out to be OK though at some point I really didn’t think that I can get it through.
I started VM in Weenix pretty late. When I look back, it turns out that I only had 18 days to finish it up. It still has some bugs and I have no idea how to pinpoint them. But I’m still happy that I can finally get it done in such a tight schedule. I have never been totally on schedule, and I really know that driven by deadline can be a terrible process management and a lot pressure on me. It’s just who I am that keeps me doing this.
Relating this to some speech I just saw, maybe I should just simply try to do more things in the same time schedule. You’ll just find a way to utilize your potential and get it done.