Tag: code

Recursively remove .DS_Store files

If your working on a coding project and your submitting it to version control, heres how to remove the meta-schmeg that OS X leaves around:

find . -name '*.DS_Store' -type f -delete

If your using GIT as your versioning control system then I’d suggest making a .gitignore file in the root of the project after running this command and before you git init to save yourself some bother.

Compare two folders’ contents

On a Unix/Mac you can use:
diff -rq folder1 folder2

Ruby on Rails on Mac OS X in 5 minutes

So I just discovered that Leopard comes with a version of Ruby on Rails (RoR) pre-installed. The only problem is its a bit dated but there is a command-line one-liner to update it all no sweat with RubyGem (the Ruby package manager):

Continue reading »

handy Javascript debugging function

Actually taken from the JS v1.4 Guide and modified to be a little more useful:

function showme(obj, obj_name) {
   var result = ""
   var null_list = "";
   obj_name = (obj_name != '')? obj_name: 'obj';
   for (var i in obj) {
		if(obj[i] != null && obj[i] != '')
			result += obj_name + "." + i + " = " + obj[i] + "\n";
		else
			null_list += i + ", ";
   }
   return result + "\n NULL propertys: \n" + null_list;
}

Pass it an object you want to see the properties of and it will show them to you. Like so:

alert(showme(item[i]));

Why WordPress can’t be shared

Aim

I have about 6 different WordPress installs on my host. One for me, one for my company TSD and 3-4 for friends and family on sub domains. The issues I have with it are:

  • Upgrading is a pain
  • Sharing plugin-ins is a pain
  • Gets worse for every new blog I install

So I tried to modify the WP code so that it could be installed (and upgraded) in one place and then used for many blogs on the same server. I found out that as it stands WP‘s design doesn’t scale very well. I guess it wasn’t meant to, but when you work with it you get the feeling it could…

Continue reading »

Regular Expression to remove HTML tables

Just figured out this regular expression to remove all tables from a HTML document:

</?table[^>]*>|</?tr[^>]*>|</?td[^>]*>|</?thead[^>]*>|</?tbody[^>]*>

Extremely useful for cleaning up prehistoric mark-up with a text editor that supports regular expression find-and-replace searches.

And to go all the way, this one removes font tags too:

</?table[^>]*>|</?tr[^>]*>|</?td[^>]*>|</?thead[^>]*>|</?tbody[^>]*>|</?font[^>]*>