Skip to content

Instantly share code, notes, and snippets.

@ezr
ezr / index.html
Last active January 18, 2023 04:06
Google Cloud function to create QR codes
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title></title>
<style>
</style>
</head>
@ezr
ezr / stopwatch.go
Last active October 3, 2022 20:10
A CLI stopwatch
package main
import (
"fmt"
"os"
"time"
"github.com/gdamore/tcell/v2"
"github.com/ltcsuite/lnd/ticker"
"github.com/mattn/go-runewidth"
@ezr
ezr / tealdeer-config.toml
Created July 3, 2022 03:03
Config file for tealdeer (TLDR) with lighter colors than the default
[style.description]
underline = false
bold = false
italic = false
[style.command_name]
foreground = { rgb = { r = 255, g = 255, b = 255 } }
underline = false
bold = false
italic = false
@ezr
ezr / comm.py
Created May 25, 2022 03:27
similar to unix comm command
#!/usr/bin/env python3
# Similar to the unix tool comm.
# Does not require input to be in sorted order.
# Defaults to finding the intersection of two lists.
import argparse
def slurp(fname):
f = open(fname)
@ezr
ezr / cheat.py
Created December 3, 2021 03:56
Print out a cheat sheet, falls back to tldr pages
#!/usr/bin/env python3
# depends on:
# https://github.com/sharkdp/bat
# https://github.com/tldr-pages/tldr
from glob import glob
from os import listdir, environ
import subprocess
from sys import argv
@ezr
ezr / zip-args.py
Created November 18, 2021 02:57
takes lists and merges them into columns
#!/usr/bin/env python3
import argparse
from sys import argv, stderr
parser = argparse.ArgumentParser(description='zip together lists')
parser.add_argument("-s", "--separator", default=" ", help='character to separate items', required=False)
parser.add_argument("lists", nargs="+")
args = parser.parse_args()
@ezr
ezr / portchecker.go
Created October 12, 2021 17:47
Google cloud function to scan a given IP/TCP port.
package portchecker
/* A Google cloud function that takes an address and a TCP port.
It scans the port and tells you whether its open or not.
If "addr" is not supplied, then it scan the requestor.
Example usage:
$ curl --header "Api-Key: $API_KEY" --data "port=443&addr=142.250.65.174" https://us-region-projectname.cloudfunctions.net/portchecker
*/
@ezr
ezr / printf-loop.sh
Created September 22, 2021 00:45
Print the supplied format once for each line of stdin
#!/usr/bin/env bash
USAGE=$(cat <<-END
Error: no argument supplied.
This program prints the template once for each line of stdin. It only substitutes one variable in the printf format string.
Usage:
$0 <printf_format> < data
@ezr
ezr / textsub.py
Created September 21, 2021 02:27
Print the supplied template once for each line of stdin
#!/usr/bin/env python
import sys
if len(sys.argv) == 1:
text = "{text}"
message = '''\
Error: no argument supplied.
This program prints the template once for each line of stdin. {text} in the template is replaced with the line from stdin.
#!/usr/bin/env python3
# argv[1] is the path to a configuration file
# the config file is a CSV file of the form date,path,message. EG:
# 03-03-2022,/home/user/py/remind/f,remember to do a backup
# 10-22-2021,/home/user/.motd,get tickets for Dune
from datetime import datetime
import os
import re