Skip to content

Instantly share code, notes, and snippets.

Brent Maxwell brentmaxwell

Block or report user

Report or block brentmaxwell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brentmaxwell
brentmaxwell / DelimitedStringToTable.sql
Last active Apr 5, 2017
Delimited string to table
View DelimitedStringToTable.sql
CREATE FUNCTION [dbo].[DelimitedStringToTable]
(
        @String nvarchar(MAX),
        @Delimiter nvarchar(1)
)
RETURNS @Items TABLE
(
        Item nvarchar(50)
)
AS
@brentmaxwell
brentmaxwell / AutoMapperConfig.cs
Last active Dec 6, 2017
Put automapper configs in model classes NOTE THIS DOES NOT WORK WITH THE LATEST VERSION OF AUTOMAPPER
View AutoMapperConfig.cs
public class AutoMapperConfig
{
/// <summary>
/// Function that is called in the Global.asax file
/// Runs through and calls each of the functions below, registering the various mappings
/// </summary>
public static void Execute()
{
RegisterOtherMaps();
RegisterMapperHelpers();
@brentmaxwell
brentmaxwell / rowcounts.sql
Created Mar 17, 2015
Get *approximate* row counts of all tables in a db
View rowcounts.sql
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.ROWS)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U' AND
si.id = OBJECT_ID(so.name)
GROUP BY so.name ORDER BY so.name
@brentmaxwell
brentmaxwell / UnixTimeExtensions.cs
Created Mar 17, 2015
Extensions to convert Unix time to DateTime
View UnixTimeExtensions.cs
namespace System
{
public static class UnixTimeExtensions
{
public static long ToUnixTime(this DateTime datetime)
{
return (long)(datetime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
}
public static DateTime FromUnixTime(long time)
You can’t perform that action at this time.