Skip to content

Instantly share code, notes, and snippets.

View chklauser's full-sized avatar

Christian Klauser chklauser

View GitHub Profile
@chklauser
chklauser / ChunkedStreams.java
Last active May 2, 2022 15:22
A Java stream combinator that splits a stream into chunks of a fixed size. Last chunk in the stream might be smaller than the desired size. Ordering guarantees depend on underlying stream.
public final class ChunkedStreams {
private ChunkedStreams(){}
@SuppressWarnings("SameParameterValue")
public static <T> Stream<List<T>> chunks(Stream<T> sourceStream, int size) {
var source = sourceStream.spliterator();
return StreamSupport.stream(new Spliterator<>() {
final List<T> buf = new ArrayList<>();
@Override
public boolean tryAdvance(Consumer<? super List<T>> action) {
@chklauser
chklauser / lk.ps1
Created January 31, 2022 22:13
Powershell version of my favorite custom bash function: 'lk' (look; shows a thing; decides how to show it based on the path/file extension)
New-Module -Name Lk -ScriptBlock {
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
if (-not (Get-Command -ErrorAction SilentlyContinue rich)) {
Write-Error '`rich` not installed. See https://github.com/Textualize/rich-cli'
}
if (-not (Get-Command -ErrorAction SilentlyContinue less)) {
Write-Error '`less` not installed. `scoop install less` maybe?'
}
function Show-Item {
param(
// Task builder for F# that compiles to allocation-free paths for synchronous code.
//
// Originally written in 2016 by Robert Peele (humbobst@gmail.com)
// New operator-based overload resolution for F# 4.0 compatibility by Gustavo Leon in 2018.
// Revised for insertion into FSharp.Core by Microsoft, 2019.
//
// Original notice:
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights
// to this software to the public domain worldwide. This software is distributed without any warranty.
//
@chklauser
chklauser / arbalest.kanata.kbd
Created December 30, 2024 14:06
Kanata Keymap for home row modifiers on and a nav cluster
#| --------------------------------------------------------------------------
KMonad: US ansi 100% template
This file contains the `defsrc` configuration for a standard US-ansi 100%
keyboard. Modelled on a standard DAS-keyboard 100%. Copy out the 'defsrc'
layer to start your own keyboard configuration. Copy out the `deflayer`
template to easily start a new layer with matching `transparent` buttons.