Skip to content

Instantly share code, notes, and snippets.

@htp
htp / curl-websocket.sh
Last active April 25, 2024 14:57
Test a WebSocket using curl.
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 August 31, 2016 00:30
A skeleton 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 March 11, 2017 17:43
A solution to the Jindosh Riddle from Dishonored 2, written in Prolog.
% 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 July 2, 2020 07:17
A post-receive hook for "deploying" static sites using Git.
#!/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."