Browse by Month RSS Feed
  • September 2010
  • August 2010
  • July 2010
  • May 2010
  • April 2010
  • March 2010

  • Filed under: Code, JavaScript, Life @ 8:24 pm
    // usage: myNum.roundToDecimalPlace(2); // If myNum was 152.15759, will return 152.16
    Number.prototype.roundToDecimalPlace = function(numDecimalPlaces)
    {   
      var currentVal = this;
      var multiplier = Math.pow(10, numDecimalPlaces);
      var roundedNum = Math.round(currentVal *= multiplier) / multiplier;
      return roundedNum;
    }

    Comments (0)


    xgettext woesJuly 28, 2007
    Filed under: Form Tools, Open Translate @ 1:37 am

    Boy this was a pain. Here's the UNIX command for generating a .po file from all PHP files in a folder (and subfolders).
    find ./ -iname "*.php" -exec xgettext -L PHP -j -o messages.po --keyword=_e {} \;Â

    - Note: the messages.po file needs to exist first.
    - Note: the --keyword=_e clause lets gettext know to parse strings within calls to the function named _e().

    It still produces a bunch of warnings, but I gather they're harmless.

    Comments (0)


    Filed under: Flash Image Scroller @ 9:30 pm

    A new update to the Flash Image Scroller: the scroller now has the option of passing the thumbnail information to javascript when a user clicks an image, rather than just load a new page or target a particular iframe/frame. This is a nice addition to the script, putting more control in the hands of the developer. You could use this feature for any number of things - such as keeping a log of what thumbnails a user clicks, or loading a thumbnail into a particular page element, like a div tag.

    The image scroller now includes code from the Flash / JavaScript Integration Kit written by Christian Cantrell and Mike Chambers from Adobe. This allows for full integration between Flash and javascript - very handy stuff.

    On a sidenote, Mike and Christian are now on the Adobe AIR team. I actually met Mike very briefly when he came to Vancouver earlier this month on the AIR Bus Tour. Nice chap - and small world!

    A big thanks to Digital Nemexis for sponsoring this feature.

    Comments (0)


    Filed under: Politics @ 3:08 am

    Some kindly soul has condensed the views of all the presidential candidates on a number of hot button issues into a single table for easy reference. So if you feel particularly strongly about something - like immigration reform or same sex marriage - and want to see how a particular politician sizes up so you can make a rush to judgment, look no further! Chris Dodd wants to ban assault weapons? Bloody hippy. He just lost MY vote.

    Comments (0)


    Filed under: Form Tools @ 11:16 pm

    This was something I promised to write a good year ago, but never managed to find the time.

    I've tried to make it as clear as possible. Hopefully it'll help out those developers who need to add PayPal-enabled forms on their site (and hopefully this'll placate the folks who keep asking for it!).

    Comments (0)


    Filed under: Code, JavaScript, Life @ 12:06 am

    Removes all elements from an array that have a particular value.

    Array.prototype.removeAllOccurences= function(value)
    {
      var newArr = [];

      for (var i=0; i<this.length; i++)
      {
        if (this[i] != value)
          newArr.push(this[i]);
      }

      this.length = 0;

      for (var i=0; i<newArr.length; i++)
        this[i] = newArr[i];
    }

    Comments (2)

    Next Page »