Blog Archives

Twitter Panel

Posted in Industry Trends, Inside TFG, Tips and Tricks

Here at The Frontier Group, we have a team of designers and developers who are very good. Great, even. Fantastic. Superb. Phenomenal. Insert other synonyms for “awesome” here.

Even so, we recognize that we don’t (and can’t) know everything. Our web design and development focus is specific. In areas outside our expertise, we could always stand to learn and grow and we do every day.

This is where you come in. We’re going strong with connections here in Australia, and we’d like to reach out to our friends in the U.S. We’re looking for a few good web designers and developers to connect and share knowledge with. Okay, more than just a few – we’re looking for 50. One from each of the United States. We’d eventually like to connect with one (or several) designers and developers from every country, but we thought we’d start with one and work our way up from there.

Why are we doing this, you ask? Besides making international connections, we’d like to formulate a monthly “Ask The Experts” panel on Twitter. Once a month at a scheduled time, our panel will convene and discuss a given topic – everything from the latest Ruby gem to HTML5. Other Twitter users will be encouraged to come and hang out, learn, and contribute or “ask the experts” for advice. We’ll have our very own hashtag so the panel’s posts will be easy to locate.

We’re hoping it will be a great resource for both us and the web community.

So what do you say? Will you join us in building the Twitter panel to end all Twitter panels? A hashtag that means people actually increase their knowledge? And if you’re not a resident of the U.S., no worries. Remember, we’re aiming to connect to everywhere in the world eventually.

Express your interest in the comments, or on our Twitter.

RVM: More than Ruby 1.9 and Rails 3

Posted in Code, Ruby on Rails, Tips and Tricks, Websites or Tools

RVM is best known as a tool to help developers upgrade their applications to newer versions of Ruby and Rails (3 specifically). That said, for ruby developers, it has many features which help to make their workflow far simpler. Whilst some have shown with effort and rigorous manual process you can achieve much of what RVM offers, the following is a look into some less often discussed areas of RVM that make it my most favoured tool when it comes to development.

Gemsets and the Gemset Hierarchy

Whilst Bundler solves most of the problems related to isolating gems for me personally, on most projects I develop for there are things that make rvm’s implementation of gemsets (especially when used along with bundler) invaluable to me as a ruby developer.

Isolating Gems

A major strength of RVM is the ability to isolate gems at the system level. This keeps them safely partitioned from any other gems unrelated to my project. The way bundler isolates gems is for the most part at run time – It changes the way rubygems works to solve it’s problem and either installs all gems to a user specified path or to your gem directory.

If you are using the usr specified path option, you must to remember that your custom rubygems bin directory is not contained in your PATH. This means that you must either manually add it to the PATH, or your need to manually prefix each command with bundle exec, or alternatively you can generate the binaries into your applications bin directory and each command with ./bin/

If you take the opposite approach and install your gems into your gem home, you then need to be aware of the fact that each next install will overwrite any previous binaries – the canonical example being Rails 2 and Rails 3. The way that rubygems generates binaries lets you run gem-binary-name _version_ something to call the binary loaded from a specified gem version. Unfortunately, in Rails 3, the rails binary was moved from the rails gem into the railties gem which just so happens to break this feature of rubygems. You can try this for yourself on a new rvm gemset, install rails 2.3.8 and rails 3.0.0 and then try rails _2.3.8_ -v. If you are using the simple solution of installing to gem home, even though you are using bundler it will still overwrite the binary.

One common suggestion is to just create a wrapper binary manually (e.g. rails2) or always prefix your commands with bundle exec. In contrast RVM’s isolation works by explicitly setting rubygems home and path to directories isolated under RVM. RVM takes this even further using gemsets (think subdirectories) to handle more fine grain isolation. For example, I personally use 1 gemset per application, thus avoiding the issues described above as for each application I will have only a single version of rails installed. Even better, switching is shell-local and only persists for a single shell instance. This means that I can have two different applications with two completely different versions of Rails running at the same time in different terminal sessions without issue.

As an added bonus, because RVM isolates at the rubygems system level (using environment variables), your application doesn’t actually need to know or care about conflicts from gems that the application does not use.

Combining RVM and Bundler yields a great deal of flexibility and consisency. This affords you the ‘best of both worlds’, system level isolation with the ability to install gems from git repositories, and in application gem loading based on application environment.

For more information RVM’s gemsets, check out the Gemset’s section on the rvm site. For more information on Bundler, check out Bundler’s documentation.

Gemset Hierarchy

