Skip to content

Instantly share code, notes, and snippets.

View shalomb's full-sized avatar
🎯
Knolling

Shalom Bhooshi shalomb

🎯
Knolling
View GitHub Profile
@shalomb
shalomb / start-webserver.ps1
Last active January 4, 2024 13:10
Powershell Echo Server
#! powershell
$HttpListener = New-Object System.Net.HttpListener
$HttpListener.Prefixes.Add("http://+:80/")
$HttpListener.Prefixes.Add("http://+:18093/")
$HttpListener.Prefixes.Add("http://+:18095/")
# $HttpListener.Prefixes.Add("https://+:443/")
$HttpListener.Start()
@shalomb
shalomb / git-update-content.sh
Last active October 24, 2023 19:41
Update git content via API
#!/bin/bash
set -eu -o pipefail
content="foo and bar and baz"
content="$(base64 <<<"$content")"
sha=$(git ls-files -s foo | awk '{print $2}')
@shalomb
shalomb / setup.sh
Last active April 21, 2023 12:52
Minimal Debian Image
# Install cleanup utils
apt-get install -y deborphan
# Remove all desktop/gui/hci packages/libraries
apt-get purge -yyq --auto-remove \
task-desktop x11-common fdutils \
'*ubuntu-desktop*' \
'*X11*' '*wayland*' '*xdmcp*' '*gtk*' '*gnome*' 'x11-*' '*font*' \
'*orca*' '*bluez*' '*bluetooth*' '*audio*' '*desktop*' '*laptop*' \
'*acpi*' '*spell*' '*avahi*' '*-faq*' '*cups*' '*sane*' '*icon*' \
# neovim build dependencies
sudo apt-get build-dep neovim -t unstable
# Build tools
sudo apt install build-essential libtool libtool-bin devscripts
# git source
git clone https://github.com/neovim/neovim.git
cd neovim
# Checkout latest tag
@shalomb
shalomb / logwriter.ps1
Created December 14, 2022 17:44
PowerShell Redefine Write-Host, Write-Output for Logging
# PowerShell
Set-StrictMode -Version 2.0
Set-PSDebug -Trace 0
$ErrorActionPreference = 'STOP'
function Register-LogWriter {
<#
.SYNOPSIS
@shalomb
shalomb / 0refresh-ntp.sh
Last active January 3, 2022 15:29
Virtualbox guest time workaround
#!/bin/bash
# /etc/cron.hourly/0refresh-ntp
# Workaround for guest clock going out of skew regularly
# Essentially synchronizes systemd-timesyncd with NTP
# via timedatectl but using a reference of the datetime
# returned by http://worldtimeapi.org/api/ip
set -eu -o pipefail
@shalomb
shalomb / README.md
Last active January 10, 2022 20:37
Transparent MFA support for AWS CLI

Setup

Install/Configure AWS CLI as usual (without MFA)

$ pip install awscli
...

$ aws configure  # and setup the default profile
...
@shalomb
shalomb / main.tf
Last active September 6, 2021 19:20
Terraform hackery - null_resource/local-exec + external/program data sources
# Demo of the external data source
# https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source
data "external" "passwd_field" {
program = [ "./passwd_field.sh" ]
query = {
user = var.user
field = var.field
file = local.target_file
}
depends_on = [
@shalomb
shalomb / README.md
Last active April 22, 2021 23:15
Signing virtualbox/vmplayer kernel modules

Sign virtualbox/vmplayer drivers on secure boot systems

Usage

$ ./generate-mok-cert.sh
$ sudo reboot  # and follow the MOK enrollment wizard
$ ./virtualbox-fix.sh
@shalomb
shalomb / Makefile
Last active April 19, 2021 21:30
v - A modern rewrite of https://github.com/rupa/v using fzf/bat
install:
chmod +x ./v
install -m550 $$PWD/v ~/.local/bin/
install -m550 $$PWD/v ~/.local/bin/