Javascript escape all single and double quotes

Posted in Javascript on May 31st, 2010 by phoenixdigital

Global replace of ‘s and or “s


    value = value.replace(/\'/g, "'");
    value = value.replace(/\"/g, """);

Tags: , , , , ,

Retrieve rows where count of linked items greater than zero

Posted in MSSQL on May 30th, 2010 by phoenixdigital

Say you have two tables where one is linked to the other by it’s ID or CODE and you only want to retrieve a list of Table1 items which have linked Table2 items. You also want to get the count of Table2 items for each.

Table1
id(int)
title(varchar)
another_id(int)

Table2
id(int)
table1_id(int)
title(varchar)
date_added(date)


SELECT t1.id, t1.title, count(t2.id) 
FROM Table1 t1
JOIN Table2 t2 ON t2.table1_id = t1.id
WHERE t1.another_id = 32
GROUP BY t1.code, t1.title
HAVING count(t2.id) > 0

Now say you want a list of Table1 with the most recent Table2 item ONLY


SELECT       t1.*, t2.*
FROM         Table1 t1
INNER JOIN   Table2 t2 
ON           t2.table1_id = t1.id
LEFT JOIN    Table2 t2later
ON           t2.table1_id = t2later.table1_id
AND          t2later.date_added > t2.date_added
WHERE        t2later.table1_id is null

Ref

Tags: , ,

Freeware DVD Authoring Tool

Posted in Windows on May 27th, 2010 by phoenixdigital

Haven’t tried this out yet but DVDFlick looks like a decent freeware DVD authoring tool.

http://www.dvdflick.net/

Tags: , ,

Change Ready Message on Networked HP Printer

Posted in Hacking on May 27th, 2010 by phoenixdigital

Nifty little trick for changing the default message on most HP printers.
Read more »

Decompilation of DLLs

Posted in Windows on May 27th, 2010 by phoenixdigital

Great little application for de-compiling windows dll files. Can be used for debugging purposes to ensure that certain methods are available. Can also be used for peeking into what a dll does.

The free version is quite powerful.

Red Gate Reflector

JQuery sortable list passing new order to code behind

Posted in JQuery on May 26th, 2010 by phoenixdigital

This useful addition to jquery will allow you to take a selection of objects and return a list of attributes on them.

I use it for returning a list of IDs from a sortable list of objects. The result is usually stored in a hidden input field and submitted when the user selects a ‘Save Order Button’ the reordering in the database is then handled by the code behind.

Read more »

Tags: , ,

Setting up a Random Playlist in iTunes

Posted in Entertainment, OS X Tips, Windows on May 25th, 2010 by phoenixdigital

This is the best playlist for making sure you listen to all of your music in your iTunes library. As soon as you get home plug your iPod/iPhone in and all songs that were played since you last synced will be swapped out for new ones.
Read more »

Tags: ,

Forcefully Delete a Partition in Windows

Posted in Windows on May 21st, 2010 by phoenixdigital

Sometime windows disk management program doesn’t want to let you delete a partition. Here is an easy way to forcefully do it.
Read more »

Using Delegates and Predicates

Posted in C# Programming on May 19th, 2010 by phoenixdigital


    public new TList<T> FindAll(Predicate<T> match) 
    {
      if (match == null)
        {
          throw new ArgumentNullException("match");
        }

      TList<T> result = new TList<T>();
      foreach (T item in this.Items)
      {
        if (match(item))
        {
          result.Add(item);
        }
      }
      return result;
    }


list.FindAll(delegate(TempAddItem t) { return t.ShortCode.Trim() == 'Test'; });

Tags: , ,

Free Australian Postcode Data

Posted in Programming, Sql on May 14th, 2010 by phoenixdigital

Handy data file of all Australian postcodes with lat and long

http://www.corra.com.au/downloads/Australian_Post_Codes_Lat_Lon.zip