Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
###################################
## ##
## TITLE: ##
## ADB `pm list users` to YAML ##
## ##
## USAGE: ##
## - Download this script. ##
## - Execute it (`bash ...`). ##
## FILTER ##
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:UDP - [0:0]
:TCP - [0:0]
# Modify them!
LPORT="${LPORT:-22}"
RPORT="${RPORT:-8022}"
SSH="${SSH:-"ssh -C -q -N -f"}"
TARGET="${TARGET:-"theuser@remotehost"}"
is_pi() {
# You can replace this check to your needs.
# Just make sure you return something true.
test -f /etc/rpi-issue -a -r /etc/rpi-issue
@bryanjhv
bryanjhv / home-server.md
Created December 19, 2020 06:31 — forked from nileshtrivedi/home-server.md
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

@bryanjhv
bryanjhv / Program.cs
Created December 15, 2020 03:48
C# program menu (searches classes and runs Main method)
using System;
using System.Linq;
using System.Reflection;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var current = MethodBase.GetCurrentMethod().DeclaringType;
var methods = (
import os
import sys
import os.path
import hashlib
base = sys.argv[1]
if not os.path.exists(base):
sys.exit(1)
dirs = []
@bryanjhv
bryanjhv / jbadel.py
Created May 19, 2020 21:48
Delete JetBrains IDE Settings Sync (JBA Account) data
#!/usr/bin/env python3
# USAGE:
# 1. Download https://account.jetbrains.com/profile-details/JetBrainsPersonalData.xlsx
# 2. Open with Excel, go to Account sheet (default) and copy "Account ID" value (token)
# 3. Go to your IDE's folder and copy the "name" property from "product-info.json"
# 4. Run:
# export TOKEN=... # step 2
# export PRODUCT=... # step 3
# python3 jbadel.py
@bryanjhv
bryanjhv / turn.js
Last active May 17, 2020 20:44
TURN REST API for the browser (INSECURE!).
/*
USAGE:
TURN('mysecret', 24 * 60 * 60)
.then(({ username, credential }) => {
console.log({ username, credential })
})
*/
const TURN = ((crypto, encoder) => {
@bryanjhv
bryanjhv / fake-webcam
Created May 3, 2020 09:38
Create fake webcam for Raspberry Pi (3B+ tested)
#!/usr/bin/env sh
# REQUIRES BUILDING+INSTALLING THIS FIRST:
# https://github.com/umlaeute/v4l2loopback#install
NUM=${2:-0}
PIC=${1:-/usr/share/plymouth/themes/pix/splash.png}
if [ ! -r "$PIC" ]
then
@bryanjhv
bryanjhv / getppa
Last active June 15, 2020 03:10
Get PPA .gpg and .list files easily on Ubuntu
#!/usr/bin/python3
# USAGE:
# getppa git-core/ppa bionic
# getppa certbot/certbot bionic
# getppa git-core/ppa bionic git.%s
# getppa certbot/certbot bionic certbot.%s
from shutil import rmtree
from sys import argv, exit