Tuesday, December 21, 2010

How to install nfs server and client in ubuntu

sudo apt-get install nfs-kernel-server nfs-common portmap

to configure the mount points:
1. create directories
2. modify /etc/fstab file

Sunday, November 28, 2010

a complete way to use button_to_remote on ruby on rails

button_to_remote "text",
    {:url => { :controller => :controller,
      :action     => :action,
      :attrs => attrs   }},
    {:class => "css_class"}

Thursday, November 11, 2010

How to get the superclass of an object

I used to be able to call superclass directly, but not anymore, I don't know exactly with ruby version changed.   Now I need to make the call on from the class.

i.e.
obj.superclass <--  Not any more XXXXX

This is correct:
      obj.class.superclass

How to play with your rails environment for debugging

by running the script:
rails_project/script/console

You get all the rails project loaded and ready to play with all your models

Thursday, November 4, 2010

Sunday, October 17, 2010

emacs cool cookbook

autoindent regionESC - C - \

how to use macros in emacs

C-x (  to start recording your macro
C-x ) to save your macro


C-x C-k n

Give a command name (kmacro-name-last-macro). 
C-x C-k b
Bind the most recently defined keyboard macro to a key sequence (kmacro-bind-to-key). 


M-x insert-kbd-macro

Insert in the buffer a keyboard macro's definition, as Lisp code.


this will be available while your macro session is running, once killing it you need to recreate your macro.
Sometimes this is good because is a simple and very special thing you want to do right away.

Once the activity is kind of repetitive on regular basis, It's time to understand how to save it:

Wednesday, September 1, 2010

How to use LibXML on rails

xml_doc = LibXML::XML::Document.new
xml_doc.root = LibXML::XML::Node.new("node_name")
xml_doc.root['id'] = id.to_s
xml_doc.root << xml_ex1 = LibXML::XML::Node.new("ex1")
xml_doc.root << xml_ex2 = LibXML::XML::Node.new("ex2")
#my method to convert an array into a filler of the ex1 node
self.push_this_array_into_this_node(notifications, xml_ex1, "notification")
#my method to convert an array into a filler of the ex2 nodeself.push_this_array_into_this_node(requests, xml_ex2, "request")
return xml_doc

How to start with selenium on Ruby on Rails

script/plugin install http://svn.openqa.org/svn/selenium-on-rails/stable/selenium-on-rails


script/generate selenium first.rsel


script/server -e test -p 3001


http://localhost:3001/selenium

cookbook for testing on ruby on rails

unit test core methods
setup       -> test initialization
teardown -> test cleanup

How test a unit
ruby test/x_unit.rb

How to test a unit test
ruby test/unit/timesheet_test.rb -n test_x1

How to test controllers
rake test:functionals

How to test models
rake test:units

How to test everything
rake

How to get stats
rake stats

to replicate development schema
rake db:test:prepare

script/plugin install http://topfunky.net/svn/plugins/ar_fixtures
Once the plugin is installed, dumping a fixture is a simple matter of invoking a new rake task called rake db:fixtures:dump. Unlike the built-in loading rake task, this one takes a MODEL parameter with the name of the ActiveRecord class that you want to dump data for:
$ rake db:fixtures:dump MODEL=BillingCode