Skip to content

Instantly share code, notes, and snippets.

View skounis's full-sized avatar

Stavros Kounis skounis

View GitHub Profile
@skounis
skounis / install-ubuntu-2204-wsl2.bat
Last active October 20, 2022 12:24
WSL2 Install Ubuntu with Text User Interface
:: Download Ubuntu 22.04 from Microsoft Store
:: Launch Ubuntu 22.04. The Ubuntu installation GUI window will be black. Close it.
:: Open PowerShell and start the setup in TUI mode
sl --shutdown
wsl --unregister Ubuntu-22.04
ubuntu2204.exe --ui=tui
:: See
:: https://github.com/microsoft/WSL/issues/8525
@skounis
skounis / getandverify.sh
Created July 28, 2022 07:22
Download and verify the EU DCC Trustlist
#! /bin/bash
# Download trustlist, signature and certificate
wget https://ec.europa.eu/assets/eu-dcc/dcc_trustlist.zip
wget https://ec.europa.eu/assets/eu-dcc/dcc_trustlist.zip.sig.txt
wget https://ec.europa.eu/assets/eu-dcc/eu_signer.pem.txt
# Convert the signature file from base64 encoded to plain DER file
openssl base64 -a -A -d -in dcc_trustlist.zip.sig.txt -out dcc_trustlist.zip.sig.der
# Verify the integrity
openssl cms -verify -in dcc_trustlist.zip.sig.der -inform DER -content dcc_trustlist.zip -binary -CAfile eu_signer.pem.txt --out /dev/null
@skounis
skounis / nuke-git.sh
Last active April 5, 2022 07:35
Remove a file from Git's history
# Download bfg for
# https://rtyley.github.io/bfg-repo-cleaner/
java -jar bfg.jar --delete-files {filename}
git push --force
@skounis
skounis / open-edge.bat
Last active March 28, 2022 14:31
Open Edge with disabled security
"c:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --disable-web-security --disable-gpu --user-data-dir=c:/tmp/chromeTemp
@skounis
skounis / 7za.sh
Last active March 15, 2022 06:33
Create a AES256 encrypted .zip file with 7 zip
# Encrypt and zip
7za a -tzip -pMY_SECRET -mem=AES256 secure.zip doc.pdf doc2.pdf doc3.pdf
# Decrypt and unzip
7za e secure.zip
@skounis
skounis / cache-remove.sh
Created March 14, 2022 12:14
Git ignore and remove files from the history (cached)
# List all the ignored files previously commited
git ls-files -ci --exclude-standard
# Remove file from Git's history. It keeps it in the file system
git rm --cached path/to/file
# Remove all the ignored files
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
@skounis
skounis / create-patches.sh
Created March 10, 2022 13:59
Generate git patches
# Generate patch for last commit
git format-patch -1 HEAD
# Generate patches for last 2 commits
git format-patch -2 HEAD
# Combine the changes of the last 2 commits into on patch file
git format-patch -2 HEAD --stdout > combined.patch
@skounis
skounis / watchdog.sh
Created March 8, 2022 12:38
Drupal delete all the watchdog entries.
drush watchdog-delete all
@skounis
skounis / notes.md
Created February 28, 2022 11:33
Migrate MongoDB with mongodump and mongorestore

Dump the existing

mongodump -h 127.0.0.1:27017 -u "DB_USER" -p "PASSWORD" --db DB_NAME --archive=$HOME/backup/dump.gz --gzip

Restore

As a root user, no auth.

mongorestore --host=127.0.0.1 --gzip --archive=dump.gz
@skounis
skounis / table-size.sql
Created February 23, 2022 15:52
Show the records of all tables
SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES [WHERE TABLE_SCHEMA = '**YOUR SCHEMA**';]