Skip to content

Instantly share code, notes, and snippets.

Avatar

Harshad Sharma hiway

View GitHub Profile
@hiway
hiway / Caddyfile
Last active Nov 20, 2022
Caddyfile for Mastodon 3.x and 4.x that also maps @username@example.com -> @username@mastodon.example.com
View Caddyfile
example.com {
header /.well-known/host-meta Access-Control-Allow-Origin *
respond /.well-known/host-meta `https://mastodon.example.com{uri}`
@webfinger {
path /.well-known/webfinger*
}
reverse_proxy @webfinger {
to http://localhost:3000
@hiway
hiway / mastodon_domain_blocks.py
Last active Nov 9, 2022
Mastodon Domain Blocks WebUI
View mastodon_domain_blocks.py
"""
# Mastodon Domain Blocks
## Install
```
python -m venv venv
source venv/bin/activate
pip install click mastodon.py streamlit watchdog
@hiway
hiway / ssh-keygen.py
Last active Oct 28, 2022
Streamlit Demo - WebUI to generate/access SSH key-pairs for hosts.
View ssh-keygen.py
from pathlib import Path
from typing import List
import pyperclip
import streamlit as st
from plumbum import local
SSH_KEYS_DIR = "~/.ssh/keys"
# --- API ---
@hiway
hiway / be-minion-jail.sh
Created Jul 12, 2021
Run salt-minion in a Jailed Boot Environment on FreeBSD
View be-minion-jail.sh
#!/bin/sh
# Usage:
# First create a boot-environment with bectl:
# bectl create NAME
# Then run this script:
# be-minion-jail.sh BE-NAME
@hiway
hiway / README.md
Last active Feb 22, 2022
Creating a single process FreeBSD (12.1) Jail
View README.md

How to jail a single process web server on FreeBSD 12.1

You may have found many great resources on how to set up jails on latest FreeBSD, however there is scant information on how to go about creating a barebones jail with nothing but the one process that you want to isolate.

I was curious if I could contain a statically compiled web server that I wrote while learning Rust all by itself in a jail instead of having a full userland.

@hiway
hiway / mr600.py
Created Jan 29, 2020
Fetch and save SMS from Tp-Link Archer MR600 4G Router using Selenium and Firefox to SQLite database.
View mr600.py
#!/usr/bin/env python3
import datetime
import logging
import os
import peewee
import time
from collections import namedtuple
from selenium import webdriver
View README.md

Installing microblog.pub in a FreeBSD 12.1 (iocage) jail

sysrc ifconfig_vtnet0_name="public"
sysrc ifconfig_public="DHCP"

sysrc cloned_interfaces="bridge0"
sysrc ifconfig_bridge0_name="private"
sysrc ifconfig_private="inet 192.168.10.1/24"
@hiway
hiway / hiwaysshrc.sh
Last active May 12, 2022
My sshrc dofile to carry a custom bash prompt to remote *nix with ssh/mosh access.
View hiwaysshrc.sh
#!/usr/bin/env bash
##
## hiwaysshrc.sh
## --------------------------------------------------
##
## Install:
##
## $ ln -s $(pwd)/hiwaysshrc.sh ~/.sshrc
## $ echo "source ~/.sshrc" >> ~/.bash_profile
##
@hiway
hiway / README.md
Last active Feb 12, 2018
Automatically suspend selcted apps when not in use.
View README.md

MacOS App Auto-Suspend

This is a quick hack to test whether a Python script can manage suspending and resuming other applications on MacOS. This version is a draft and has been tested for a few hours on MacOS El Capitan, your mileage may vary.

The script should be run with system python, if you have installed another copy with brew or another manager,

@hiway
hiway / ubloom.py
Created Aug 3, 2017
A lightweight bloom filter for Micropython and Python 3 with a tiny memory footprint.
View ubloom.py
# coding=utf-8
try:
import urandom as _random
import uhashlib as _hashlib
import ubinascii as _binascii
except ImportError:
import random as _random
import hashlib as _hashlib
import binascii as _binascii