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.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language alias="pt" intName="Portuguese Portugal" localName="Portuguese Portugal" lcid="" culture="pt-PT">
<creator>
<name>The Umbraco community</name>
<link>https://our.umbraco.com/documentation/Extending-Umbraco/Language-Files</link>
</creator>
<area alias="actions">
<key alias="assignDomain">Gerenciar hostnames</key>
<key alias="auditTrail">Caminho de Auditoria</key>
<key alias="browse">Navegar o Nó</key>
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.AspNetCore.Mvc.TagHelpers
{
[HtmlTargetElement(Attributes = "is-active-route")]
@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
{