Rubénerd Blog :)

Tuesday 10th February 2009

Shell work at 01:15 in the morning != smart


It still doesn’t work… it still doesn’t work… it still doesn’t work…

I’ve heard it said by many programmers I respect that you spend 10% of your time coding, 90% debugging. I would argue it’s closer to 5% coding, 95% debugging, but the point stands. It also stands true that the more tired you get, the less obvious basic mistakes appear to be.

Case in point, this evening I decided to update my MacPorts collection on my iBook and install Gnumeric (I’ve so far only switched to pkgsrc on my MacBook Pro). For the life of me I couldn’t figure out why this single line wasn’t working:

% sudo port -v selfupdate && port -v install gnumeric

If you’ve worked in UNIX for more than 5 seconds you’d be able to tell me in an instant what I did wrong, but for the last 10 minutes I just couldn’t figure it out. It was driving me crazy! When I did I promptly hit my forehead on the table causing a glass of cold water I had placed on it to jiggle its way off the table and with an almighty crash land in a million pieces on the floor.

ASIDE: That glass thing didn’t really happen, but doesn’t it sound like something that could?

Lesson learned, don’t do any programming, scripting or shell work when you’re half asleep or not feeling well. You just don’t get much done!

As for the mistake, I only used one sudo command. Using && doesn’t carry over the higher user privileges! Simple, obvious, glaring mistake that was staring me in the face the entire time and I couldn’t see it.

Sunday 08th February 2009

The best tool for the job is the one you can use

Food poising is not fun in the slightest, but fortunately by using a combination of soothing music and Tiger Balm my headache as of a few hours ago is completely gone. Mary Wallace and my GP suggested I eat bread, rice, apples and toast of which I’m eating right now. Provided I don’t get out of this computer chair and don’t eat too quickly I think I’ll be fine.

With that in mind, I thought I’d share another quote, this time from the FreeBSD forums:

the daemon you know is better than the penguin you don’t.
~ danger@

He’s referring of course to BSD (the daemon) and Linux (the pengiun).

Reminds me of another similar quote by someone who I can’t recall right now who said [paraphrasing] the best programming language for a job is the programming language you’re best at and enjoy.

I’ve been learning a new programming language and a new OS to keep my mind sharp while I’m on holidays, you’ll see the reviews of these in upcoming days. Ironically I started learning these because I thought I needed to broaden my horizons and get out of my FreeBSD, Mac, Ruby and Perl comfort zone. Those two quotes above pretty much shoot that down in flames don’t they? I don’t mind though, I still find them fascinating.

Without sounding too cheesy, I love learning new things, or using old things in new ways. It’s one of the greatest pleasures in life.

Thursday 29th January 2009

I’d love to meet Python inventor Guido van Rossum

Guido van Rossum at OSCON 2006, by Doc SearlsWhile I admire Larry Wall and Yatsuhiro Matzumoto and use their respective Perl and Ruby programming languages, I can really relate on an entirely different level to Python inventor Guido van Rossum.

I only just discovered his new blog today, but I’ve read a lot of what he’s written so far and have have agreed with a ridiculously high 99.995% of it. It’s as if he’s my older, wiser, wittier Dutch cousin living in California!

For example, it pains me to admit this, but I didn’t know that Python was named as such because Guido was obsessed with Monty Python’s Flying Circus and other absurd, hilarious British comedy:

By the way, the language is named after the BBC show "Monty Python’s Flying Circus" and has nothing to do with reptiles. Making references to Monty Python skits in documentation is not only allowed, it is encouraged!

Frankly, if people have never watched any Monty Python, I have to question their sanity. I’ve also questioned the sanity of those chaps behind Monty Python too, but that’s for another post! And now for something, completely different!

What I’ve always thought was curious was how both Larry Wall and Yatsuhiro Matzumoto could be designers of programming languages which require such logical thought, and yet be advocates of their associated churches. I didn’t intend for that comparison to imply you can’t be a logical person of faith, but it does strike me as a non-believer (to use the HIGHLY controversial term Barack Obama used!) to be a surprising and perplexing combination.

I’m not sure if Guido van Rossum is a non-believer too, but we both do seem to share similar philosophical viewpoints. For example, when he discussed the One Laptop Per Child Programme in his post Bibles or computers: Its the same thing:

