Force absolute URLs in views throughout a response

This is more tricky than it should be because url_for, asset_path, etc. all rely on different mechanisms.

Anyway, you can use the attached trait like this:

class ExampleController < ApplicationController
  does 'host_enforcement', :for => 'some_action'
end

Short explanation:

  • asset_host is used for links to stylesheets and javascripts
  • asset_host belongs to ActionController::Base -- changes are persistent and will not be reset after a request
  • rewrite_options is used by the ..._path methods in the views
    ^...

Unobtrusive JavaScript and AJAX

Attached (see below) is some code to allow using unobtrusive JavaScript on pages fetched with an AJAX call.

After you included it, you now do not use the usual

$(function() { 
  $('.some_tag').activateStuff(); 
});

any more, but instead you write

$.unobtrusive(function() {
  $(this).find('.some_tag').activateStuff();
});

that is

  • $.unobtrusive() instead of $()
  • don't do stuff to the whole page, but just to elements nested below $(this)

Normal pages work as before (your $.unobtrusive functions are ca...

Javascript Compressor - compress code online for free

Compress and obfuscate Javascript code online completely free using this compressor.

Highlighted prompt for production shells

Insert into ~/.bashrc and reload afterwards: source ~/.bashrc

PS1='${debian_chroot:+($debian_chroot)}\[\033[41;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Apple iPhone Water Damage

Below are 12 easy steps to follow if you're iPhone has experienced water damage.

RubySpec - The Standard You Trust

RubySpec is a project to write a complete, executable specification for the Ruby programming language.

stefankroes's ancestry at master - GitHub

Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord model to be organised as a tree structure (or hierarchy). It uses a single, intuitively formatted database column, using a variation on the materialised path pattern. It exposes all the standard tree structure relations (ancestors, parent, root, children, siblings, descendants) and all of them can be fetched in a single sql query. Additional features are STI support, named_scopes, depth caching, depth constraints, easy migration from older plugins/gems, integrit...

Rethinking Rails 3 Controllers and Routes | Free PeepCode Blog

The Rails router has been written and rewritten at least four times2, including a recent rewrite for the upcoming Rails 3. The syntax is now more concise.<br />
<br />
But never mind making it shorter! It’s time for a final rewrite: Let’s get rid of it altogether!

Announcing the jQuery Mobile Project | jQuery Mobile

The jQuery project is really excited to announce the work that we’ve been doing to bring jQuery to mobile devices. Not only is the core jQuery library being improved to work across all of the major mobile platforms, but we’re also working to release a complete, unified, mobile UI framework.

Mule Design Studio’s Blog: Tips On Buying Design

You’re a business, calling a business, about conducting business. Don’t be surprised when money comes up.

Selling your software in China « Successful Software

The first thing I need to say, right off the bat: Chinese users will not buy your software. Period. That does not mean that there is no money to be made, it simply means that they will not pay for your software license.

Interoperability Happens - Death to Best Practices

Computer science is about tradeoffs and hard choices. Optimizing the code or design or architecture one way means taking hits another way.

jbarnette's johnson at master - GitHub

Johnson wraps JavaScript in a loving Ruby embrace. It embeds the Mozilla SpiderMonkey JavaScript runtime as a C extension.

mynyml's holygrail at master - GitHub

The Holy Grail of testing for front-end development; execute browser-less, console-based, javascript + DOM code right from within your Rails test suite.

pivotalexperimental's jazz_money at master - GitHub

Run your Jasmine specs without a browser

Use your singletons wisely: ten years later - The Code Whisperer

While injecting the dependency appeared to make the classes more tightly coupled, it simply revealed the coupling that already existed. A was already tightly coupled to B and B to C. When we tried to inject the dependency, we made that coupling more explicit and easier to remove.

Common Programmer Health Problems

Programming is a deceptively damaging field to be in, partly because it doesn't seem like you're doing much, and also because of the attitude many programmers have toward their body. You should care about keeping yourself healthy because, when your body is in good shape, that removes "friction" from your mental capacity so that it can focus on important things rather than annoying little problems with your physical wellness.

Alex Payne — Node and Scaling in the Small vs Scaling in the Large

...you can apply every available anti-pattern and still come out the other end with a workable system, simply because the hardware can move faster than your bad decision-making.

Hoptoad and Javascript, Sitting in a Tree, S-E-N-D-I-N-G - GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS

We didn’t want to leave front-end developers in the dark when their Javascript throws errors, so we’ve added a Hoptoad notifier for Javascript!

Too Smart for Git

The problem isn't that Git is to hard, it's that smart developers are impatient and have exactly zero tolerance for unexpected behavior in their tools. While Git is the trendy thing right now, perhaps some day you will come across a grizzled developer who is using SVN, and when you ask him why, his answer won't make sense, because it's a Zen thing.

gerrit - Project Hosting on Google Code

Gerrit is a web based code review system, facilitating online code reviews for projects using the Git version control system.

When can I use...

Compatibility tables for features in HTML5, CSS3, SVG and other upcoming web technologies