Skip to content

Instantly share code, notes, and snippets.

View GuildPortal's full-sized avatar

Aaron Lewis GuildPortal

View GitHub Profile
@GuildPortal
GuildPortal / gist:3118695
Created July 15, 2012 21:29
SQL Function to strip HTML
CREATE FUNCTION [dbo].[udf_StripHTML]
(@HTMLText VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
@GuildPortal
GuildPortal / gist:2666331
Created May 12, 2012 12:36
Including a reference in your web.config to the GuildPortal ASP.Net controls for Bootstrap
<system.web>
<pages>
<controls>
<add tagPrefix="gp5" namespace="GuildPortal.Web.UI.Bootstrap" assembly="GuildPortal.Web.UI.Bootstrap" />
</controls>
</pages>
</system.web>
@GuildPortal
GuildPortal / gist:2647942
Created May 9, 2012 18:51
Change column type from NTEXT to NVARCHAR(MAX)
ALTER TABLE dbo.ErrorLog ALTER COLUMN [Message] NVARCHAR(MAX)
/*
In case of error like "The object 'DF_ErrorLog_Message is dependent on column 'Message'", a constraint is interfering, so delete the constraint:
*/
ALTER TABLE dbo.ErrorLog DROP CONSTRAINT DF_ErrorLog_Message;
/*
Using this method will not lose any data in the converted column, but may chew up a ton of log space (and even cause the server to run out of log space) on huge tables -- even with autogrow enabled. If it's a huge table, consider using a temp table approach.
@GuildPortal
GuildPortal / gist:2647933
Created May 9, 2012 18:49
AFTER INSERT Trigger to keep table at a specified number of rows
ALTER TRIGGER [dbo].[ErrorLog_Clean_Over_500]
ON [dbo].[ErrorLog]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @countInLog int
DECLARE @countOver500 int
@GuildPortal
GuildPortal / gist:2647923
Created May 9, 2012 18:47
Add a new Foreign Key Constraint Without Validation of Existing Data
ALTER TABLE [ChildTableName] WITH NOCHECK ADD CONSTRAINT FK_[ChildTableName]_[ParentTableName] FOREIGN KEY ([ChildFieldName])
REFERENCES [ParentTableName] ([ParentFieldName])
/* e.g.: */
ALTER TABLE ChildTableName WITH NOCHECK ADD CONSTRAINT FK_ChildToParent_ParentTableName FOREIGN KEY (ParentTablePKName)
REFERENCES ParentTableName (ParentTablePKName)
@GuildPortal
GuildPortal / gpGetForum.js
Created May 1, 2012 18:33
Retrieve info on a single Forum for a GuildPortal Site
// To be used in a GuildPortal.com Free Form Text/HTML widget (in RAW mode), or
// a Site Mod. Will only return data that the currently logged in user can see,
// and in case of a user that is not logged in, will only return public data.
// Requires git://gist.github.com/2568546.git and git://gist.github.com/2568601.git,
// and that the querystring contains the ForumID=### parameter.
var forumId = getQs("ForumID");
$.ajax({
@GuildPortal
GuildPortal / gpGetTopic.js
Created May 1, 2012 15:34
Retrieve info for a single Topic in a GuildPortal site's Forum
// To be used in a GuildPortal.com Free Form Text/HTML widget (in RAW mode), or
// a Site Mod. Will only return data that the currently logged in user can see,
// and in case of a user that is not logged in, will only return public data.
// NOTE: Requires git://gist.github.com/2568546.git and git://gist.github.com/2568601.git,
// and that the ForumID, TopicID, and GuildID be passed in via the querystring.
var guildId = getQs("GuildID");
var forumId = getQs("ForumID");
var topicId = getQs("TopicID");
@GuildPortal
GuildPortal / gpGetPostsForTopic.js
Created May 1, 2012 15:30
Retrieve a Page of Posts for a Topic in GuildPortal
// To be used in a GuildPortal.com Free Form Text/HTML widget (in RAW mode), or
// a Site Mod. Will only return data that the currently logged in user can see,
// and in case of a user that is not logged in, will only return public data.
// NOTE: Requires git://gist.github.com/2568546.git and git://gist.github.com/2568601.git,
// and that the ForumID, PageNumber, TopicID, and GuildID be passed in via the querystring.
var forumId = getQs("ForumID");
var pageNumber = getQs("PageNumber");
var topicId = getQs("TopicID");
@GuildPortal
GuildPortal / gpGetTopicsForForum.js
Created May 1, 2012 15:21
Retrieve a Page of Topics for Specified Forum in GuildPortal
// To be used in a GuildPortal.com Free Form Text/HTML widget (in RAW mode), or
// a Site Mod. Will only return data that the currently logged in user can see,
// and in case of a user that is not logged in, will only return public data.
// NOTE: Requires git://gist.github.com/2568546.git and git://gist.github.com/2568601.git,
// and that the ForumID, PageNumber, and GuildID be passed in via the querystring.
var forumId = getQs("ForumID");
var pageNumber = getQs("PageNumber");
var guildId = getQs("GuildID");
@GuildPortal
GuildPortal / gpGetMailMeta.js
Created May 1, 2012 15:15
Retrieve mailbox counts for logged-in GuildPortal user
// To be used in a GuildPortal.com Free Form Text/HTML widget (in RAW mode), or
// a Site Mod. Will only return data that the currently logged in user can see,
// and in case of a user that is not logged in, will only return public data.
// NOTE: Requires git://gist.github.com/2568546.git and git://gist.github.com/2568601.git
var inboxItemCount = 0;
var sentItemsCount = 0;
var serviceNewsCount = 0;