Clean your SQL Server database!

Here are some lines of code that can help clean your database from test data so you can start over with a fresh canvas.

/* Disable constraints and triggers (if any) */

exec sp_MSforeachtable ‘ALTER TABLE ? DISABLE TRIGGER ALL’

/*Perform delete operation on all table for cleanup, or you can put specific delete <tablename> commands if you want to only do a subset of deletions

exec sp_MSforeachtable ‘DELETE ?’

/*Enable Constraints & Triggers again*/
exec sp_MSforeachtable ‘ALTER TABLE ? ENABLE TRIGGER ALL’

/*Reset Identity on tables with identity column*/
exec sp_MSforeachtable ‘IF OBJECTPROPERTY(OBJECT_ID(”?”), ”TableHasIdentity”) = 1 BEGIN DBCC CHECKIDENT (”?”,RESEED,0) END’

Unable to cast object of type ‘ Issue

I came across this error:

System.InvalidCastException: Unable to cast object of type ‘<TakeIterator>d__3a`1[Class]’ to type ‘System.Collections.Generic.List`1[Class]’.

This occured when trying to use the Take extension (list.Take(n)) from a generic list of objects.   The problem is when you use the Take extension, it returns a new sequence (


I got around this issue by using:

list.Take(8).ToList() which gets the new sequence and then converts back to the generic list.

References: live! is now live!  this site loads in my personal photos of christchurch from flickr and loads in my tweets + all tweets that have the keyword “christchurch”.

It uses jquery for scrolling through the thumbnails using your mouse wheel and various jquery plugins for twitter and flickr.

Check it out!

List of JQuer plugins used:

jQuery Flickr – jQuery plug-in

jQuery mousewheel plugin

jQuery Twitter plugin

jCarouselLite image slider

Also, try out which was setup by Verb..thanks to Verb for allowing me to share this idea.

JFactory::getDate() doesn’t automatically add offset

By default, calling JFactory::getDate() doesn’t automatically apply the timezone offset.   The default date/time is GMT.

By using the following code, you can set the offset from the global joomla configuration file

$thisJApp = &JFactory::getApplication();
$thisJDate = JFactory::getDate();
$thisJDate ->setOffset($thisJApp ->getCfg(‘offset’));
echo $thisJDate->toFormat(“%A %d %b %Y”);

If you want to set the date from a logged in user you can try:


$JUser =& JFactory::getUser();
$JDate = JFactory::getDate();
echo $JDate->toFormat().'<br>';
echo ‘offset=’ . $JDate->getOffset() . ‘<br>';