Archive for the ‘Quick Tips’ Category

TIP: Hiding the Windows Live Messenger icon

No Comments » by Jon Hibbins on 14 January 2010
Filed under: Platform, Quick Tips, Windows

If you use Windows Live Messenger a lot, you’ll have noticed that the icon now resides on the taskbar, where you can easily change status and quickly send an IM to someone. If you prefer to keep Windows Live Messenger in the system tray, where it’s been for previous releases, just close Windows Live Messenger, edit the shortcut properties and set the application to run in Windows Vista compatibility mode.

T-SQL Date Only Function

No Comments » by Jon Hibbins on 24 November 2009
Filed under: Code, Database, MSSQL2005, MSSQL2008, Quick Tips, SQL Server, Software Development, TSQL

CREATE FUNCTION [dbo].[DateOnly] (@Date DATETIME)
RETURNS DATETIME
BEGIN
    RETURN DATEADD(d, DATEDIFF(d, 0, @Date), 0)
END

TSQL Last Day Of The Month

No Comments » by Jon Hibbins on 23 November 2009
Filed under: Code, MSSQL2005, MSSQL2008, Quick Tips, SQL Server, TSQL

CREATE FUNCTION [dbo].[LastDayOfTheMonth] (@Date DATETIME )
RETURNS DATETIME
BEGIN
    RETURN dateadd(ms, -3, DATEADD(mm, DATEDIFF(m, 0, @Date) + 1, 0))
END

4 Coding tips

No Comments » by Jon Hibbins on 26 August 2009
Filed under: .NET, C#, Code, Java, Objective-C, PHP, Quick Tips, Software Development

1: Delete It !
If a chunk of code comment or class is not used, don’t comment it out, just delete it.

2: Write clear code.
“make sure you document code that’s hard to understand”. Question: why is the code hard to understand?

3: Comment
Comments can indeed be useful but mostly as a summary of action

4: Don’t Repeat Yourself
Duplication is bad. If you have more than 4-5 lines of code that do the same thing in a single class, refactor to remove duplication.

Check if a Javascript function exists

1 Comment » by Jon Hibbins on 22 March 2009
Filed under: Code, Javascript, Quick Tips

If you want to check if a Javascript function exists before you attempt to call it and get an error try:

if(typeof window.Function == 'function') {
// function exists
Function();
}

SVN Port TCP Port is 3690

1 Comment » by Jon Hibbins on 12 February 2009
Filed under: .NET, C#, Code, OSX, Platform, Quick Tips, Software Development, Unix/Linux, Windows

If you need to access SVN remotely, by default it runs on port TCP port 3690, so you need to make sure it is open in your firewall etc.

Search Stored Procedures

No Comments » by Jon Hibbins on 5 December 2008
Filed under: Code, Database, MSSQL2005, MSSQL2008, Objective-C, Quick Tips, SQL Server, TSQL, iPhone

Ever had the need to search stored procedures to find redundant tables or text that needs replacing or re-factoring ?

Here’s a script to help (Sorry for the cursor, I’m sad with myself for using it :-( )

-- Search string
DECLARE @SearchString nvarchar(50)
SET @SearchString = 'Search String'
 
-- Required Declares
DECLARE @getdbname sysname
DECLARE @sqlstm nvarchar(1000)
DECLARE SeachCursor cursor FOR 
-- Get All The Names into the SeachCursor
SELECT '['+name+']' FROM [master].[dbo].[sysdatabases] ORDER BY name 
OPEN SeachCursor
-- Add the Search Pattern
SET @SearchString = '%' + @SearchString + '%'
--Get the first Name
FETCH NEXT FROM SeachCursor INTO @getdbname
WHILE @@FETCH_STATUS=0
	BEGIN
	--set the statement to define the search condition, with variables
	SET @sqlstm = '
	SELECT [SP].[Specific_Catalog] AS [Database_Name], [SP].[Routine_Name] AS [Stored Procedure Name],[SP].[Routine_Definition] AS [Routine_Definition]
	FROM '+ @getdbname+'.[Information_Schema].[Routines] AS [SP]
	WHERE PatIndex('+''''+@SearchString+''''+', [Routine_Definition]) > 0'
	--Execute the Query
	EXEC (@sqlstm)
	FETCH NEXT FROM SeachCursor INTO @getdbname
	END
--Close the Cursor and Deallocate it from memory
CLOSE SeachCursor
DEALLOCATE SeachCursor

iPhone Developer Provision Issue on Device

7 Comments » by Jon Hibbins on 27 August 2008
Filed under: Objective-C, Quick Tips, iPhone

After a number of compile to iPhone device issues, specifically: “entitlement ‘application-identifier’ has value not permitted by provisioning profile” and “Command /usr/bin/codesign failed with exit code 1″, I have worked out you can have one and only one developer provision and developer application on the iPhone at a time otherwise you get installation errors etc…

I also had to have the correct Bundle Identifier in the Info.plist file and make sure the ‘Code Signing Identity’ and ‘Code Signing Provisioning Profile’ was also correct.

Hopefully this is useful to someone, Good Luck!!!

Objective-C Mod Command

No Comments » by Jon Hibbins on 22 August 2008
Filed under: Code, Objective-C, Quick Tips, Software Development, iPhone

If you are looking for the Objective-C Mod Command then look no further

To get the equivalent of a = b div c then :

a = b % c

Quick Tip: C# Current Application Version

2 Comments » by Jon Hibbins on 11 August 2008
Filed under: Quick Tips

Quick Tip: C# Current Application Version:

System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;