Jan 19, 2013

Increase main partition size in Ubuntu within VMWare Fusion

I should have known better than to start with just 10GB.

VMWare Fusion: Assigning IP Addresses for NAT-Configured VMs via DHCP and Port Forwarding

Great if you work with a desktop and a laptop. You can keep all the VMs in one place and just connect to them from the other machine.

sudo vi /Library/Preferences/VMware Fusion/vmnet8/nat.conf

Jan 31, 2011

Manually printing a Drupal view with PHP

In order to manually print a view you can run the following code:


There are some cases where you may want to alter the view before it is transformed into HTML. You can achieve that with the following code.

    //Get the view and push it to its pre-execution state
    $my_view = views_get_view('my_view_machine_name');
    //Do whatever you want to alter the view object now
    //For example, pass arguments to it.
    $my_view->args[] = 1;
    //Execute to get results filled in
    //Then return the view as HTML

Jan 30, 2011

Install Drush and Drush Make install on Mac OS X Snow Leopard

  • Download the latest version of Drush and move the unacrchived folder, "drush," to your Applications folder (or any folder of your choice).
  • Open the Terminal application.
  • Open the "drush" folder and drag the file named "drush" into an active terminal window.
  • Make the drush file executable with this command.

chmod u+x path/to/drush

  • In the terminal go to your home directory and open '.profile' in the editor of your choice. The file is invisible so you will need a text editor that can open hidden files.
  • Add the path of the folder that contains the drush file to your PATH. Changing something like this:

export PATH=$PATH

to this:

export PATH=/Applications/drush:$PATH

  • Once you have Drush installed run the following command to install Drush Make:

drush dl drush_make

Jan 29, 2011

Make it better

Some really cool text animation. I really like the sound work as well.

Make it better from Sebastianbap on Vimeo.

Oct 14, 2010

Google Fixes the Untitled Document Problem

The combination of an incomplete understanding of the title tag and it being set to "Untitled Document" by default in new Adobe Dreamweaver documents has led to thousands of pages being posted on the web with no descriptive title. Since search engines use the title tag as the linked text in their results many of these untitled pages were near impossible to find until now. Sawyer McFarland Media reports that Google has made a change in it's search engine to provide better title in it's results based on the the page's content.

Kudos to Google for doing the work to fix this issue for their end users. However as web site owners and developers we need to make sure we are describing our pages as accurately as possible with page titles, descriptions, and URLs.

Via Sawyer McFarland Media

Jun 22, 2010

Flash Player installer without the cruft

John Welch explains that if you look into the package contents of the Flash Player installer you will find the true installer at the following location:


This installer will not force you to quit all of your browsers.

(via John Gruber)

Feb 22, 2010

JavaScript Ternary Operator

When you have a simple if...else statement like the following:

    var a = true;
    if (a == true) {
    else {

It may be best to use the ternary operator.

    var a = true;
    //(Test) ? (if) : (else);
    (a == true) ? alert("True") : alert("False");

References: Javascript (JS) Tutorial - Ternary Operators code, syntax ccondition, JavaScript Ant - The Conditional Operator (Ternary Operator)

Feb 15, 2010

Parse class values: Retrieving custom meta data from an HTML element's class name

The problem

I had HTML that had class information on each object that signified how deeply it was indented (e.g. "indent-5"). I needed to use the value of the indent to make various comparisons in another. To solve this problem I created a simple utility function.

NOTE: All functions were written with a dependancy on jQuery.


I created an array of the object's classes by splitting the string at the instance of a space. I made the assumption that the indent class would always be the first and accessed the first element of the object class array I created. I then took this string and removed the "indent-" part and parsed the rest as an integer. The result was an integer I could use for numeric comaprisons in my main function.

function parseObjLevelNumber(obj) {
  var objClass = $(obj).attr("class");
  var objClassArray = new Array();
  objClassArray = objClass.split(" ");
  var objLevel = parseInt(objClassArray[0].replace(/indent-/, ""));
  return objLevel;

Revision 1 - RegEx

When I looked at my code again I realized that my original function could be made more generic so that it could be a general purpose utility function. Since the new function could not assume an object class array position or the string that should be removed I made these two values arguments to the function.

When first writing this I ran into a minor problem when trying to use the RegEx string as a normal string. Apparently you need to convert a string into a RegEx variable if you want it to be used as a variable.

    function parseClassValueRegEx(obj, pos, attrName) {
        var objClassArray = $(obj).attr("class").split(" ");
        var attrNameRegEx = new RegExp(attrName);
        var classValue = objClassArray[pos].replace(attrNameRegEx, "");
        return classValue;

Revision 2 - JSON

As much as the RegEx version of the function was better it still forced one to make assumptions about what position in the array the item you wanted was. I removed position as an argument and tried to find a way one could access the class attribute by name. For example if you wanted the "indent" level of an object you would only need to ask for "indent."

I decided that the best way to do this would be to create a JSON object that contains all the class attributes a element has.

I first set up my empy JSON array. I then loop through the values in the object's class array (e.g. "indent-1") and I split those values against the "-" to create another array called "keyValue." Then I push values into the JSON array with the assumption that the prefix, "[0]," will always be the key and the suffix, "[1]," will always be the value.

    function parseClassValue(obj, attrName) {
        var objClassArray = $(obj).attr("class").split(" ");
        var objClassValues = { };
        for (var i in objClassArray) {
            var keyValue = objClassArray[i].split("-");
            objClassValues[keyValue[0]] = keyValue[1];
        var classValue = objClassValues[attrName];
        return classValue;

Jan 18, 2010

Prevent the loss of unsaved data with OnBeforeUnload

Sometime last year I learned about the onUnload event, which is available on the "window" object. Today I thought I could use it to prevent a user from leaving a web page if, for example, there is unsaved data that will be lost. I quickly realized that it would not work. The "onunload" event happens after the user has already "unloaded" the page. I needed an event that fired before the user action and naturally came upon, "onBeforeUnload."

The onBeforeUnload event is Microsoft specific and is not included in the W3C specification but fortunately seems to be a de facto standard in the modern web browsers. Support is in the latest versions of FireFox, Safari, Chrome and Internet Explorer. Below is a code example and screenshots of resulting dialog boxes in Safari and Google Chrome.

window.onbeforeunload = function() {
    return "There is unsaved data on this page.";

Safari Dialog

Chrome Dialog

Safari's dialog default formatting is close to an exact match of all other browsers. Google Chromem however, displays a much smarter dialog. It didn't take much thought to realize that they did this for their web applications. If for example, you try to reload an unsaved e-mail in Gmail you will trigger an "onBeforeUnload" event.

To clear the beforeUnload event just set the value of it to null as follows:

window.onbeforeunload = null;

See the example.


Subscribe to Front page feed