Skip to content

Instantly share code, notes, and snippets.

View dampee's full-sized avatar

Damiaan dampee

View GitHub Profile
@dampee
dampee / MyApplicationEvents.cs
Last active April 11, 2016 08:12
LastChanceContentFinder (404 not found for umbraco)
public class MyApplicationEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentLastChanceFinderResolver.Current.SetFinder(new MyLastChanceContentFinder());
}
}
@dampee
dampee / Custom.DateFolder.config
Created October 3, 2016 15:07
datefolder setup for news
<?xml version="1.0"?>
<DateFolder DateFolderAlias="dateFolder">
<DocumentType Alias="newsItem" DatePropertyAlias="postDate" />
<!--<DocumentType Alias="PressReleaseItem" DatePropertyAlias="date" />
<DocumentType Alias="EventItem" DatePropertyAlias="startDatetime" />-->
</DateFolder>
@dampee
dampee / getmedia.cs
Last active May 18, 2017 13:57
Search media on nodename without descendants
var internalSearchProvider = ExamineManager.Instance.SearchProviderCollection["InternalSearcher"];
var query = ExamineManager.Instance.CreateSearchCriteria()
.NodeTypeAlias("image")
.And().NodeName("Desert.jpg".ToLowerInvariant())
.Compile();
var results = Umbraco.TypedSearch(query, internalSearchProvider);
@dampee
dampee / dunittest.snippet
Last active May 31, 2023 01:51
Unittest snippet for visual studio
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>dunittest</Title>
<Author>
</Author>
public class CustomVersionProvider : IVersionProvider
{
private Lazy<string> _productVersion = new Lazy<string>(() =>
{
var assembly = Assembly.GetExecutingAssembly();
var assemblyVersion = assembly.GetName().Version;
var productVersion = string.Format("{0}.{1}.{2}", assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build);
// additional info
var dateFormat = "dd.MM.yyyyTHH:mm:ss";
productVersion += string.Format(" (built: {0}) (LastWriteTime: {1})",
@dampee
dampee / MediaExportController.cs
Created January 27, 2017 13:31
export media library (umbraco v6 + umbraco v7)
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>
@dampee
dampee / MediaController.cs
Created December 28, 2018 13:46
Reproduction of U4-9904
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
@dampee
dampee / ChargebeeController.cs
Created January 10, 2019 20:32
chargebee in webapi
[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 / generate_dto.sql
Last active March 9, 2023 12:39 — forked from gemyago/generate_dto.sql
TSQL script to generate POCO/DTO from database table
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 / AzureStorageStorageHelper.cs
Created January 15, 2019 14:04
Clean azure blob storage container name
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"))