Value | Color |
---|---|
\033[0;30m | Black |
\033[0;31m | Red |
\033[0;32m | Green |
\033[0;33m | Yellow |
\033[0;34m | Blue |
\033[0;35m | Purple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension that adds the [chunked] method to a [Stream] of [List]s, to | |
/// allow dividing that [Stream] of (potentially) arbitrarily sized [List]s into | |
/// a stream of fixed sized [List]s. | |
extension ChunkedStream<T> on Stream<List<T>> { | |
/// Convert the stream to a chunked stream, where each chunk is of the given | |
/// [size]. The size of each chunk must be at least one, but the size may be | |
/// any number larger than one (if the stream is finished before a chunk is | |
/// finished, that chunk is returned as-is). | |
Stream<List<T>> chunked(final int size) async* { | |
if (size < 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is a TypeScript version of the `Completer` class from Dart. | |
* | |
* A `Completer` provides a future that can be imperatively concluded (once and | |
* only once) with either `#complete` or `#completeError`. | |
* Once the completer has completed (or errored), the future will be resolved | |
* with the specified value. | |
* | |
* This is trivially implemented by instantiating a Promise and capturing the | |
* resolve and reject functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// This class extends [SizedBox] whilst implementing [PreferredSizeWidget] | |
/// based on the defined size. This allows the use of [SizedBox] in places | |
/// where [PreferredSizeWidget] is required, such as in [AppBar.preferredSize]. | |
class PreferredSizedBox extends SizedBox implements PreferredSizeWidget { | |
const PreferredSizedBox({super.key}); | |
const PreferredSizedBox.shrink({super.key, super.child}) : super.shrink(); | |
const PreferredSizedBox.expand({super.key, super.child}) : super.expand(); | |
PreferredSizedBox.fromSize({super.key, super.child, super.size}) | |
: super.fromSize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { promisify } = require('util'); | |
const exec = promisify(require('child_process').exec); | |
/** Returns a random byte as a floating-point decimal between 0 and 1. */ | |
async function random() { | |
const payload = await exec(`gpg-connect-agent "SCD RANDOM 1" /bye`); | |
const randomBytes = payload.stdout.split('\n')[0].substr(2); | |
const buffer = Buffer.from(randomBytes, 'utf-8'); | |
const number = buffer.readUIntBE(0, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin ClientControllerSupport {} | |
abstract class Client { | |
void doSomething(); | |
static isControllable(Client client) { | |
return client is ClientControllerSupport; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Macros do | |
defmacro matching_tuple_values(n, a, b) do | |
# If we've reached n = 0 for the Macro invocation, we've already checked | |
# the elements at that index, so we can | |
if n < 1, do: true, | |
else: quote do: ( | |
# Check that elem(a, n - 1) == elem(b, n - 1). | |
(elem(unquote(a), unquote(n) - 1) == elem(unquote(b), unquote(n) - 1)) | |
# Then, check that this also holds recursively for | |
# matching_tuple_values(n - 1, ...). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* gpio.s - Library for working with GPIO pins in ARM32 assembly. | |
* Version 1.1.1 (Dec/2/22) | |
* | |
* Changelog: | |
* ========== | |
* v1.1.1 (Dec/2/22): | |
* - Make gpioMode pull up for input and pull down for output. | |
* v1.1 (Dec/1/22): | |
* - Add gpioRead and gpioPull functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* gpio.s - Library for working with GPIO pins in ARM32 assembly. | |
* Version 1.0 (Oct/10/22) | |
* | |
* Changelog: | |
* ========== | |
* v1.0 (Oct/10/22): | |
* - Initial Release | |
* | |
* License: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This does not work under Linux because we lack the ability to access the MMIO/GPIO memory via DMA. | |
.global initializeGPIO | |
initializeGPIO: | |
PROLOGUE | |
/* Use the SOC proc file to determine the MMIO base offset. */ | |
// Call open to get a file descriptor for the device tree proc file. | |
LDR R0, =socRangesProcFile |
NewerOlder