Skip to content

Instantly share code, notes, and snippets.

@theherk
theherk / lest.md
Last active June 9, 2023 14:19
Reddit / Lest: A replacement backend implementing a similar API contract.

Reddit / Lest

A replacement backend implementing a similar API contract.

Reddit is trying desperately to kill third party applications and in the process its own community. You can read more about it here. This proposal makes only two assumptions.

  1. Reddit has taken for granted that which got it where it is.
  2. Reddit is replaceable.

Reddit is massive in terms of scale, but not in terms of complexity. So, it can be replaced, but maybe not practically. I made this post on /r/technology a week ago, and it got some traction. Since then, I have received several emails and offers of labor and funding.

import csv
def get_record_max_temps():
return {
"Jan": 12.5,
"Feb": 13.8,
"Mar": 21.5,
"Apr": 25.4,
"May": 29.8,
@theherk
theherk / main.py
Created April 26, 2022 18:38
Timing simple slicing vs itertools.pairwise
#!/usr/bin/env python3
from statistics import fmean
import timeit
times_slice = timeit.repeat(
stmt="l = [924, -5, 24, 1, 0, 242, -5, 42, 5, 1, -9, 50, 3, 432, 0, -5, 4]; x = l[:-1]; y = l[1:]"
)
times_itertools = timeit.repeat(
stmt="x, y = zip(*pairwise([924, -5, 24, 1, 0, 242, -5, 42, 5, 1, -9, 50, 3, 432, 0, -5, 4]))",
@theherk
theherk / Makefile
Created November 25, 2021 13:51
Install the latest version of terraform locally with GNU Make.
OS := linux
ifeq (${shell uname},Darwin)
OS := darwin
endif
ARCH := amd64
help: ## show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z./_-]+:.*?##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
bin:
@theherk
theherk / Makefile
Created November 25, 2021 13:51
Install the latest version of pre-commit locally with GNU Make.
help: ## show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z./_-]+:.*?##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
bin:
mkdir -p $@
bin/pre-commit: LATEST := ${shell curl --silent "https://api.github.com/repos/pre-commit/pre-commit/releases/latest" | jq ".. .tag_name? // empty" | tr -d '"v'}
bin/pre-commit: URL := https://github.com/pre-commit/pre-commit/releases/download/v${LATEST}/pre-commit-${LATEST}.pyz
bin/pre-commit: bin ## install pre-commit
curl -L ${URL} --output $@
@theherk
theherk / windows-10-title-bar-color-hack.md
Created September 3, 2020 13:46
Windows 10 Title Bar Color Hack

When Windows is left to decorate the title bar, it can look undesirable, and there is no way to readily change it in the way I wanted. So based on a few sources, I've come up with the following solution.

In my case, the issue was the title bar for emacs, but it is the case for many applications.

These steps will allow the continued use of accent color, but set the title bar to a color of your choice.

Steps

  1. Set the accent color in the Personalization > Colors interface to the color you want the title bar.
  2. Under "Show the accent color on the following surfaces", select "Title bars and window borders"
@theherk
theherk / playground.rs
Created March 2, 2018 01:02 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::io::{Error, ErrorKind};
fn hmm(go: bool) -> Result<String, Error> {
match go {
true => Ok(String::from("good to go")),
_ => Err(Error::new(ErrorKind::Other, "bad")),
}
}
fn gonogo(go: bool) -> Result<String, Error> {
@theherk
theherk / sshuttle.service
Created September 19, 2016 21:57
systemd service unit file for sshuttle
[Unit]
Description=sshuttle service a permanent tunnel
After=network.target
[Service]
ExecStart=/usr/bin/sshuttle -r h4s@localhost:39111 0.0.0.0/0 --dns -D --pidfile=/var/run/sshuttle.pid -e 'ssh -i /home/h4s/.ssh/whtunnel2'
Restart=always
Type=forking
PIDFile=/var/run/sshuttle.pid