Skip to content

Instantly share code, notes, and snippets.

@craigphicks
craigphicks / README.md
Last active May 23, 2025 04:02
systemd user service to run a docker container

The systemd servicefile codium-server.service is executed at boot time. It executes a script startup-codium-server.sh which calls docker run ...., the details of which are not shown here. The docker container being run will fork, and the service can/does not keep track of it. That's why Type=oneshot is used in the service file.

Lingering has to be set up so that the user service can be run even when the user has not logged on:

loginctl enable-linger $USER

To check that linger setting

@craigphicks
craigphicks / README.md
Last active May 22, 2025 22:42
Unlocking LUKS full disk encryption with a USB key (for e.g., headless)

Unlocking LUKS full disk encryption with a USB key

Use case

It is being used to boot up a headless system running debian12 (bookworm)

Prepare USB

Prepare a USB containing a file keyfile which contains a password to open the LUKS partition. The UUID of the USB will be used. In this example case it is 69A0-9BE4.

@craigphicks
craigphicks / equation-1.md
Created February 11, 2025 00:52
equation 1 for

$$ P_{\text{crit}} = \text{cdf}(\frac{\sqrt{NK}\ (K-1)}{2^{m+2}}; 0, 1) $$

@craigphicks
craigphicks / decision-rules-output.md
Last active February 11, 2025 01:49
Output of decision rules table code example

Correspondence between m and PyTorch call form

m call
24 argsort(rand((batch_count,K)))
32 argsort(randint(low=-2**31,high=2**31-1,(batch_count,K),dtype=integer32))
64 argsort(randint(low=-2**63,high=2**63-1,(batch_count,K),dtype=integer64))
@craigphicks
craigphicks / setup-aws-linux-for-gpu.sh
Created August 17, 2024 10:04
Setup an AWS Linux AMI with NVIDIA-Linux-x86_64 drivers and nvidia-container-toolkit
#!/bin/bash
set -e
# Step-by-Step Installation Guide
# Step 0: Remove existing NVIDIA drivers and CUDA installations
sudo yum erase -y nvidia cuda
# Step 1: Update the system and install dependencies
@craigphicks
craigphicks / lerna-serial.ts
Created January 6, 2022 02:06
Workaround for lerna run bug (not calling in topological order).
Lerna issue [ Lerna does not run scripts according to topological order #2731 ](https://github.com/lerna/lerna/issues/2731)
reports the bug, but issue was closed although not resolved.
Strangely, I didn't **notice** any problem until adding new scopes in the project.
But now I have the same bug.
I threw up something quick to get builds working again, and posted it here.
It's a near replacement but uses regexp instead of globbing.
### Keybase proof
I hereby claim:
* I am craigphicks on github.
* I am craigphicks (https://keybase.io/craigphicks) on keybase.
* I have a public key ASC8QGnm0y40XjjMeoQiia7-7ESqROa6XhlL-g9in4RUPQo
To claim this, I am signing this object:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"type": {
"info": "this is a ts.Type with id=86",
"flags": [
"Union"
],
"objectFlags": [
"PrimitiveUnion"
]
@craigphicks
craigphicks / commonjs-index.js
Created July 26, 2021 06:52
comparison of index.js produced with module:CommonJs vs. module:es2020 under yamato_daiwa-es_extensions
(() => {
"use strict";
var e, t = {
5272: (e, t) => {
Object.defineProperty(t, "__esModule", {
value: !0
}), t.default = function(e, t) {
for (const [a, n] of e.entries())
if (t(n)) return a;
return null
@craigphicks
craigphicks / custom-tsc.ts
Last active January 6, 2021 13:21
Typescript - How to compile only one (or more) files from a project using all the project settings from the tsconfig file(s)
import * as ts from 'typescript';
import * as fs from 'fs';
import * as path from 'path';
import * as cp from 'child_process';
import * as dm from '../src-ts/deep-merge-objects';
function compile(fileNames: string[], options: ts.CompilerOptions): void {
const program = ts.createProgram(fileNames, options);
const emitResult = program.emit();
const allDiagnostics = ts