Pickem Players Rejoice

Imagine how foolish you’d feel when someone pointed out that the small “football pickem” site you developed last weekend in your basement for your 20 friends doesn’t update the standings live.  Such an obvious feature that everyone would want.

Now imagine you’re a major corporation making millions off fantasy football and have been at it for years… but you still don’t update the standings live.  Yahoo is weird sometimes.

but here’s the patch (tested for 3 seconds in Firefox and Chrome, so it’s practically inconceivable that there’d be bugs) => Install via userscripts

1 Comment

Filed under Javascript

New Machine

The old Macbook Pro finally kicked it, so… on to the new one.  Just thought I’d share my “what to install” list of all-stars that survived the jump from the old machine to the new.  Missing anything?

* FluidApp

* Yammer via Fluid

* Adium (AIM/GMail/Nextpoint Gmail/Yahoo)

* OpenOffice

* OnePassword

* Firefox

… firebug

… live http headers

* Chrome

* Alfred

* iTerm

* Seashore

* Dropbox

* Skitch

* svndiff (http://drupal.org/node/191106)

* Skype

* Camino

* StuffIt Expander

* Picasa

* SlimBatteryMonitor

* TextMate

…. svn, resolve with macgreerver

* Cyberduck

* CoRD

* NeoOffice

(and just let me know if you want more detail on any than just the name)

Update: forgot… Menu Meters

Update 2: forgot to disable Flash (in general) and install the YouTube5 Safari extension

Update 3: SlidePad

Leave a comment

Filed under hardware, software

Dock Badge for Yammer via Fluid

If you’re interested in running Yammer, on OSX, in a Site Specific Browser (SSB), so that you can launch it like a normal application, etc:

1.) get Fluid (free) and install it

2.) launch Fluid and setup with your Yammer feeds url (like: https://www.yammer.com/company.com)

3.) In Preferences -> Advanced of your new “Yammer app”, select “Allow browsing to any URL” (if login keeps sending you to your “real browser” you don’t have this checked)

4.) Click the scripty looking icon in the top bar and choose “Browse userscripts.org” -> search for “Yammer” and choose “Fluid Badge for Yammer Unread Messages”. Install it and activate it.

5.) You should probably restart your Yammer application now.

That’s it.  Enjoy and let me know if you have issues.

Leave a comment

Filed under browser, Javascript

bob != the greatest

Fun bug. It’s not all that hard to see once you sort out what line it’s on, but when the sauce is much thicker… the initial Hash definition may not be the first place you check.

…and when I say “you”, I of course mean “me”. It may not be the first place me check.

>> a = Hash.new{ |h,k| h[k] = 1; bob = "lame" }
=> {}
>> a[0]
=> "lame"
>> a[0]
=> 1
>> a = Hash.new{ |h,k| bob = "the greatest"; h[k] = 1 }
=> {}
>> a[0]
=> 1
>> a[0]
=> 1

Leave a comment

Filed under Ruby

MySQL Triggers w/Rails

I recently incorporated db-triggers with a Rails app to maintain some counts that were otherwise fairly expensive to retrieve.  Rails wasn’t super-pumped about the idea (what with the “keep all the logic in the app” approach and all), but sometimes… you know… you know better than your framework.

Some things I was aiming for:

  1. Set them up with normal migrations.
  2. Test them with the normal test suite/normal fixtures.
  3. Make recovery/reset simple for when the table (inevitably) is somehow out of sync.

The “frequent counts” table

I’ll have multiple counts but not TOO many — enough that I don’t want to have a column per count but not enough that I mind using “LIKE” to lookup patterns, so my table has: id, code, current_count.

Code will be a unique key (important later) and be formatted like “style_ABC_size_456”.

So, when a new item is added it’ll be associated with a style and some sizes – each combination will either need to be setup (with a current_count = 1) or an existing combo will be found and +=1.

The FrequentCount class has the fairly straightforward finders that you’d expect + methods to reset each of the counts that it contains.  The reset methods follow the pattern “reset_frequent_count_COUNT_NAME” -> they clear the existing counts that they maintain before repopulating them.

I also threw in a reset_all method that looks for anything on the class following the “reset_frequent_count_COUNT_NAME” pattern and runs them.

The trigger-SQL

The SQL for creating the triggers will be needed by the migration as well as the test suite.  In fact, the test suite will need to run them somewhat often due to the way the standard tests “prepare” the database.

I ended up throwing it in lib/trigger_sql.rb.  Methods there are named with the pattern “sql_for_TABLE_OPERATION_TRIGGER_NAME” ex: sql_for_items_insert_style_and_size

Many of the triggers could not rely on pre-existing rows.  i.e. a new style/size combination needs to INSERT where an existing combo could update ( +=1 ).  To get around this, I relied on the unique key setup earlier on the “code” field for the frequent counts table.  <– that allowed me to lean on insert statements with “ON DUPLICATE KEY” clauses with update statements.  Something like this…
create trigger items_insert_style_and_size after insert on items
for each row
insert into frequent_counts(code, current_count)
values (concat(‘style_’, new.style, ‘_size_’, new.size), 1)
on duplicate key update current_count = current_count + 1;
The Migration

