How to Create a Date Time Snippet in Sublime Text 2 (Dynamic Signature with Time Stamp)

You’ll have to create a new plugin. From the menu bar select

Tools > New Plugin

Copy the Python script from the signature.py file. Remember to replace your email address (it’s example.com).
Save the file, signature.py, is fine. Next open up Preferences > Key Bindings – Default and add a new entry.

ctl+alt+s will add the snippet to the first line of your file.

Transform Matching Text with Gsub in Ruby and Regular Expression

Here is a gist that demonstrates how easy it is to transform text using #gsub and a block with Ruby.

For more helpful string extensions in Ruby check out our Ruby Gem on GitHub https://github.com/AgilionApps/rails_extensions

Color Output with Test:Unit, AutoTest and Ruby 1.9

If you are testing using Test:Unit (rather than RSpec) and you’re using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded and not available and will break your tests.

The solution is to require Test:Unit version 2.0.0 in your Gemfile, require the testrunner.rb script in test/test_helper.rb and reopen and implement the guess_color_availability method.

Then you can just run the autotest command (or bundle exec autotest) from your project directory. When you save a file your tests will be run for the file that has been changed and the results will be fully colorized!

23 Sep 2011, 4:02pm
ruby
by

leave a comment

Class << Self Explained


# Define a class with a class method "find"
# Usage
# Apple.find("macintosh")
class Apple
   def self.find(variety)
      # code goes here
   end
end

# Same as above but notice the lack of self prefix before the method name
# Usage
# Apple.find("macintosh")
class Apple
   class << self
      def find(variety)
         # code goes here
      end
   end
end

See the full pastie here: http://pastie.org/2580020

7 Jul 2011, 11:43pm
Posts:
by

leave a comment

Changing GitHub Issue State in Git Commit Message

Changing issue state in git commit message for Github issues

fixes #xxx
fixed #xxx
fix #xxx
closes #xxx
close #xxx
closed #xxx

Example

git commit -am'complete bug fix closes #123'

Email Regex

Regular Expression that Matches Email Addresses:

/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/

Vim Tips and Tricks

The following tips and tricks can be put into your .vimrc file

Remap jj to esc

imap jj &lt;Esc&gt;

Quickly leave edit mode and back to visual mode with jj. This is probably the fastest key combination possible and one of the most frequent key combinations while editing in vim.

Remap semicolon “;”

nnoremap ; :

Instead of shift, semicolon (which produces a colon) just remap the semicolon to a colon while in visual mode.

You can alias commands with vim

command Tab, :tabnew

The only caveat is that your alias must start with a capital letter.

How to Upgrade RVM on Mac OS X

I had an old version of rvm installed and wanted to upgrade. So old in fact that the resource for upgrading no longer existed.

rvm update

just returned a 301, redirect.

Luckily, the following worked

# checks out from repo
rvm update --head
# will reload rvm environment
rvm reload
# finally, the upgrade command works!
rvm get latest