Skip to content

Instantly share code, notes, and snippets.

@mmguero
mmguero / Vagrantfile
Last active December 2, 2021 23:23
Windows 10 enterprise evaluation Vagrantfile for libvirt provider with chocolatey and Ubuntu WSL2 (with native docker) installed to a new hard drive
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "vagrant-windows-10-enterprise-x64-eval"
config.vm.box = "peru/windows-10-enterprise-x64-eval"
config.vm.communicator = "winrm"
# Admin username and password (see also WSL username/password setup in WSL_Ubuntu_Setup.ps1)
@mmguero
mmguero / Vagrantfile
Created December 8, 2021 18:19
Vagrantfile for Debian 11 with podman
unless Vagrant.has_plugin?("vagrant-sshfs")
raise 'vagrant-sshfs plugin is not installed!'
end
unless Vagrant.has_plugin?("vagrant-reload")
raise 'vagrant-reload plugin is not installed!'
end
# hack: https://github.com/hashicorp/vagrant/issues/8878#issuecomment-345112810
class VagrantPlugins::ProviderVirtualBox::Action::Network
@mmguero
mmguero / map_instructions
Created January 3, 2022 16:07
create large PNG satelite image map
1. docker run -v $PWD/output:/app/output/ -p 8080:8080 -it aliashraf/map-tiles-downloader
2. navigate to http://localhost:8080 and follow the on-screen prompts
3. cd ./output/############/##
4. for DIR in 9*; do pushd "$DIR"; convert -append *.png ../$DIR.png; popd; done
5. convert 9*.png +append ../../../all.png
6. may need to edit /etc/ImageMagick-6/policy.xml
@mmguero
mmguero / zeek_intel_pull.sh
Created January 12, 2022 19:42
pull zeek intel feeds for Malcolm zeek in Docker
#!/usr/bin/env bash
[[ "$(uname -s)" = 'Darwin' ]] && REALPATH=grealpath || REALPATH=realpath
[[ "$(uname -s)" = 'Darwin' ]] && DIRNAME=gdirname || DIRNAME=dirname
if ! (type "$REALPATH" && type "$DIRNAME") > /dev/null; then
echo "$(basename "${BASH_SOURCE[0]}") requires $REALPATH and $DIRNAME"
exit 1
fi
SCRIPT_PATH="$($DIRNAME $($REALPATH -e "${BASH_SOURCE[0]}"))"
@mmguero
mmguero / Vagrantfile
Last active April 26, 2022 23:54
Windows 10 (libvirt provider) with script for installing scoop
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "vagrant-windows-10-enterprise-x64-eval"
config.vm.box = "peru/windows-10-enterprise-x64-eval"
config.vm.communicator = "winrm"
# Admin username and password
@mmguero
mmguero / ssh_with_yubikey_example.txt
Last active May 3, 2022 20:10
create SSH key with YubiKey
› ssh-keygen -t ed25519-sk
Generating public/private ed25519-sk key pair.
You may need to touch your authenticator to authorize key generation.
Enter PIN for authenticator:
You may need to touch your authenticator (again) to authorize key generation.
Enter file in which to save the key (/home/mmguero/.ssh/id_ed25519_sk):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mmguero/.ssh/id_ed25519_sk
Your public key has been saved in /home/mmguero/.ssh/id_ed25519_sk.pub
@mmguero
mmguero / self_signed_key_gen.sh
Last active October 20, 2022 21:21
generate self-signed CA, server/client .crt/.key files and dhparam.pem
#!/usr/bin/env bash
# https://gist.github.com/mmguero/ee69524da6a93296d888530f1a55c178
# generate self-signed CA, server, and client .crt/.key files and dhparam.pem
# can test with:
# openssl s_server -Verify 999 -CAfile ca.crt -key server.key -cert server.crt -accept 44330 -www
# openssl s_client -CAfile ca.crt -key client.key -cert client.crt -showcerts -connect localhost:44330
@mmguero
mmguero / store_unique.sh
Last active October 20, 2022 21:20
create an SQLite3 database and store (or retrieve) a unique value in it
#!/usr/bin/env bash
# https://gist.github.com/mmguero/29e93d47bc7b967e2dc85dbfd352c9d1
# create an SQLite3 database and store (or retrieve) a unique value in it
set -e
set -u
set -o pipefail
shopt -s nocasematch
@mmguero
mmguero / git_clone_all.sh
Last active October 20, 2022 21:42
clone all of a GitHub user's or organization's repositories and set up upstream remotes for forks
#!/usr/bin/env bash
# "git clone" all of a GitHub user's or organization's repositories (up to 100)
# if the repo is a GitHub fork, add the parent fork as an upstream remote.
# https://gist.github.com/mmguero/04bbbc8660e0b554740cae938069d527/edit
ENCODING="utf-8"
GIT_API_URL_PREFIX="https://api.github.com"
@mmguero
mmguero / mkv_subtitle_extract.sh
Last active October 20, 2022 21:25
extract all subtitles from an MKV/MP4 file
#!/usr/bin/env bash
# extract all subtitles from an MKV/MP4 file
# https://gist.github.com/mmguero/efea277a272aacceca60bcccf1a15563
shopt -s nocasematch
toolPath=''