Perks of the Job
Posted by Sam
Nearly three months ago I posted a blog about Barkley (my employer) being on 20/20. Originally, I believe the story was supposed to air in November and then it was allegedly pushed back so they could extend our time. Well, looks like we are back in the news for being a top place to work. This time we are being recognized by CNN. Yes, that CNN. You can read the whole article here.
If you don't have time or desire to read the article I'll sum it up for you. Barkley came in number one in a list of twelve companies that are noted for being great places to work. We even beat out Google who was quite a ways behind us at number seven. Read it for yourself if you don't believe me. The funny thing is that they left off quite a few perks. Some of which they list under other companies, like the paid winter break. Maybe they felt like they needed to leave something for the other guys to brag about. I won't rehash all of our perks, but if you care you can go read my old blog post. I've said it before and I'll say it again. Barkley isn't a perfect place to work, but they definitely spend a lot of time, money and thought on their employees. I guess this makes sense since employee owned, but it's still pretty impressive how us lowly employees get treated. I for one am very glad to be a part of Barkley!
Tags: barkley
Merry Christmas to Me!
Posted by Sam
This year was probably the best Christmas I've ever had and the icing on the cake was that I asked Katie to marry me on Christmas day and she accepted. I wasn't sure at first because tears could go an either way, but eventually I heard a yes through the tears (of joy). :) Here's a shot of her beautiful wedding ring.
Tags: personal
Bad Christmas Gifts
Posted by Sam
In my last post (Annoying Flash Issues) I referred to the Barkley Holiday site that I was working on. I couldn't really talk about what it was at the time, but we unveiled it last week so I think I can safely publish the site URL on my blog. The site is called the Bad Gift Emporium and it's really bad. On purpose. The idea is you can upload your bad gifts for all the world to see. If you are willing to part with your bad gift you can even trade or sell it on the site. Let me know what you think.
Annoying Flash Issues
Posted by Sam
So I'm working on the Barkley Holiday site for 2007 and I ran into several frustrating things today. A little background on the site. The backend is written in Ruby on Rails and the frontend is flash based. I use LiteSpeed's excellent web server for the application and web server. The backend of the site is pretty simple. It's using the attachment_fu plugin to upload and resize photos and then simple XML to communicate with the Flash frontend.
The first problem I had today was that Flash couldn't get the XML when running inside IE6 on Windows. It works everywhere else. Grrr. The Flash developer found an article that was mostly wrong, but had just enough truth to help me find the real problem. When using rxml templates Rails will automatically return a content type of 'application/xml'. For whatever reason when you combine this with gzip compression, Flash and IE6 you can run into a situation where IE6 won't push the XML to Flash. If you turn off the compression it works fine. I turned off compression in LiteSpeed for dynamic content and everything worked. I really wanted the compression so I kept poking around to see if I could find another solution. Turns out if you leave compression enabled and change the content type to 'text/xml' then everything works fine. Stupid Internet Explorer! So if you are using Flash with RXML, IE6 and dynamic gzip compression you should set the content type like so.
@headers['Content-Type'] = "text/xml"
The next problem I had with Flash was that images weren't being resized with attachment_fu when they were uploaded from the Flash frontend. If I loaded them with the backend HTML interface everything worked as expected. This turned out to be a relatively easy problem, but it still bugs me. Flash doesn't set the correct MIME type when it uploads files. Instead of uploading the files with a MIME type of 'image/jpeg', 'image/jpg' or something sane Flash pushes files up with a generic 'application/octet-stream' MIME type. Attachment_fu was seeing this MIME type and didn't think it was an image so it wouldn't resize it. Since we are only uploading images to this particular application I hacked the attachment_fu plugin to accept 'application/octet-stream' as a valid image MIME type. There might be a better way to do this but I needed it done yesterday so here is the original code found in attachment_fu > lib > technoweenie > attachment_fu.rb.
#original code
And here is the code with the MIME type needed to process Flash uploads.
@@content_types = ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg']
#hacked code
@@content_types = ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg', 'application/octet-stream']
I'm not sure if the first problem that I ran into is Flash's fault or IE6, but the second issue definitely seems like a problem with Flash. The browsers push up the MIME type so why can't/doesn't Flash?
Tags: rubyonrails litespeed
The little things
Posted by Sam
It's the little things in life that make a big difference. I recently ran into a problem where I thought ImageMagick was corrupting my images when it resized them. Turns out the problem was the database. In my migration I'd only specified :binary for the datatype. It looked like this.
create_table :db_files do |t|
Well in MySQL this means that it defaults to a Blob which only holds 64k. Originally the images were being scaled to 182x182 so this didn't present a problem as all the images seemed to come in under 64k. A couple days later I had to adjust this to 250x250 and then we started getting 'corrupt' images. Turns out some images just needed more space and some didn't. I looked through my Agile Web Development in Rails book and only saw a Binary datatype and didn't find an obvious way to make it bigger. Then I stumbled across a page that talked about setting the size to have a bigger limit and ActiveRecord will automatically give you a larger Blob datatype. In order to accommodate the bigger images I created the following migration.
t.column :data, :binary
end
class ChangeMaxImageSize < ActiveRecord::Migration
Woo Hoo! Thankfully that solved it.
def self.up
change_column :db_files, :data, :binary, :limit => 512.kilobytes
end
def self.down
change_column :db_files, :data, :binary
end
end
Some frameworks look great on the surface and the more you use them the uglier they get. That was certainly my experience with Struts. It created as many problems as it solved. I've had a very different experience with Rails. It constantly surprises me with how well thought out and usable it is. I'm not a Rails fanboy I just like things that work and for most cases Rails just works.
Tags: rubyonrails