Operating systems design
Yesterday I found this terrific presentation on building a more efficient Ruby interpreter that guys from Phusion gave on Google TechTalks.
This reminded me I wanted to delve deeper into the whole OS design subject. I could start by following the whole Tanenbaum–Torvalds debate on kernel architecture since 1992 ;), but I think I found a better way:
Operating Systems Design and Implementation by Tanenbaum and Woodhull, which interestingly contains abridged code of the whole Minix 3 OS.
Domain Specific Languages explained
The idea of creating internal DSLs in programming languages has always seemed kind of awkward to me. How can you create a DSL in Lisp for example? It would just be a collection of classes and mehtods/functions that you call - in other words a library or an API and with those pesky parentheses on the top. And to be honest, I’ve never dug any deeper into this subject, because it only seemed a fancy name for an old thing to me.
But yesterday while browsing the most popular Ruby questions on stackoverflow, I found a link to a very nice presentation on DSLs (PDF) by Obie Fernandez. It kind of opened my eyes on what it is all about and, what is more important, nicely showed what were the initial ideas behind RoR. Make it a DSL for writing web applications!
And I really liked this quote from Jamis Buck:
“The fascinating thing is that, in my experience, most well-written Ruby programs are already a DSL, just by nature of Ruby’s syntax.”
I think it really helps to remember what you should expect of yourself when writing a new piece of code in Ruby.
PS. Two years is a pretty nice interval between blog posts, isn’t it? At least a realistic target for me ;). Guess one shouldn’t have taken the “I’ll be writing more about that soon” seriously.
How to vertically align an image within a div. Again.
Yeah, so the topic is old, all right. One can find hundreds of articles on the web. Nevertheless, I spent a few hours yesterday looking for an elegant and simple solution to this problem.
I wanted to:
- center an image of an unknown size (but of known maximum size) within a div element
- simple implementation in pure CSS, no tables
- cross-browser compatibility on all major browsers
I found one solution on Webmaster World forum. It worked on IE, but not in Firefox. After some more research I added a hack proposed by Nicholas Gagne and now it seems to work on both browsers:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
div {line-height:150px; text-align: center; width: 150px;
font-size: 150px;}
img {vertical-align:middle;}
*>div{font-size:12px;}
</style>
</head>
<body>
<div style="border:1px solid gray;">
<img src="/images/examples/test.jpg">
</div>
</body>
</html>
Pay attention to the DOCTYPE declaration: it has to be strict XHTML. It doesn’t work with transitional in Firefox. You can replace the line-height, width and font-size of course, just keep the “vertical” pixel sizes the same - width can be different.
I tested it in IE6 and Firefox 2.0.0.11
Using IMAP to migrate email messages to GMail
Many people on internet forums are asking how to migrate their mailboxes from desktop email clients to GMail. I tried to do it myself today and it seems that the easiest solution is very hard to find on the web.
It appears that with the current GMail version supporting IMAP, you no longer need external tools like gExodus or Google GMail Loader. All you need is your desktop email client supporting IMAP. Thunderbird for example does support it, so to migrate all your messages you need to:
- Enable IMAP in your GMail settings
- [optional] Create label(s) in GMail for your imported messages
- Configure Thunderbird to access GMail account using IMAP - any of previously created labels will appear as folders in Thunderbird
- Move or copy your messages to All Mail folder or any of the label folders
That’s it! All the information in your messages will be preserved (including dates) and if you copy/move them to the labeled folders they’ll be automatically labeled in GMail.
Useful URLs for RoR 2.0
I spent last evening coding a new web app in RoR 2.0 till 2 a.m. This is fantastic how smooth and enjoyable the experience is. Although I had previously coded a few other apps in RoR and I loved it too, this time it was even better.
I feel it’s mainly because I found a ton of great tutorials and documentation I didn’t have previously. And although I own the 2nd edition of the Rails book it doesn’t cover the RESTful features deeply enough and this is the killer feature in 2.0.
Here’re some URLs that I think are worth sharing:
- Railscasts - a fantastic collection of free RoR screencasts by Ryan Bates
- attachment_fu plugin by Rick Olson and a great tutorial by Mike Clark
- acts_as_commentable plugin
- role_requirement and restful_authentication plugins
Hope it’s useful!
Eric Sink on Eclipse
Eric Sink, a die hard “Microsoftie”, is writing a series of articles on his experiences with Eclipse. Boy, it feels like a teacher prising my kid :). I didn’t think I’m one of those who feel so attached to their tools of choice :)
Tungsten T3 and Motorola V3
My collection of gadgets isn’t as impressive as Scott Hanselman’s is, but I’m constantly working on it, so last week I bought a Palm Tungsten T3. Yes, I know it’s not the latest and greatest, but it’s perfectly fine for me. It has a good calendar obviously, but also Bluetooth on board, which means email and web browsing work seamlessly (well, almost). It also has a 400 MHz CPU so it can play good quality MP4 videos on its wide screen. And I bought it for around $180 with a complete set of accessories that come in the original box.
I wrote “almost” about the connectivity part though, because of one little hiccup, which you probably won’t notice, unless you own a Motorola V3 (RAZR). Configuring a GPRS Internet connection over Bluetooth with this phone was a nightmare. Even though I had the latest drivers from Palm. They worked fine for the SMS/dialer part, but not for the GPRS modem part.
After two days of searching the Internet (I did the mistake of looking for a general solution, not the V3 specific one) it finally works, thanks to a post on Palm forum.
So, in short, here’s what you need to do. The settings I used are for polish provider Era GSM, so where I typed erainternet, you should put something specific to your provider; same for the DNS.
Create a new connection on the Palm: go to Prefs -> Connection -> New and configure as follows:
Name: LAN V3 (or whatever) Connect to: Local Network Via: Bluetooth Device: (tap to find, select your phone, follow the guidelines)Go to Prefs -> Network -> New and type
Service: Dialup Connection (or whatever) User name: erainternet Password: erainternet Connection: LAN V3 (the one you created above)Select Details and and set it to:
Connection type: PPP Idle timeout: Never Query DNS: (unchecked and put 213.158.194.1) IP Address: (checked) AutomaticSelect Script and enter the following:
Send: at+cgdcont=1,"IP","erainternet" Send CR: Send: ATD*99# Send CR: End:
You’re done.
If you want to use your Palm to send SMSs or use Dialer, add another connection, this time configuring it as Phone and using Universal Phone Driver.
Book recommendations
I plan to add a separate page with book recommendations but for now I’ve created the sidebar with titles I’m currently reading.
Just added Practical Common Lisp (I came back to this book after a short brake - you can use Lisp in a Box with it) and Concrete Mathematics. The latter is part of my quest to refresh my math knowlege - I’ll be writing more about that soon.
Dynamic Drive CSS Layouts
Check out those pure CSS page templates from Dynamic Drive.
Pick your fixed/fluid version and column layout and download!



