Skip to content

Instantly share code, notes, and snippets.

View groboclown's full-sized avatar
💭
Designing Monkey Pants

groboclown

💭
Designing Monkey Pants
View GitHub Profile
@groboclown
groboclown / lines-with-unicode-character.sh
Last active February 19, 2024 04:08
Teach A Shell Script How To Parse Unicode Files
#!/usr/bin/env sh
# Licensed as CC-0
# An example script for teaching the shell script how to parse and work with Unicode files.
# In this example, the code scans the input file for lines that contain a specific Unicode character.
# The character must be represented as a UTF-32be (big endian) hex string.
# For example, to search for 'A', use '00000041'
# This script uses the tools:
# common core unix tools: 'tr', 'echo', 'cut' and 'test' (aliased as '[')
@groboclown
groboclown / concurrent_reduce.go
Last active October 17, 2023 16:10
Golang Concurrent Reduce when Order Matters
// Released under the Public Domain
// Where applicable, consider this CC-0
// Inspired by the Rope science documents from the Xi text editor:
// https://xi-editor.io/docs/rope_science_01.html
package main
import (
"context"
"crypto/sha256"
"fmt"
@groboclown
groboclown / map-reduce.go
Last active October 14, 2023 19:15
Go Concurrent Monoid Map Reduce
// Released under the Public Domain
// Where applicable, consider this CC-0
// Inspired by the Rope science documents from the Xi text editor:
// https://xi-editor.io/docs/rope_science_01.html
package main
import (
"context"
"fmt"

Creates a CycloneDX SBOM by way of tox.

The current implementation is limited to working with a pyproject.toml file and the tox configuration in a separate tox.ini file. It's tested against Python 3.10.

This is intended to be run in an independent tox environment with no dependencies. A good format for the tox environment in the tox.ini file is:

[testenv:sbom]
@groboclown
groboclown / trailing_commas.py
Last active January 15, 2024 16:00
PyLint Extension for Enforcing Trailing Commas
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# Under the this license, this extension applies the GPL to the extension itself, which is
# only used when run as part of PyLint. Therefore, it can be included in your project
# without triggering the viral clause.
# For details: https://github.com/groboclown/pylint-trailing-commas/blob/main/LICENSE
# Copyright (c) https://github.com/groboclown/pylint-trailing-commas/blob/main/CONTRIBUTORS.txt
# type: ignore
"""
@groboclown
groboclown / load-properties.gradle
Last active August 5, 2019 13:52
An example gradle file for loading a hierarchy of properties from several locations in a well defined order. It also allows for the properties to be written as plain groovy scripts, and defined as closures so they can depend on other, overwritten properties.
/**
* load-properties.gradle
*
* USE: Include in your root project's `build.gradle` file:
*
* ```(groovy)
* apply from: "$rootDir/init/load-properties.gradle"
* ```
*
* Add a `$rootDir/init/categories.gradle` file to define which
@groboclown
groboclown / Dart-Futures.md
Last active September 17, 2016 00:43
Dart sequential execution of Futures

Dart uses Future objects whenever there might be a delay in the execution of the code, say reading the contents of a File or launching a Process. Running chaining Futures such that they run one after the other requires returning a future from within the Future:

Future<X> f1 = action1();
f1 = f1.then((x) => action2());

The key here is the re-assignment of f1 to the result of the then call.

To chain an arbitrarily long list of Futures, you can setup the code like this: