Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Change Binding Port in Microsoft WebMatrix Site Such as node.js Project

Permalink

Microsoft now is become quit outdated technology after they release so many outdated technology, but WebMatrix is in my opinion, the best tools to right node.js tools in Windows.

But I'm used to using port 3000 as default debug port since I'm switch to Ruby & Rails, so really not want to change port time to time, so here is how to change binding port.

D:\EricDocuments\IISExpress\config\applicationhost.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.applicationHost>
<sites>
<site name="firstNode" id="1">
<application path="/" applicationPool="UnmanagedClassicAppPool">
<virtualDirectory path="/" physicalPath="D:\EricDocuments\My Web Sites\firstNode" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:3000:localhost" />
</bindings>
</site>
</sites>
</system.applicationHost>
</configuration>

Just find the your node.js project entry in applicationhost.config and change port.

Frequently Used R Package List and Install Hint

Permalink

Confirm works at Ubuntu 14.04 / 12.04.

  • knitr - A general-purpose package for dynamic report generation in R
  • rmarkdown - Dynamic Documents for R
  • SixSigma - Six Sigma Tools for Quality and Process Improvement
  • sqldf - Perform SQL Selects on R Data Frames
  • tseries - Time series analysis and computational finance
  • quantmod - Quantitative Financial Modeling Framework
  • doBy - Groupwise summary statistics, general linear contrasts, population means (least-squares-means), and other utilities
  • rJava - Low-Level R to Java Interface to support RWeka and xlsx
run before install rJava
R CMD javareconf
  • xlsx - Read, write, format Excel 2007 and Excel 97/2000/XP/2003 files
  • RCurl - General network (HTTP/FTP/...) client interface for R
To install rgdal package
apt-get install libcurl-dev
  • devtools - Tools to make developing R code easier
  • gplots - Various R programming tools for plotting data
  • ggmap - A package for spatial visualization with Google Maps and OpenStreetMap
  • googleVis - Interface between R and the Google Chart Tools
  • rworldmap - Mapping global data, vector and raster.
  • rgdal - Bindings for the Geospatial Data Abstraction Library
To install rgdal package
apt-get install libgdal1-dev
apt-get install libproj-dev # or libproj if not found
  • ROracle - Oracle database interface (DBI) driver for R.

    ROracle need Oracle Client install, and further additional setup procedure

  • pls - Multivariate regression methods Partial Least Squares Regression (PLSR), Principal Component Regression (PCR) and Canonical Powered Partial Least Squares (CPPLS).

  • assertthat - assertthat is an extension to stopifnot() that makes it easy to declare the pre and post conditions that you code should satisfy.

  • dplyr - A fast, consistent tool for working with data frame like objects, both in memory and out of memory.

  • data.table - Fast aggregation of large data (e.g. 100GB in RAM), fast ordered joins, fast add/modify/delete of columns by group using no copies at all, list columns and a fast file reader (fread). Offers a natural and flexible syntax, for faster development.

  • earth - Build regression models using the techniques in Friedman's papers "Fast MARS" and "Multivariate Adaptive Regression Splines".

  • kernlab - Kernel-based machine learning methods for classification, regression, clustering, novelty detection, quantile regression and dimensionality reduction. Among other methods kernlab includes Support Vector Machines, Spectral Clustering, Kernel PCA, Gaussian Processes and a QP solver.

  • caret - Classification and Regression Training, Misc functions for training and plotting classification and regression models.

  • rpart - Recursive Partitioning and Regression Trees

  • party - A Laboratory for Recursive Partytioning

  • RWeka - An R interface to Weka (Version 3.7.12). Weka is a collection of machine learning algorithms for data mining tasks written in Java, containing tools for data pre-processing, classification, regression, clustering, association rules, and visualization.

  • ipred - Improved predictive models by indirect classification and bagging for classification, regression and survival problems as well as resampling based estimators of prediction error.

  • randomForest - Breiman and Cutler's random forests for classification and regression

  • gbm - Generalized Boosted Regression Models

  • Cubist - Regression modeling using rules with added instance-based corrections

  • VGAM - Vector Generalized Linear and Additive Models, An implementation of about 6 major classes of statistical regression models. At the heart of it are the vector generalized linear and additive model (VGLM/VGAM) classes. Currently only fixed-effects models are implemented, i.e., no random-effects models. Many (150+) models and distributions are estimated by maximum likelihood estimation (MLE) or penalized MLE, using Fisher scoring.

  • mda - Mixture and flexible discriminant analysis, multivariate adaptive regression splines (MARS), BRUTO...

  • klaR - Miscellaneous functions for classification and visualization developed at the Fakultaet Statistik, Technische Universitaet Dortmund

  • e1071 - Misc Functions of the Department of Statistics, Probability Theory Group (Formerly: E1071), TU Wien

  • C50 - C5.0 decision trees and rule-based models for pattern recognition.

  • ROCR - Visualizing the Performance of Scoring Classifiers

  • ISLR - Data for An Introduction to Statistical Learning with Applications in R

Notes to Upgrade Ruby 2.0.0-p195 in Windws 7

