Skip to content

Instantly share code, notes, and snippets.

View kdwinter's full-sized avatar

Kenneth De Winter kdwinter

  • Ghent, Belgium
  • 06:05 (UTC +01:00)
View GitHub Profile
@Toliak
Toliak / RESEARCH.md
Last active November 7, 2024 11:45
Huawei Matebook D16 RLEF-X NVMe Laptop Disk is read-only after sleep problem research and fix

I have bought laptop Huawei Matebook D16 RLEF-X. Tried to use Arch Linux and encountered with the problem:

  1. Turn on the suspend mode (sudo systemctl suspend)
  2. Close the laptop lid
  3. Wait a few minutes
  4. Open the laptop back
  5. Use mount to see that the disk is read-only. Moreover, it determines like read-only, however, it is just broken. No zsh history, no executables, no way to poweroff without power button long-press.

OpenBSD logo     Rails logo     Falcon logo


Choose OpenBSD for your Unix needs. OpenBSD -- the world's simplest and most secure Unix-like OS. A safe alternatve to the frequent vulnerabilities and overengineering of Linux and related software (NGiNX & Apache (httpd-asiabsdcon2015.pdf), OpenSSL, iptables/nftables, systemd, BIND, Postfix, Docker etc.)

OpenBSD -- the cleanest kernel, the cleanest userland and the cleanest config

@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created February 5, 2022 22:51
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@huntrar
huntrar / full-disk-encryption-arch-uefi.md
Last active November 10, 2024 10:43
Arch Linux Full-Disk Encryption Installation Guide [Encrypted Boot, UEFI, NVMe, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS and an encrypted boot partition (GRUB) for UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and self-signed kernel and bootloader.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

Note: The system was installed on an NVMe SSD, substitute /dev/nvme0nX with /dev/sdX or your device as needed.

@erikw
erikw / znp
Last active September 11, 2024 21:03
znp: Wrap shell command in ZFS pre-post snapshots and log outputs.
#!/usr/bin/env bash
# Runs a command wrapped in ZFS pre-post snapshots. The whole data pool is recursively snapshotted.
# Analogous to my snp script for BTRFS: https://gist.github.com/erikw/5229436
# Usage: $ znp <commands>
# e.g.: $ znp pgk upgrade
# e.g.: $ znp portmaster -aG
# e.g.: $ znp freebsd-upgrade install
zfs_pool=zroot
@spicycode
spicycode / myweechat.md
Last active September 4, 2024 03:08 — forked from pascalpoitras/config.md
My always up-to-date WeeChat configuration (weechat-dev)

WeeChat Screenshot

Enable mouse support

/mouse enable

Encrypted password in sec.conf

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@saponace
saponace / LUKS + ext4 on one disk
Last active May 25, 2019 23:29
RAID1 disk setup
Let /dev/sdb be the disk.
# Create partition
sudo cfdisk /dev/sdb -> cerate partition /dev/sdb1
# Initialize disk data with random bits
sudo shred --verbose --random-source=/dev/urandom --iterations=3 /dev/sdb1
# Create the cryptographic device (leave hash and iter-time to default values if the drive will be mounted on a slow device)
sudo cryptsetup --verbose --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 luksFormat /dev/sdb1
# Open device
sudo cryptsetup open --type luks /dev/sdb1 DEVSDB1
@johnramsden
johnramsden / zfsinstall-1-setup.sh
Last active June 6, 2024 09:43
Install scripts for installing Arch Linux on ZFS. Not runnable, just listed commands.
#!/bin/bash
# Check before running, may need intervention
# Pass in the following to the script, or hardcode it.
# Uncomment if hardcoding input.
BOOT_PARTITION="/dev/sdg1"
DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093"
DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266"
POOL="vault"