GhettoCo.de

Dot Dot Dit Dit Dot Dot Dash

Installing .deb Packages Locally

My current job is in a PHP shop and although we have ruby installed on our production machines, it’s basically the system ruby packaged with our OS. Being a ruby developer, I’ve developed quite a quiver of ruby scripts and tools over the years that allow me to personally do my job better, regardless of what language I’m developing in. Most of those scripts rely on RubyGems not installed on the machines. While installing gems locally is a long-solved problem, sometimes a gem needs to be compiled against a native component that isn’t installed on the machine. So how do we install it so we can build our gem, yet not disturb the system?

In this example, I’ll show you how to install the mysql development packages so that the mysql gem can be built.

Creating Angularjs Services in Coffeescript

For my latest personal project, MicBooker, I’ve decided to go with the AngularJS framework. In a very short amount of time, I’ve been able to get further, faster with Angular than I have with any of the other MV* javascript frameworks I’ve tried. Nothing against the other frameworks, it just seem they’re all changing and improving so rapidly that the documentation isn’t keeping up.

So far, I’ve found Angulars docs to be much better and they even have several screencasts and tutorials to help you get up-to-speed quickly. That said, I did run into my first issue that caused me a bit of head-scratching. It took me a couple of hours of experimentation to implement custom services and filters in Angular.

In case you’re having similar problems, here’s a brief outline of what worked for me.

Y’all Cray

Technically, I currently work for a well-established company. Workforce-wise, they’re not huge but their operations are significant. Couple that with the fact that they deal primarily with banks, and it’s no surprise that their process is very “enterprisey”. Luckily, I don’t “really” work for that company. I’m the CTO of a much smaller “startup” that’s being seeded by the owner of said larger company.

It’s so funny to talk with the C# and Java developers from the parent company because they just don’t “get” how we work. For instance, testing. We’ll be consuming their services via a SOAP API (I said they were enterprisey). Today, one of their devs came by my office to talk to me about the various error conditions and codes in their API. Some of them will be newly created in their system specifically for how we’ll be using the system. The developer assured me that they’d get them implemented as soon as possible so I can start to test my logic for handling them.

I told him not to worry and assured him that as long as the service will match the specs, then I can start writing and testing my code before they get finished building it.

“But how can you test hitting our service if it’s not built?”

“Oh, I could do it a bunch of ways but I’ll probably just stub out the calls with webmock or something. Even after the service is built, most of our tests won’t actually hit the service anyway unless I delete the VCR cassettes.”

blink blink…stare…what…I don’t…did he just say VCR cassettes?

As he was walking away, I swear I heard him whisper under his breath, “That dude’s crazy”.

One of these days, I hope get a minute to sit down with those guys and show them how we run tests. Until then, I guess we’ll just have to live with being those crazy kids down the hall.

Bootstrapping Design

I can’t count how many times I’ve started a new project, wireframed it, built it, and then had the whole thing fall apart when it came time to do the work of actually finishing the design. Usually, it’s a personal project that, while you hope others may find some value in it, it’s not a money-making venture. So I don’t want to spend much on it.

That means I definitely don’t want to pay a designer. Nothing against designers. I’m in awe of them and the products they produce. I just can’t justify the cost of a good designer for a pet project that even I’m going to be over in a couple of months. And if I’m going to use a not-so-great designer, I may as well do it myself.

That’s why I was intrigued by Jarrod Drysdale’s new ebook, Bootstrapping Design.

Paperclip Defaults and the Asset Pipeline

The latest stable version of Paperclip hasn’t yet been updated for the Asset Pipeline. This only affects the default image which is served if no file has been uploaded for the attached asset. If you’d like your default “missing” images served from image assets in the pipeline, configure the default_url like this:

app/model/foo.rb
1
2
3
4
5
class Foo < ActiveRecord::Base
  has_attached_file :avatar,
    :styles => {:small => "300x300>", :thumbnail => "80x80#"},
    :default_url => ActionController::Base.helpers.asset_path('missing_:style.png')
end

Multiple Asset Pipelines

I’m working on a project that needs both mobile and web interfaces. We’re building the mobile interface with Sencha Touch and the web version with good ol’ jQuery.

I setup the app for mobile similar to Ryan Bates’ Mobile Devices RailsCast. This allows us to serve different views to the client depending on whether or not the device is a mobile device.

But what about the javascript and coffescript? We’re going to need different behaviour on the client side depending on which view is rendered and I want it all to take advantage of the Asset Pipeline. So I decided to try and make a parallel asset pipeline