Skip to content

Instantly share code, notes, and snippets.

@brainsik
brainsik / README.md
Last active March 26, 2024 00:21
NixOS / Nix notes

Notes from running NixOS in a local VM.

The attached configuration.nix sets users immutable to force managing them through the config. The primary user is added to the wheel group and the wheel group has passwordless sudo access. All passwords are set by hash (using mkpasswd). SSH keys can be added for the primary user and/or Tailscale SSH can be enabled.

Everything below is run as root.

Partition, format, mount, configure:

@brainsik
brainsik / font.css
Last active February 14, 2024 00:52
My trashy CSS to make Obsidian use the fonts I like
:root{
/* editor mode */
--text-editor: 'iA Writer Mono S';
/* code */
--font-monospace: 'FiraCode Nerd Font';
}
body {
font-family: var(--default-font);
@brainsik
brainsik / color_log.py
Created September 24, 2011 03:51
ANSI colored Python logging
import logging
from termcolor import colored
class ColorLog(object):
colormap = dict(
debug=dict(color='grey', attrs=['bold']),
info=dict(color='white'),
warn=dict(color='yellow', attrs=['bold']),
@brainsik
brainsik / rules.json
Last active February 1, 2023 08:07
Darktide - Armoury Exchange - filter rules
[
{
"minStats": 360
},
{
"minBlessingRarity": 3,
"item": [
"Staff"
]
},
@brainsik
brainsik / httrack-mediawiki.sh
Last active September 29, 2022 16:37
Create a static HTML archive of a MediaWiki site.
# $URL - the url to mirror
# $PATH - where to put the httrack files
httrack $URL -O $PATH -v -x \
--disable-security-limits \
-F 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15' \
-c16 -%c32 -%k \
-s0 -n -%u \
'-*api.php*' '-*index.php*' '-*title=*' '-*Special:*' \
'+*Special:SpecialPages' '+*Special:AllPages' '+*Special:Categories' \
@brainsik
brainsik / dotdict.py
Created June 11, 2011 00:31
Override Python's dict with this for JS style dot notation access :-)
# encoding: utf-8
class DotDict(dict):
def __init__(self, *a, **kw):
dict.__init__(self, *a, **kw)
for key in self:
self._validate_key(key)
def _validate_key(self, key):
@brainsik
brainsik / b2-cp.md
Created March 15, 2021 16:48
Upload a file to B2 Cloud Storage using SSE-C (customer managed key)

Generate key

dd if=/dev/random of=keyfile count=1 bs=32

Upload file

Endpoint is found in the bucket details via console.

@brainsik
brainsik / minimal-infra.md
Last active March 5, 2021 22:14
Minimalist Infrastructure

Minimalism

Minimalist infrastructure is the practice of building only what you need with the fewest number of resources. This is a philosophy, not a religion, you shouldn't build bad infrastructure to achieve a minimalist design. A minimalist design should lead to good infrastructure by reducing the amount of resources under management and the complexity of the design.

Avoid state

When designing your system, avoid storing additional state. Often the data you want to store is already available in the system. Using the system as the source of truth can avoid the difficult business of ensuring data consistency.

As an example, let's say you want to be able to rollback a Fargate deploy if the new task definition results in a service that won't become healthy. One option would be store the working task definition in something like DynamoDB (or git or any number of bad choices). However, your ECS service already has this information: the previous, healthy service is still running. Instead of managing a

@brainsik
brainsik / install-terraform-provider-aws.sh
Created January 22, 2021 01:53
Installs the AWS Terraform provider to your local plugins directory
#!/bin/sh
set -eu -o pipefail
set -x
version=$1
cd terraform-provider-aws
git fetch
git checkout .
@brainsik
brainsik / install-tf-11-14.sh
Created May 23, 2019 23:30
How to install an older version of a Homebrew forumla
brew uninstall terraform
brew extract --version 0.11.14 terraform homebrew/cask
brew install terraform@0.11.14