Skip to content

Instantly share code, notes, and snippets.

@kdarty
kdarty / WebMail.cs
Created April 30, 2014 17:17
Simple SMTP Mail Client Helper class written in C# to send Email Asynchronously. NOTE: Uses Log4Net for logging.
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Configuration;
using System.Net.Mail;
using System.Net.Mime;
using System.Threading.Tasks;
using System.Web;
@kdarty
kdarty / HtmlHelper.cs
Last active August 29, 2015 14:00
Basic HTML Helper class for C# to Convert To and From HTML providing Extensions to test if a String contains HTML.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace MyApp.Helpers
{
public static class HtmlHelper
@kdarty
kdarty / ExtensionMethods.cs
Last active June 16, 2022 09:30
A running list of helpful Extension Methods for C# projects.
using Microsoft.Owin.Security;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
@kdarty
kdarty / Database-Analysis-Report.sql
Last active August 29, 2015 14:03
Database Analysis Report (SQL Server)
--Database Analysis Report for SQL Server
--Author: M.Ali
--Source: http://stackoverflow.com/questions/19433902/how-to-analyze-tables-for-size-in-a-single-db-using-sql-server
SET NOCOUNT ON
DBCC UPDATEUSAGE(0)
-- DB size.
@kdarty
kdarty / Drop-All-Stored-Procedures.sql
Last active August 29, 2015 14:03
Drop All Stored Procedures for SQL Server
/******************************************************/
/** Description:Deletes all Stored Procedures in the **/
/** given Database. **/
/** **/
/** WARNING: This can be very Dangerous. Verify **/
/** your current Database connection **/
/** before use. It is recommended to **/
/** enter the Target Database in the **/
/** USE clause. **/
/** **/
@kdarty
kdarty / Search-SQL-Server-For-Given-Search-Term.sql
Created July 2, 2014 12:51
Search all SQL Server Modules (Procedures, etc) for given Search Term
-- Search all SQL Modules (Procedures, etc) for given Search Term
DECLARE @Search varchar(255)
SET @Search='what I am looking for'
SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'
ORDER BY 2,1
@kdarty
kdarty / resolve-user-login.sql
Created July 2, 2014 13:32
Re-sync or resolve a User from an Imported Database to an Existing SQL Server User Login Account
/***************************************************************************/
/* Use the following Stored Procedure call to re-sync or resolve a user */
/* from an imported database to an existing SQL Server User Login Account. */
/***************************************************************************/
EXEC sp_change_users_login 'Auto_Fix', 'UserName'
@kdarty
kdarty / LINQ2XML-Example.cs
Created July 2, 2014 13:47
Simple Example of using LINQ 2 XML to Parse XML Data Entries into C# Objects
// Simple Example of using LINQ 2 XML to Parse XML Data Entries into C# Objects
// Author: Sergey Berezovskiy
// Source: http://stackoverflow.com/questions/14226473/c-sharp-parsing-xml-file
// NOTE: Your XML file should have a single root node
var xdoc = XDocument.Load(path_to_xml);
var entries = from e in xdoc.Descendants("entry")
select new {
Id = (int)e.Attribute("id"),
Type = (string)e.Attribute("type"),
@kdarty
kdarty / 0_reuse_code.js
Created July 2, 2014 13:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kdarty
kdarty / SQL-Server-Constants-Example.sql
Created July 2, 2014 14:43
Constants in SQL Server
--Constants in SQL Server
--Since SQL Server and T-SQL doesn't support the concept of
--Constants, this is one example of how to mimic the functionality.
--Source: http://stackoverflow.com/questions/26652/is-there-a-way-to-make-a-tsql-variable-constant
CREATE FUNCTION fnConstant()
RETURNS INT
AS
BEGIN
RETURN 2