The second feature I use often is the global gemset. Each ruby interpreter installation comes with two gemsets out of the box – the default (blank) gemset (e.g. ree-1.8.7-2010.02) and the global gemset (e.g. ree-1.8.7-2010.02@global). When you use any gemset, rvm not only sets the gem home to a uniq directory for the given gemset (ensuring gems are installed in the correct place) but it also sets GEM_PATH.

Much like PATH, GEM_PATH is a colon separated list of directories that rubygems uses to look up gems when requiring them. By installing a gem to the global gemset for any ruby, e.g. ree-1.8.7-2010.02@global, it will automatically be made available (including it’s binaries) inside both the default gemset and any user-defined gemsets. E.g.,

  • ree-1.8.7-2010.02
  • ree-1.8.7-2010.02@bighelpmob
  • ree-1.8.7-2010.02@tedxperth

Will all have access to gems installed in ree-1.8.7-2010.02@global.

This comes in super handy for things like awesome_print, wirble, bundler, git-up, homesick – Namely, gems you want available in every environment.

Unfortunately, bundler currently does not support multiple items in BUNDLE_PATH. We have hope it will be added in the future but for now gems you want shared between apps using bundler, you’ll get some duplication.

Default Global Gemset Contents

As an added bonus along side the global gemsets, rvm provides a way to declare a file which tells it what gems to install initially. To do this, it uses a ruby string-based directory hierarchy (see the link below) to look for a global.gems file that rvm then imports – For example, my ~/.rvm/gemsets/global.gems (that is imported into the global gemset of all ruby interpreter installs) contains the following simple list:

rake
rdoc
awesome_print
bundler
git-up
ghost
homesick
wirble

For more information on this feature, be sure to read the Automatic Gemset Initialization page on the RVM site.

Set operations

If you are writing gems, one of the most important things you can do as a Ruby developer these days is to ensure they work on all of the major implementations. At the moment, for most gem developers you should generally be testing your code against:

  • REE / 1.8.7
  • 1.9.2
  • Rubinius
  • Jruby

And optionally, MagLev and MacRuby. RVM provides tools making it simple to run code and commands against multiple rubies. This includes but is not limited to running Rake tasks and tests / specs. The idea being to make it as frictionless as possible to test your gem against all of the above interpreters. As an example, you can run:

rvm rake test

Which will run rake test against all of your installed ruby interpreters (using default gemset for each). You may need to do some manual setup (e.g. installing test gem dependencies) but rvm tries to make it all as simple as possible and more importantly, heavily integrated into your normal work flow whilst staying out of the way.

Along side rake, rvm also provides wrappers for many common binaries (e.g. ruby, spec and the like) plus the --json and --yaml flags which make it simple to get a summarised view of the program results. Using rvm exec, you can even perform set operations against any arbitrary command.

There is a whole lot more set operations can do and I suggest anyone using or considering using rvm read the set’s section on the rvm site. Go forth and have sets!

One of the most commonly encountered problems (since for most people, the ruby interpreter you’d normally use is distributed as a binary install) are related to external dependencies – Namely, things like readline, iconv and openssl.

In an attempt to make life easier (and in particular, work around common problems like a neutered libedit instead of readline on OSX), rvm provides the rvm package set of commands that make it easy to install sandboxed versions of these in the ~/.rvm/usr directory.

As an example, to work around the libedit vs. readline issue on OSX, you can build your ruby against readline 6.0 by running:

rvm package install readline
rvm install <ruby> --with-readline-dir=$HOME/.rvm/usr

And, as an added bonus, to automatically patch older versions of ree and 1.8.7 to respond to Control-C immediately (for example, in irb) instead of when you press enter, you can replace the rvm install command above with:

rvm install <ruby> --with-readline-dir=$HOME/.rvm/usr --patch readline-fix

Simple Ruby Upgrades

Say, for example, a new version of 1.9.2 comes out in the next few weeks and you want to automatically update your rubies to match it correctly. As of approximately rvm 1.0.0, we added an rvm upgrade command that automatically handles doing the following:

  • Installing the new ruby
  • Moving across gemsets
  • Updating wrapper scripts and aliases

The only thing you typically have to update are references in your .rvmrc’s and your passenger configuration. But, with a little forethought (e.g. creating an alias using rvm alias create), it’s entirely possible to make it so the entire upgrade is automatic.

I have personally used this feature to move from the 1.9.2 release candidate to the final patchlevel 0 release – I used rvm upgrade to simplify the process of updating each time it was bumped.

