Huge Dropbox Cache File

Recently, I noticed that my hard drive usage had suddenly doubled. Using OmniDiskSweeper as a tool to quickly visualize my folder and file sizes, I discovered that my Dropbox cache file (in /Users/<username>/.dropbox/cache) had grown to 26GB!  There seem to be some issues with cache management in Dropbox, but my usage also probably didn’t fit a normal use case. What behavior of mine caused this, and what did I do about it?

Background

I write code on 2 different machines: my (aging) MacBook Pro and a 24″ iMac.  Looking back, I should have replaced the MacBook and added a 24″ monitor instead of buying the iMac, but that’s hindsight…

Anyway, I was actually keeping certain Ruby on Rails projects in git in folders in Dropbox.  Yes, I know this is slightly redundant when using a version control system, and I caught some flak for this from a colleague.  But the convenience was amazing. I often get up from my iMac mid-coding session and end up plopping down someplace else with the laptop and resuming.  It is so nice not to have to commit, push, and pull every time this happens.  In fact, sometimes I don’t even completely plan it; I’ll leave the house for an errand, and end up staying out and coding from a coffee shop.  Since I rarely leave home without my laptop (which I’m beginning to think is a character flaw) this works well for me.

Syncing a git repo through Dropbox

Up until now, I’ve had very few problems syncing a git repository through Dropbox.  The only real issue I ever encountered was that the file permissions would change on executable files. Newly created files with 755 permissions would sometimes turn to 644 when synced to the other machine.  Doing a fresh git checkout on just these files would restore the permissions and they would stay correct.  (I never bothered trying to solve this problem permanently).

