re-"require"-ing: how's the speed?
What this is about
So I like the design that, when you need a particular library in your code, you require it in right there in the method/class (JIT library-loading, so to speak), even if it means the require directive will get executed more than once. Running through irb you can tell that calling require twice on the same library is usually much faster the second time, but how much faster?
Read on for benchmarks!
Starting new projects
So I know I'm not the only dev who does this, but I tend to start a lot of projects -- and not finish them. I'm coming up with a checklist of things that I want to make sure I do before getting involved in any new projects.
Read on for some of the initial questions you should ask yourself, and what to do next.
Nifty easy screencast software
Not necessarily the easiest or the best, but it certainly looks cool and could very much have a niche to call its own. It's called uTIPu.
Check it out. Someday I'll create a screencast for something useful.
Gotcha with Sequel and Association Caching
One thing to remember with Sequel is that it caches associations -- for an hour, by default. Normally this is good -- if I say my_model.my_associated_models twice in one request, I'd like that to be cached. But at least with Ramaze, where you can access a variable that persists between requests (via session, like session[:user]), you have to remember that associations on that session object get cached, too. So what does that mean? That means if you have a user view their posts (with session[:user].posts), and then they go make a post, and then they come back to view their posts again...the new post won't be in the list of posts! So you have two basic options here, that I know of -- either a) manually kill the cache by putting session[:user].refresh on the action that alters the associations of session[:user], or b) put session[:user].refresh in a place that gets executed at the beginning of every request.
Sprockets — it's a good thing
Came across an interesting utility library: Sprockets. It's a Ruby-powered Javascript preprocessor. It's used for three things -- embedding other js files into the current js file, ensuring required assets get copied to the assets root, and for interpolating constants (like version numbers, author, etc) into the js file. I found it browsing Prototype.js's source -- really cool stuff. Also funny because I came across it by accident and I was just contemplating designing an identical tool. Good thing and bad thing at the same time
Ruby 1.9 and OpenSSL on Ubuntu
Having trouble getting openssl working on your Linux box and Ruby 1.9 (or 1.9.1, specifically)? Here's something to give a try...
Moving…
I'm paying two webhosting companies a total of $30 a month, so I thought I'd try to consolidate that, which means moving stuff off of the server this blog is hosted on. May experience some temporary interruptions...
Accessing GM_xmlhttprequest from event handlers bound by jQuery
So I like jQuery. And I like Greasemonkey. I especially like the ability of Greasemonkey's ajax calls to go cross-domain. But how do I get access to this functionality in my event handlers? Calling GM_xmlhttprequest in a method that doesn't execute while the Greasemonkey sandbox is still alive doesn't work. At first I didn't think it was possible, but I discovered a way...using setInterval.
Google Reader Commenter script
At Esther's request, I wrote a script that lets you comment on blogs that are in your Google Reader list. Right now it only works on Blogger and WordPress blogs, but that's actually a fair number of blogs.
Requirements: Firefox, Greasemonkey Plugin
Check it out here: GitHub repository
Here's a picture: Picture
Projects updates
Eh, so none of my projects strike me as interesting anymore. The stylometry app seemed sort of gimicky (and pseudo-science at best), and the blog app is sort of ho hum web 2.0 ruby framework stuff. And if I wanted it to be a good blog, even remotely comparable to Wordpress...I'd have to put in dozens of hours.
Now I need to figure out what a good use of my time is. Pretty sure Left 4 Dead isn't it, but it is quite entertaining. I think what I need to do is...instead of trying to come up with ideas for projects out of the blue, come up with ideas that are solutions for problems I'm having, something I would use and benefit from even if no one else did. My Notepad app sort of fits that description, but is very limited in scope. I would like something bigger to work on, that still meets that description...