Permalink

Finally, I go to ruby 2.0, after the first patch p195 release, roughly three month the ruby 2.0 released in its 20 years celebration. I using the rubyinstaller.org version and also it's devkit, the detail installation procedure is very like previous 1.9.3, so won't repeat here now, but I do found some trick which should in fact including in the official document but not, so I would list as below:

  1. Need manually install the sqlite3.

    1. run C:\DevKit\devkitvars.bat
    2. mkdir c:\temp
    3. download http://packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x86-windows.tar.lzma to c:\temp
    4. c:\Temp>bsdtar --lzma -xf sqlite-3.7.15.2-x86-windows.tar.lzma
    5. c:\Temp>gem install sqlite3 --platform=ruby -- --with-opt-dir=C:/Temp
  2. Using below .gemrc and reinstall the gems like yajl-ruby, win32console or bcrypt-ruby if you found the x86-mingw32 version can not work out of box.

edit/create the .gemrc as below content
---
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- https://gems.ruby-china.com
:update_sources: true
:verbose: true
gem: --no-document --platform=ruby
  1. You may want to comment out the "DL is deprecated, please use Fiddle" warning at C:\Ruby200\lib\ruby\2.0.0\dl.rb since it's annoy and you are not the irb/pry or some other gems code owner...

Ruby 2.0 performance is somewhat improved and it's worth to using it right now.

  1. Create Environment Variable SSL_CERT_FILE and point to cacert.pem, example C:\Ruby200\cacert.pem.

Thought After JMP Scripting Language Training

Permalink

I learn quite a lot of R in last 4 months in my spare time by attending a network based class. Today I also got a chance to attend a official SAS JMP software course called "Introduction to the JMP Scription Language" by my employer (only one day), so I would like to record some my thought about R and JMP here.

The most amazing part of JSL script is the funtion Expr, Insert Into and Name Expr, the teacher introduce JSL(JMP Script Language) as object oriented language, but using the three function mentioned before, I think the JSL is primarily a functional language instead, you building a new expression in the beginning of the program, modify the expression in the mid based on the condition or iteration way, then at the end of JSL script, evaluate the whole program as a expression.

So the JSL and R in the language level, share a lot about theoretical language feature/design priciple, although there is also quite a lot syntax detail difference.

On the other hand, the JMP and R design priciple in User Interface part is totally different, JMP is a totall interactive, click-select-OK-repeat windows application while the R is even no GUI windows by default.

So JMP and R is the best gay friend in each other in my option, you start explore and found the suitable math model/chart in JMP, after you confident that you have a more clear/stable solution, you using R as a implement tools to building free solution, so you got the best part of each other: JMP for its excellent UI and interactive workflow; R for its totally free license and be able to export it's program as a web application.

Setup Mirror Between 2 or More Git Server Using Hooks Script

Permalink

First make sure the two server can using ssh to login each other, then add remote mirror to bare git repository.

Add a bare-repository push mirror remote
git remote add --mirror=push cvpgitip01 git@10.11.37.110:repositories/Feng-Wu/demo.git

Add hooks post-commit in bare git repository.

Push the mirror from a post-commit hook
#!/bin/sh
exec git push cvpgitip01 -f --mirror

Install Shiny Server in Ubuntu 12.04

Permalink

R package Shiny originally not support R Studio Server, so shiny.R need change before install

install shiny package for R Studio
cd ~
wget http://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz
tar xvfz shiny_0.13.2.tar.gz
vi shiny/R/server.R
# search 'Listening on http://' and replace 'startServer(host, port' to 'startServer("0.0.0.0", port'
# search 'Test port to see if we can use it' and replace 'try(startServer(host, port' to 'try(startServer("0.0.0.0", port'
# search 'QtWebKit' and replace 'paste("http://", browseHost,' to 'paste("http://", "your.rstudio.host.name",'
tar cvfz shiny_0.13.2-server.tar.gz shiny
R CMD INSTALL shiny_0.13.2-server.tar.gz # (may need install htmltools before this line)
service rstudio-server restart # if you previous install shiny from CRAN

Before install shiny server, make sure you install node.js version 0.8.17 or higher and meet prerequisites.

install shiny-server
npm install -g shiny-server # install shiny-server

or use the offline install mode:

Build and install Shiny Server offline
git clone https://github.com/rstudio/shiny-server
cd shiny-server/
node tools/bundle-offline-installer.js
mv shiny-server-0.3.0.tgz ..
cd ..
npm install --no-registry -g shiny-server-0.3.0.tgz

The sample shiny server config file.

Example Shiny Server configuration
run_as shiny;
log_dir /var/log/shiny-server/;
server {
listen 3838 127.0.0.1;
location /first {
app_dir /var/shiny-server/first;
}
location /diamonds {
app_dir /var/shiny-server/diamonds;
}
}

Change Devise User Password in Rails Console

Permalink

Reset a Devise user password in the Rails console
# $ rails console production
u=User.where(:email => 'usermail@gmail.com').first
u.password='userpassword'
u.password_confirmation='userpassword'
u.save