I recently added a Javascript file to my bundle with sinatra-bundles that uses Javascript’s eval functionality. The call to eval executed code that referenced a method parameter. sinatra-bundles compresses Javascript files, and as part of that, shrinks variable names. Normally this isn’t a problem, but in this case of eval, it became a problem, since it was trying to reference a local variable that no longer existed (because it got shrunk to s...
Verbose Logging
software development with some really amazing hairHijack AJAX requests like a terrorist
AJAX requests are a grand thing. They let you request things from your server without refreshing the page. Now, if you are trying to proxy a page, you can rewrite all the links in the page to point back through your proxy, but AJAX requests are another thing. Oh wait no they’re not! You can’t rewrite them when you proxy the page (by proxy, I mean you request my page with a URL param to another page, and I pull in that page, do some stuff, and ...
Read the full article
Proper rack middleware ordering
It occurred to me the other day, that I should take a look at the middleware I use on this blog. I don’t know what it was. My spidey senses just tingled. Boy was I right. I totally had it backwards. Rack middleware is a fantastic thing. It’s like a little encapsulated rack application that you can use to filter, process, or otherwise mess with responses. There is middleware to add etags, configure caching, catch and log exceptions, deal with c...
Read the full article
Making nth-child work everywhere
The nth-child pseudo selector is a nice feature in CSS3. Well, most of the things in CSS3 are pretty sweet. Chris Wanstrath has a good post on the nth-child selector, and I’d suggest reading it for a bit more in depth on what the nth-child selector actually does, as I just cover getting the same effect in all browsers. Unfortunately, while Internet Explorer does support some of the CSS3 stuff, it doesn’t support a bunch of them either. (Discla...
Read the full article
sinatra-bundles: Easy asset bundling for sinatra
sinatra-bundles is an easy way to bundle CSS and Javascript assets in your sinatra application. Yes! It has tests! They are on runcoderun Usage sinatra-bundles combines Javascript and CSS into one file. Meaning, you can bundle 2 or more Javascript files into one, similar with CSS stylesheets. Any bundled files are expected to be in the public directory, under ‘javascripts’ and ‘stylesheets’ Assuming you have the following files in public: ./st...
Read the full article
Using Date objects with Ruby Ranges
I used to have some really ugly code to generate the archive links you see on the right column of this blog. It was terrible. Granted it was some of the first code I wrote on this blog, and I was cruising through it because I just wanted to get it done and working, but still, it’s not really a valid excuse. It can be seen here. I had a thought the other day that it would be much better handled by the Range class, and boy was I right, although ...
Read the full article
Hacking markItUp! to help me embed videos
I use swfobject to embed videos because, as I explained back here, just blindly copying the embed code doesn’t work that well half the time, and videos end up being different sizes, etc. I was getting kind of fed up with having to go back and remember how to do it every time though. The format is pretty straightforward, but I don’t embed videos often enough to actually remember the exact syntax, so I found myself going back to posts with video...
Read the full article
My Ruby Style
The folks at Thoughtbot have a Ruby community survey online, and you should all go take it. Well, as long as you are a ruby developer. Otherwise it doesn’t really matter. Anyway, I wanted to throw out what I do for ruby style (and general programming style in some cases). I hate the 80 character limit. Get a real monitor would you please? I don’t align assignment operators. I don’t indent private/protected keywords. I keep the code after pr...
Read the full article
Get your Wordpress out of my Blogging Software
Hopefully you didn’t notice much, except the speed increase, but my blog is no longer on the behemoth that is Wordpress. While Wordpress served me well for quite some time on my other blog it always kind of bugged me. Well no more! I took a couple days (basically 2 full days and 2 evenings) and wrote my own little blogging engine from scratch. You can find it on github and get forking if you so choose. What I used: ruby and sinatra They are pr...
Read the full article