Feed aggregator

How to use different favicons for development, staging, and production

SoftwareAs.com - Sat, 06/07/2014 - 09:29

It’s useful to have different favicons for each environment during development, as Pamela recently pointed out. Here’s how I do it.

First, generate the images. Most graphics editor have some kind of Colorize tool and if you do it often, use ImageMagick to change colors programmatically. If you’re lucky enough to have a green brand logo, a cool combo would be traffic lights. Justsaying.

Now, set the favicons according to your environment. Should you just use /favicon.ico location or point to the location in head? The answer is both. /favicon.ico is useful for third-party plugins whose HTML you don’t control, as well as quick hack pages you can’t be bothered configuring with proper metadata. A link tag in html head is useful for revving the icon when it changes, to bust any cached version. So use both.

To set favicon in HEAD, ensure the path is dynamically generated instead of hard-coded:

HTML4 < view plain text >

  1. %link(rel="icon" href="#{favicon_path}" type="image/x-icon")

The path is generated like such as:

ruby < view plain text >

  1. def env_suffix
  2.   Rails.env.production? ? '' : "-#{Rails.env}"
  3. end
  4.  
  5. def favicon_path
  6.   asset_path "favicon#{env_suffix}.ico"
  7. end

It’s arguably bad form to use “production” strings in production, so the env_suffix nonsense above will hide it. If you don’t care about that, just call your production icon favicon-production.ico and save yourself a little hassle.

As mentioned earlier, we also want just /favicon.ico to exist. A quick way to do that is copy it when the apps starts or define /favicon.ico as a route and serve the file as favicon_path, defined above, with sufficient cache expiry time (e.g. 1 day). e.g.:

ruby < view plain text >

  1. def favicon
  2. path = ActionController::Base.helpers.asset_path "favicon#{env_suffix}.ico"
  3. send_file path, type:"image/x-icon", disposition:"inline"
  4. end

For bonus points, you might want to use similar techniques to provide overriding stylesheets for development and staging. Then you can introduce a text label or change background color, etc.

A digital DC power supply -- part 3: command control from the PC

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Guido Socher
Categories: Linux

Computer Assisted Simulation of DNA using Linux and Perl

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Carlos Andrés Pérez
Categories: Linux

Automate the creation of graphs with Graphviz

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Jean-Etienne Poirrier
Categories: Linux

LF Tip: #defines for writing portable C-code

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Guido Socher
Categories: Linux

A digital DC power supply -- part 2: the software

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Guido Socher
Categories: Linux

Book review: The Linux Enterprise Cluster

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Tom Uijldert
Categories: Linux

LF Tip: USB mice and laptops

LinuxFocus.org - Wed, 04/11/2012 - 18:35
by Guido Socher
Categories: Linux

Ovolabs Phlink not working in OS X Lion

OutOfControl - Thu, 09/15/2011 - 13:01

Worried that Ovolabs Phlink telephonic software will stop working when you upgrade to Apples OS X Lion? You have good reason to, as it won't work. Anyone who has Ovolabs Phlink will know that support seems to have been dropped many moons ago! No develop is ongoing but Ovolabs is happy to take your money, if you want to throw it at them, in exchange for their product. This is quite sad, as Ovolabs Phlink telephonic software appears to be one of the better packages out there, if you want to use your Mac as an answering machine.

This is where ThinkSoftware.net steps in. Fabien Octave from ThinkSoftware has written a small kextunload startup item that will fix the issue, and allow Phlink to run as it should. I've downloaded and installed the package, it does what it says it does, and nothing more.

The link: http://thinksoftware.net/phlink-lion.html
The forum thread at Ovolab: http://www.ovolab.com/support/forum/viewtopic.php?t=2482

PS: I noticed after the most recent update from Apple, that Phlink once again sees calls coming in, but still won't pickup. The unload of com.apple.driver.AppleUSBCDC is still needed.


Categories: Linux

Syndicate content
Comment