Archives For ruby

The Command-T plug-in provides an extremely fast, intuitive mechanism for
opening files and buffers with a minimal number of keystrokes. It’s named
“Command-T” because it is inspired by the “Go to File” window bound to
Command-T in TextMate.

I was trying to install Command-T into VIM with the Pathogen plugin. I kept getting

checking for ruby.h... *** extconf.rb failed 
***Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

I realized my rvm environment was choosing the incorrect gcc and developer tools. I used the system ruby and was able to run everything without a hitch.

rvm use system    
cd ruby/command-t
ruby extconf.rb
make
sudo make install

Style Guides

May 21, 2013 — Leave a comment

Well-designed code is much easier to maintain, optimize, and extend, making for more efficient developers. That means more focus and energy can be spent on building great things, which makes everyone happy—users, developers, and stakeholders.

Ruby – Github Style Guide

Python – Official PEP8 Style Guide

require 'rubygems'
require 'mail'

# Set up delivery defaults to use Gmail
Mail.defaults do
  delivery_method :smtp, { 
    :address => 'smtp.gmail.com',
    :port => '587',
    :user_name => '<user>@gmail.com',
    :password => '<password>',
    :authentication => :plain,
    :enable_starttls_auto => true
  }
end

# Send email with attachment.
mail = Mail.new do
  from     '<user>@gmail.com'
  to       'test@gmail.com'
  subject  'Hi, Michael Le'
  #add_file :filename => 'hello_world.txt', 
:content => File.read('hello_world.txt')

end

# Don't forget delivery
mail.deliver!

You can check Mikel Lindsaar’s mail gem on github.

Ruby or Python?

July 16, 2012 — Leave a comment

For those who have experience with other programming languages such as C++ and Java, you will have an easier time learning Ruby.
For those who have never coded or have very little experience, I think Python is much easier to pick up as your first programming language.

I started out with Ruby (after learning C++, Java and other various languages), but dabbled a bit into Python, and because of that dabbling, I learned how to code Ruby better and understand the fundamentals of Computer Science better.