My Ruby (and Rails)
   environment
 Reuven M. Lerner • reuven@lerner.co.il
Rails Underground, Israel • July 13th, 2011
Who am I?

• Web developer, software architect,
  consultant, lecturer/trainer
• Linux Journal columnist since 1996
• Mostly Ruby on Rails + PostgreSQL, but
  also Python, PHP, jQuery, and lots more...
Want to learn Rails?

• I’m teaching a course at Hi-Tech College
• Not very far from here!
• August 14 - 18 , 2011
            th    th


• (I can do private training as well...)
Also:

• I’m swamped with Ruby work!
• Want to help me out?
• (I need to sleep!)
• Come speak with me after my talk...
Tools are important
Shell
• For years, I used bash
 • GNU Bourne-Again Shell
• I recently switched to zsh
• I use the plugin, “oh my zsh”
• Did it change my life? No.
 • But some things are easier
Better things

• Easy-to-customize prompt
• Saner history (across terminal tabs)
• Automatic updates of oh-my-zsh
• One configuration file (.zshrc)
Things I use often

• C-z (suspend) and fg
• Emacs keybinding
• C-r (reverse search
• Customized prompt
iTerm2
• The OS X terminal is OK
• iTerm used to be much better
• Recently rewritten as iTerm2
• I use very few of the features
 • Lots of tabs, though!
• My favorites: Search, movie playback
rvm
• Don’t develop in Ruby without rvm
• Really, it’s amazing
• I use 1.8.7, 1.9.2, and JRuby day to day
 • Learn about updates!
• .rvmrc for each project I work on
• Gemsets vs. bundles — bundles are winning
irb
• I use irb (or the Rails console) every day
• If you’re programming in Ruby, then you
  should probably have IRB open always!
• Every piece of code I write, more or less, is
  tried in IRB first
• Debugging largely happens for me in IRB
Gems for IRB!

• There has been an explosion of IRB-
  enhancing gems
• I’ll present some of them
• Most or all of these are from the “irbtools”
  gem, which packages them together
ap


• “Awesome print” — and it is!
• Data structures look nicer, in color
Sorted methods!

• How often do you write
  foo.methods.sort
• Now you can just write
  foo.methods
every_day_irb

• Puts shell commands in IRB!
  ls
  cat
  pwd
;nil after long evals

• Cute trick: If you’re reading a lot of data, add
  ;nil
• to the end of your command, so that IRB
  won’t print it all.
hirb
• Shows data in a table
• Sort of like ap, but for to_s
• Better with ActiveRecord output
• If you want to disable it (I do by default),
  just set Hirb::View.disable, or
  Hirb::View.enable
methodfinder

• Methodfinder.find
• Object#find_method
  "abc".find_method("ABC")
sketch

• Anonymous edits
• Named edits
• Great with emacsclient (for Emacs users)
  sketch
  sketch :foo
GNU Emacs
• One True Editor
• I’ve used it since 1988 (yes, 1988!)
• More operating system than editor
• Configure it in Emacs Lisp
 • Full, Turing-complete language with
    oodles of functions for text, files,
    networks, and psychoanalysis
Ideal Emacs keyboard
Required anti-vi joke
Subject: Re: HELP: music for cl, vi, vlc, pi

Date: 14 May 1996 10:35:43 +0200

Alan> vi doesn't play music.

David> Sure it does.

In fact, vi has a special mode just for music. If you
are not in insert mode, you are in `beep' mode:
whatever you press produces a beep. In the best
tradition of vi, there is of course just one note
(you know: small is beautiful) but this is just one
of those reasons why vi hackers love vi.
How Emacs works
How Emacs works


              Lisp
            function
How Emacs works


                    Lisp
    Key binding
                  function
How Emacs works


                            Lisp
Keystroke   Key binding
                          function
Sounds crazy?

• It’s great.
• Define functions. Or install packages.
• Set bindings (global or modal).
• Use control-alt-shift-meta-cokebottle
Function, binding
(defun indent-buffer (&optional which-buffer)
  "Indents a buffer (default is current)."
  (interactive "bBuffer to indent: ")
  (indent-region (point-min) (point-max) nil)
  (beep)
  (message "Done indenting"))


(global-set-key   "ei" 'indent-buffer)
(add-hook 'ruby-mode-hook
          '(lambda ()
             (interactive)
             (inf-ruby-keys)

       (rainbow-delimiters-mode t)
             (turn-on-font-lock)
             (ruby-electric-mode t)

       (rvm-activate-corresponding-ruby)

       (if (and (not (null buffer-file-name))

   
        (file-writable-p buffer-file-name)

 
 
           (not (string-match "jruby" rvm--
current-ruby-binary-path)))

   
   (flymake-mode))

       ))
Snippets

• TextMate fans, rejoice — Emacs has
  snippets, too!
  • It has had “abbrevs” forever
• Even import TextMate snippets
• I don’t use these that much, to be honest
Intellisense?

• Everyone in Israel asks about it!
• Emacs has a few options that come close
• I’ve used it on a few occasions, but never
  really liked it
Flymake


• Check your syntax (with a background
  Ruby process) as you type!
• Errors? The line appears in red
Ruby electric mode


• Inserts extra quotes, braces,
• Also inserts “end” after class, module, if,
  etc.
Rainbow delimiters

• Fancy braces!
• Each set of parens/braces gets its own
  color
• Lovely when you have a hash
Rinari
• Rinari Is Not A Rails IDE
• Keyboard shortcuts to jump to related
  parts of the code
• Tries to be minimal
• There’s also emacs-rails — more
  functionality, but updated less frequently
ERb and Haml


• Handles colorizing, indenting
• Flymake works inside of ERb, also!
Switching buffers

• From controllers (C-c ‘ f c) — functional
  tests (C-c ‘ f t)
• Models (C-c ‘ f m) — unit tests (or C-c ‘ f t)
• Switch to the log (C-c ‘ f o)
Tags
• Index of names in your files
• Jump to the right file/line
• Even search/replace
• I go back and forth on using tags ... they
  work really well, but I’m often too lazy, and
  end up using “git grep”
Emacs server

• If you’re starting Emacs more than once a
  day, then you’re doing something wrong
• Open buffers
• Connect from outside
 • e.g., sketch (from before, in IRB)
Magit

• Use Git from within Emacs!
 • Stage, Commit, Stash
 • Branch, Merge
 • Push, pull
• Fully integrated, and works really nicely
Rails development environment talk
Macros

• Record a macro
• Replay any number of times
• Super-duper useful, especially when
  converting files
Firefox plugins

• I use Firefox as my main browser
• Not the fastest (for now!)
• Not updated like Chrome (for now!)
• But it has excellent plugins
Firebug
• Everyone’s favorite JavaScript/Ajax
  debugger
• Console
• Execute JavaScript
• Modify CSS in real time
• Truly an amazing piece of software
Web developer

• “View Generated HTML” — my favorite!
• Also:View HTTP request, response headers
• Mark items with boxes
Growl

• Notification system under OS X
• Autotest + Growl gives me nice output for
  red/green
• Just require “autotest/growl” in your
  ~/.autotest file
Pow
• Finally, I have to run things locally
• 37signals recently released Pow for OS X
• (There’s talk of doing it for Linux, too)
• Super-duper easy:
 • symlink from ~/.pow/foo to project foo
 • Now go to http://foo.dev !
Thanks!
(Any questions?)
     reuven@lerner.co.il
   http://www.lerner.co.il/
        054-496-8405
“reuvenlerner” on Skype/AIM

More Related Content

PDF
Bringing Concurrency to Ruby - RubyConf India 2014
PPTX
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
PDF
JRuby: Pushing the Java Platform Further
KEY
Erlang: TL;DR
PDF
Ruby projects of interest for DevOps
PDF
Great Tools Heavily Used In Japan, You Don't Know.
KEY
Hybrid concurrency patterns
PDF
Making CLI app in ruby
Bringing Concurrency to Ruby - RubyConf India 2014
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
JRuby: Pushing the Java Platform Further
Erlang: TL;DR
Ruby projects of interest for DevOps
Great Tools Heavily Used In Japan, You Don't Know.
Hybrid concurrency patterns
Making CLI app in ruby

What's hot (20)

PPTX
Ruby, the language of devops
KEY
Perl in Teh Cloud
PDF
Lock-free algorithms for Kotlin Coroutines
PDF
Functional Programming for Busy Object Oriented Programmers
PDF
Python to go
PDF
Ruby in office time reboot
PPTX
Taming the resource tiger
PPTX
Tofu and its environment
PDF
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
KEY
Building MapAttack
PDF
10 Things you should know about Ruby
PDF
Code for Startup MVP (Ruby on Rails) Session 1
PDF
Ruby is dying. What languages are cool now?
PPTX
ZeroMQ at Oredev 2013
PDF
Opal chapter 4_a_new_hope
PDF
Getting Started with Go
PDF
Why Plone Will Die
KEY
Message:Passing - lpw 2012
PDF
Building Asynchronous Applications
PPTX
I18nize Scala programs à la gettext
Ruby, the language of devops
Perl in Teh Cloud
Lock-free algorithms for Kotlin Coroutines
Functional Programming for Busy Object Oriented Programmers
Python to go
Ruby in office time reboot
Taming the resource tiger
Tofu and its environment
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
Building MapAttack
10 Things you should know about Ruby
Code for Startup MVP (Ruby on Rails) Session 1
Ruby is dying. What languages are cool now?
ZeroMQ at Oredev 2013
Opal chapter 4_a_new_hope
Getting Started with Go
Why Plone Will Die
Message:Passing - lpw 2012
Building Asynchronous Applications
I18nize Scala programs à la gettext
Ad

Viewers also liked (20)

PDF
Responsive web design
KEY
Rails console
PDF
Big Data — Your new best friend
PDF
Ukrainian branch of WDC
KEY
Rails tools
KEY
Ruby objects
PDF
Web APIs: The future of software
PDF
Introduction to Version Control Systems
KEY
Rails traps
PDF
Rails israel 2013
PDF
What can Ruby learn from Python (and vice versa)?
PDF
PostgreSQL, your NoSQL database
PDF
Python's magic methods
PDF
Technical training business talk.key
KEY
Why ruby and rails
KEY
PostgreSQL
PDF
User interface design
PPT
Online Stock Trading
PDF
Intro to cloud computing — MegaCOMM 2013, Jerusalem
PDF
Why Zsh is Cooler than Your Shell
Responsive web design
Rails console
Big Data — Your new best friend
Ukrainian branch of WDC
Rails tools
Ruby objects
Web APIs: The future of software
Introduction to Version Control Systems
Rails traps
Rails israel 2013
What can Ruby learn from Python (and vice versa)?
PostgreSQL, your NoSQL database
Python's magic methods
Technical training business talk.key
Why ruby and rails
PostgreSQL
User interface design
Online Stock Trading
Intro to cloud computing — MegaCOMM 2013, Jerusalem
Why Zsh is Cooler than Your Shell
Ad

Similar to Rails development environment talk (20)

PDF
Ruby tutorial
PDF
Ruby Presentation
PPT
Intro To Ror
PDF
The Enterprise Strikes Back
ODP
PDF
How to Begin to Develop Ruby Core
KEY
MacRuby: What is it? and why should you care?
DOCX
Page List & Sample Material (Repaired)
KEY
Intro to Ruby (and RSpec)
PDF
IJTC%202009%20JRuby
PDF
IJTC%202009%20JRuby
PDF
Ruby tutorial
PPTX
Ruby And Ruby On Rails
PPT
PDF
Kon nichi wa_ruby
PDF
ruby pentest
PDF
Metaprogramming in Ruby
PDF
RVM and Ruby Interpreters @ RSC Roma 03/2011
KEY
Ruby v cpp_preso
Ruby tutorial
Ruby Presentation
Intro To Ror
The Enterprise Strikes Back
How to Begin to Develop Ruby Core
MacRuby: What is it? and why should you care?
Page List & Sample Material (Repaired)
Intro to Ruby (and RSpec)
IJTC%202009%20JRuby
IJTC%202009%20JRuby
Ruby tutorial
Ruby And Ruby On Rails
Kon nichi wa_ruby
ruby pentest
Metaprogramming in Ruby
RVM and Ruby Interpreters @ RSC Roma 03/2011
Ruby v cpp_preso

More from Reuven Lerner (7)

PDF
Functional Python Webinar from October 22nd, 2014
KEY
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
KEY
Git talk from Open 2011 conference in Israel
PDF
Dynamic languages, for software craftmanship group
KEY
Modern Web Technologies — Jerusalem Web Professionals, January 2011
KEY
PostgreSQL talk, Database 2011 conference
PDF
ActiveRecord 2.3
Functional Python Webinar from October 22nd, 2014
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Git talk from Open 2011 conference in Israel
Dynamic languages, for software craftmanship group
Modern Web Technologies — Jerusalem Web Professionals, January 2011
PostgreSQL talk, Database 2011 conference
ActiveRecord 2.3

Recently uploaded (20)

PDF
Comparative analysis of machine learning models for fake news detection in so...
PPTX
Training Program for knowledge in solar cell and solar industry
PPTX
Microsoft User Copilot Training Slide Deck
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
4 layer Arch & Reference Arch of IoT.pdf
PPTX
future_of_ai_comprehensive_20250822032121.pptx
PPTX
MuleSoft-Compete-Deck for midddleware integrations
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PPTX
Internet of Everything -Basic concepts details
PPTX
Configure Apache Mutual Authentication
PDF
SaaS reusability assessment using machine learning techniques
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PPTX
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
Comparative analysis of machine learning models for fake news detection in so...
Training Program for knowledge in solar cell and solar industry
Microsoft User Copilot Training Slide Deck
Custom Battery Pack Design Considerations for Performance and Safety
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
4 layer Arch & Reference Arch of IoT.pdf
future_of_ai_comprehensive_20250822032121.pptx
MuleSoft-Compete-Deck for midddleware integrations
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
Co-training pseudo-labeling for text classification with support vector machi...
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Improvisation in detection of pomegranate leaf disease using transfer learni...
Internet of Everything -Basic concepts details
Configure Apache Mutual Authentication
SaaS reusability assessment using machine learning techniques
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf

Rails development environment talk

  • 1. My Ruby (and Rails) environment Reuven M. Lerner • [email protected] Rails Underground, Israel • July 13th, 2011
  • 2. Who am I? • Web developer, software architect, consultant, lecturer/trainer • Linux Journal columnist since 1996 • Mostly Ruby on Rails + PostgreSQL, but also Python, PHP, jQuery, and lots more...
  • 3. Want to learn Rails? • I’m teaching a course at Hi-Tech College • Not very far from here! • August 14 - 18 , 2011 th th • (I can do private training as well...)
  • 4. Also: • I’m swamped with Ruby work! • Want to help me out? • (I need to sleep!) • Come speak with me after my talk...
  • 6. Shell • For years, I used bash • GNU Bourne-Again Shell • I recently switched to zsh • I use the plugin, “oh my zsh” • Did it change my life? No. • But some things are easier
  • 7. Better things • Easy-to-customize prompt • Saner history (across terminal tabs) • Automatic updates of oh-my-zsh • One configuration file (.zshrc)
  • 8. Things I use often • C-z (suspend) and fg • Emacs keybinding • C-r (reverse search • Customized prompt
  • 9. iTerm2 • The OS X terminal is OK • iTerm used to be much better • Recently rewritten as iTerm2 • I use very few of the features • Lots of tabs, though! • My favorites: Search, movie playback
  • 10. rvm • Don’t develop in Ruby without rvm • Really, it’s amazing • I use 1.8.7, 1.9.2, and JRuby day to day • Learn about updates! • .rvmrc for each project I work on • Gemsets vs. bundles — bundles are winning
  • 11. irb • I use irb (or the Rails console) every day • If you’re programming in Ruby, then you should probably have IRB open always! • Every piece of code I write, more or less, is tried in IRB first • Debugging largely happens for me in IRB
  • 12. Gems for IRB! • There has been an explosion of IRB- enhancing gems • I’ll present some of them • Most or all of these are from the “irbtools” gem, which packages them together
  • 13. ap • “Awesome print” — and it is! • Data structures look nicer, in color
  • 14. Sorted methods! • How often do you write foo.methods.sort • Now you can just write foo.methods
  • 15. every_day_irb • Puts shell commands in IRB! ls cat pwd
  • 16. ;nil after long evals • Cute trick: If you’re reading a lot of data, add ;nil • to the end of your command, so that IRB won’t print it all.
  • 17. hirb • Shows data in a table • Sort of like ap, but for to_s • Better with ActiveRecord output • If you want to disable it (I do by default), just set Hirb::View.disable, or Hirb::View.enable
  • 19. sketch • Anonymous edits • Named edits • Great with emacsclient (for Emacs users) sketch sketch :foo
  • 20. GNU Emacs • One True Editor • I’ve used it since 1988 (yes, 1988!) • More operating system than editor • Configure it in Emacs Lisp • Full, Turing-complete language with oodles of functions for text, files, networks, and psychoanalysis
  • 22. Required anti-vi joke Subject: Re: HELP: music for cl, vi, vlc, pi Date: 14 May 1996 10:35:43 +0200 Alan> vi doesn't play music. David> Sure it does. In fact, vi has a special mode just for music. If you are not in insert mode, you are in `beep' mode: whatever you press produces a beep. In the best tradition of vi, there is of course just one note (you know: small is beautiful) but this is just one of those reasons why vi hackers love vi.
  • 24. How Emacs works Lisp function
  • 25. How Emacs works Lisp Key binding function
  • 26. How Emacs works Lisp Keystroke Key binding function
  • 27. Sounds crazy? • It’s great. • Define functions. Or install packages. • Set bindings (global or modal). • Use control-alt-shift-meta-cokebottle
  • 28. Function, binding (defun indent-buffer (&optional which-buffer) "Indents a buffer (default is current)." (interactive "bBuffer to indent: ") (indent-region (point-min) (point-max) nil) (beep) (message "Done indenting")) (global-set-key "ei" 'indent-buffer)
  • 29. (add-hook 'ruby-mode-hook '(lambda () (interactive) (inf-ruby-keys) (rainbow-delimiters-mode t) (turn-on-font-lock) (ruby-electric-mode t) (rvm-activate-corresponding-ruby) (if (and (not (null buffer-file-name)) (file-writable-p buffer-file-name) (not (string-match "jruby" rvm-- current-ruby-binary-path))) (flymake-mode)) ))
  • 30. Snippets • TextMate fans, rejoice — Emacs has snippets, too! • It has had “abbrevs” forever • Even import TextMate snippets • I don’t use these that much, to be honest
  • 31. Intellisense? • Everyone in Israel asks about it! • Emacs has a few options that come close • I’ve used it on a few occasions, but never really liked it
  • 32. Flymake • Check your syntax (with a background Ruby process) as you type! • Errors? The line appears in red
  • 33. Ruby electric mode • Inserts extra quotes, braces, • Also inserts “end” after class, module, if, etc.
  • 34. Rainbow delimiters • Fancy braces! • Each set of parens/braces gets its own color • Lovely when you have a hash
  • 35. Rinari • Rinari Is Not A Rails IDE • Keyboard shortcuts to jump to related parts of the code • Tries to be minimal • There’s also emacs-rails — more functionality, but updated less frequently
  • 36. ERb and Haml • Handles colorizing, indenting • Flymake works inside of ERb, also!
  • 37. Switching buffers • From controllers (C-c ‘ f c) — functional tests (C-c ‘ f t) • Models (C-c ‘ f m) — unit tests (or C-c ‘ f t) • Switch to the log (C-c ‘ f o)
  • 38. Tags • Index of names in your files • Jump to the right file/line • Even search/replace • I go back and forth on using tags ... they work really well, but I’m often too lazy, and end up using “git grep”
  • 39. Emacs server • If you’re starting Emacs more than once a day, then you’re doing something wrong • Open buffers • Connect from outside • e.g., sketch (from before, in IRB)
  • 40. Magit • Use Git from within Emacs! • Stage, Commit, Stash • Branch, Merge • Push, pull • Fully integrated, and works really nicely
  • 42. Macros • Record a macro • Replay any number of times • Super-duper useful, especially when converting files
  • 43. Firefox plugins • I use Firefox as my main browser • Not the fastest (for now!) • Not updated like Chrome (for now!) • But it has excellent plugins
  • 44. Firebug • Everyone’s favorite JavaScript/Ajax debugger • Console • Execute JavaScript • Modify CSS in real time • Truly an amazing piece of software
  • 45. Web developer • “View Generated HTML” — my favorite! • Also:View HTTP request, response headers • Mark items with boxes
  • 46. Growl • Notification system under OS X • Autotest + Growl gives me nice output for red/green • Just require “autotest/growl” in your ~/.autotest file
  • 47. Pow • Finally, I have to run things locally • 37signals recently released Pow for OS X • (There’s talk of doing it for Linux, too) • Super-duper easy: • symlink from ~/.pow/foo to project foo • Now go to http://foo.dev !
  • 48. Thanks! (Any questions?) [email protected] http://www.lerner.co.il/ 054-496-8405 “reuvenlerner” on Skype/AIM

Editor's Notes