Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am subsetpark on github.
  • I am zdsmith (https://keybase.io/zdsmith) on keybase.
  • I have a public key whose fingerprint is 1418 37FB 75F4 70F9 B465 E89E 8135 42F3 EB9A C1F7

To claim this, I am signing this object:

@subsetpark
subsetpark / Nim
Last active August 29, 2015 14:18 — forked from scottmries/Nim
# coding=utf-8
from sys import argv
import random, time
def bold(s):
return '\033[1m'+s+'\033[0m'
def italic(s):
@subsetpark
subsetpark / gist:70ce20f1503a829bba0a
Created May 14, 2015 21:06
django/db/models/base.py:102
def full_clean(self, exclude=None, validate_unique=True):
"""
Calls clean_fields, clean, and validate_unique, on the model,
and raises a ``ValidationError`` for any errors that occurred.
"""
errors = {}
if exclude is None:
exclude = []
else:
exclude = list(exclude)
@subsetpark
subsetpark / gist:367f0d3fde503a1e481c
Created June 16, 2015 15:48
Building Python 2.7.10 on Ubuntu 14.04 LTS
$ sudo apt-get install -y gcc-multilib g++-multilib libffi-dev libffi6 libffi6-dbg python-crypto python-mox3 python-pil python-ply libssl-dev zlib1g-dev libbz2-dev libexpat1-dev libbluetooth-dev libgdbm-dev dpkg-dev quilt autotools-dev libreadline-dev libtinfo-dev libncursesw5-dev tk-dev blt-dev libssl-dev zlib1g-dev libbz2-dev libexpat1-dev libbluetooth-dev libsqlite3-dev libgpm2 mime-support netbase net-tools bzip2
$ wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
$ tar xvf Python-2.7.10.tgz
$ cd Python-2.7.10/
$ ./configure --prefix /usr/local/lib/python2.7.10 --enable-ipv6
$ make
$ sudo make install
proc recv*(connection: Connection): int =
var
socket = connection.socket.get()
buffer = newSeq[byte]()
b: byte
while true:
try:
let bytesReceived = socket.recv(addr(b), 1, 1)
proc recv*(connection: Connection): int =
var
socket = connection.socket.get()
data = newString(FRAME_MAX_SIZE)
try:
result = socket.recv(addr data[0], FRAME_MAX_SIZE, timeout = 10)
data.setLen(result)
except TimeoutError:
discard
@subsetpark
subsetpark / Wordpress API demo - root
Created April 10, 2019 14:50
Wordpress API demo - posts
[i] zax/SERV-1499/invoice-email ~/frame-src/massdriver & http OPTIONS https://demo.wp-api.org/wp-json/
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Authorization, Content-Type
Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
Allow: GET
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Wed, 10 Apr 2019 14:33:23 GMT
import TypeClass
defmodule Minotaur do
defstruct name: ""
end
defimpl TypeClass.Property.Generator, for: Minotaur do
def generate(_), do: %Minotaur{name: "#{:crypto.strong_rand_bytes(2)}"}
end
@subsetpark
subsetpark / trick-taking-games.md
Created September 5, 2019 02:42
A brief introduction to trick-taking games

A HAND

In every game, all the players receive some given number of cards. To play one hand is to play a series of tricks, where each player chooses one of the cards in their hand and plays it to the middle, and one of the players ends up winning the trick. Usually, the hand is finished when all the cards have been played in tricks, and deal rotates to the left and a new hand starts.

TRICKS

A trick is a single rotation, where everybody playing plays one of the cards in their hand to the middle. One person leads, or plays first, and then play proceeds to that player's left, until everyone in the game has played one card. A single person then wins the trick, and takes the cards that were played to signify they've won.

The rules that determine what a person may lead, what others may play after, and who wins are the meat of most games.

@subsetpark
subsetpark / erlang.kak
Created June 1, 2020 13:55
A half-baked kakoune language file for erlang.
# Detection
# ---------
hook global BufCreate .*\.(erl|hrl) %{
set-option buffer filetype erlang
}
# Highlighters
# ------------