HOWTO Grok Regular Expressions

Published by Michael de Silva on Saturday, 15 June 2013


I'm not ashamed to say that I've been more a consumer of publicly-crafted regexes over the years. All the texts on the subject have been cryptic enough, that it's something I never actually bothered looking into seriously enough, and boy-oh-boy I wish I had done this sooner!

Today, I took that step and am already on my way to enlightenment thanks to

  1. #regex on irc.freenode.net and ShiningThrough for his help
  2. http://regex101.com/ which is the best online regex tool I've come across to date (thanks ShiningThrough!)
  3. http://regexone.com/ interactive lessons on groking regexes

I've compiled my solutions as I make my way through these lessons as a Gist for reference and it would be great if you could share your solutions as well. Here's are a couple examples

#### Lesson 9 - http://regex101.com/r/yZ4qG2

Objective:

    match   1.   abc
    match   2.    abc
    match   3.                   abc
 ...(continued)

Just Tweeted by @bsodmike!

Code & Tech

Installing RMagick & ImageMagick on OS X Mountain Lion

It's another one of those pesky gem installs.

  gem install rmagick -v '2.13.1'
  Building native extensions.  This could take a while...
  ERROR:  Error  ...(continued)

Modularizing C Code: Managing Large Projects

Today I set about tinkering on an old project involving driving a multiplexed 7-segment display. I will be writing about this in more detail shortly. Here's a snap fr ...(continued)

Setup Python on Mac OS 10.8 (Mountain Lion) with pip and Virtual Environment Tools

Here are some of the best posts I've found detailing the process of setting up Python with pip, virtualenv and virtualenvwrapper. I recommend that you read throu ...(continued)

 

Ruby

Debugging with ruby-debug in Funny-Falcon's Performance Patched Ruby 1.9.3 and RVM

Yesterday I found adding the following to the Gemfile

group :development, :test do
  gem 'linecache19', '0.5.13'
  gem 'ruby-debug-base19', '0.11.26'
  gem ' ...(continued)

What's New in Ruby 2.0 ~ Get it Now!

There are two fantastic resources I came across detailing what's new in Ruby 2.0, the first of which

...(continued)

Let's Disqus!

Update: Interestingly, the first comment I've received via Disqus was from Tomash and he correctly pointed out while this was a nice 'e ...(continued)


Installing RMagick & ImageMagick on OS X Mountain Lion

Published by Michael de Silva on Tuesday, 28 May 2013


It's another one of those pesky gem installs.

  gem install rmagick -v '2.13.1'
  Building native extensions.  This could take a while...
  ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

          /mike/.rbenv/versions/1.9.3-p392/bin/ruby extconf.rb
  checking for Ruby version >= 1.8.5... yes
  extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
  checking for gcc... yes
  checking for Magick-config... yes
  checking for ImageMagick version >= 6.4.9... yes
  checking for HDRI disabled version of ImageMagick... yes
  checking for stdint.h... yes
  checking for sys/types.h... yes
  checking for wand/MagickWand.h... yes
  checking for InitializeMagick() in -lMagickCore... no
  checking for InitializeMagick() in -lMagick... no
  checking for InitializeMagick() in -lMagick++... no
  Can't install RMagick 2.13.1. Can't find the ImageMagick library or one of the dependent libraries. Check the ...(continued)

Electric RC Theory 101: Calculating Gear Ratios, Rollout, and Top Speed

Published by Michael de Silva on Thursday, 09 May 2013


For this example I will be taking my Hot Bodies D8T Monster Truggy as an example to base the calculations on. Here are some details

  • Motor: Castle Creations 2,200kV model 1515 1Y
  • Pro-Line 3.8" Badlands with an Outer Diameter (OD) of 148.33mm tyres.

The gear ratio at the centre differential

50T Spur/13T Pinion = 3.85:1 gear ratio

For the front and rear diffs, the axle ratio is

Beveled spur 43T / Spiral pinion 10T = 4.3:1

We can therefore calculate the Final Drive Ratio (FDR)

FDR = (3.85)(4.3) = 16.6:1

Let's now take a look at rollout which is defined as

Rollout is the ratio of how many revolutions of the motor causes the tires to move one inch.

and 1" = 25.4mm

466mm/16.6 = 28mm per motor rev.
28mm/25.4mm = 1.1:1 rollout

I typically run this @ 4S which means 2200kV x 14.8vdc x 0.9 = 29,304 RPM; note that I've compensated for a 10% drop in cell voltage due motor loading, ...(continued)

Modularizing C Code: Managing Large Projects

Published by Michael de Silva on Saturday, 04 May 2013


