Browsed by
Month: April 2012

My dotfiles

My dotfiles

Finally I created a repository with my dotfiles.

Dotfiles are configurations files, usually with their names beginning with a dot (hidden files) and located in your home directory (~/).

The repository is: https://github.com/lucascaton/dotfiles

Check the instructions in the link above, in order to get the dotfiles.

The dotfiles are focused on the Ruby language, but there’s also Git and PostgreSQL configuration files. I’ve included files as .bash_profile, .gitconfig, .irbrc (using pry), .pryrc, .psqlrc and .rvmrc. There is also a list of ruby gems (file “default.gems”).

My vimfiles can be found at: https://github.com/lucascaton/vimfiles

I have tested it only in OSX 10.7, but it should work in any *nix without problems.

Regex to match Youtube URLs (using Ruby)

Regex to match Youtube URLs (using Ruby)

I created a regular expression in order to match Youtube URLs.

Currently, the most common URLs from Youtube are http://youtube.com and http://youtu.be:

/^(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?([\w-]{10,})/

This regex will match:

  • http://youtube.com/watch?v=1234567890
  • https://youtube.com/watch?v=1234567890
  • http://www.youtube.com/watch?v=1234567890
  • http://www.youtube.com/watch?v=12345-67890
  • https://www.youtube.com/watch?v=1234567890
  • http://youtu.be/1234567890
  • https://youtu.be/1234567890
  • http://www.youtu.be/1234567890
  • https://www.youtu.be/1234567890
  • http://www.youtube.com/watch?v=1234567890&feature=context&context=G2de15aaFAAAAAAAAAAA
  • www.youtube.com/watch?v=1234567890
  • youtube.com/watch?v=1234567890
  • youtu.be/1234567890

And won’t match:

  • youtube.com
  • youtube.com/
  • youtube.com/watch
  • youtube.com/watch/
  • youtu.be
  • youtu.be/