Skip to content

Instantly share code, notes, and snippets.

@htp
htp / curl-websocket.sh
Last active May 3, 2021
Test a WebSocket using curl.
View curl-websocket.sh
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@htp
htp / Makefile
Last active Aug 31, 2016
A skeleton Makefile.
View Makefile
.DEFAULT_GOAL = targets
# List available targets.
.PHONY: targets
targets:
@echo Available targets are:
@echo
@awk -v default_goal=$(.DEFAULT_GOAL) '/^# / { \
description = substr($$0, 3); \
line = ""; \
@htp
htp / jindosh.pl
Created Mar 11, 2017
A solution to the Jindosh Riddle from Dishonored 2, written in Prolog.
View jindosh.pl
% At the dinner party were Lady Winslow, Doctor Marcolla,
% Countess Contee, Madam Natsiou, and Baroness Finch.
%
% The women sat in a row. They all wore different colors and
% Baroness Finch wore a jaunty green hat. Madam Natsiou was at
% the far left, next to the guest wearing a blue jacket. The lady in
% red sat left of someone in white. I remember that red outfit
% because the woman spilled her whiskey all over it. The traveler
% from Dunwall was dressed entirely in purple. When one of the
% dinner guests bragged about her Ring, the woman next to her
@htp
htp / static-site-post-receive-hook
Created Jul 2, 2020
A post-receive hook for "deploying" static sites using Git.
View static-site-post-receive-hook
#!/bin/sh
main() {
local temporary="$(mktemp -d)"
local repository="/path/to/bare/repository.git"
local deployment="/path/to/site/root"
echo -n "Copying files... "
git --work-tree="${temporary}" --git-dir="${repository}" checkout --force
echo "done."