Skip to content

Instantly share code, notes, and snippets.

@cocowalla
cocowalla / splunk.log
Created October 12, 2018 09:19
docker service logs -f my_service
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f | [WARNING]: provided hosts list is empty, only localhost is available. Note
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f | that the implicit localhost does not match 'all'
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f |
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f |
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f | PLAY [localhost] ***************************************************************
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f |
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f | TASK [Gathering Facts] *********************************************************
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f | Friday 12 October 2018 09:12:47 +0000 (0:00:00.040) 0:00:00.040 ********
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f | ok: [localhost]
sinks_splunk.1.9tyicwhik6cj@linuxkit-00155d3ad12f |
@cocowalla
cocowalla / Debouncer.cs
Last active July 7, 2022 13:49
Simple debounce
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MyNamespace
{
public class Debouncer : IDisposable
{
private readonly CancellationTokenSource cts = new CancellationTokenSource();
private readonly TimeSpan waitTime;
@cocowalla
cocowalla / Program.cs
Created December 7, 2018 20:31
Subcommands with Oakton
using System;
using System.Linq;
using System.Threading.Tasks;
using Lamar;
using Oakton;
using MyApp.Commands;
namespace MyApp
{
internal class Program
@cocowalla
cocowalla / EnumExtensions.cs
Created February 4, 2019 19:44
Enum display name extension method
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
namespace Acme.Utils
{
public static class EnumExtensions
@cocowalla
cocowalla / Dockerfile
Last active July 11, 2024 17:23
TimescaleDB on debian stretch-slim
# Docker image for PostgreSQL with the TimescaleDB extensions installed, running on a Debian Stretch-Slim base
# Begin by building TimescaleDB
FROM postgres:11.2 AS build
ENV TIMESCALEDB_VERSION 1.2.2
ENV TIMESCALEDB_SHASUM="c8e8071c24707e3fa8a50abb788c85d03a1bd9d9dea2e273b4abf407f39c182a timescaledb-${TIMESCALEDB_VERSION}.tar.gz"
RUN buildDeps="curl build-essential ca-certificates git python gnupg libc++-dev libc++abi-dev pkg-config glib2.0 cmake libssl-dev" \
&& apt-get update \
@cocowalla
cocowalla / Maths.cs
Last active April 23, 2023 15:07
64-bit integer multiplication
// Non-intrinsics path is based on https://stackoverflow.com/a/51587262/25758, which is faster than any other portable 64-bit multiplication function I've found
public static class Maths
{
/// <summary>
/// Multiplies 2 unsigned 64-bit integers, returning the result in 2 ulongs representing the hi and lo bits
/// of the resulting 128-bit integer
/// </summary>
/// <remarks>
/// <seealso cref="System.Numerics.BigInteger"/> can perform multiplication on large integers, but it's
@cocowalla
cocowalla / code.asm
Created May 8, 2019 10:32
SIMD XOR Optimisation
; Core CLR v4.6.27615.73 (coreclr.dll) on amd64.
MyClass..ctor()
L0000: push rbp
L0001: sub rsp, 0x20
L0005: lea rbp, [rsp+0x20]
L000a: mov [rbp+0x10], rcx
L000e: cmp dword [rip+0xbffb], 0x0
L0015: jz L001c
L0017: call 0x7ffc61fad9e0
@cocowalla
cocowalla / WyHash64.cs
Created July 10, 2019 19:46
Wyhash incremental hash
using System;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
// ReSharper disable InconsistentNaming
// ReSharper disable SuggestVarOrType_BuiltInTypes
namespace WyHash
{
/// <inheritdoc />
/// <summary>
@cocowalla
cocowalla / bsod-report.html
Created August 10, 2019 15:04
BSOD report for mac-precision-touchpad
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head><title>Crash List</title></head>
<body>
<h3>Crash List</h3>
<br><h4>Created by using <a href="http://www.nirsoft.net/" target="newwin">BlueScreenView</a></h4><p><table border="1" cellpadding="5"><tr bgcolor="E0E0E0">
<th>Dump File
<th>Crash Time
<th>Bug Check String
<th>Bug Check Code
<th>Parameter 1
@cocowalla
cocowalla / Ecies.cs
Last active June 22, 2024 14:07
Simple ECIES implementation
using System;
using System.Security.Cryptography;
// ReSharper disable SuggestVarOrType_SimpleTypes - BCL rules
namespace Crypto
{
/// <summary>
/// Simple implementation of ECIES (Elliptic Curve Integrated Encryption Scheme) based on http://www.secg.org/sec1-v2.pdf, section 5.1
/// Things not implemented:
/// - Encoding parameters using compressed points; only uncompressed points are used