Monday, 18 January 2010

TSQL: Order by Null OR zero first

The snippet below will order your values with any values as NULL or Zero first.

SELECT event_ID, event_title, event_date
FROM table_events
ORDER BY case when event_date is null or event_date = 0 then 1 else 2 end, event_date DESC

If you use union, you'll need to wrap your union statement within another SELECT before you can use the ORDER BY CASE statement above.

For example:

SELECT *
FROM
(
SELECT A, B, C
FROM Table1
UNION
SELECT X, Y, Z
FROM Table2
) X
ORDER BY A, B, C

Friday, 15 January 2010

Markdown: Simplifying HTML

This is an interesting concept, simplifying HTML so you can markup a document as easily as typing up a word document.

Wednesday, 23 December 2009

TSQL: Granting Permissions

GRANT INSERT ON table
TO sqluser
GO

GRANT UPDATE ON table
TO sqluser
GO

SQL Profiler: Wild Cards

When adding wild cards to filter by textdata column, be sure to include the percentage characters around your text string.

For example:

%WHERE bass = null%

Friday, 18 December 2009

TSQL: Newline, Carraige returns into char or varcahr field

To insert new line + carraige returns (\r\n) into a char or a varchar field you'll need to convert the to char(13)+char(10) before running your UPDATES or INSERTS.

Tuesday, 15 December 2009

Sysadmin: cURL

Found a very powerful commandline tool for transferring data across a multitude of protocols.
"curl is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction."
http://curl.haxx.se/

Adobe AIR: Getting Started

Adobe AIR
" Adobe AIR is a cross-operating system runtime that enables you to use your existing HTML/Ajax, Flex, or Flash web development skills and tools to build and deploy rich Internet applications to the desktop.

Adobe AIR applications support native desktop integration, including clipboard and drag-and-drop support, local file IO, system notification, and more. " - http://www.adobe.com/devnet/air/

Essentially, AIR allows you to easily package up your browser based web application created in HTML/AJAX/Flash/Flex and deploy it to clients as a desktop application.

Getting Started

To start you'll need to download the Adobe AIR SDK. The SDK is available from Adobe's website. The SDK contains the necessary javascript libraries and also a debugger, packaging utility for creation of installation files AND self-signed certificate generator. There is no IDE that comes with the SDK. Current version is 1.5.3

For an IDE you can use any text editor, but if you wish to have a GUI interface, the options are to use Aptana Studio or Adobe Dreaweaver CS3/CS4 with Adobe Air Extensions for Dreamweaver.

A step by step guide to writing your first Hello World AIR application using any text editor can be found here.

http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ecc.html

Interesting

Wednesday, 9 December 2009

JQUERY: Get select value and text

Get Value:

$('#selectList').val();

Get Text:

$('#selectList :selected').text()

Get Multiple Text:

var foo = [];
$('#multiple :selected').each(function(i, selected){
foo[i] = $(selected).text();
});

Thursday, 19 November 2009

XML, XSLT - Equivalent CASE statement in XSLT

 1: <poem author="jm" year="1667">
 2:  <verse>Seest thou yon dreary Plain, forlorn and wild,</verse>
 3:  <verse>The seat of desolation, void of light,</verse>
 4:  <verse>Save what the glimmering of these livid flames</verse>
 5:  <verse>Casts pale and dreadful?</verse>
 6: </poem>
 7:  
 8: <xsl:template match="poem">
 9:  
 10:  <xsl:choose>
 11:  <xsl:when test="@year < 1638">
 12:  The poem is one of Milton's earlier works.
 13:  </xsl:when>
 14:  
 15:  <xsl:when test="@year < 1650">
 16:  The poem is from Milton's middle period.
 17:  </xsl:when>
 18:  
 19:  <xsl:when test="@year < 1668">
 20:  The poem is one of Milton's later works.
 21:  </xsl:when>
 22:  
 23:  <xsl:when test="@year < 1675">
 24:  The poem is one of Milton's last works.
 25:  </xsl:when>
 26:  
 27:  <xsl:otherwise>
 28:  The poem was written after Milton's death.
 29:  </xsl:otherwise>
 30:  
 31:  </xsl:choose>
 32:  
 33: </xsl:template>

XML, XSLT - Beginner's Guide

Create 2 files, 1 XML the other XSLT.
Populate the XML file with your XML data.
Reference your XSLT by using the following syntax.

1: <?xml-stylesheet type="text/xsl" href="poem.xslt"?>

Host your XML file on your webserver and open the XML file in your browser to view the transformed XML.