Skip to content

Instantly share code, notes, and snippets.

@subsetpark
subsetpark / interp.c
Last active August 17, 2021 09:58
baby's first Janet C module
#include <janet.h>
// Function to be exported
// Returns a Janet; that's the static value that boxes a dynamic Janet type
// argc: number of arguments it was called with
// argv: arguments array
static Janet interp(int32_t argc, Janet *argv) {
// Assert that argc == 2
janet_fixarity(argc, 2);
@subsetpark
subsetpark / plugin_opts.lua
Created August 8, 2021 05:25
A working efm language server config for janet/lua
require('lspconfig').efm.setup {
init_options = {
documentFormatting = true,
hover = true,
documentSymbol = true,
codeAction = true, completion = true
},
settings = {
rootMarkers = {".git/"},
languages = {
@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
# ------------
@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
Janet 1.12.2-5df8ac5 linux/x64 - '(doc)' for help
repl:1:> (import fugue)
nil
repl:2:> (fugue/defproto shape ())
@[@{:_prototype_allocations {} :_object-id shape_000006 :_prototype? true :_object-name :shape :_fields () :new <function new-from-shape>} <function shape?>]
repl:4:> (fugue/defproto square shape (x {:init? true}))
@[<function x> @{:_prototype_allocations {} :_object-id square_00000a :_prototype? true :_object-name :square :_fields (:x) :new <function new-from-square>} <function square?>]
(defmacro
defclass
`
Define a CLOS-style class.
`
[name parent & attributes]
(def forms @[])
(let [init-args @[]
names-with-defaults (mapcat |[(keyword ($0 0)) (($0 1) :default)]
attributes)]
Hello, Joe!
@subsetpark
subsetpark / vs.md
Last active October 13, 2020 22:31
Installing VS Code / VS Live Share under Linux
  1. Install the normal VS Code binary. I did this using the visual-studio-code-bin package on AUR for Arch Linux.
  2. Access the Extensions pane in the left-hand sidebar.
  3. Search for Live Share in the extensions search. There are a couple extensions associated with Live Share, but the Live Share Extension Pack will include all of them.
  4. There is now a Live Share affordance in the colored status bar at the bottom of the window. Clicking on it will prompt you to sign in and authenticate via OAuth.
  5. NOTE! I wasn't able to get Github auth to work. I had to create a Microsoft account and then do auth via Microsoft.
  6. After going through the OAuth flow, the Live View affordance at the bottom will be replaced by the email you used to auth into Microsoft.
  7. Open the directory you want to collaborate on.
  8. In the menu provided by the Live View affordance, you can copy the invite link for your session to the clipboard.
  9. Send the link to whomever you want to collaborate with.
@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.

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