On the Worldwide Wonder Web there are numerous mentions of metaprogramming in connection with Ruby. Up until now I’ve kinda glossed over it with a mental Postit to investigate later.
Whilst trying to decide what to blog about today I followed a link that took me to Hal Fulton’s (Author of “The Ruby Way”) page and subsequently on to an article that he had written about metaprogramming. The article is a brief introduction to the subject, illustrating the power of Ruby in this regard. The big “R” has mucho mojo dude, check it out.
Categorized in Unexpected Finds
At some point you will probably want to create some browser content for your web application. If you use Camping that means using Markaby, the Ruby HTML generator. Markaby is baked into Camping and can be installed as a plugin for Rails, but it can just as easily be incorporated into a standard Ruby script.
Define your page layout in Ruby syntax like so (this example was saved as an ordinary ruby script – mktest.rb):-
#!/usr/bin/env ruby
require ‘rubygems’
require ‘markaby’
mab = Markaby::Builder.new
mab.html do
head { title “Things to do” }
body do
h1 “Stuff I need to remember”
ul do
li “Feed the cat”
li “Pay credit card bill”
li “Get a better job”
end
end
end
puts mab.to_s
Then run the code and see the output:-
$:>ruby mktest.rb
<html><head><meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type”/><title>Things to do</title></head><body><h1>Stuff I need to remember</h1><ul><li>Feed the cat</li><li>Pay credit card bill</li><li>Get a better job</li></ul></body></html>
I like it. I like it a lot!
Categorized in Ruby Stuff
Task automation is a great way to increase productivity (ask any serious sysadmin) and is overlooked by many computer users because either they don’t know how to do it, or they can’t be bothered to learn yet another language. I’m as guilty as the next guy of continuing to do repetitive actions by hand, shame on me!
Applescript is widely used on the Mac platform to automate tasks, however as a language it leaves a lot to be desired. Enter rb-appscript, a Ruby library “that allows you to control scriptable Mac OS X applications using ordinary Ruby scripts”.
If you need or ought to cut some Applescript code, but you want to get Ruby wid it, just sudo gem install rb-appscript and hack away.
Categorized in Unexpected Finds
This old dog needs to retrain. No question, the skillset on my CV is not going to get me where I need and want to be. My personal circumstances have changed, making it imperative that I work from home or very near home which means teleworking is my preferred modus operandi. I have decided that learning Ruby may be the gateway to my goals, but I have a problem.
My CV doesn’t indicate to potential employers that I can hack Ruby because I am self-taught. ‘Self-taught’ in the sense that I have bought books, read articles and collected information from the Internet and completed tutorials. None of this seems to make a jot of difference to employment agencies here in the UK, not to mention that teleworking opportunities seem to be in short supply.
In an attempt to gain some ‘real world’ Ruby experience I have offered my services free of charge in exchange for the opportunity to do some CV friendly Ruby work. I put out a brief message on a couple of Ruby Google Groups asking for help, not really expecting positive feedback. To say that I was pleasantly surprised would be an understatement. Not only did I receive encouragement and support, as luck would have it a kind soul offered to set me some Ruby coding exercises (thank you kind soul!) which I started yesterday.
My faith in human nature somewhat restored, I continue on my quest for that elusive Ruby teleworking gig. If anyone reading this can assist me, please do notĀ hesitate to get in touch.
Categorized in Heartfelt Pleading
I’ve been learning French on and off for years. Since leaving school I’ve flirted with it on numerous occasions, however, to date I’m still not fluent.
I’ve been learning Ruby for less timeĀ and already I feel more at home with it than I do French. It seems that I love the idea of learning French but I love learning Ruby.
Categorized in Random Muttering