Once, I actually ended up with a conflict in the git index, but it was easily resolved since Dropbox doesn’t blow away any files in this case (it just appends the name with “(conflicted copy)”.

Enter Autospec

The other day, I begin using autospec combined with spork (highly recommended by the way) in my testing.  Something about this process generates lots of log files (temporary or otherwise, I haven’t checked).  While this was going on, the Dropbox cache files on the other computer where silently growing HUGE.

By the time I realized it, the cache files for a 4 day period had grown in size from something normal to 26GB!!!

I surrender

I probably should take the time to figure out exactly what’s going on, maybe even give the Dropbox guys some pointers on how to replicate this situation.  I still might – I still love Dropbox and it has its place in my computing.

But for now, I’m going to take my git repos out my Dropbox.  I was feeling guilty about it anway – it felt like I was doing something dirty – so this was the straw that broke the camel’s back.

As for reclaiming the space?  Its safe to delete your Dropbox cache files.  Just shut down Dropbox, delete the cache files (individual folders or the while ~/.dropbox/cache folder) and then restart Dropbox.

Posted in Computing, Rails | Tagged , , | Comments closed

Windy City Rails 2009 Recap

One of the best things about my new job in Grasshopper Labs is that we’ve made it part of my goal plan to attend some Ruby/Rails conferences.  I made a good choice to attend Windy City Rails in Chicago a couple weekends ago.

The location == great.  I wish I had more time to explore Chicago while I was there, but its a fun city and being on the river at the Westin was awesome.

I particularly enjoyed the tutorial session “Behavior Driven Rails with RSpec and Cucumber“.  We’ve settled on following a BDD style using RSpec and Cucumber at work, so I was keenly interested in this one.  It started a bit slow for me – the experience level of the attendees varied widely, so we were forced to start “at the beginning”.  Despite this, the real treat was being able to just watch David Chelimsky and Corey Haines pair program.  I’m fairly new to pair programming, although what I’ve done so far has shown its value to me.  Observing two guys like David and Corey pair proves that value.  You can witness them discover things, push each other, help each other, and focus more keenly than they otherwise would alone.  It really is magic.

Thanks to everyone who was a part of Windy City Rails.  I fully intend to return next year, hopefully with a little more time on my hands to really enjoy the city.

Posted in Rails | Comments closed

Changing the Rails field_error_proc on a per-controller or per-action basis

So we know we can change how rails displays errors in forms with fields that fail validation. I came across a reason to need to change the ActionView::Base.field_error_proc temporarily, and then set it back… sort of like having different values for the field_error_proc in different places. I came across this post that basically uses a helper method to store the old field_proc_error value, change it, then change it back. Realizing that I could do that brought me to a solution that works better in my case.

My solution is to use an around filter on my controller and a custom class. This way, I can set how form validation errors are displayed on entire controllers or certain actions.

I created a new file called field_error_proc_changer.rb in my lib directory as follows:

class FieldErrorProcChanger
  def initialize(proc)
    @new_proc = proc
  end

  # This will run before the action. Returning false
  # aborts the action.
  def before(controller)
    @old_proc = ActionView::Base.field_error_proc
    ActionView::Base.field_error_proc = @new_proc
    true
  end

  # This will run after the action if and only if
  # before returned true.
  def after(controller)
    ActionView::Base.field_error_proc = @old_proc
  end
end

Now, you can replace the existing field_error_proc using a normal around_filter

class RandomController < ApplicationController

  around_filter FieldErrorProcChanger.new(
    Proc.new {|html_tag, instance| "#{html_tag}"}
  )

  def index
    foo = bar
  end
end

Or on only certain actions like

  around_filter FieldErrorProcChanger.new(
    Proc.new {|html_tag, instance| "#{html_tag}"}
  ), :o nly => [:index]

The value for field_error_proc I’m showing actually doesn’t add anything to the field with validation errors (I’m using a custom form builder that adds special classes to fields with errors, so I don’t need any html added). But, you could add a fancier proc too:

around_filter FieldErrorProcChanger.new(
  Proc.new  do |html_tag, instance|
    html = &#8220;&#8221;
    html << %{<div class="ridiculous_construct">}
    html << %{<span>There&#8217;s an error over here!</span>}
    html << %{#{html_tag}</div>}
  end
)

Why would you want to do this? In my case, I’m adding an extension to the Radiant CMS. My extension has an administrative interface, and my forms aren’t exactly like the default Radiant forms. Radiant sets its own field_error_proc, which I don’t want in my controllers, but I don’t want to change the way the native Radiant admin works or looks.

Posted in Home | Tagged , | Comments closed

Solving a blank page problem with the Comatose CMS

I’ve hit this on 2 different installs of the Comatose CMS plugin for Ruby on Rails (now hosted on Google Code ) so I thought I’d write it down. Just after the install, I can go to the admin page (example.com/comatose_admin) just fine. But if I try to go to the root of the site, where I expect to see the default Comatose “Home Page”, I instead see a blank page. My logs show a 404 error too.

What’s happening is that comatose is checking the database for a page with a fullpath of ” (empty string). But my database has the “Home Page” fullpath stored as NULL, so it doesn’t find it. I don’t know if this is a config problem with my database or an error in the migration script at this point.

The easy fix is to edit the “Home Page” in comatoseadmin and immediately save it. The fullpath value is replaced with an empty string and the 404 error is solved.

Posted in Home | Tagged | Comments closed

Using ActionMailer with SMTP in a development environment

I just ran in to a problem where I wanted to use SMTP delivery for an ActionMailer mail in a Rails app running on my local development machine. When I sent the email, it seemed to send with no problems (no errors raised) but it didn’t get delivered and I couldn’t find it. So I changed my authentication credentials to supply a bad password, and still it didn’t complain. Ah, there’s the problem. It really should complain, with a

Net::SMTPAuthenticationError (535 Incorrect authentication data)

The Rails app needs to be restarted to pick up the configuration settings. This was on a Locomotive environment with Rails 1.2.3.

Posted in Home | Tagged | Comments closed

I hate GI Joe

GI Joe ruined my weekend. I was cleaning out the attic in preparation for selling our house, and I came across my childhood toys (that my attic inherited from my parents’ attic when they sold their house). At first it was a nice moment of nostalgia as I recalled the easy life of being a kid and playing all day long. But then I was faced with the dilemma of What Do I Do With All This Stuff? I am NOT going to pack them up in boxes to transport to the next house (then the next, then the next). At first I thought I’d just donate them to charity, but wait!!! What if they’re worth something?!?! A quick check on ebay surprised me – there’s a lot of collectors out there who will pay some decent money for an early 80’s GI Joe. How exciting! And look, there’s a website that will help you match up all those guns and backpacks with the correct figure! I can match all these things up and sell them for $5 – $10 bucks a pop! By 1am Sunday I realized how bad of an idea this was. It was taking forever, and I hadn’t even taken any pictures for ebay.

After sleeping on it and then consulting my Wise Counselor (wife), I resolved (well.. she told me) to just slap the whole darn lot up on ebay. Forget the sorting and labeling, just get it out there. That even ended up taking too long, but at least I was able to move on to other things. But I couldn’t help thinking that I’d been bitten by the bug that causes everyone everywhere to keep things they don’t need for years and years and years – “I can’t throw this away, what if its worth something one day!” Sure, everything has value to someone, and ebay makes that far to easy to discern. But I could have profited much more this weekend by either getting the house on the market, or doing some work for some clients, or even taking a nap. I ain’t going to get rich based off of the stuff in the attic, and even if I was, at this point I’d rather not know about it. It feels much better to give it away or throw it in the trash – especially when that trash is the Wake County Convenience Center down the street where you can throw just about anything in this big dumpster then they press the button and reduce it all to the size of a peanut – SWEET!

So GI Joe, thanks for the good times, but you really ruined my weekend. For your sake, I hope the person who buys you on ebay doesn’t throw you in dumpster one day.

Posted in Home | Tagged , | Comments closed

Crash Monkey Porter

I brewed some beer a few months back. It was my 2nd batch ever (and first in about 2 years) and I thought it turned out pretty good! Good enough that almost all 5 gallons are almost gone. Granted, I did give a lot of it away; but I did have my fair share for myself… so, time for a review!

My Crash Monkey Porter is, well, a porter. It pours almost jet black with 2 fingers of creamy tan head that sticks around like a carpet on top of the beer. It smells of coffee with an earthy sweetness. It tastes similar to how it smells, with a definite roasted flavor. Unfortunately, it also has a bit of a metallic flavor, sort of bitter. I’m guessing this has something to do with the water I used – I used tap water this time rather than bottled water. I’ll probably use bottled next time or make sure I filter the water better.

If I were doing a beer advocate style review, here’s what it would look like:

(1-5 scale: 1=awful, 3=average, 5=exceptional)
Appearance (20%): 4.0
Smell (20%): 3.5
Taste (40%): 3.0
Mouthfeel (10%): 4.0
Drinkability(10%): 3.5

For a total of a 3.45.

Crash Monkey Porter (named after my dog, Crash) is supposed to be a copy of Sierra Nevada Porter. I just bought a Sierra Nevada single the other day, so I’m going to do a blind taste test this weekend!

Posted in Home | Tagged | Comments closed

Return to Reynolds

I just got back from historic Reynolds Coliseum where I watched NC State beat Marist in the 2nd round of the NIT. That was a wild game, but returning to Reynolds brought back a lot of memories for me. I was at State during the Pack’s last 3 seasons in Reynolds (before they moved in to the RBC). We were never very good during those, but being back there tonight brought back all sorts of great college memories.

Read More »

Posted in Home, Life | Tagged , | Comments closed

Quittin’ Time

It’s definitely worth a mention here – I resigned from my “real job” last week to pursue my passion for web development and design. The title of this post is a little harsh, because I don’t like to think I’ve “quit” anything. I’m just moving on to an exciting new chapter. I was proud to have been a part of the design team that delivered the Xbox 360 processor (we won EE Times 2006 Design Team of the Year for that!). But my interest in processor design and big-company life has been superseded by my entrepreneurial spirit and interest in the (new) web. I’m actually getting back to my roots – as a high-schooler in 1995 I volunteered (because they couldn’t pay, but they could teach) at a company who delivered the now-defunct “Greensboro Online” city directory and various other websites. I’ve been hooked on the web ever since.

My new business is called Tiji Web Development. More on that name, and the website, will be forthcoming!

Posted in Home, Life | Tagged , , , , | Comments closed

Go Pack!

Just wanted to give a shout out to my NC State Wolfpack as they try to complete their improbable run through the ACC tournament. Can they knock off Carolina? I don’t expect it. But then again, I haven’t expected much this season and have been pleasantly surprised again and again. Thanks to the team and thanks to Coach Lowe for a fun season!

But man, I can’t help think about ‘83

Posted in Home, Life | Tagged , | Comments closed