Skip to content

Instantly share code, notes, and snippets.

View scotthaleen's full-sized avatar
λ

スコット scotthaleen

λ
View GitHub Profile
@scotthaleen
scotthaleen / Caddyfile
Created September 1, 2023 16:25
caddy cors all
(cors) {
@options {
method OPTIONS
}
header @options {
Access-Control-Allow-Origin *
Access-Control-Allow-Methods *
Access-Control-Allow-Headers *
defer
}
@scotthaleen
scotthaleen / git-http-backend.go
Last active September 6, 2022 20:06
Simple no auth git-http-backend handler in go - linux
package main
import (
"bytes"
"fmt"
"log"
"net/http"
"net/http/cgi"
"net/http/httputil"
)
@scotthaleen
scotthaleen / backpressure.go
Created April 28, 2022 02:09 — forked from marianogappa/backpressure.go
Example backpressure implementation in Go
/*
This snippet is an example of backpressure implementation in Go.
It doesn't run in Go Playground, because it starts an HTTP Server.
The example starts an HTTP server and sends multiple requests to it. The server starts denying
requests by replying an "X" (i.e. a 502) when its buffered channel reaches capacity.
This is not the same as rate-limiting; you might be interested in https://github.com/juju/ratelimit
or https://godoc.org/golang.org/x/time/rate.
@scotthaleen
scotthaleen / multiple-host-reverse-proxy.go
Created January 14, 2022 16:05 — forked from ego008/multiple-host-reverse-proxy.go
Multiple host reverse proxy in Go
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
)
var (
@scotthaleen
scotthaleen / html5.html
Created November 8, 2021 15:44
minimal html5 page
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<title>html5</title>
</head>
<body>
HTML 5
</body>

Fix tkinter on osx

import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

brew install tcl-tk zlib
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/tcl-tk/lib -L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/tcl-tk/include -I/usr/local/opt/zlib/include"
@scotthaleen
scotthaleen / 0Python Color Logger.md
Last active January 8, 2024 14:46
Color Logging in Python 3.8

Install

pip install colorama pyyaml

Example

output

@scotthaleen
scotthaleen / emacs.sh
Last active March 9, 2024 18:20
emacs master
#!/bin/bash
export EMACSLOADPATH="${EMACSLOADPATH}:$(pwd)"
open -a ~/Applications/Emacs.app --args --eval "(cd \"${PWD}\")" "$@"
@scotthaleen
scotthaleen / i3-config
Created March 11, 2020 20:39
i3 config
# ~/.confing/i3/config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
(defn flattener
[input flattened?]
(((fn [f] (f f))
(fn [f]
(fn [x xs]
(if (flattened? x)
(cons x ((f f) (first xs) (rest xs)))
(if (empty? x)
xs