Hi, I'm Ben Oakes and this is my geek blog.
Currently, I'm a Software Developer at Hedgeye.
Previously, I was a Research Assistant in the Early Social Cognition Lab at Yale University and a student at the University of Iowa.
I also organize NewHaven.rb.
I do development with Ruby, JavaScript, SQL, HTML, and CSS. I have an amazing fiancée named Danielle Smith.
We have a simple application that doesn’t have an ActiveRecord dependency. It’s deployed to Heroku, and it’s been working fine on Rails 3.0.x since April 2011. We knew we weren’t using ActiveRecord for database connectivity, but we let it be, since it wasn’t causing any issues.
When upgrading to Rails 3.1, we found that every single page would give ActiveRecord::ConnectionNotEstablished on our staging environment on Heroku. The same error didn’t happen in development. Although we might have been able to get gem 'pg' set up and working, we really didn’t need an ActiveRecord dependency at all.
That’s what Rails 3.1.0 generates when running rails new myproject --skip-active-record. (Note that require "active_record/railtie" is commented out.) This solved our ActiveRecord::ConnectionNotEstablished problem, but gave us a few others, namely:
Fixtures
ActiveRecord::RecordNotFound (used for 404s)
Fixtures
There’s some normal stuff to get rid of in terms of spec_helper.rb and/or test_helper.rb. Here’s an example:
# File spec/spec_helper.rb
# # If you're not using ActiveRecord, or you'd prefer not to run each of your
# # examples within a transaction, remove the following line or assign false
# # instead of true.
# config.use_transactional_fixtures = true
You may have others. Tarantula had to be adjusted for us, for example.
ActiveRecord::RecordNotFound
ActiveRecord::RecordNotFound, however, was an interesting problem. Everything worked fine without ActiveRecord except the places where we were using ActiveRecord::RecordNotFound to give a HTTP 404 to the user agent. That seems strange in a lot of ways, because a 404 shouldn’t have anything to do with your chosen ORM. My first intuition was to do require 'active_record/errors' (see also the Rails docs), but that caused problems with assumptions in 'rspec/rails'.
Right now, the below is what we ended up with:
# File: config/application.rb
# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
# For errors like ActiveRecord::RecordNotFound
require "active_record"
Our automated tests (Rspec, integration tests, Tarantula, Selenium, etc) all pass with it and we no longer get ActiveRecord::ConnectionNotEstablished, but we still have an ActiveRecord dependency I don’t like. (There must be another error we can raise — I don’t entirely like the render '/404.html', status: 404 solution for several reasons.)
We’re trying rack-ssl-enforcer out on our Padrino-based project. It seems to work when configuring like so:
# File: app/app.rb
class MyApp < Padrino::Application
# [...]
configure :production do
require 'rack-ssl-enforcer'
use Rack::SslEnforcer
end
end
We're using it with Padrino with some success. It's great that such a common need is really simple to set up. However, even after looking through the docs further, I'm surprised that I can request over HTTP and I don't get redirected to HTTPS. I've yet to figure out the issue, but it seems to meet our needs just fine otherwise.
This is in response to Dan Mayer's article Force all Sinatra traffic to https. I had started to comment, but his blog errored-out when submitting. Thanks for posting it, Dan!
Alright, you may be wondering why I’m making a blog post about a VCR in 2011. Blu-Ray is supposed to kill DVD any year now, right?
A VCR is actually a more relevant device in 2011 than I would have originally thought, mostly because of one reason: lots of people don’t want VHS tapes anymore. It’s really easy to find all sorts of free and cheap copies of movies you would want but wouldn’t buy otherwise. Goodwill and Salvation Army are good examples; we’ve spent a few dollars and ended up with a dozen movies, including older Star Trek movies I’d never seen (picked up for $0.25 a piece), along with lots of good 80s, 90s, and early 2000s movies. Freecycle and “urban recycling” (or “curb shopping”) often turn up with good offers too, but for free. They all play with better quality than I seem to remember, too.
When it comes down to it, price really is king. Sure, they may not play that great on a HDTV, but since we’re not planning to upgrade soon (or re-buy all our movies on Blu-Ray as Hollywood seems to be hoping), it’s a great option for getting a lot of good movies for next to nothing — especially since we don’t have cable.
That said, we recently had a problem with our VCR (also free, of course): The tracking looked to be completely off, leaving us with nothing but static. We had thought Delta ruined some tapes in our recent holiday trip (they ruined enough of our other things), since we’ve previously used the VCR just fine.
My first instinct was to use the channel up/down buttons on our universal remote to try to adjust the tracking. That didn’t help at all. The menu wasn’t very helpful, either. It’s a Sharp VC-A593, which I couldn’t find more than a few questions about and dead links to manuals online. After testing cable connections and with tapes we’ve previously viewed, it definitely was a tracking problem. But I did find a solution.
Solution: Use the channel up/down butons on the VCR itself. You may have to rapidly push up/down 50+ times to see any difference at all, but eventually it came back to life.
At some point, the tracking fell out of alignment and we hadn’t noticed. We were about to throw it out, until I played around with it some more.
My girlfriend is moving in just a few days but still has quite a few books listed on Amazon that would be great to sell before packing everything up. Take a look around — you might find something worth picking up!
I’ve had the great pleasure of working with some other local Ruby developers to reignite NewHaven.rb over the last few weeks. Our second official event is a “Ruby, White, and Blue Hackfest” tomorrow, July 1st. It’s going to run from 6-9 pm at Blue State (the Wall St location). Everyone is welcome — don’t worry about skill level! You bring a laptop, we bring the community.
Right now, the plan is to get together and work on a few projects that group members are interested in, including our upcoming website. I’d also like to talk about what we should do for our next event.
This has to be one of the coolest things I’ve seen in a while. Such an awesome idea! I think he should have used Link from Zelda II when you get a mushroom, though.
I’ve been working hard on redesigning this site. You can see what it used to look like, above. It’s been a fun ride: I took this opportunity to learn more about HTML5 and CSS3. I’m pleased with what I’ve made. The result of my work is the custom WordPress theme you see now. I learned a lot in redesigning this site (mostly HTML and CSS, but a little PHP too). Over time, I’ll be rolling out some summaries of what I learned in blog posts.
Geek section: As it’s just a personal site, I’ve been experimenting with new HTML5 features and semantic tags, keeping the markup as minimal as possible, and applying visual effects only through CSS. As a result, there are very few images (all the gradients, shadows, rounded corners, and animation are pure CSS3) and the design degrades elegantly for older browsers. It even looks decent in the 9-year-old IE6. I’m preferring the new video and audio tags instead of Flash or other plugins as much as possible. The site even works (and looks) great on my iPhone. HTML5 and CSS3 still have problems, but the future of the web looks bright.
I also took the time to pull together some old content from other sites. There are still some gaps, but there are posts going all the way back to 2002. (I cringe a little reading some of it, but it’s interesting to see how much I have—and haven’t—changed.) Some posts have only been living on a hard drive for the last 8 years, but others have been on other services like Blogger. I’ve done my best to redirect links here.
Please let me know what you think in the comments.
It’s great the Supreme Court is starting to reflect the population a little better. If anyone has an argument against that, I’m guessing it’s almost certainly BS.
I recently purchased a Philips Smart Surge Protector (SPP3225WA/17). It’s nice because it can detect when an attached device is turned off and then turn off any other devices attached. This is especially useful when used with a computer because most peripherals are unusable when the computer is off, so there’s no sense in leaving them on.
It’s a great idea in theory, but I had problems using it with my Mac mini (OS X Leopard 10.5.4). Specifically, I want to use the built-in power scheduling (see “Energy Saver” -> “Schedule…” in System Preferences) to have the Mac turn off everything so we don’t have to remember to do so at the end of the day. Everything worked fine using the normal “Shut Down” command, but I didn’t want to have to make sure no one was doing anything every night. I wanted to use something like “Sleep”, but unfortunately, once the Mac went to sleep, it would turn off the attached external hard drives which would, in turn, wake the Mac back up. (It would also complain about not being properly ejected.) The most the Mac would stay asleep would be a couple of seconds.
But I found a solution! According to some information I found, there’s a way to change from using the default “sleep” and use something closer to what Windows users may know as “hibernate”. (It exists normally in OS X, but is only triggered by low battery.) To force it to always “hibernate” when sleeping (which is fine in the case of the Mac mini), you can run the following command at the command line:
sudo pmset -a hibernatemode 1
To reset this back to normal, run:
sudo pmset -a hibernatemode 3
Using this hibernate mode, the Mac no longer turns itself back on when the power to the external hard drives goes off. You can then set the Mac to sleep on whatever schedule works for you in System Preferences and everything else should turn off around 15 seconds after it starts going to sleep. (You’ll have to give it a little bit because it has to write the contents of memory to disk, which takes time.)
However, one problem still remains: OS X will still complain about the disks being removed improperly. To get around this, I wrote a small shell script which ejects them 5 minutes before the scheduled sleep time. You’ll need to tailor it to your setup, of course.
#!/usr/bin/env bash
# ~/bin/eject_external_drives
if [ -d "/Volumes/Time Machine" ]
then
diskutil eject "/Volumes/Time Machine"
fi
if [ -d "/Volumes/Storage" ]
then
diskutil eject "/Volumes/Storage"
fi
Today’s been shaping up pretty well. I actually woke up at a decent time. The last few days, I’ve been enjoying sleeping until noon, but today I was up and about at nine. Not at night either, nine this morning!
I’ve been getting tons done with this new laptop. I’ve spent most of the week moving files from other computers to this new one. At this point, I have most of my personal files all in one place. Believe it or not, that’s a truly gratifying experience. And now, I can have an extra copy of all these files on me at all times, thanks to the USB JumpDrive I received for my birthday.
However, there was one thing that made the day great. I finally received my ACT scores. I’m not going to say what I got, but I will say that I solidly qualify for all the scholarships that require at least a 30.
And that’s not all: earlier this afternoon I got my car washed. I paid for a regular automatic wash–no wax, no dryer–but I received both of these free. I asked the manger if he wanted me to pay extra, but he said it wasn’t necessary after thanking me.
Let’s hope things go as well next year! Happy New Year everybody!