Saturday, May 22, 2010
Happiness by Matthieu Ricard
I read the book twice. Mr. Ricard gives advice how to be happy. The book is the introduction to Buddhist.
Sunday, May 16, 2010
City of Thieves
City of Thieves by David Benioff is about World War II: siege of Leningrad, Nazi and jews and more.
Sunday, April 25, 2010
hermit
hermit - a person who has withdrawn to a solitary place for a life of religious seclusion.
benign
benign - being kind
Tuesday, April 20, 2010
The Black Swan by Nassim Nicholas Taleb
This book is about randomness and uncertainty. Read it twice. Excellent book.
Link
Link
Monday, April 19, 2010
Eating Animals by Safran Foer
Factory farming is main focus of the book. It's about how factory farming money machine "produce" animals. Safran Foer tell us why factory farming must be stop.
Btw: Interesting fact that Hitler was vegetarian.
Eating Animals link on amazon
Btw: Interesting fact that Hitler was vegetarian.
Eating Animals link on amazon
Friday, April 2, 2010
Cohort
Cohort
In statistics and demography, a cohort is a group of subjects who have shared a particular experience during a particular time span[1] (e.g., people born in 1950; Irish women born in 1970; truck drivers who smoked between age 30 and 40). Cohorts may be tracked over extended periods of time in a cohort study. The cohort can be modified by censoring, i.e. excluding certain individuals from statistical calculations relating to time periods (e.g. after death) when their data would contaminate the conclusions
cohort
In statistics and demography, a cohort is a group of subjects who have shared a particular experience during a particular time span[1] (e.g., people born in 1950; Irish women born in 1970; truck drivers who smoked between age 30 and 40). Cohorts may be tracked over extended periods of time in a cohort study. The cohort can be modified by censoring, i.e. excluding certain individuals from statistical calculations relating to time periods (e.g. after death) when their data would contaminate the conclusions
cohort
Monday, March 22, 2010
Ruby Notes
[Output]
"puts" writes to the screen with a carriage return at the end
"print" does the same thing without the carriage return
[Reading from the Console]
$name = STRDIN.gets
[Functions]
def welcome(name)
puts "hi #{name}" # "#{}" evaluate the variable
end
[Call Functions]
welcome("Mike") or welcome "Mike"
Extra arguments are gathered into the last variable if preceded with a "*"
def test(a=1,b=2,*c)
[Variable]
- Global variables start with '$'
- Class variables start with '@@'
- Instance variable start with '@'
- Local variables, method names, and method parameters start with lower case letter
- Class names, module names and constants start with uppercase letter
- Variable are composed of letters, numbers and underscrores
- Method Names may end with:
'?' - imply a boolean operation
'!' - imply something dangareous, like strings being modified
- __END__ on its own line with no white space, are ignored
- Lines between =begin and =end are ignored
[Collections]
- mystuff = %w{tivo nokia ipaq} # make a string array
- select # populates a new array with members which meet a criteria
[Loops]
for i in 1..4
[Regular Expressions]
- /a/ =~ # find first "a" and return position
- %r{a} =~ # same thing as above
- /p.r/ =~ # matches any character
[Blocks]
Blocks are nameless chunks of code that may be passed as an argument to a function.
def whereisit
yield
end
whereisit {puts "where is the money?" }
where is the money?
- each # iterated through each item of a collection
- detect # returns the first item matching a logical expression
- select # returns all items matching a logical expression
- collect # returns an array created by doing the operation on each element
- inject # is the reducer function in Ruby. "inject" loops over an enumerable and performs an operation on each object and returns a single value
[File I/O]
- Read File into a string:
file = File.new("myfile.txt")
mytext = file.read
- Read an entire file into an array of lines
lines = IO.readlines("data.txt")
- Read a file line by line
file = File.open("file.txt")
while line = file.gets
puts line
end
ensure
file.close # ensure that file is close
end
OR
IO.foreach("data.txt") { |line| puts line }
- Read only a few bytes at at time
require 'readbytes'
file = File.new("myfile.txt")
while bytes = file.readbytes(80)
print bytes+"\r\n"
end
file.close
Saturday, March 20, 2010
Dead Horse Bay
Today is beautiful whether. First hiking trip of 2010 was to Far Rockaway with the stop in Dead Horse Bay
Friday, March 19, 2010
Billy Elliot (Broadway)
I saw Billy Elliot Broadway Show yesterday.
The shows include politics, music and dancing. Good show. Recommend
The shows include politics, music and dancing. Good show. Recommend
Subscribe to:
Posts (Atom)