Skip to content

Instantly share code, notes, and snippets.

View JimiSweden's full-sized avatar

Jimi Friis JimiSweden

  • Live For Real
  • Stockholm Sweden
View GitHub Profile
@jonleighton
jonleighton / base64ArrayBuffer.js
Last active December 18, 2024 15:41
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@hofmannsven
hofmannsven / README.md
Last active February 7, 2025 13:12
Git CLI Cheatsheet
@vkhorikov
vkhorikov / CustomerController.cs
Last active July 30, 2024 14:25
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@WilbertOnGithub
WilbertOnGithub / QueueBackgroundWorkItem example
Created May 13, 2015 09:16
QueueBackgroundWorkItem example
public class ValuesController1 : ApiController
{
// POST api/<controller>
public void Post([FromBody]string value)
{
HostingEnvironment.QueueBackgroundWorkItem(ct => StartBackgroundTask());
}
private async Task StartBackgroundTask()
{
@asmagin
asmagin / GenerateSitecoreNugetPackages.ps1
Last active November 25, 2019 18:42
Powershell script to generate nuget packages with dependencies
param(
[string] $Major = "8",
[string] $Minor = "1",
[string] $Update = "0",
[string] $Date = "151003",
[string] $nugetPath = ".\tools\nuget.exe",
[string] $downloadsPath = ".\downloads",
[string] $nuspecTemplate = ".\tools\package.nuspec.xml",
[string] $apiKey,
[string] $nugetFeed = "http://use-your.own/nuget/Sitecore-Libs"
@jermdavis
jermdavis / BasePipelineTypes.cs
Last active December 20, 2021 16:08
An example of strongly typed data pipelines, with some trivial examples
using System;
namespace StronglyTypedPipelines
{
/// <summary>
/// Base type for individual pipeline steps.
/// Descendants of this type map an input value to an output value.
/// The input and output types can differ.
/// </summary>
@jermdavis
jermdavis / LoopStep.cs
Created October 26, 2016 11:17
A possible looped pipeline step for processing IEnumerable<> inputs
using System.Collections.Generic;
namespace StronglyTypedPipelines
{
public class LoopStep<INPUT,OUTPUT> : IPipelineStep<IEnumerable<INPUT>, IEnumerable<OUTPUT>>
{
private IPipelineStep<INPUT, OUTPUT> _internalStep;
public LoopStep(IPipelineStep<INPUT, OUTPUT> internalStep)
using System;
namespace StronglyTypedPipelines
{
public abstract class BasePipelineStep<INPUT, OUTPUT> : IPipelineStep<INPUT, OUTPUT>
{
public event Action<INPUT> OnInput;
public event Action<OUTPUT> OnOutput;
// note need for descendant types to implement this, not Process()
@CodeMyUI
CodeMyUI / before-after-3-layer-image-slider-vanilla.markdown
Created July 16, 2017 11:22
Before After 3 Layer Image Slider (Vanilla)

Before After 3 Layer Image Slider (Vanilla)

Playing around with a new idea using my two layer before/after image slider. Keeping it minimal. Keeping it vanilla. Like it if it's useful :)

A Pen by Huw on CodePen.

License.

@biased-badger
biased-badger / Angular 8 HMR
Last active February 2, 2021 16:28
Angular 8 HMR
npm install --save-dev @angularclass/hmr