Skip to content

Instantly share code, notes, and snippets.

@gzxu
gzxu / sedutil-pbkdf2.sh
Last active June 26, 2024 22:30
Unlock an SED-supporting SSD with sedutil Hardware Encryption
device=sdb
serial="$(ls -la /dev/disk/by-id | grep "/$device\$" | sed 's/ /\n/g' | grep ata | sed 's/_/\n/g' | tail -n1)"
read -r -s password
hashed=$(SERIAL="$serial" PASSWORD="$password" python3 -c 'import hashlib, base64, os; print(base64.b64encode(hashlib.pbkdf2_hmac("sha1", os.environ["PASSWORD"].encode(), os.environ["SERIAL"].ljust(20, " ").encode(), 75000, 32)).decode())' | base64 -d)
sudo sedutil-cli -n --listLockingRanges "$hashed" /dev/$device
@rojenzaman
rojenzaman / create_wp_db.sh
Last active September 6, 2024 12:20
with mysql root
#!/bin/bash
if [ "$#" -lt 4 ]; then
echo "`basename $0` <mysql-root-passwd> <db user> <ip> <db password>";
exit 1;
fi
mysql --user=root --password=$1 <<EOF
CREATE DATABASE wordpress;
CREATE USER '$2'@'$3' IDENTIFIED BY '$4';
@vms20591
vms20591 / gist:b8b17b3c44fc9b62ff734c0b588014db
Last active June 1, 2024 11:21
Virtualbox - Arch Linux installation - Full Disk Encryption with detached LUKS header & unecrypted boot

Pre-Requisites

  1. Arch Linux iso
  2. Virtualbox
  3. Two virtual HDDs - 8G (main) & 1G (detached header & boot) respectively

Preparing the disks

Step 1

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.

location = /404.html {
root /usr/share/nginx/error;
}
error_page 404 /404.html;
location = /50x.html {
root /usr/share/nginx/error;
}
error_page 500 502 503 504 /50x.html;
@Jiab77
Jiab77 / create-DNS-over-TLS-bridge-with-unbound-stubby-and-systemd-on-ubuntu-server-18.04.md
Last active October 16, 2024 03:22
This gist will explain how to create a DNS-over-TLS bridge for the local network.
@Jiab77
Jiab77 / setup-DNS-over-TLS-with-systemd-on-ubuntu-18.04.md
Last active August 23, 2024 22:43
This gist will explain how to setup DNS-over-TLS on your local computer.

Setup DNS-over-TLS with systemd on Ubuntu 18.04

This gist will explain how to setup DNS-over-TLS on your local computer.

Verify systemd version

To make it work, you need at least systemd version 237 or 242.

I'll use the version 242 in this gist.

@marcduiker
marcduiker / ffmpeg_video_for_twitter.md
Last active June 1, 2024 04:35
FFmpeg command for creating video for Twitter

Convert pngs to mp4

This FFmpeg command reads images named frame_[4 char digit].png and converts it to an mp4 using the h264 encoding which Twitter accepts. The bitrate is set to 5M to reduce blocking as much as possible while keeping the size small.

ffmpeg -framerate 10 -i frame_%04d.png -c:v h264_qsv -b:v 5M video.mp4

Convert and scale an existing mp4 to 1080:

ffmpeg -i input.mp4 -c:v h264_qsv -vf: scale=1080:-1 -b:v 5M output.mp4

# find merge-request which contains commit in GitLab
# https://gitlab.com/gitlab-org/gitlab-foss/-/issues/28037
# https://stackoverflow.com/a/17819027/7277090
git config --add remote.origin.fetch '+refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*'
git fetch origin
git for-each-ref --contains <hash> | grep merge-requests | head -n 10