Skip to content

Instantly share code, notes, and snippets.

@marciogoularte
marciogoularte / Result.cs
Created October 11, 2023 14:53 — forked from m-jovanovic/Result.cs
Result type
public class Result
{
protected internal Result(bool isSuccess, Error error)
{
if (isSuccess && error != Error.None)
{
throw new InvalidOperationException();
}
if (!isSuccess && error == Error.None)
@marciogoularte
marciogoularte / Database.cs
Created July 13, 2023 21:16
Small class for making SQL calls to SQL Server from .NET Core
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace Core.Data
{
/// <summary>
///
/// </summary>
@marciogoularte
marciogoularte / ClassGenerator.sql
Created July 13, 2023 21:15 — forked from DanElliott/ClassGenerator.sql
Generate C# class from database table
--modified from SO: http://stackoverflow.com/questions/5873170/generate-class-from-database-table
--added table and column
declare @TableName sysname = 'TableName'
declare @Result varchar(max) = '[Table(Name = "' + @TableName + '")]
public class ' + @TableName + '
{'
select @Result = @Result + '
[Column(DbType = "' +
@marciogoularte
marciogoularte / ActivePageTagHelper.cs
Created July 13, 2023 21:10 — forked from DanElliott/ActivePageTagHelper.cs
Adds an "active" class to the given element when the route parameters match. An Active Page Tag Helper for use with Razor Pages.
[HtmlTargetElement(Attributes = "is-active-page")]
public class ActivePageTagHelper : TagHelper
{
/// <summary>The name of the action method.</summary>
/// <remarks>Must be <c>null</c> if <see cref="P:Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Route" /> is non-<c>null</c>.</remarks>
[HtmlAttributeName("asp-page")]
public string Page { get; set; }
/// <summary>
/// Gets or sets the <see cref="T:Microsoft.AspNetCore.Mvc.Rendering.ViewContext" /> for the current request.
@marciogoularte
marciogoularte / umbraco 7 db cleanup.sql
Created December 15, 2021 14:02 — forked from csharpforevermore/umbraco 7 db cleanup.sql
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
-- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
-- http://borism.net/2008/12/16/fixing-a-large-cmspropertydata-table-in-umbraco/
DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
-- dump logs
-- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
DELETE FROM umbracolog WHERE Datestamp < @createdDate
-- clean up old versions
DELETE FROM cmsPropertyData WHERE
@marciogoularte
marciogoularte / jq-scrollspy.html
Created May 24, 2021 17:42 — forked from ambitstream/jq-scrollspy.html
Simple jQuery scrollspy script
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<header>
<nav>
@marciogoularte
marciogoularte / ModelExtensions.cs
Created October 28, 2020 17:21 — forked from elizabeth-young/ModelExtensions.cs
Mvc ModelState extensions to get error list from ModelState
using System.Collections.Generic;
using System.Linq;
usingusing System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
namespace Gists.Mvc.Helpers
{
public static class ModelExtensions
{
@marciogoularte
marciogoularte / MultiNodeTreePickerIdToUdiMigrator.cs
Created September 14, 2020 15:58
Migrate Ids to Udis for Umbraco.MultiNodeTreePicker
using System;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Web;
namespace Sniper.Umbraco
{
public static class MultiNodeTreePickerIdToUdiMigrator
{
@marciogoularte
marciogoularte / bootstrap-custom.css
Created May 7, 2020 23:21 — forked from IAMIronmanSam/bootstrap-custom.css
Custom bootstrap for sharepoint specific
/*bootstrap 3 resets for SharePoint*/
/*border-box causes many issues with SP*/
*, *:before, *:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
/*reset elements that B3 is expecting to be border-box*/
* [class^="col-"], * [class^="col-"]:before, * [class^="col-"]:after,
.container, .container:before, .container:after,
@marciogoularte
marciogoularte / gist:d395c3c80def3348fe76c521196b8a85
Created February 17, 2020 01:40 — forked from ar3cka/gist:ed2217ee17f6bd3f2a91
CQRS. In Process Command Dispatcher
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using System.Threading.Tasks;
namespace Demo
{