Skip to content

Instantly share code, notes, and snippets.

Avatar
🌱
natura

Gioele De Vitti devgioele

🌱
natura
View GitHub Profile
@devgioele
devgioele / partial-except.ts
Created January 8, 2023 09:35
A TypeScript type that makes all keys of an object optional, except for the keys given. Useful for making less strict variants of an existing type.
View partial-except.ts
/** Make all keys of T optional except for K. */
type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
@devgioele
devgioele / arch-rpi-64-full-disk-encryption-ssh-unlock.md
Last active January 18, 2023 04:47 — forked from gea0/arch-rpi-64-full-disk-encryption-ssh-unlock.md
Tutorial for installing a 64-bit Arch Linux ARM system on the Raspberry Pi 4B, with an encrypted root filesystem, and the option to remotely unlock it via a pre-boot SSH daemon.
View arch-rpi-64-full-disk-encryption-ssh-unlock.md

Arch Linux ARM 64 on Raspberry Pi 4B With Full Disk Encryption And SSH Unlock: 2022 Edition

There are multiple ways to get a full disk encrypted arch linux system on raspberry. In this tutorial, we will install a 64-bit arch linux armv8 system, using dropbear as ssh server for remote pre-boot unlocking of the root filesystem. However, it will still be possible to unlock and use the pi as usual, with a keyboard and monitor. We will also create an unencrypted partition in the installation process, usable as a rescue system.

For different setup options, see the end of the document.

Get The Image and check the signature

@devgioele
devgioele / publish.yml
Created May 30, 2022 15:37
Publish to a private GitHub NPM registry with caching
View publish.yml
name: Publish to the private GitHub NPM registry
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
jobs:
@devgioele
devgioele / env.ts
Created May 13, 2022 18:43
Load env vars utility
View env.ts
const msgMissing = (key: string): string => `Missing env var '${key}'`
export const loadOptionalEnvVar = (key: string): string | undefined =>
process.env[key]
/**
* Load an environment variable.
* @param key The key used to access the environment variable.
* @returns The value of the environment variable.
*/
@devgioele
devgioele / .env
Last active May 12, 2022 14:52
Verify env vars with Node.js
View .env
ARR1 = "value1 value2 value3"
ANOTHER = "test"
OPTIONAL_EXAMPLE = "optional test"
@devgioele
devgioele / renameRecursively.ps1
Last active December 9, 2021 13:58
Powershell cmd to rename files recursively using a regex
View renameRecursively.ps1
# Changing the file extensions of files from .js to .tsx
Get-ChildItem ./src -File -Recurse | Rename-Item -NewName { $_.Name -replace '\.js','.tsx' }
@devgioele
devgioele / HoareLomuto.java
Created December 14, 2020 11:39
Hoare and Lomuto Algorithms
View HoareLomuto.java
int partitionLomuto(int[] A) {
int l = 0, r = A.length - 1;
int p = A[r];
int ll = l - 1;
for (int bu = l; bu < r; bu++) {
if (A[bu] <= p) {
ll++;
swap(A, ll, bu);
}