I’m not surprised that the pope is pleased by the OLPC program. The mentality from which it springs is the same mentality which in past centuries created the missionary programs. The idea is that we, the west, know what’s good for the rest of the world, and that we therefore must push our ideas onto the “third world” by means of the most advanced technology available. In past centuries, that was arguably the printing press, so we sent missionaries armed with stacks of bibles.

These days, we have computers, so we send modern missionaries (of our western lifestyle, including consumerism, global warming, and credit default swaps) armed with computers

I certainly hadn’t thought of it that way before, and my secular mind did appreciate the comparison!

And now for something, completely different!

But back to computer science: I’ve never really looked into Python as a programming language, though I’ve heard good things about it from other "scripting language" users… C/C++ users don’t count in this case because any language that’s interpreted instead of compiled/tested/compiled sends them into fits of agony!

I was going to look into experimenting with Haskell before I head back to Adelaide in March, but perhaps I’ll check out Python instead. As a Perl and Ruby guy I suspect the jump would be much easier than Haskell anyway, which is both good and bad of course. Python definitely looks like it has a very clean and minimalistic syntax which appeals to me visually as well as mentally, if that makes sense.

#!/usr/bin/env python
print 'You rock Guido van Rossum! \n'

Guido van Rossum also has quite a good Wikipedia page. I’m not Bill Kurtis.

Wednesday 24th December 2008

Using env in shebang scripting language lines

Directly referencing your interpreter? Crazy...
Directly referencing your interpreter? Crazy…

I haven’t written any geeky programming technical posts for a long time. Christmas Eve seems like just as good a time as any. Funny how Perl programming specifically always reminds me of Christmas because I got my first proper job after high school in 2004 writing Perl/MySQL code around Christmas time so I could buy people presents. Happiest time of my life then because I had purpose, direction and optimism.

This morning I’m talking about using env in the shebang line of scripting language source files (FreeBSD man reference). Quite frankly I’m surprised that as of 2008 the majoraty of files I download and look through still reference hard links to the interpreters such as the examples below:

#!/usr/bin/perl -w
#!/usr/local/bin/ruby

The problem with hard/specific referencing is that you can’t assume your system will have a filesystem configured in the same way as another. While us users of Unix-like systems are fortunate that our said systems have so much in common, there are still enough subtle differences between Unix-like OSs and even distributions of the same OS to cause problems.

For example, most GNU/Linux systems place all non system critical files in the /usr/bin directory. As a FreeBSD user I shivver in terror at the mere thought of this; on the BSDs we’re even more specific and seperate non system critical files that come as part of the core system in /usr/bin, and files we later install ourselves in /usr/local/bin or /usr/local/pkg depending on our package manager. Much stricter, cleaner and easier to maintain… but that’s for another post.

The solution to this is to call our scripting language using env which checks your system for the desired interpreter and executes. This means Linux users can share with BSD users can share with Mac OS X users etc without worrying about how said systems are configured. You can even pass regular options, very nice.

#!/usr/bin/env ruby -w

Using env to reference basic sh shell scripts would be overkill, but for languages such as bash, Ruby, Python, Perl etc it just makes sense. Sure you could just assume all your clients and servers will be GNU/Linux folk, and perhaps you’d be right… for now. I’m all for future proofing.

Saturday 01st November 2008

Rubenerd Blog October 2008 rambling summary

A Swindon based 63 service
"A Swindon based 63 service" by The Oxford Bus Page

It’s official, October 2008 has been the best month for the Rubenerd Blog since August 2006. In total 63 posts have been submitted compared to 23 posts last month and 37 the month before last. Realistically many of these have been long and involved but many more have been silly posts with less than three lines. Still, that’s 63 random thoughts and ideas which isn’t as high as the ridiculous 110 I made back in August 2006 but it’s close.

In a kind of ironic twist, it seems that the more work and studying I need to do, the more material appears here. I think connecting my mind to a keyboard and letting all the ideas flow is a fantastic coping mechanism. It also allows me to keep my mind alert when I take breaks instead of being a passive consumer like I would be if I just watched TV.

ASIDE: For some reason I think this post will be getting the "pointless milestone" tag. The question is, how can I pull off putting a picture from an anime series on here too so I can use the "pointlessly fun anime reference" tag as well. These are the thoughts that keep me up at night. That and coffee. That made no sense.