This is currently undocumented on the rvm site but documentation will be added – for the moment, in your rvm install, run rvm help upgrade and/or rvm upgrade help.

Location Matters

One of the underlying decisions related to rvm’s architecture is where it installs your rubies – In most cases, rvm will install your rubies into ~/.rvm/rubies and gems into ~/.rvm/gems. This means that you should almost never have to use sudo for commands (there are a few exceptions, most notably passenger which relies on root permission in order to bind to port 80).

This approach is simple on the scale of things but also brings a lot of freedom – for one, it means you are free to experiment with a Ruby / RVM setup, wiping it away when you’re done with a simple rm -rf ~/.rvm && mv .rvm-original .rvm.

.rvmrc files

All of this is fine and dandy, but when you still have to manually switch ruby interpreters and rubies each time you do something, it can become mildly annoying rather fast. For this exact reason RVM offers project-specific .rvmrc files – If you haven’t encountered them before, project .rvmrc’s are files that are automatically sourced into the current shell when you change (cd) into a directory containing one. These files can contain anything that is valid shell script (and to prevent RVM automatically running code you don’t want, it defaults to asking you to trust it the first time it is run) making things like project bootstrapping and configuration simple and mostly automatic after a quick setup in the project root directory:

rvm --rvmrc --create <ruby>@<gemset>

In my own projects, I use these to automatically install the Ruby if not present, create and use a project-specific gemset and then do the minimum possible required to bootstrap the new environment – in most cases, this is simply a matter of installing a few gems (e.g. for me, I install bundler via rvm gemset import).

In some cases, I even automatically run bundle install (with 1.0, if you have the gems already installed, this is very fast) hence the first time I cd into a project it essentially bootstraps the entire environment for me automatically.

Ultimately, this approach means that the Ruby interpreter and gemset switching are completely transparent to me – No matter which project I’m using, ruby and irb are available and point to the correct executable for the current project I am in. When integrated with some code I wrote for ruby summer of code, it’s even possible to have passenger automatically use this .rvmrc file to automatically change your application’s gemset at run time.

For more information on .rvmrc files, check out the rvmrc page and the Project Workflow page on the rvm site. See RVM’s passenger integration page page for more details on gemsets with passenger.

Conclusion

I hope that you have found at least one new or useful thing about RVM. RVM has been invaluable to me as a developer on multiple open source projects over the last several months. It makes it simple for me to do things that are otherwise harder or less flexible and generally stays out of my way.

Why Your Clients Should Upgrade Their Web Browsers

Posted in Industry Trends, Inside TFG, Tips and Tricks

I think the IT industry has a tendency to push our clients and users to upgrade, or change things to suit our requirements or desires. Often times the reasons may be rooted in practicality, but as good IT workers tend to develop heuristics for problem solving they can sometimes find it hard to explain their reasoning.

A good example is browser upgrades. We all know it’s a worthwhile suggestion, and having the latest browser is the best option in most cases, but explaining that to a user or client can be difficult. It can be especially difficult if you don’t have face time with a user; the most common situation in the web environment.

Telling a user that the site works better in Firefox 3 or Safari 4 will, perhaps, just lead to the user finding a site that works better with their browser instead. It would be nice if we tried a different tact, and in doing so helped not only ourselves, but the wider community of developers. After all we want the same outcome : to have our work viewed the way we intended, for the minimum amount of work. Cross browser development sucks!

I was thinking the other day that I don’t think I’ve ever heard from a developer that users should switch browsers for security reasons, or any other reason the user would care about. Users don’t care about ACID compliance, or Javascript optimisations or any other technicalities. What they do care about though is security, especially now that mainstream operating systems, manufacturers and financal institutions have gotten the word out about phishing and other vulnerabilities.

  • All the latest browsers support some form of malware protection and anti-phishing protection. This increases user security.
  • All the latest browsers concentrate on process isolation and run time optimisations. This decreases crashes and increases browsing speed.
  • All the latest browsers have been improving standards compliance. This increases the likelihood that more sites will work for the user.
  • All the latest browsers manage their own update process. The user isn’t required to remember to stay up to date in the future.
  • All the latest browsers have the latest patches and updates and latest features. This gives the user the most secure, fastest, and feature packed experience.

We all know that unless you have a very good reason, it’s silly to be running an old browser. However when was the last time you explained the benefits for them personally? Increased security, increased stability, increased speed, more compatibility with other sites and the latest features available.

If you find a better way to sell your clients on spending 5 minutes to upgrade their browser then make sure you spread the word. Every user you convert is a win for the web community and the internet in general!

