Skip to content

Instantly share code, notes, and snippets.

View abitofhelp's full-sized avatar

Michael Gardner abitofhelp

View GitHub Profile
@abitofhelp
abitofhelp / series-part-4-structs-and-when-elision-fails.md
Last active October 11, 2025 01:01
Understanding Rust Lifetime Elision - Part 4

Understanding Rust Lifetime Elision - Part 4:

Structs, Lifetimes, and When Elision Doesn't Apply

Part 4 of 4: A comprehensive guide to mastering Rust's lifetime elision rules


Series Navigation

@abitofhelp
abitofhelp / series-part-3-rule-3.md
Last active October 11, 2025 01:36
Understanding Rust Lifetime Elision - Part 3 of 4

Understanding Rust Lifetime Elision - Part 3 of 4:

Rule 3 - The Method Receiver Rule

Part 3 of 4: A comprehensive guide to mastering Rust's lifetime elision rules


Series Navigation

@abitofhelp
abitofhelp / series-part-2-rule-2.md
Last active October 11, 2025 00:59
Understanding Rust Lifetime Elision - Part 2

Understanding Rust Lifetime Elision - Part 2:

Rule 2 - The Single Input Lifetime Rule

Part 2 of 4: A comprehensive guide to mastering Rust's lifetime elision rules


Series Navigation

@abitofhelp
abitofhelp / rust-lifetime-elision-part-1.md
Last active October 11, 2025 01:02
Understanding Rust Lifetime Elision - Part 1 of 4

Understanding Rust Lifetime Elision - Part 1:

Rule 1 - Introduction

Part 1 of 4: A comprehensive guide to mastering Rust's lifetime elision rules


Series Navigation

  • Part 1: Introduction and Rule 1 ← You are here
@abitofhelp
abitofhelp / rxgenerator.kt
Created July 1, 2019 09:13
Reactive streaming from Azure Blob to rxjava generator/parser. This snippet shows how to stream content from Azure Blob Storage using their Java SDK v11 and reactive streams. The blob's stream is fed into a rxjava/rxkotlin generator, which parses sample data from the blob stream. Subscribers use the Flowable to work with each sample parsed from …
/**
* Method generator parses sample data from a json stream.
* @param sampleJsonUrl String is the URL to the Azure Blob Storage sample data.
* @return Flowable<Sample> is a cold, synchronous, stateful and backpressure-aware
* generator of features.
*/
fun generator(sampleJsonUrl: String) =
blobStorage.downloadBlob(sampleJsonUrl)
.map { bbuf: ByteBuffer -> JsonFactory().createParser(bbuf.array()) }
.map { jParser ->
@abitofhelp
abitofhelp / Dockerfile-DeployAspNet2IISWithPsWebDeploy
Created December 19, 2018 07:39
Dockerfile to deploy an AspNet app to IIS in a container using PSWebDeploy
# The general framwork of my script is based on fragments from all over the Internet, including
# the following website. Since there is no clear owner of this information and it was contributed
# by many people, I am assuming that an MIT license is appropriate.
# https://fluentbytes.com/deploying-asp-net-4-5-to-docker-on-windows/
# docker run -p 8088:80 --restart always --name aspnetdocker -dit abitofhelp/aspnetdocker
# Now we can browse to the website. Be aware that you can only reach the container from the outside,
# so if you would browse to localhost, which results in the #127.0.0.0 you will not see any results.
# You need to address your machine on its actual hostname or outside IP address.
@abitofhelp
abitofhelp / go-stream-file-between-goroutines-with-pipe.go
Created September 15, 2018 03:04
This gist implements a streaming process where a chunk of data is read from a file in a goroutine, the data is passed through a channel to another goroutine, which writes the data to a Linux pipe.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2018 A Bit of Help, Inc. - All Rights Reserved, Worldwide.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Package main implements streaming of a file through a FIFO pipe, from which data is written to a new file.
// Using a FIFO pipe avoids having to allocate buffers within the for loop, which eliminates a data race condition
// on reading data from the file and sending it to the channel. However, using a pipe is slower than a
// channel. A quick test with a 3.9GB binary file required 5.3s with a channel, and 12.6s with a pipe.
// I've created a companion gist,"go-stream-file-between-goroutines-with-channel" for comparison.
@abitofhelp
abitofhelp / cs-job-scheduler.cs
Created August 14, 2018 22:14
This gist implements a job scheduler that makes it easier to have long running jobs go to sleep and wake up on a schedule.
using System;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using NLog;
using NodaTime;
using NodaTime.Text;
// Copyright 2009 The Noda Time Authors. All rights reserved.
// Use of this source code is governed by the Apache License 2.0,
@abitofhelp
abitofhelp / cs-fast-file-scanner.cs
Last active August 14, 2018 22:02
This gist is for a very high-performance file system scanner that supports international characters and paths longer than .NET's limitation.
/*
* Copyright (c) 2008-2015 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software (Alphaleonis) 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:
*
@abitofhelp
abitofhelp / cs-stringextensions.cs
Last active August 14, 2018 22:01
This gist implements methods that extend the abilities of string objects.
////////////////////////////////////////////////////////////////////////////////////////////////////
// file: Extensions\StringExtensions.cs
//
// summary: Implements the string extensions class
////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Linq;
using System.Security.Cryptography;