Given I’m posting so many entries from my iPhone now as well, I think the next logical step in the evolution of this long winded and overly verbose trail of consciousness is to include some form of location metadata into each post. In this way I could see just how many words I have typed while I was sitting at the Boatdeck Cafe in Mawson Lakes or the huge Starbucks with lots of comfortable lounge chairs in Millennia Walk in Singapore. I have a sneaking suspicion they might be where most of this stuff gets done!

ASIDE: Millennia Walk was just across from where the Singapore Formula 1 night race was held. It’s a really bizzare building with gigantic pyramid like skylights that stretch above the main shopping area by several whole floors. I did work for people around Suntec City and Millennia Walk after I finished high school in 2004.

Millennia Walk, Singapore
Millennia Walk, Singapore by williamcho

The place of the Rubenerd Show I think is also starting to evolve again. Previously I would speak everything I was thinking into that show, now it’s much more of a spur of the moment type of project which I hope will improve the quality. I wish I had the self confidence that Frank Nora has by being able to speak into a voice recorder as I walk down the street with people staring at me the whole time… perhaps at some point I’ll get to that stage.

At some point I would also like… ney LOVE, to be able to finally move all this material onto the content management system I wrote myself in Ruby (without Rails… it bothers me how people assume it must use it if it’s a Ruby web app) earlier this year too. Perhaps after the exams and this latest project I’m doing for a client I’ll take a solid week off to do that.

Yukikiro Matsumoto I’m fed up with all these constant WordPress updates; it is a great blogging system if you want millions of bells and whistles but don’t want to do any programming yourself, but it’s incredibly top heavy for what I want to do here. Not only that, but it’s written in PHP. As a guy who also loves Perl, I have nothing against PHP, it’s just Ruby is so much more Smalltalk like and is so elegant. Ruby code can be syntax-highlighted and printed onto posters it looks so nice. Yukihiro Matsumoto knew what he was doing!

ASIDE: My beautiful late mum thought that Yukihiro Matsumoto was cute.

I’d love to learn though how to better integrate MediaWiki with Ruby applications though, I love MediaWiki and I’d love to start using it again for my own projects. For a while I was a maintainer of an intranet wiki system and I wrote a lot of Ruby scripts that PHP would call using system calls, but it wasn’t very elegant. If I could figure out how to better integrate them, I could write so many scripts for Whole Wheat Radio to do trippy things Jim would have to start blocking my IP address because I’d be using all WWR’s idle CPU power. Wouldn’t that be fantastic?

BRAINWAVE: Wouldn’t it be great to be able to use the same user database for my Ruby CMS and MediaWiki? Then I could leave my CMS for the blogging portion, and use MediaWiki for the Wiki side, but the users would be consistant. I’m so smart it’s scary sometimes. Okay, I’m more scary than smart.

Well that post started constructively and quickly deteriorated into rambling quickly… sorry about that. 63 posts though. Like the way I got back on topic again by referencing what I was supposed to be discussing? That’s called "skill" and it’s not something you can learn at any fancy tertiary educational institution.

Thursday 02nd October 2008

Nitpicking open source and free… again

Despite really like Ruby and Perl, due to time constraints and other obligations I’m still reluctantly using WordPress and PHP on most of my blog powered sites including this one. Until I make the desperatly wanted switch, WP news still affects me and I take a somewhat interested view of what’s going on. Not exactly a glowing endorsement, but then again it is the middle of the day here in Mawson Lakes so if I started glowing it would be a bit of a waste of energy.

It seems the widely used Revolution Theme for WordPress has gone open source. From the Weblog Tools Collection article:

Brian Gardner’s Revolution Theme for WordPress is going 100% Open Source. All the themes that are currently on Brian’s Revolution site will no longer be available as or October 31st and will be replaced with a set of new themes that will be developed and released under the GPL. The original Revolution themes will continue to be supported for those who have purchased them in the past.

Now I hate to be a nitpicker and certainly I consider myself more practical than ideological when it comes to the great software debate, but isn’t this an example of something becoming Free Software and not just Open Source? Aren’t most applications written in interpreted languages Open Source by their very nature because you can read the files? If Brian Gardner is releasing his themes under the GPL, then wouldn’t that make them Free (as in speech as well as beer) instead of just Open Source?

I guess it boils down to disclosure; if you purchase a theme from someone instead of downloading it gratis, there’s probably a clause limiting your right to redistribute or share the code. Still, isn’t that more of an issue of the software not being Free, rather than it not being Open Source?