Embedding Dynamically Generated Images in Emails with Actionmailer

Posted in Code, Ruby on Rails, Tips and Tricks

We recently had to embed images into our emails that were being sent with Actionmailer, and as such we turned to the inline_attachment plugin to achieve this. It very easily parses your mail output and overrides the ActionView path_to_image helper to attach the file and create an appropriate path to the attached image inside the email while splitting your mail into appropriate parts as necessary.

What we needed to do though was embed a dynamically generated image into the email. The image didn’t exist on the file system previously so we couldn’t use the standard image_tag helper that inline_attachment was patching.

So we extended ActionView to include a new tag helper attach_image_file that uses the existing inline_attachment part management and just a properly referenced image. The methods from inline_attachment take care of attaching the file to the email and splitting the mail content into the appropriate parts.

Here’s my code. I just added it into my initializers directory :

module ActionView
  module Helpers
    module AssetTagHelper
      def attach_image_file(file)
        @part_container ||= @controller
        if @part_container.is_a?(ActionMailer::Base) or @part_container.is_a?(ActionMailer::Part)
          basename  = "barcode.gif"
          ext       = basename.split('.').last
          cid       = Time.now.to_f.to_s + "#{basename}@inline_attachment"

          @part_container.inline_attachment(:content_type => "image/#{ext}",
                                        :body         => file,
                                        :filename     => basename,
                                        :cid          => "<#{cid}>",
                                        :disposition  => "inline")

          return ""
        end
      end
    end
  end
end

It did what we need, and allows us to properly inline a dynamic image. You could use similar code to inline pretty much anything that your target mail reader supports. Apple Mail for instance may provide PDF previews.

Part 3 – Maximising the effect of your Facebook fan page

Posted in Industry Trends, Tips and Tricks, Websites or Tools

Read Part 2 of our series in case you missed it.

Let us pick up where we left off last time. I had just begun examining the Facebook fan pages, and how you can apply them to your business. In particular we discussed the advertising platform. Advertising is just one aspect of these pages that can really drive your business. Let’s discuss the other potential areas of benefit now.

Company Announcements

If you have an important announcement to make, what’s the quickest and easiest way to get that information to your customers and followers? With a Facebook status update of course. Lets say you want to advertise your Holiday trading hours, or you have just launched a new product, or service. In 30 seconds you could have pushed this information to your customers. Anyone who follows you on Facebook will see this message on their home page.

Customer stories

You can write status updates that encourage customers to write back to you. Writing an engaging status update is a good way to start discussions. Once you get some traction with this method, you will soon be cultivating a community around your fan page. The more interactions with your page, the more likely it is that your page will get noticed. You know the rest.

This can also give you some valuable feedback on exactly how you deal and respond with your customer base, or with what you are doing in the market place.

Surveys/competitions

This is one area where having a fan page can really work for you. Coordinating a fan-centric competition is relatively straightforward, and this can be a great way to generate some buzz around your brand. The frameworks are already in place for you, and you just need to know what sort of competition you want to run, and then you can be on your way. The viral nature of sites like Facebook mean that your competition can get large exposure, without you having to spend the earth.

Likewise, conducting a survey can be a great way to improve areas of the business, and encouraging fans to participate in your surveys is as simple as setting up the survey, and posting a status update.

You can also use Facebook Ads to generate interest to either your competition or survey.

Linking to blog

If you’ve just written a great blog post, you’ll want to get it in front of as many eyes as possible. Having sustained readers on your blog is always a desired outcome, and Facebook gives you an opportunity to direct readers to your blog. When you write your post, make sure you follow it up with a succinct and catchy status update attaching the link to the blog. That way your fans will be driven to your blog and hopefully become regular readers.

Instant feedback

This is probably one of the key areas that Social Media can have a real impact on your business. The moment you do something that someone loves or hates, you’re going to hear about it. Having this sort of feedback at your fingertips is something that money can’t buy. We’re moving in to a world where you will be connected with your customer base (and critics) whether you like it or not. You can use this to your advantage.

Hopefully you’re really starting to see the potential for this in your areas of business. If you need any more information or have any questions on just how Facebook can expand your business, don’t hesitate to get in touch.

Next week, we’ll be moving on to Twitter and how you can leverage that platform for your business.

Twitter

Great web stats at @petrescue , the driving force behind the rebuild of their systems by @frontiergroup . http://t.co/MTvfoxnU

@frontiergroup about 2 weeks ago #

Search Posts

Featured Posts

Categories

Archives

View more archives