Skip to content

Instantly share code, notes, and snippets.

Avatar

Damiaan dampee

View GitHub Profile
@dampee
dampee / umbraco db cleanup.sql
Last active Feb 19, 2021
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
View umbraco db cleanup.sql
-- 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
@dampee
dampee / generate_dto.sql
Last active Nov 13, 2020 — forked from evgeny-myasishchev/generate_dto.sql
TSQL script to generate POCO/DTO from database table
View generate_dto.sql
DECLARE @tableName NVARCHAR(MAX), @schemaName NVARCHAR(MAX), @className NVARCHAR(MAX)
--------------- Input arguments ---------------
SET @tableName = 'MyTableName'
SET @schemaName = 'dbo'
SET @className = @tableName + 'Dto'
--------------- Input arguments end -----------
DECLARE tableColumns CURSOR LOCAL FOR
SELECT cols.name, cols.system_type_id, cols.is_nullable FROM sys.columns cols
@dampee
dampee / updatescript
Created May 29, 2020
Custom tables from OUR umbraco
View updatescript
GO
/****** Object: Schema [HangFire] Script Date: 19-May-20 16:26:21 ******/
CREATE SCHEMA [HangFire]
GO
/****** Object: Table [dbo].[cmsTagToTopic] Script Date: 19-May-20 16:26:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
@dampee
dampee / ImagesApiController.cs
Last active Mar 2, 2020
Resave all images. After an umbraco Upgrade from 6 to 7 you might have empty .URL's when using the image cropper. Resave all images by calling this API endpoint once.
View ImagesApiController.cs
using System.Web.Http;
using System.Collections.Generic;
using Umbraco.Core.Models;
using Umbraco.Web.WebApi;
namespace Our.Umbraco
{
public class UpgradeHelperController : UmbracoAuthorizedApiController
{
[HttpGet()]
@dampee
dampee / LoremIpsumBuilder.cs
Created Jul 3, 2014
Lorem ipsum generator in c#
View LoremIpsumBuilder.cs
/// <summary>
/// Lorem Ipsum Generator
/// </summary>
/// <remarks>
/// Based on Javascript Version of Marcus Campbell - Version 2.0 (Copyright 2003 - 2005)
/// Open-source code under the GNU GPL: http://www.gnu.org/licenses/gpl.txt
/// </remarks>
/// <example>
/// LoremIpsumBuilder _lib = new LoremIpsumBuilder();
/// string test = _lib.GetLetters();
@dampee
dampee / MediaExportController.cs
Created Jan 27, 2017
export media library (umbraco v6 + umbraco v7)
View MediaExportController.cs
using System;
using System.IO;
using System.Web.Hosting;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.WebApi;
/// <summary>
View RetryHelperAsync.cs
using System;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using log4net;
namespace Utils
{
@dampee
dampee / AzureStorageStorageHelper.cs
Created Jan 15, 2019
Clean azure blob storage container name
View AzureStorageStorageHelper.cs
public static bool IsValidContainer(string containerName)
{
// Container names must be valid DNS names, and must conform to these rules:
// * Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
// * Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names.
// * All letters in a container name must be lowercase.
// * Container names must be from 3 through 63 characters long.
// $root is a special container that can exist at the root level and is always valid.
if (containerName.Equals("$root"))
View ChargebeeController.cs
[RoutePrefix("Chargebee")]
public class ChargebeeController : ApiController
{
private readonly ILoggingService _loggingService;
private readonly TicketCountRepository _ticketCountRepository;
private readonly IBusinessRepository _businessRepository;
private readonly IBus _bus;
public ChargebeeController(ILoggingService loggingService, TicketCountRepository ticketCountRepository, IBusinessRepository businessRepository,
IBus bus)
@dampee
dampee / MediaController.cs
Created Dec 28, 2018
Reproduction of U4-9904
View MediaController.cs
using System.IO;
using System.Linq;
using System.Net;
using System.Web.Http;
using Umbraco.Core.Models;
using Umbraco.Web.WebApi;
namespace U4_9904.Controllers
{
public class MediaTestController : UmbracoApiController