Skip to content

Instantly share code, notes, and snippets.

@chutchinson
chutchinson / aoc2020-day1.kt
Created December 1, 2020 18:49
Advent of Code 2020 Kotlin
import java.io.File
import java.util.*
// https://rosettacode.org/wiki/Combinations#Kotlin
inline fun <reified T> combinations(arr: List<T>, m: Int) = sequence {
val n = arr.size
val result = Array(m) { arr[0] }
val stack = LinkedList<Int>()
stack.push(0)
while (stack.isNotEmpty()) {
public static string GenerateId(int length)
{
const string symbols = "abcdefghijklmnopqrstuvwxyz0123456789";
byte[] buffer = null;
try
{
buffer = ArrayPool<byte>.Shared.Rent(length);
@chutchinson
chutchinson / Program.cs
Last active February 21, 2020 23:43
NAudio Opus
using Concentus.Structs;
using NAudio.Wave;
using System;
using System.Threading.Tasks;
namespace AudioGen
{
public class BufferedSampleProvider : ISampleProvider
{
private float[] Buffer { get; }
@chutchinson
chutchinson / PerformanceMonitor
Last active December 28, 2015 09:39
PerformanceMonitor implementation in Java. Allows sampling of performance characteristics over time. It's possible to define a performance item with a limited number of samples, and a defined sampling rate (only collect sample into buffer every n milliseconds, regardless of number of calls to record method). Performance items can be tagged for f…
import com.google.common.base.Preconditions;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;