Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Monday, February 6, 2012

R and Rserve on Windows

This is easy if your system is 32-bit.  If it is 64 bit you need to make sure you are using 32-bit R because the R serve binary is 32 bit!
  1. Install the windows R binary package (accepting the defaults)
  2. Put the R bin directory on your path (right click computer  Advanced Properties  Environment Variables).  
    • For a 32-bit Windows install you should use a path like this:  C:\Program Files\R\R-2.14.1\bin
    • For a 64-bit Windows install you need to link to the i386 folder: C:\Program Files\R\R-2.14.1\bin\i386
  3. Fire up R from the cmd line (make sure that it is the 32 bit R, even if you are on a 64-bit computer) and execute the command: install.packages("Rserve") -- note to where it installs Rserve.
  4. Copy the binaries Rserve.exe and Rserve_d.exe to your R bin directory referenced aboved.
  5. Fire up a new cmd line and run the command: "R CMD Rserve' and configure the firewall popup to allow rserve to work.
  6. You know if everything is working if you can execute this code inside of irb (depends on rserve/simpler [gem install rserve-simpler]):
    • require 'rserve/simpler/R'
  7. Remember to start rserve from a separate commandline window before running any other code.  Also remember that you only get one connection in windows... so make it count.

Monday, April 11, 2011

rvm with Ubuntu 10.04 and 10.10

If you plan on doing a lot of development in ruby, then rvm (ruby version manager) is the way to use lots of different ruby versions and gems. If you just want to run ruby, you should use your system's package manager.

This is a condensed version of Chistopher Irish's excellent write-up

(leading $ is the bash prompt)

$ sudo apt-get install curl git-core ruby
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

If you haven't already replaced your .bashrc, you probably have a line in there like this:
[ -z "$PS1" ] && return

Replace that line with:

if [[ -n "$PS1" ]]; then

Then, add this to the last line of the .bashrc file (however, you can leave off that very final, dangling 'fi' if you did NOT have a return statement that you replaced earlier).

if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi

fi

There are going to be prerequisites to installing most ruby's. Use the command rvm notes to discover those dependencies for your system.

Okay, we'll grab some prerequisites for compiling 1.9.2:

$ sudo aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf

Now, we can list the ruby versions we can install, install 1.9.2, and set it as default.


rvm list known  # see which ruby versions we could install
rvm install 1.9.2-head
rvm --default 1.9.2-head  # make ruby 1.9.2 our default

Tuesday, March 15, 2011

bacon and autotest

Took a little to figure this out, so thought I would share.  You need an empty file in your spec folder called .bacon in your spec folder.  This appears to load up a lot of the proper bacon environment things into autotest.  However, if you want to override specific behaviors, you do that in a .autotest file in the top directory.


touch spec/.bacon

Inside .autotest:
require 'rubygems'
require 'bacon'
require 'autotest/bacon'

# see inside /lib/autotest/bacon.rb for template

class Autotest::Bacon < Autotest
  undef make_test_cmd
  def make_test_cmd(files_to_test)
    # I modified this to only include _spec.rb files:
    args = files_to_test.keys.flatten.select {|v| v =~ /_spec.rb$/ }.join(' ')
    args = '-a' if args.empty?
    # TODO : make regex to pass to -n using values
    # use bacon -h to see all your possible options!
    "#{ruby} -S bacon -I#{libs} -o TestUnit #{args}"
  end
end