Eric Guo's blog.cloud-mes.com

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

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

Grid Computing Answer for Python Code Dojo Class Two

Permalink

The answer for Python Code Dojo Class Two, which I attend today as seven language in seven week hold by Shanghai TopGeek.

calculate the maximum value found by summing all the rows and columns of a grid of numbers
stin="""01 34 46 31 55 21 16 88 87 87
32 40 82 40 43 96 08 82 41 86
30 16 24 18 04 54 65 96 38 48
32 00 99 90 24 75 89 41 04 01
11 80 31 83 08 93 37 96 27 64
09 81 28 41 48 23 68 55 86 72
64 61 14 55 33 39 40 18 57 59
49 34 50 81 85 12 22 54 80 76
18 45 50 26 81 95 25 14 46 75
22 52 37 50 37 40 16 71 52 17"""
g=[map(int, str.rsplit(row)) for row in str.rsplit(stin, '\n')]
d={}
for idx, val in enumerate(g):
d[sum(val)]="row %s"%(idx+1)
tg=zip(*g)
for idx, val in enumerate(tg):
d[sum(val)]="col %s"%(idx+1)
kd=list(d.keys())
kd.sort(reverse=True)
print "Max value: %s: %s" % (d[kd[0]], kd[0])

The complete part of the class:

  1. Code Dojo Class One
  2. Code Dojo Class Two
  3. Code Dojo Class Three - An Intro to TDD and unittest of Python