Eric Guo's blog.cloud-mes.com

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

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.

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

Add hooks post-commit in bare git repository.

#!/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:

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.

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;
}
}

How to Avoid the Ruby Debugger Warning Already Initialized Constant VERSION in Rubymine

Permalink

Now I'm using the Rubymine instead of pry-debugger as my primary Rails environment, Rubymine has much great debug facility and what's more, I spend $17 when the JetBrains offer 75% off at the Mayan Doomsday.

But I found a problem that rubymine always refuse to enter the debug mode when I using my pl-form project in below warning:

debugger-1.2.3/lib/ruby_debug.so: warning: already initialized constant VERSION

finally I found prject Gemfile need a little review:

group :development do
gem 'quiet_assets'
# Disable below two line if you using rubymine
#gem 'pry-rails'
#gem 'pry-debugger'
end