Skip to content

Instantly share code, notes, and snippets.

View jcdickinson's full-sized avatar
🐵

Jonathan Dickinson jcdickinson

🐵
View GitHub Profile
@jcdickinson
jcdickinson / forward.bat
Created January 25, 2017 13:11
Forward Azure Storage Emulator
netsh interface portproxy add v4tov4 listenport=20000 connectaddress=127.0.0.1 connectport=10000 protocol=tcp
netsh interface portproxy add v4tov4 listenport=20001 connectaddress=127.0.0.1 connectport=10001 protocol=tcp
netsh interface portproxy add v4tov4 listenport=20002 connectaddress=127.0.0.1 connectport=10002 protocol=tcp
REM Your connection string will be similar to:
REM DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
REM AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
REM BlobEndpoint=http://192.168.0.2:20000/devstoreaccount1;
REM TableEndpoint=http://192.168.0.2:20002/devstoreaccount1;
REM QueueEndpoint=http://192.168.0.2:20001/devstoreaccount1;
@jcdickinson
jcdickinson / readme.md
Created October 10, 2016 13:07
Git History Transplant

Git History Transplant

If you've copied a repository instead of forking it, and need to merge changes across.

Source Repository

  1. Merge into your current branch if you have to.

  2. Identify the commit where the divergence occurred. Create a branch off of it for easy reference:

@jcdickinson
jcdickinson / FastBufferManager.cs
Created October 3, 2016 09:39
Fast Buffer Manager
/// <summary>
/// Represents a buffer manager.
/// </summary>
sealed class FastBufferManager
{
private const int Decongest = 16;
/// <summary>
/// Represents a portion of the buffers, designed to reduce congestion.
/// </summary>
@jcdickinson
jcdickinson / Select-Regex.ps1
Created August 18, 2016 18:09
Select Regex
Function Select-Regex {
Param(
[Parameter(ValueFromPipeline=$True)] $Input,
[Parameter(Mandatory=$True, Position=0)] [String] $Pattern
)
Begin {
$Regex = New-Object Regex $Pattern, 'ExplicitCapture'
}
Process {
@jcdickinson
jcdickinson / Program.cs
Created August 17, 2015 11:07
Find All Roots For Type
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Diagnostics.Runtime;
using System.IO;
using System.Collections;
using System.Diagnostics;
namespace EEHeap
using System.Security.Cryptography;
/// <summary>
/// Represents the Murmur 3 Hash Algorithm.
/// </summary>
/// <remarks>
/// Murmur 3 is not cryptographically secure, instead it is used
/// for content identification.
/// </remarks>
public sealed class Murmur3 : HashAlgorithm
@jcdickinson
jcdickinson / Demo.cs
Created July 8, 2015 18:13
Return To SynchronizationContext
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
async void button1_Click(object sender, EventArgs e)
{
var context = SynchronizationContext.Current;
@jcdickinson
jcdickinson / Program.cs
Created July 8, 2015 17:11
ThreadContext
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ContextDemo
{
class SimpleContext : SynchronizationContext
{
public override void Post(SendOrPostCallback d, object state)
{
@jcdickinson
jcdickinson / readme.md
Last active May 4, 2022 22:14
Templates in C

Based on an idea by Andread Arnold-Bos. Instead of having two files the template instantiations are done within the same file as the template.

@jcdickinson
jcdickinson / workstealingstack.h
Last active March 26, 2023 04:15
C++ Lock-Free Work Stealing Stack
#pragma once
#include <atomic>
// A lock-free stack.
// Push = single producer
// Pop = single consumer (same thread as push)
// Steal = multiple consumer
// All methods, including Push, may fail. Re-issue the request
// if that occurs (spinwait).