Safari 5.0.5 won’t play HTML5 video

2012.03.30 | HTML5, Video, Web Development | ,

Trying to play HTML5 video in Safari but getting a blank video screen?  Possibly with 0:00 second video length?

I posted the solution over on SO but basically this head scratcher can be solved by using a full URL for the <video>’s src attribute.  If you don’t, Safari doesn’t even try to fetch the video.

I think this bug is only present in very specific versions of Safari (possibly just 5.0.5).

filesystem: /etc/mtab exists in filesystem & initscripts: /etc/profile.d/ exists in filesystem

2012.03.17 | Linux | ,

Using Arch Linux and getting the following error in pacman?

error: failed to commit transaction (conflicting files)
filesystem: /etc/mtab exists in filesystem
initscripts: /etc/profile.d/ exists in filesystem
Errors occurred, no packages were upgraded.

There’s actually two problems here.

First, delete /etc/profile.d/  See here.

The second issue can be resolved by passing ‘–force’ into pacman.  See here.

“Object # has no method ‘isXDomain'”

2012.03.11 | Javascript | , , , ,

If you’re using Socket.IO with NodeJS, Firefox reports the error “this.isXDomain is not a function” while Chrome complains with “Object #<Object> has no method ‘isXDomain‘”.

The solution to this problem has nothing to do with Cross Domain policies, it just happens to be the first place the Socket.IO script fails when you forget to create the socket with the ‘new’ keyword.

So change your code that looks like this:

this.socket = io.Socket('localhost', {port: 8888} );


this.socket = new io.Socket('localhost', {port: 8888} );

SCRIPT438: Object doesn’t support property or method ‘bind’

2012.03.08 | Javascript, Web Development | , , , ,

The problem: Internet Explorer 8 and below don’t support the ‘bind’ method (not to be confused with jQuery’s .bind()).

To fix, simply add the .bind method to the Function prototype.  Instructions to do that can be found here.

if (!Function.prototype.bind) {
 Function.prototype.bind = function (oThis) {
 if (typeof this !== "function") {
 // closest thing possible to the ECMAScript 5 internal IsCallable function
 throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");

var aArgs =, 1),
 fToBind = this,
 fNOP = function () {},
 fBound = function () {
 return fToBind.apply(this instanceof fNOP
 ? this
 : oThis || window,

fNOP.prototype = this.prototype;
 fBound.prototype = new fNOP();

return fBound;

jQuery function to iterate and sum over a selection of elements

2012.02.26 | Javascript | , , ,

I thought this was kind of clever so I’m posting it here.  Basically what we want to do is sum the widths of a bunch of elements with a certain class name.  Here’s the code:

var totalWidth = $('.class-name').toArray().reduce(
  function(a,b) { return a + $(b).width() },

Read up on Javascript’s reduce functionality if you’re unfamiliar, as it is something many languages have and is quite useful.

The “.width()” function is just an example (so in this case it would sum the widths of all .class-name elements).

Ruby on Rails unit test: cannot find table error

2012.01.18 | Rails, Ruby | ,

If your Ruby on Rails unit tests complain about not being able to find a table after you’ve added a new model, it just means you forgot to prepare the test database with the latest data.  The error looks like this:

ActiveRecord::StatementInvalid: Could not find table ‘yourtablenamehere’

To fix, just run:

rake db:test:prepare

and then re-run your test.

Git: Remove all deleted files from git repository

2012.01.17 | Version Control | ,

Let’s say you’ve deleted some files that are being tracked in git, and you want to remove them entirely from git.  Find the solution here.

Error in rake db:migrate: rake aborted! uninitialized constant Rake::DSL

2012.01.14 | Ruby | , ,

I’ve never had this issue before, but I recently started using rvm and for whatever reason got the following error when trying to do rake db:migrate

rake aborted!
uninitialized constant Rake::DSL
/usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2482:in `const_missing’

After googling around and trying a bunch of convoluted solutions (many which addressed a broken 0.9.0 build of rake), I found that adding the following line to my Rakefile fixed everything:

require ‘rake/dsl_definition’

Reload your VIM .vimrc file without exiting the vim editor

2012.01.13 | Vim | , ,

If you’re mucking about with your .vimrc file and want to test your latest changes, simply use (while editing the .vimrc file itself):

:so %

Use vi / vim to remove ^M characters from files

2012.01.12 | Vim | , ,

Sometimes you’ll be handed a file from a Windows user and it will contain a bunch of “^M” characters at the end of every line.  Removing them is easy, just run the command:


To get the “^M” properly, don’t type “^” and “M”.  Instead, type “ctrl + v”, then “ctrl + m”.