Skip to content

Instantly share code, notes, and snippets.

View SamJakob's full-sized avatar
:octocat:
Programming

SamJakob SamJakob

:octocat:
Programming
View GitHub Profile
@SamJakob
SamJakob / kramdown_rfc_test.mkd
Created March 29, 2022 00:57
Bare-bones example for kramdown-rfc

title: Test Protocol abbrev: TP docname: draft-test-00 date: 2022-03-29 category: std submissionType: IETF

ipr: trust200902 area: Applications

@SamJakob
SamJakob / .zshrc
Created April 5, 2022 05:54
zsh script to check if in an npm directory when trying to run yarn
# ...
# Ensure yarn is not run in an npm directory.
yarn() {
if [ -f "./package-lock.json" ]; then
echo "no... this is an npm directory"
else
command yarn $@
fi
}
@SamJakob
SamJakob / Tensorboard.md
Created April 25, 2022 18:11
Helper class for Tensorboard (can be used directly in Jupyter notebooks)

Tensorboard Helper

Usage

  1. Add tensorboard.py to your project.
    • Add the file to your project and import it.
    • Or, if using Jupyter Notebook, paste it into a code cell.
  2. Initialize the class as follows:
# Clear any logs from previous runs
!rm -rf ./logs/
@SamJakob
SamJakob / dart_extensions_example.dart
Created September 2, 2022 21:53
Dart Extensions example
/// Library A
class Animal {
final String name;
const Animal({ required this.name });
}
class Dog extends Animal {
final String breed;
@SamJakob
SamJakob / pi-gpio-with-device-tree.s
Last active October 10, 2022 11:18
Raspberry Pi ARM32 GPIO using Device Tree
// 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
@SamJakob
SamJakob / gpio.s
Created October 10, 2022 11:19
Raspberry Pi ARM32 GPIO
/**
* 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:
@SamJakob
SamJakob / gpio.s
Last active December 2, 2022 22:14
gpio.s (v1.1.1)
/**
* 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.
@SamJakob
SamJakob / matching_tuple_values.ex
Created December 25, 2022 04:21
Simple/naive Elixir macro to check if up to N values in a tuple match for guard clauses
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, ...).
@SamJakob
SamJakob / ansi-escape-colors.md
Last active April 2, 2023 00:29 — forked from JBlond/bash-colors.md
ANSI color codes, escaped for use in scripts

Regular Colors

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
@SamJakob
SamJakob / main.dart
Created July 18, 2023 20:13
Backwards-compatible ControllableClient implementation.
mixin ClientControllerSupport {}
abstract class Client {
void doSomething();
static isControllable(Client client) {
return client is ClientControllerSupport;
}
}