Skip to content

Instantly share code, notes, and snippets.

View zpqrtbnk's full-sized avatar

Stephan zpqrtbnk

View GitHub Profile
@zpqrtbnk
zpqrtbnk / Article.cs
Last active December 22, 2015 23:49
Umbraco strongly typed published content experiments
// demo of a basic strongly typed published content for an article
// you just need to drop the following class anywhere in your code
// and every strongly typed methods returning IPublishedContent will
// actually return an Article instance (which is an IPublishedContent)
// we want the class named Article though the content type alias is 'newsArticle'
[PublishedContentModel("newsArticle")]
public partial class Article : PublishedContentModel
{
public Article(IPublishedContent content)
@zpqrtbnk
zpqrtbnk / ContentSet.cshtml
Last active December 23, 2015 04:49
Demo usage of ToContentSet()
// IPublishedContent implements IsFirst, IsOdd, Index and various stuff
// so technically it's possible to do
@foreach(var content in contents)
{
<div class="@(content.IsFirst() ? "first" : "") @(content.IsOdd() ? "odd" : "even")" id="item-@(content.Index())">
@content.Name
</div>
}
// however, because of some issues in IPublishedContent, IsFirst, IsOdd, Index... all
@zpqrtbnk
zpqrtbnk / markdown.md
Last active March 20, 2018 08:18
Markdown Sandbox

Umbraco Version 8 Technical Notes

Welcome


@zpqrtbnk
zpqrtbnk / Test.cs
Last active August 29, 2015 14:14
Recurse Vs Stack Benchmark
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestRunner
{
@zpqrtbnk
zpqrtbnk / ValueTuple3Benchmark.cs
Last active May 31, 2020 07:57
ValueTuple Benchmark
using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Validators;
// here are the results I get:
@zpqrtbnk
zpqrtbnk / NamedServiceExtensions.cs
Last active January 11, 2019 17:52
Named Services for MS.DI
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
namespace MSDI
{
public static class NamedServiceExtensions
// executed with:
// var config = DefaultConfig.Instance
.WithArtifactsPath(artPath)
.AddDiagnoser(MemoryDiagnoser.Default)
.AddJob(Job.InProcess);
// BenchmarkRunner.Run(typeof(NullCoalesce), config);
public class NullCoalesce
{
private bool _toggle;
@zpqrtbnk
zpqrtbnk / HazelcastIssue466.cs
Created August 31, 2021 18:13
HazelcastIssue466
// Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// I have a concern that despite having lots of tests and "good enough" test coverage, we
// are more or test "testing everything" in the hope of catching issues, but not using a
// very deterministic approach. I would rather split our tests per layers, and validate
// that each layer is OK.
//
// This file contains a sample test for the HMap.SetAsync method (aka map.set) that does
// rely on the entire client-side pipeline of using the codec to create a message,
// serializing the message and sending its frames over a TCP socket -- but does *not*
// rely on an Hazelcast cluster: instead, the test relies on a lightweight server that
// can receive, and respond to, messages. We use it to capture and validate the message
@zpqrtbnk
zpqrtbnk / HazelcastClientSingleton.cs
Created October 19, 2021 17:27
HazelcastClientSingleton
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and