Skip to content

Instantly share code, notes, and snippets.

View johnrichardrinehart's full-sized avatar

John Rinehart johnrichardrinehart

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="">
<style>
</style>
<script src=""></script>
<body>
@johnrichardrinehart
johnrichardrinehart / configuration.nix
Created October 11, 2021 09:51
configuration.nix to use for fresh installs of NixOS 21.05 (enables flakes and sets some standard options for grub/UEFI)
{ config, pkgs, ... }:
let
grubOptions = {
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/vda";
};
uefiOptions = {
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@johnrichardrinehart
johnrichardrinehart / install.sh
Last active October 11, 2021 08:36
NixOS swap and MBR install script
#!/usr/bin/env bash
# You can fetch to disk with
# curl -o install.sh <raw_gist_url>
#
# Run with `sudo`
# Environment variables:
# NIXOS_INSTALL_SWAP_SIZE (default: "8GiB")
# NIXOS_INSTALL_ROOT_DRIVE (default: "/dev/sda")
# NIXOS_INSTALL_EDIT_CONFIGURATION_FILE (default: "yes", accepted value: "no")
@johnrichardrinehart
johnrichardrinehart / install.sh
Last active September 25, 2021 15:25
NixOS UEFI automated install
#!/usr/bin/env bash
# Run with `sudo`
# Environment variables:
# NIXOS_INSTALL_SWAP_SIZE (default: "8GiB")
# NIXOS_INSTALL_ROOT_DRIVE (default: "/dev/sda")
# NIXOS_INSTALL_EDIT_CONFIGURATION_FILE (default: "yes", accepted value: "no")
# https://stackoverflow.com/a/2013589
NIXOS_INSTALL_SWAP_SIZE="${NIXOS_INSTALL_SWAP_SIZE:=8GiB}"
@johnrichardrinehart
johnrichardrinehart / pointer_deref_vs_value.sh
Last active September 15, 2021 16:53
A shell script that compares: A) assigning a pointer to a variable and B) assigning the pointer to a dereferenced pointer to a variable
#!/usr/bin/env bash
fifo="tmp.fifo"
mkfifo "${fifo}"
# write the below go code to the fifo
function write_pointer_deref {
cat <<EOF > ${fifo}
package foo
@johnrichardrinehart
johnrichardrinehart / nixos_in_virtualbox.md
Last active May 5, 2024 19:05
NixOS from "scratch" as Virtualbox Guest

Steps

New VirtualBox Machine

  1. Create a new disk image (I use VDI for compatibility with VirtualBox)
  2. Allocate some RAM (>6 GiB to start)
  3. Add some video memory and enable 3D acceleration, if needed
  4. Optional: Enable EFI (instead of BIOS)
  5. Attach nixos-minimal ISO for installation
  6. Boot into the ISO

Inside the Live CD

UEFI instructions

@johnrichardrinehart
johnrichardrinehart / stressballer.go
Created February 11, 2021 10:39
Stress test demo code for charm.io
package main
import (
"context"
"flag"
"fmt"
"sync"
"time"
"github.com/chromedp/cdproto/network"
# build an ISO image that will auto install NixOS and reboot
# $ nix-build make-iso.nix
let
config = (import <nixpkgs/nixos/lib/eval-config.nix> {
system = "x86_64-linux";
modules = [
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
({ pkgs, lib, ... }:
let
@johnrichardrinehart
johnrichardrinehart / webpack-dev-server_output
Created November 27, 2020 10:17
webpack-dev-server doesn't accept contentBase as a valid field
/home/john/Downloads/repos/project/app/.yarn/cache/schema-utils-npm-3.0.0-e97702da81-a084f593f2.zip/node_modules/schema-utils/dist/validate.js:104
throw new _ValidationError.default(errors, schema, configuration);
^
ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration has an unknown property 'contentBase'. These properties are valid:
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, injectClient?, injectHot?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, overlay?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }
at validate (/home/john/Downloads/repos/project/app/.yarn/cache/schema-utils-npm-3.0.0-e97702da81-a084f593f2.zip/node_modules/schema-utils/dist/validate.js:104:11)
at new Server (/home/john/Downloads/repos/project/app/.
@johnrichardrinehart
johnrichardrinehart / LFS-compiler-bootstrapping.gv
Created September 16, 2020 23:15
A graphviz file outlining the LFS GCC compiler bootstrap sequence
digraph G {
// edges
subgraph cluster_degradedgcc {
style=filled;
color=lightgrey;
cc1 -> lapih -> glibc -> libstdcpp1;
label=< <b> cc1: Degraded bootstrap cross-compiler </b> >;
}
subgraph cluster_supgcc {