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
Ruby: Classes vs. Module
"Ruby Modules are similar to classes in that they hold a collection of methods, constants, and other module and class definitions. Modules are defined much like classes are, but the module keyword is used in place of the class keyword. Unlike classes, you cannot create objects based on modules nor can you subclass them; instead, you specify that you want the functionality of a particular module to be added to the functionality of a class, or of a specific object. Modules stand alone; there is no "module hierarchy" of inheritance. Modules is a good place to collect all your constants in a central location."
Require
require and load take strings as their arguments
[require "sinatra"]
[load "bicycle.rb"]
Include
accpet any number of Module objects
[include Enumerable, Comparable]
Every class ia a module, the include method does not allow a class to be included within another class.
Can mix in more than one module in a class. However, a class cannot inherit from more than one class.
Class names tend to be nouns, while module names are often adjectives.
Source #1
Source #2
Require
require and load take strings as their arguments
[require "sinatra"]
[load "bicycle.rb"]
Include
accpet any number of Module objects
[include Enumerable, Comparable]
Every class ia a module, the include method does not allow a class to be included within another class.
Can mix in more than one module in a class. However, a class cannot inherit from more than one class.
Class names tend to be nouns, while module names are often adjectives.
Source #1
Source #2
Wednesday, March 17, 2010
bg, fg, ^Z, ^C
CTRL+Z (or ^Z) - suspend or stopped. To list of jobs and their state by running jobs -l.
CTRL+C (or ^C) - kill the process
bg - background
fg - foreground
jobs -l => lists jobs in background
+ flag on the output of jobs -l indicates the current job and the - flag indicates the previous job.
The %% and %+ names refer to the current job while %- refers to the previous job.
More Info: More Jobs
CTRL+C (or ^C) - kill the process
bg - background
fg - foreground
jobs -l => lists jobs in background
+ flag on the output of jobs -l indicates the current job and the - flag indicates the previous job.
The %% and %+ names refer to the current job while %- refers to the previous job.
More Info: More Jobs
Subscribe to:
Posts (Atom)