Skip to content

Instantly share code, notes, and snippets.

View scotthaleen's full-sized avatar
λ

スコット scotthaleen

λ
View GitHub Profile
@scotthaleen
scotthaleen / smallest_jpg_bytes.txt
Last active April 29, 2024 13:29
Smallest Valid JPG
# http://web.archive.org/web/20111224041840/http://www.techsupportteam.org/forum/digital-imaging-photography/1892-worlds-smallest-valid-jpeg.html
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 48 00 48 00 00 FF DB 00 43 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF C2 00 0B 08 00 01 00 01 01 01 11 00 FF C4 00 14 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF DA 00 08 01 01 00 01 3F 10
# Base64 Encoded
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxA=
@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 / 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 / ConsCarCdr.js
Created February 10, 2016 16:31
JavaScript implementation of cons, car and cdr
function cons(x, y) {
return function(w) { return w(x, y) };
};
function car(z) {
return z(function(x, y) { return x });
};
function cdr(z) {
return z(function(x, y) { return y });
@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 / stream_to_bytes.clj
Created October 20, 2016 21:15
Clojure: read an io/stream to a byte array
(require '[clojure.java.io :as io])
(def fp "/path/to/file")
(defn stream->bytes [is]
(loop [b (.read is) accum []]
(if (< b 0)
accum
(recur (.read is) (conj accum b)))))
@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>