- if CBV terminates, then so does CBN - since CBN will evaluate less than or equal parameters than CBV
- CBV avoids repeated recomputation of values
- force scala to do CBN, by defining
def fun(x:Int, y:=>Int) - disjunction and conjunction (&& and ||) are short-circuit operators - the right side will only be evaluated in certain cases.
- in certain cases like
if(r==0) return 1
there is an errorScala: type mismatch; found : Unit required: Boolean- this happens because you have to have an else clause, otherwise the type checker doesn't know what the return type is when it's not the case
return fn(a-1)is tail recursive butreturn n * fn(a-1)is not
in1 <- c(TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE)
x[in1]```
* single [] operator returns the same class - except in matrix. To get the same behavior in matrix, set ``` drop=FALSE``` attribute
* ```x[1,,drop=FALSE] ```
* ```attributes(y) ``` to list all attributes of a data strucuture
* ``` attr(y, "class")``` to print out one particular attribute
* lists also work as hashes ```x <- list(foo = 1:4, bar=0.6) x$foo ```
| d <- data.frame(PT=c(3,2,5,1)) | |
| d <- data.frame(d, capacity=1/d$PT) | |
| d$flow_rate <- min(d$capacity) # no demand numbers here | |
| d <- data.frame(d, process_capacity=min(d$capacity)) | |
| d <- data.frame(d, cycle_time=1/d$process_capacity) | |
| d <- data.frame(d, dlc=sum(d$PT)) | |
| d <- data.frame(d, idle_time=d$cycle_time-d$PT) | |
| d <- data.frame(d, total_idle_time=sum(d$idle_time)) | |
| d <- data.frame(d, total_labor_content=sum(d$PT)) | |
| d <- data.frame(d, labor_util=d$total_labor_content/(d$total_labor_content+d$total_idle_time)) |
| -- PostgreSQL 9.2 beta (for the new JSON datatype) | |
| -- You can actually use an earlier version and a TEXT type too | |
| -- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
| -- Inspired by | |
| -- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html | |
| -- http://ssql-pgaustin.herokuapp.com/#1 | |
| -- JSON Types need to be mapped into corresponding PG types | |
| -- |
sudo apt-get install golang git mercurial git clone https://github.com/hanwen/go-mtpfs.git cd go-mtpfs go build sudo mv go-mtpfs /usr/local/sbin/go-mtpfs sudo chmod a+x /usr/local/sbin/go-mtpfs sudo mkdir /media/mtp sudo chmod 775 /media/mtp sudo /usr/local/sbin/go-mtpfs -allow-other=true /media/mtp
| # run using ```rvm jruby-1.6.7 do jruby "-J-Xmx2000m" "--1.9" tej.rb``` | |
| require 'rubygems' | |
| require 'nokogiri' | |
| require 'csv' | |
| f = File.open("/tmp/preview.html") | |
| doc = Nokogiri::HTML(f) | |
| csv = CSV.open("/tmp/output.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => true}) |
| require 'fastercsv' | |
| require 'csv' | |
| require 'net/http' | |
| require 'sanitize' | |
| #CSV_FILE_PATH = File.join(File.dirname(__FILE__), 'c2i.csv') | |
| CSV_FILE_PATH = File.join('/tmp', 'Computers_Accessories_Master.csv') | |
| =begin |
| * aptitude install sudo | |
| * add the following to /etc/apt/sources.list | |
| <pre> | |
| deb http://ftp.br.debian.org/debian squeeze main | |
| deb-src http://ftp.br.debian.org/debian squeeze main | |
| deb http://ftp.br.debian.org/debian squeeze-updates main | |
| deb-src http://ftp.br.debian.org/debian squeeze-updates main | |
| deb http://security.debian.org/ squeeze/updates main |
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-keyring/daemon-components/secrets FALSE
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-keyring/daemon-components/pkcs11 FALSE
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-keyring/daemon-components/ssh FALSE
eval `ssh-agent`
echo $SSH_AUTH_SOCK #copy the path that is displayed as a result
#whenever you want a new shell: SSH_AUTH_SOCK= ssh xxx@2.2.2.2
aptitude install autoconf automake bison build-essential curl git-core libapr1 libaprutil1 libc6-dev libltdl-dev libreadline6 libreadline6-dev libsqlite3-0 libsqlite3-dev libssl-dev libtool libxml2-dev libxslt-dev libxslt1-dev libyaml-dev ncurses-dev openssl sqlite3 zlib1g zlib1g-dev
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
export PATH="/usr/local/rbenv/bin:$PATH" eval "$(rbenv init -)"
on cmdline