Monday, 31 May 2010

HTML Email: Problems with uniformity across desktop and web based clients

There seems to be a lot of quirks when rendering HTML/CSS content in email clients whether they be desktop or web based clients.

This article is useful when comparing tags that are supported by various clients.


And here's a code validator from mailchimp:


Before gmail became popular, alot of developers where putting the style tag inside the body tag, however since gmail now strips this out, unfortunately, the only sure way to handle CSS in your email is to do them in-line.

Tuesday, 27 April 2010

TSQL: Comma Delimited List from column values

-- SQL 2000, Retrieve desired data
-- With SQL 2000, we will create a User Defined Function to do the concatenation.
-- While this solution can also be used with SQL Server 2005/SQL Server 2008,
-- the previous suggestion is more efficient.
CREATE FUNCTION dbo.fnMakeCommaDelimitedList
( @TempID int )
RETURNS varchar(1000)
AS
BEGIN
DECLARE @TempTable table
( TempValue varchar(20) )
DECLARE @TempList varchar(1000)
SET @TempList = ''
INSERT INTO @TempTable
SELECT DocumentId
FROM TechnicalDocSubscriberDoc
WHERE SubscriberId = @TempID
IF @@ROWCOUNT > 0
UPDATE @TempTable
SET @TempList = ( @TempList + TempValue + ', ' )
RETURN substring( @TempList, 1, ( len( @TempList ) - 1 ))
END

-- Usage
SELECT
ID, contactname, companyname, email, email, companyadd, suburb, state, postcode, contactphoneno,
SubscriberList = dbo.fnMakeCommaDelimitedList( ID )
FROM technicaldocsubscriber
GROUP BY ID, contactname, companyname, email, email, companyadd, suburb, state, postcode, contactphoneno

-- Clean up
DROP FUNCTION dbo.fnMakeCommaDelimitedList

Friday, 16 April 2010

Chrome: Proxy Pac

Our company utilise a proxy pac file for internal users to access the outside world.

For chrome you'll need to add the following extensions:

"drive:\chrome install location\chrome.exe" --proxy-pac-url="http://proxypacurl/proxy.pac"

OTHER proxy example settings:

You will have to use command-line flags to override.
These are the ones available:

--no-proxy-server
--proxy-auto-detect
--proxy-bypass-list=XXX
--proxy-pac-url=XXX
--proxy-server=XXX

See the source code for documentation.

For example:

Send all traffic through the SOCKS 5 server "foobar:1080"
chrome --proxy-server="socks5://foobar:1080"

Send all traffic through the HTTP proxy server "foo:6233"
chrome --proxy-server="foo:6233"

Use the custom PAC script to resolve proxy servers:
chrome --proxy-pac-url="file:///home/foobar/tmp/myscript.js"

Thursday, 8 April 2010

ASP: HTTP Headers for CSV filetypes

// these headers avoid IE problems when using https:
// see http://support.microsoft.com/kb/812935

header("Cache-Control: must-revalidate");
header("Pragma: must-revalidate");

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=$filename.csv");

Monday, 1 March 2010

WCF: svclog viewer SvcTraceViewer.exe

Fire up SvcTraceViewer.exe located under:

C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin

OR just run via your VS console window and type in "svctraceviewer"

VS2008: The breakpoint will not currently be hit. No symbols have been loaded for this document.

My VS instance crashed while I was trying to add a WCF service. Had to terminate the process. But when I restarted, I noticed strange behaviours with the IDE. I could no longer debug my project and would receive an error stating that "The breakpoint will not currently be hit. No symbols have been loaded for this document."

A bit of googling found this article.

The solution for me was to:

1. start debug
2. ctrl+alt+u.
3. Look for project in list and note path.
4. Close VS.
5. In explorer navigate to cache location in step 3, delete location of the cache usually under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\xxx
I just deleted everything in root.
6. Deleted both bin and obj folder of each project.
6. Restart VS
7. Rebuild




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%