Skip to content

Instantly share code, notes, and snippets.

public class ContentCopierAppComponent : IUserComposer
{
public void Compose(Composition composition)
{
composition.ContentApps().Append<ContentCopierApp>();
}
}
public class ContentCopierApp : IContentAppFactory
{
@sniffdk
sniffdk / keybase.md
Last active September 9, 2019 18:37
keybase.md

Keybase proof

I hereby claim:

  • I am sniffdk on github.

  • I am sniffdk (https://keybase.io/sniffdk) on keybase.

  • I have a public key ASBZAFC_yIlaOhmzIQ87-JL9NJP3ehfKL8RXsW9OmDIjwQo

@sniffdk
sniffdk / DetachedIdPublishedContent.cs
Last active May 3, 2019 11:41
Wrap an Examine SearchResult in IPublishedContent
public class DetachedIdPublishedContent : DetachedPublishedContent
{
public DetachedIdPublishedContent(int id, Guid key, string name, PublishedContentType contentType, IEnumerable<IPublishedProperty> properties, IPublishedContent containerNode = null, int sortOrder = 0, bool isPreviewing = false)
: base(key, name, contentType, properties, containerNode, sortOrder, isPreviewing)
{
Id = id;
}
public override int Id { get; }
}
@sniffdk
sniffdk / PdfModule.cs
Created June 6, 2018 09:40
Snippet to demo how an http module can be used to check pdf requests
public class PdfModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PostAuthorizeRequest += PostAuthorizeRequest;
}
void PostAuthorizeRequest(object sender, EventArgs e)
{
var context = HttpContext.Current;
@sniffdk
sniffdk / editor.controller.js
Created May 17, 2018 11:22
Simple custom Umbraco dropdown plugin
angular.module("umbraco").controller("SimpleDropDown",
function ($scope) {
});
@sniffdk
sniffdk / 1. ost.cs
Last active April 19, 2018 10:44
OST poc create user request
private static string baseUrl = "https://playgroundapi.ost.com";
private static string key = "xxx";
var name = "apiuser";
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
var request = $"/users/create?api_key={key}&name={name}&request_timestamp={timestamp}";
var signature = Sign(request);
var values = new Dictionary<string, string>
@sniffdk
sniffdk / replace.sql
Last active November 16, 2018 17:31
Replace ntext sql
-- https://stackoverflow.com/a/4341677/701242
UPDATE [table]
SET [column] = CAST(REPLACE(CAST([column] as NVarchar(MAX)),'find','replace') AS NText)
WHERE [column] LIKE '%find%'
0451e06107fce07bfdf8128a88173cf75575dc07c8949bb28f53c76e2481ae80fe7ac196389a4626c5e12abddf45986b875b6c9f2f39beab372a16bc295a97b2b2
@sniffdk
sniffdk / 1 poc.txt
Last active September 28, 2017 18:09
TagHelpers and ViewComponents poc
The basic idea is, that I want to avoid writing html in the tag helper class.
This poc, if it worked, would simply pass the ModelExpression down to a view component, where the actual html lives.
From there we would then render various tag helpers based on the ModelExpression.
Unfortunately, it seems that tag helpers in the view component simply creates a ModelExpression of the passed in ModelExpression, inception?
So, to make it work, I guess I would need to "trick" tag helpers into accepting an existing ModelExpression? Doable?
@sniffdk
sniffdk / overlay-expander.js
Last active November 16, 2018 17:31
Fork of the Umbraco Dialog Expander code which uses mutation observers instead of mutation events
(function ($) {
var expander = function (node) {
var overlay = $(node);
// The toggle is already added, don't do anything
if (overlay.find(".overlay-expander--toggle").length > 0) {
return;
}
var toggle = $("<a href class='btn overlay-expander--toggle'><i class='icon icon-navigation-left'></i></a>");