In any event I congratulate Brian for going down this path. I suspect he will be getting far more users and interest after doing this, and he deserves all of it.

And now I’m off for a Caeser salad. I’ve been having cravings for Caeser salad. Is that healthy?

Sunday 01st June 2008

Ruby 1.8.7 released

Ruby

Akinori MUSHA announced today that Ruby 1.8.7 has been released.

The new version of Ruby includes many bug fixes, lots of feature enhancements backported from 1.9 and some performance improvements since 1.8.6 while maintaining stability and backward compatibility with the previous release to a high degree. See the bundled documentation for details about compatibility issues.

~ Ruby 1.8.7 released

Saturday 24th May 2008

Just ordered a Yubikey

YubikeyAfter listening to a recent episode of Security Now I’ve gone ahead and purchased myself a Yubikey!

The Yubikey is a phenomenal new device that’s smaller than most memory keys that when plugged into a USB port and the loan button on the case is pressed, a one time password is generated and entered. It does this on any HID enabled operating system including my beloved Mac OS X and FreeBSD without extra drivers because it shows itself as a regular USB keyboard. It’s so beautifully simple!

The best part is that the API is open and accessible from a number of different programming languages such as Ruby, PHP and Python (not sure about Perl just yet).

In the coming weeks I’m going to try to implement my Yubikey into my Ruby CMS. I’m really excited!

Thursday 22nd May 2008

Latest computer book haul

Having received payment for my latest one off project today, I celebrated by going down to Wheelock Place and splurging on a Starbucks Venti Dulce de Leche from next door and buying some computer books I’ve been dying to get. I’m a wild guy you see.

Happiness is a stack of new interesting computer books!
Happiness is a stack of new interesting computer books!

I find that I learn new skills much faster if I’m given examples and real world applications of technologies rather than just the usual “an array is a collection of objects yada yada” theory. The O’Reilly Cookbooks are absolutely fantastic for this, what irritates me is that I only just discovered them recently when I had to learn Python in a hurry for an assignment. I learned more from that one book than many hours sifting through tutorial pages and the dry slides from the uni.

Starbucks Dulce de LecheAs for the FreeBSD book, heck I just wanted to see how it works! Perhaps a little over my head right now, but we’ll be looking at the Linux kernel at some point so this could be an interesting side study for comparison.

From the blurbs:

The Design and Implementation of the FreeBSD Operating System
As in earlier Addison-Wesley books on the UNIX-based BSD operating system, Kirk McKusick and George Neville-Neil deliver here the most comprehensive, up-to-date, and authoritative technical information on the internal structure of open source FreeBSD.
Perl Cookbook
Find a Perl programmer, and you’ll find a copy of Perl Cookbook nearby. Perl Cookbook is a comprehensive collection of problems, solutions, and practical examples for anyone programming in Perl. The book contains hundreds of rigorously reviewed Perl “recipes” and thousands of examples ranging from brief one-liners to complete applications.
Ruby Cookbook
The Ruby Cookbook is the most comprehensive problem-solving guide to today’s hottest programming language. It gives you hundreds of solutions to real-world problems, with clear explanations and thousands of lines of code you can use in your own projects. From data structures and algorithms, to integration with cutting-edge technologies, the Ruby Cookbook has something for every programmer.

And now I’m off to bed. 00:07, that’s pretty early for me!

Sunday 04th May 2008

Setting up MediaWiki for registered user edits only

UPDATE: The Whole Wheat Radio wiki is back online again.

With the Whole Wheat Radio outage in effect I decided to create some mockup pages outlining some ideas over on my university intranet’s [sic] MediaWiki installation, but after some vocal opposition I decided to whip up a temporary WWR wiki testbed over at http://rubenerd.com/projects/wwr. Feel free to mess around there with WWR related whatnot while the mothership is offline and you have a Sunday morning to kill as I do right now!

If you’re using a wiki under similar circumstances and you don’t need or want anonymous edits compared to a bigger, more collaborative effort like Wikipedia, all it takes is appending one line to your ./LocalSettings.php file:

# Block edits by anonymous users
$wgGroupPermissions['*']['edit'] = false;

I know, I know… that was actually TWO lines, but the point is only the last line actually invokes the functionality described, the first is just a comment… which you should always include. Okay, okay I see your point.

< Older posts
Dedicated to my groovy late mum Debra Schade.