Ruby on Rails Development:
Redis tutorial
Tips:
- use INCR to make variable increased by 1, it’s atomic command, thread safe.
- LPUSH, RPUSH, LLEN, LPOP, RPOP, LRANGE, list commands
- SADD, SREM, SISMEMBER, SMEMBERS, SUNION combine two sets
- ZADD, Z is a Sorted Sets based on the associated score.
- HSET, HGETALL, HGET, hash set in Redis, set value and get value.
For future reading: Redis Doc, Redis Commands, Redis Twitter Clone, Redis data type
Firebug in Firefox is a great tool!!!:
Problem and Tips:
如果想要找到element的绑定事件,请用firebug in firefox
Click the firebug icon, choose the “Enable all active panels” to activate the great functionality.
I can get the binding event for the element.
About the ruby performance optimization: 正在读这本书的Beta版本
Ruby Performance Optimization
两点注意:memory和GC,临时的变量,String::<< is very efficient. Each iterator will get a lot of objects created.
Ruby bad in two areas: large data processing and complex computations. Ruby的两个弱势的地方。
Databases are really good at complex computations and other kinds of data manipulation.
Rewrite the Ruby gem in C.
- Q: 智力竞猜,irb有多少的实现?
A: One line: loop { p eval gets }
use PRY the great console instead of the irb:
gem install pry pry-doc gist
gist String#each___line, put the code on github.
help to see command list of pry.
show-method, show-doc
in pry, use . to use the shell command
nesting
jump-to 0
show-input
!
amend-line, change the method code.
Pry can do:
- show method definition, ruby and C implementation.
- show input of users.
- gist the help doc to github
- .cd change the locaiton through the shell command.
- go into the gem and show contants, method, …
- jump-to in the nesting gems
- amend-line modify the mistake before.
edit-method method, open a new editor window to modify the code.
binding pry, for debug
whereami
install gem pry in the rails, modify config/environment/devlopment.rb file,
ls -i, show the variables,
Josh Mair, explain the pry
like step in debugging, remote debuggin, pry-exception___explorer open pry after the exception happened,