Today I set about tinkering on an old project involving driving a multiplexed 7-segment display. I will be writing about this in more detail shortly. Here's a snap from today's session

As for modularising C code, here are some fantastic resources on the topic

  1. Modularizing C Code: Managing large projects — by Dean Camera

  2. Headers and Includes: Why and How

Setup Python on Mac OS 10.8 (Mountain Lion) with pip and Virtual Environment Tools

Published by Michael de Silva on Monday, 29 April 2013


Here are some of the best posts I've found detailing the process of setting up Python with pip, virtualenv and virtualenvwrapper. I recommend that you read through these first.

My install process is detailed in the following gist

Improved Productivity with vim-sparkup, zencoding-vim, argokai, and vim-signify

Published by Michael de Silva on Sunday, 07 April 2013


Here are some curated enhancements to boost your vim productivity

Argokai

This is just one really sexeh theme for vim; grab it here.

vim-signify

Sy shows all added, deleted and modified lines since the last commit via Vim its sign column. It supports several version control systems.

Grab it here.

the_silver_searcher > Ack

A much faste ...(continued)

Debugging with ruby-debug in Funny-Falcon's Performance Patched Ruby 1.9.3 and RVM

Published by Michael de Silva on Friday, 08 March 2013


Yesterday I found adding the following to the Gemfile

group :development, :test do
  gem 'linecache19', '0.5.13'
  gem 'ruby-debug-base19', '0.11.26'
  gem 'ruby-debug19', :require => 'ruby-debug'
  #...
end

...and running bundle install just would not work. The reason is ruby-debug19 is no longer maintained and there's a recommended fork called debugger that works on 1.9.2 and 1.9.3 and installs easily for rvm/rbenv rubies.

However, I wanted to get ruby-debug19 to install and followed the advice of this post on Stackoverflow and created a gist to allow installing this under my particular version of ruby-1.9.3-p327-fastGist: Install ruby-debug19 with Falcon patched ruby-1.9.3-p327-fast

### UPDATE: ruby-debug19 is no longer maintained, use https://github.com/cldwalker/debugger

# Install wit ...(continued)

My First 5 Minutes On A Server; Or, Essential Security for Linux Servers

Published by Michael de Silva on Wednesday, 06 March 2013


My First 5 Minutes On A Server; Or, Essential Security for Linux Servers by Bryan Kennedy is a must read. It was featured on HN a couple days back and is a decent check-list of things to cover when setting up a new server/VPS.

Highly recommended!

What's New in Ruby 2.0 ~ Get it Now!

Published by Michael de Silva on Friday, 01 March 2013


There are two fantastic resources I came across detailing what's new in Ruby 2.0, the first of which

and there's another with many examples that's a bit more verbose.

Installing Ruby 2.0 was quite painless for me; I'm on Mac and have homebrew installed, it's certianly much easier with than without.

rvm get head && rvm install 2.0.0

This should end up spitting any brew related errors; you'll have to install those missing libs and simpy run the command again to compile ruby-2.0.0-p0 from source.

Enjoy!

Urushi Lacquered Beauties from Japan, Handmade by Nakaya

Published by Michael de Silva on Thursday, 14 February 2013


Late August last year, I joined The Fountain Pen Network (TFPN)'s group page on Facebook — 'Singapore Fountain Pen Lovers'.

About a week or two prior to joining, I was in Singapore and had visited the Aesthetic Bay on Orchard @ ION. I've known about the 'Bay for many years and even popped into their branch at Funan Centre on previous trips, although I wasn't too serious on anything in particular.

In the past, I've seen snaps of beautiful maki-e pieces by Nakaya, Namiki, Danitrio online and thought to myself, 'one day, perhaps I'll get around to one of these...'. Since 2008, my other Japanese fountain pen has been my faithful Sailor Executive 1911 Naginata Togi.

Whilst perusing through the group page, one of the first posts I came across looked similar to this

<img src="https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-a ...(continued)

Kyosho Inferno MP777 SP1 (Custom) Nitro to Electric Conversion

Published by Michael de Silva on Monday, 11 February 2013


I recently received some inspiration for 'going' electric and decided to perform a conversion on one of my 1/8th scale buggies. I've got two - a Mugen Seiki MBX5 ProSpec and this Kyosho Inferno MP777 which includes many upgrades taking it to a custom SP1.

This conversion is based on the Kyosho Inferno 1/8 Brushless Conversion Kit and the entire process was extremely easy. On the plus side, the MP777 did not require any of the supplied 'washers' during the installation process and meant less things to keep track of during the build.

Going Electric...!

For this conversion I've chosen a Castle Creations Neu-Castle 1515 1Y 1/8 Brushless Motor (2200Kv). This has a manufactur ...(continued)