Skip to content

Instantly share code, notes, and snippets.

View dampee's full-sized avatar

Damiaan dampee

View GitHub Profile
@nul800sebastiaan
nul800sebastiaan / gist:1553316fda85011270ce2bde35243e5b
Created October 15, 2021 13:07
Fully unattended Umbraco 9 + Starter Kit install with automatic DB creation in SQL server
dotnet new umbraco -n UmbracoUnattended --connection-string "Server=GORDON\SQLExpress;Database=UmbracoUnattended;User Id=sa;Password=abc123;"
cd UmbracoUnattended
Set-Item Env:\UMBRACO__CMS__GLOBAL__INSTALLMISSINGDATABASE true
Set-Item Env:\UMBRACO__CMS__UNATTENDED__INSTALLUNATTENDED true
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERNAME "Test"
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL "test@test.com"
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD "test123456"
dotnet add package Umbraco.TheStarterKit
public class ProductComponent : IComponent
{
private readonly IExamineManager _examineManager;
private readonly ProductIndexCreator _productIndexCreator;
public ProductComponent (IExamineManager examineManager, ProductIndexCreator productIndexCreator)
{
_examineManager = examineManager;
_productIndexCreator = productIndexCreator;
}
@JimBobSquarePants
JimBobSquarePants / DominantColor.cs
Created June 7, 2018 11:58
Get dominant color from an image using ImageSharp and ImageProcessor
// ##### ImageSharp #####
using (var image = Image.Load<Rgb24>(inPath))
{
image.Mutate(
x => x
// Scale the image down preserving the aspect ratio. This will speed up quantization.
// We use nearest neighbor as it will be the fastest approach.
.Resize(new ResizeOptions() { Sampler = KnownResamplers.NearestNeighbor, Size = new Size(100, 0) })
@dawoe
dawoe / DefaultController.cs
Created November 7, 2017 08:20
Donut Cache examples from Umbraco UK Festival talk "The need for speed"
public class DefaultController : RenderMvcController
{
[UmbracoDonutOutputCache(CacheProfile = "LongPageCache",
Options = OutputCacheOptions.NoCacheLookupForPosts &
OutputCacheOptions.ReplaceDonutsInChildActions, Order = 100)]
public override ActionResult Index(RenderModel model)
{
return base.Index(model);
}
}
// See https://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit, jQuery version with arrays and objects support
function post(path, parameters) {
var form = $('<form></form>');
form.attr("method", "post");
form.attr("action", path);
$.each(parameters, function(key, value) {
if ( typeof value == 'object' || typeof value == 'array' ){
$.each(value, function(subkey, subvalue) {
/// <summary>
/// Throttles duplicate requests.
/// Based loosely on <see href="http://stackoverflow.com/a/21011273/427899"/>
/// </summary>
public sealed class AsyncDuplicateLock
{
/// <summary>
/// The collection of semaphore slims.
/// </summary>
private static readonly ConcurrentDictionary<object, SemaphoreSlim> SemaphoreSlims
@rposbo
rposbo / statsd_graphite_ubuntu14.sh
Last active November 2, 2015 19:38
A single script to setup StatsD and Graphite on Ubuntu 14.10 on Azure
#!/bin/bash
echo "#### Starting"
echo "#### apt-get updating and installing"
sudo apt-get update
sudo apt-get install screen libexpat1-dev libicu-dev git build-essential curl software-properties-common python-software-properties -y
echo "#### Installing node"
# Node
. ~/.bashrc
@bradjolicoeur
bradjolicoeur / gist:e77c508089aea6614af3
Created August 8, 2014 20:15
Powershell Script to Increment Build Number in AssemblyInfo.cs
#
# This script will increment the build number in an AssemblyInfo.cs file
#
$assemblyInfoPath = "C:\Data\Temp\AssemblyInfo.cs"
$contents = [System.IO.File]::ReadAllText($assemblyInfoPath)
$versionString = [RegEx]::Match($contents,"(AssemblyFileVersion\("")(?:\d+\.\d+\.\d+\.\d+)(""\))")
Write-Host ("AssemblyFileVersion: " +$versionString)
@leekelleher
leekelleher / cmsContentType_Usage.sql
Last active January 19, 2024 19:03
Umbraco - database analysis - SQL Queries
-- Copied from Hendy https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/72814-creating-a-list-of-unused-doc-types#comment-233729
-- Find all unused docTypes
-- These results may contain docTypes that are masters of used ones, so need to exclude these too...
SELECT
A.nodeId as 'DocTypeId',
B.text AS 'Name',
A.alias AS 'Alias'
FROM
cmsContentType A LEFT JOIN
@leekelleher
leekelleher / MyApplication.cs
Last active December 19, 2015 13:59
Example of Umbraco 6.1's IContentFinder
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Mvc;
using Umbraco.Web.Routing;
namespace Our.Umbraco
{
public class MyApplication : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)