|
Thu, 30 Mar 2006
This past week marked the first anniversary of my coming out as gay (by the reckoning of the Hebrew calendar, that is). I celebrated on Tuesday by taking a really long, enjoyable hike, and maybe I'll write about it a bit later. I'd just like to take the opportunity to look back and take stock of how good this past year has been for me. It's felt like the process of recovering from a long bitter illness. After the fever finally breaks, it takes a little while before you're strong enough to get up out of bed and roaming around, and there's still a period after that in which you're still gaining back your original strength. And after that, you can even learn how to live more healthfully than ever before. With a charming bit of synchronicity, I stumbled upon the perfect quote to commemorate this occasion: "The isolation and secrecy were harder to bear than the malady itself." I found this in an article that was quite unrelated to the topic, but it struck me as a fitting way to describe my past life. So on that note, I'll point out a few other articles by Jonathan Rauch that I read this past weekend that I found a lot more interesting. I'll start with "Gay Marriage 5: It's Good for Kids", which sums up what I think is the best case for gay marriage I've encountered so far. Dad, I'd like if you'd print that out for Mom to read, as I'd like to hear her sound off her opinion on the topic. I'll recommend "Will Frankenfood Save the Planet?" for Jonathan to read to inspire him in his studies, and for Rebecca to read to maybe balance out her opinions on genetically modified foods a little more. And finally, "Caring for Your Introvert" is good advice for anyone who wants to deal with me. Sun, 19 Mar 2006
So I'm sitting around in the downtown Tel Aviv apartment of the guy I'm dating, hacking on the computer while he's away at work, when suddenly amid the traffic noises outside the window I hear the sound of high-pitched male voices melodically chanting "Na Nach Nachma Nachman Me'uman" to the accompaniment of electronic, heavy-beat, dance club music. Blasted out of automobile speakers. At top volume. I laughed not because this could be considered a strange occurrence in my life, but because I realized that events such as this have become part of my version of normalcy. Baruch habah la'aretz. Sat, 11 Mar 2006
I've been quite negligent in my writing duties lately, gentle reader. So let me quickly scribe for you the latest news in my life. First of all, my brother Seth proposed to his girlfriend, Rachel Siegel, on the night of Valentine's day, and she accepted. Requisite link to OnlySimchas. Huge mazal tov! My own love life has been creeping forward lately too. Through JDate.com, I met a nice guy named Moshe who's living in Tel Aviv. Due to recent end-of-winter illnesses and general busyness, we've only seen each other a few times in the past month, but we've been phoning and emailing frequently. I hope to see more of Moshe in the near future. And that's about all that's newsworthy lately. Tue, 07 Feb 2006
Most of this past Sunday was spent finishing up a first workable stab at solving a small problem in Web development that I'd been thinking about for a long time. I don't ask for much: just a simple little template system that works well for a set of HTML documents which are mostly static, as opposed to a template system that's only really appropriate for writing highly dynamic Web applications. You know, just a little something that makes it easy to factor out the common bits of information that should be the same for all pages in a Web site so you can edit the common stuff in just one place and have the change propogate to all pages on the site. This isn't a new problem by any stretch of the imagination, but all the solutions I'd ever seen (from HTML pre-processors to "include" directives in SSI or PHP) turned the pattern I wanted to use inside out. Instead of studding every single page in a big collection of HTML documents with commands to suck in a common header and footer, I wanted to keep my documents clean and free of their surrounding context as much as possible. The more generic container should include the specific document content, not the other way around. Since I finally got around to treating myself to a serious education in Rails last week, I discovered that my prayers for a more beautiful alternative to the inclusion pattern were answered by its layout system. My only problem was that Rails is very heavily geared toward writing database-backed Web applications that follow the MVC pattern, and doing anything else with it goes against the many assumptions that are part and parcel of the framework. However, Ruby on Rails scores big points in my book by being very flexible about its assumptions. If you are patient enough and clever enough to figure out how, you can very cleanly override Rails' assumptions and I was thus able to scratch my Web development itch with a quite elegant solution. Since I want to keep the bulk of the content for the Web sites I maintain in a directory-structured filesystem instead of a database, I was already violating Rails' most obvious assumption of database-centered storage. But it turns out that the more significant issue was that Rails assumes that each URL that it receives should correspond to a method in an instance of a controller class, while I wanted to retain the more boring, traditional custom of mapping from URLs into files in the filesystem tree. I certainly wasn't going to try to predict and enumerate the name of every file that I'd want to serve and hard-code a method for it in the URL-handling class for Rails. So I got around this at first with Rails' routing facility, specifically by using a PathComponent in a route that would direct everything to a single method in my document-serving controller class with the filename part of the URL passed handily as a parameter. Very neat and clean: the only code I had to write was a very simple method that does a little preprocessing on the requested file name and calls a function to render the appropriate document with the right layout. But there's still a problem. When I actually deployed the site as a CGI program run by Apache HTTPD, it was horribly slow. The computer I use for my Web server might not have the most modern hardware in existence, but I still don't consider a 1.2 GHz CPU with 512 MB of RAM underpowered at all. And yet, the overhead for starting the Rails framework code is so large that it's completely impractical to wait for it for every single HTTP request. This is obviously why the Rails community is so big on FastCGI. So I tried using FastCGI. I really honestly tried. But neither mod_fastcgi nor mod_fcgid for Apache 1.x or Apache 2.x worked reliably for me. I spent enough time trying to debug the setup with completely insufficient error messages to get fed up with the affair. It was easy for me to give up because I knew I had an alternative. I knew that I was only really using a small bit of what Rails provides, namely ActionPack, although that piece does happen to be one of the most significant ones. Since ActionPack can be used easily all by itself, I could use it to write a simple, fast, standalone CGI script that is nearly identical to the controller I wrote for use within the context of Rails. The main adaptation that had to be made was to compensate for the loss of the above-mentioned routing system. Without Rails' routing, I wasn't sure how to map all URL requests to the a single method within my controller class. I was back to working around the assumption that every different URL would be handled by a different method in the controller class. I knew there had to be a way to write a Ruby class that would respond to any method at all, without having to mention the name of the method in my code. I was goaded by the fact that I knew exactly how to do this simplistic sort of metaprogramming in Python, as I'd used this sort of trick in the past: just override the __getattr__ method, and the name of the attribute/method that the caller tried to invoke will be found as the first parameter. After doing enough looking around, I discovered that Ruby's equivalent is the "method_missing" method. Voila! A CGI script that neatly renders any old HTML document that you've templated with embedded Ruby code, assuming that the name of the document is given in the "action" parameter passed either as a GET or POST variable. But we don't want URLs that look like "http://example.com/cgi-bin/document_controller.cgi?action=some/thing.html". We want "http://example.com/some/thing.html". So Apache's mod_rewrite comes to the rescue with the following .htaccess incantations:
And we're done. Documents that share a common layout without being riddled with superfluous repetition. Pretty URLs. All done with mere teeny snippets of code. I'm happy. (Well, OK. The script certainly has room for improvement. Most significantly, different sets of documents on the same site should be able to use different layouts. Ideally, the decision of which layout to use would be based on which directory the document resides in. But that's something for another day.) Sun, 05 Feb 2006
My brother Seth and his girlfriend Rachel took today off to come north to visit Tzfat. They arrived this evening between 6 and 7. Becca made us yummy dinner of pasta with fish sauce, and we had dessert on cake and on some luscious Godiva white chocolate liqueur that Rebecca had picked in the duty-free in Paris on our way home to Israel. Ashira entertained us endlessly, of course, and only continues to grow more assertive and expressive. Her newest trick is saying "uh-oh!" at events that usually involve her launching an object into space, and I must attest that it is the cutest thing in the world. Rachel had a grand little adventure getting thoroughly lost in the labyrinth that is the Tzfat roadway system while driving back to Becca and Avraham's house after going out to visit a family she knows in town, but she found her way in the end with much telephone guidance from Rebecca. It was generally an evening well filled with quality hanging out time with most of my siblings. Although I missed the last couple hours of the evening: the liquor made me so sleepy that I conked out right on the hard stone floor. It was amazingly uncomfortable when I got up, but it seems these bones are still young enough to spring back from such abuse in practically no time. Thank G-d for small favors. |
Site Index
Diary Categories
Previous Entries
<< 1 2 3 4 5 6 7 8 9 10 11 [12] 13 14 15 16 17 18 19 20 21 22 23 24 25 26 >>
Entries by Date
Entries by Month
2007-Sep2007-Aug 2007-Jun 2007-May 2007-Apr 2007-Mar 2007-Feb 2007-Jan 2006-Dec 2006-Nov 2006-Oct 2006-Aug 2006-Jul 2006-Jun 2006-May 2006-Apr 2006-Mar 2006-Feb 2006-Jan 2005-Dec 2005-Nov 2005-Oct 2005-Sep 2005-Aug 2005-Jul Here is a version of this page more appropriate for printing. You can also read this diary via RSS 0.91 or RSS 2.0. If you ask me, I can also add you to the list of people who will automatically receive new entries at their email address. |
|||||||||||||||||||||||||||||||||||||||||||||||||