• OzBargain 'My Comments' Menu Item User Script
    August 15, 2011 - 1 minute read -
    greasemonkey userscript greasemonkey ozbargain comments menu item

    This user script adds a 'My Comments' link to the main links bar on the OzBargain website, to allow quick navigation to the current logged in user's 'Comments' page. This is helpful if you like to check back for replies to comments you've made, or simply see if anyone +1'd your post.

    Tested on Google Chrome & Firefox 4/5/GM 0.9.3

    My Comments

  • Google Apps Gmail/domain setup stuck on 'Updating'
    August 15, 2011 - 1 minute read -
    apps google web domain google-apps updating subdomain

    I ran into a little stumbling block while trying to setup Google Apps gMail with a domain at one company and web hosting at another. In my case, a domain with GoDaddy and hosting with HostGator.

    The instructions Google provides are quite simple. All you need to do is update the MX records for your domain with the following:

    • ASPMX.L.GOOGLE.COM. (Priority: 10)
    • ALT1.ASPMX.L.GOOGLE.COM. (Priority: 20)
    • ALT2.ASPMX.L.GOOGLE.COM. (Priority: 20)
    • ASPMX2.GOOGLEMAIL.COM. (Priority: 30)
    • ASPMX3.GOOGLEMAIL.COM. (Priority: 30)
    • ASPMX4.GOOGLEMAIL.COM. (Priority: 30)
    • ASPMX5.GOOGLEMAIL.COM. (Priority: 30)

    GoDaddy even provides a wizard [dead] to do this, which is where things can go wrong. The wizard only works if you have your domain's DNS hosted with goDaddy. If you have your Name Servers pointing elsewhere, like your hosting provider, your MX records will remain unchanged and google apps setup will continue to report "Updating (May take upto 48 hours)" indefinitely.

    Instead, you need to update the MX records at wherever your Name Servers are pointing. Most likely in your hosting company's control panel. It makes perfect sense, but if you're doing things in a hurry it's easy to make the mistake.

  • Using Perl Regular Expressions to Replace substr Calls
    August 10, 2011 - 1 minute read -
    perl regex regular expressions characters substrings strings

    Suppose we want to format digits with commas after the 2nd and 5th digits.
    Ie. Convert 12345678 to 12,345,678

    Using substr, perl's substring method, this is achieved with:

    $old = ‘12345678’
    $new = substr( $old, 0, 2 ) . ',' . substr( $old, 2, 3 ) . ',' . substr( $old, 5, 3 );
    # result: 123,456,78

    It works and it’s fine, but perl critic will complain about the use of the numbers 0,2,3 and 5. You could go ahead define them as constants, but that’s cumbersome for trivial substr parameters.

    Using a regular expression provides another option.

    $old = ‘12345678’
    $old =~ m/([d]{2})([d]{3})([d]{3})/;
    $new .= $1 . ',' . $2 . ',' . $3;
    #result: 123,456,78

    It’s easily readable to anyone looking at your code and best of all perl critic won’t complain about it.

  • Older posts Newer posts