I’ve already given away most of the fun stuff about the migration.  It just needs to run through the triggers that are being setup at this specific time, doing things like:
and then make sure to populate it all (with that reset_all) method when we’re done. <– next time out I may want to call specific methods to reset just the ones I care about but this first time, I can just do the whole table.

Testing with Fixtures
Rails goes a little too far when running the default test tasks for us – it ends up nuking the triggers on us, but not to fear: it’s a quick hack in the Rakefile.
I’m going to spare you some details (drop me a line if you want them) but I basically overrode the db:test:prepare method to call a special version of the clone_structure task.  My version has a dependent task that does:
# find methods that follow our pattern of “methods providing trigger sql” and execute the contents of each
TriggerSql.methods.select{ |m| m =~ /sql_for_.+/ }.each do |method_name|
As you see there, it’s leaning on that naming convention “sql_for_TABLE_OPERATION_TRIGGER_NAME” to find the sql to (re)apply.
That’s it!
Migrations set them up and share the code to do so with the fixtures that can repeat the tests whenever we need.  Those reset methods also come in handy not only for the initial population (by the migration) but we can call them manually should we need them.

Leave a comment

Filed under deployment, rails, Ruby, SQL, Test Driven Development (TDD)

Friend’s Price

A friend was asking the other day about getting a little site up and running for his small business.  Seems like the scope is going to be quite small (famous last words) and there are a few things I’ve been meaning to checkout lately, so I think I’m going to give it a stab.

Night one went something like this:

I got an invite (did they do invites?) to checkout Heroku really early on.  At the time, I remember devoting a night to it – working with an online editor (or maybe I was ssh’d in with vi or something?) and basically just getting a little “Hello World” up and running.  Ever since bumping into Jim Fiorato’s app/case study the other day, I’ve been meaning to revisit a bit.

It’s entirely likely that the friend’s site will actually not need anything but static HTML, but hey: I can always tune the caching and free hosting can’t be argued with, right?

So, I opened an account out at herku.com and grabbed the heroku gem; installed git (officially taking me off the short list of people that still hadn’t given it a chance) and set to work on getting my app out there.

I hadn’t written anything, so I was just wanting to throw the “welcome to Rails” app out there to make sure everything was setup correctly.  The first bump was some fun with SSH keys.  I’m actually still not sure exactly what the issue was but there seemed to be some commands that were respecting the path to the key that I had setup but some others that seemed to be looking in the default location (~/.ssh).  I am actually thinking now that I probably could have got around it with a little more effort put into the config but I ended up just using the default key location — no probs after that.

At that point + some very simple/standard Rails app config, it was incredibly early to push the app out there, setup a few tables (via migrations) and get to work.

A little effort into a pretty basic layout and we’re underway.  It’s nothing spectacular to checkout at the moment – generic copy, placeholder colors/blocks and text… but someday it’ll be a star.

Leave a comment

Filed under rails, Recommended Sites, Ruby

Online Office? or Goog Docs?

I’m sure you’ve seen that Microsoft announced it will be bringing a free version of Office to the web.  It looks like that may actually still be a year out, but nevertheless it’s got me thinking about whether I’ll be a customer.

Google Docs is great but let’s face it, the best part about it is plain and simple: It groks .docs (and xls and whatever else).  If it didn’t… I imagine I might have a few docs out there — some random things people “shared” with me and what not, but add in the ability to handle .doc files and it becomes an essential tool for anyone lacking a copy of Office.

So, Microsoft’s announcement that Office will be available FREE online is a Goog Docs killer, right?  … nah.  I really think it would be but the thing about “Free online Office” is… it’s only free if you’re already paying… and while 400M people are — YOU, my friend, are not.

So, what will it take for this to be a success amongst the 2 groups of people I care about?  Let’s label them (1) Me and (2) My Uncle Rob.


I love having things online and everything that goes along with it, but… gotta be free.  Google’s online offerings are far from having perfect interfaces, but as any good 36-signals-following kid will tell you: free + simple = winner.  I just can’t justify paying $50/yr (to make up a number) to have Word online.  I know it’s $4 a month… but sorry: I’m out.

Uncle Rob

Uncle Rob doesn’t really get the whole online thing.  That’s not to say he doesn’t use/like technology.  or that he doesn’t like his Y! Mail and playing some online Euchre.  It literally means: he doesn’t know what it means to have documents hosted online.  If you give him Office online, he’s going to wonder why he can’t go to his harddrive to copy all his files to his fancy new flash drive.

But here’s the thing: he wants Office.  He doesn’t want something that can read and write doc files via “Save As” (or even worse “Export As”.  He just wants it to work – and look like the thing he uses at work.  THIS is why this whole plan may work.

So, what will it take to make me recommend it to him?  … gotta be free.  If he has to pay $50/year — no question about it: I’m telling him to have his kid buy him the $150 Student copy for his own machine.  It’ll be easier for him to understand and it doesn’t force him to send all his Uncle-Robby-Friends “share links” or use that pesky “Export As”.  If the prices are even close (and they really are), it’s the obvious choice for him.

Maybe they’ll figure these things out?  … or maybe they won’t AND the interface will suck.  It’ll be interesting to see how things look when we actually get closer to the release.


Filed under browser, Usability