Skip to content

Instantly share code, notes, and snippets.

View dampee's full-sized avatar

Damiaan dampee

View GitHub Profile
@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>
@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 / 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 / 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 / umbracoTraceLog.txt
Created February 15, 2016 13:54
log after clean install of umbraco 7.4 using nuget
2016-02-15 14:52:56,906 [P1364/D2/T1] INFO Umbraco.Core.CoreBootManager - Umbraco 7.4.0 application starting on DESKTOP-JJOR4ST
2016-02-15 14:52:56,927 [P1364/D2/T1] INFO Umbraco.Core.PluginManager - Determining hash of code files on disk
2016-02-15 14:52:56,934 [P1364/D2/T1] INFO Umbraco.Core.PluginManager - Hash determined (took 7ms)
2016-02-15 14:52:56,973 [P1364/D2/T1] INFO Umbraco.Core.PluginManager - Starting resolution types of umbraco.interfaces.IApplicationStartupHandler
2016-02-15 14:52:57,129 [P1364/D2/T1] INFO Umbraco.Core.PluginManager - Completed resolution of types of umbraco.interfaces.IApplicationStartupHandler, found 0 (took 156ms)
2016-02-15 14:52:57,138 [P1364/D2/T1] INFO Umbraco.Core.PluginManager - Starting resolution types of Umbraco.Core.PropertyEditors.IPropertyEditorValueConverter
2016-02-15 14:52:57,145 [P1364/D2/T1] INFO Umbraco.Core.PluginManager - Completed resolution of types of Umbraco.Core.PropertyEditors.IPropertyEditorValueConverter, found 0 (took 6ms)
2016-02
@dampee
dampee / umbraco db cleanup.sql
Last active November 9, 2021 12:57
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
@dampee
dampee / ImagesApiController.cs
Last active March 2, 2020 18:34
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.
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 / ContentServiceTests.SortOrder.cs
Created June 11, 2015 13:04
Sort Order check after Content Delete unit test (U4-6642)
[Test]
public void Delete_SortOrder_Is_Correct()
{
// Arrange
var contentService = ServiceContext.ContentService;
var root = contentService.GetById(NodeDto.NodeIdSeed + 4);
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
var contentList = CreateChildrenOf(contentType, root, 3);
contentService.Save(contentList);
### Keybase proof
I hereby claim:
* I am dampee on github.
* I am damiaan (https://keybase.io/damiaan) on keybase.
* I have a public key whose fingerprint is 8916 1EB8 0874 7B83 C747 A50C 09B2 0515 7944 DF39
To claim this, I am signing this object:
@dampee
dampee / gist:a77654eef93df7322753
Created April 14, 2015 15:11
create umbraco macro with custom properties
// Using old namespace to create Macro, since Umbraco.Core.Models.Macro is still an internal class in Umbraco V7.1.8
var macro = new Macro.Macro { Alias = alias, Name = name, ScriptingFile = scriptingFile, UseInEditor = useInEditor, RenderContent = renderContent };
macro.Save();
var newMacro = Services.MacroService.GetByAlias(alias);
foreach (var macroProperty in macroProperties)
{
newMacro.Properties.Add(macroProperty);
}
Services.MacroService.Save(newMacro);