Skip to content

Instantly share code, notes, and snippets.

View amacdougall's full-sized avatar

Alan MacDougall amacdougall

View GitHub Profile

Keybase proof

I hereby claim:

  • I am amacdougall on github.
  • I am amacdougall (https://keybase.io/amacdougall) on keybase.
  • I have a public key ASAGCmbFfRcSjbInd-pBM-SHxNJCAVCs8wJ1RvZj3opBjAo

To claim this, I am signing this object:

@amacdougall
amacdougall / simple_membership_set.js
Created August 2, 2016 19:10
Very basic set-like collection, supporting only contains/add/remove.
function is(a) {
return b => a === b;
}
function isNot(a) {
return b => a !== b;
}
class SimpleMembershipSet {
constructor(values = null) {
@amacdougall
amacdougall / magic_and_civilization.md
Last active June 29, 2016 20:30
Departures and Returns of Magic

Lately I've been reading The Book of the New Sun, by Gene Wolf. I began reading it once, when I was a teenager, but I didn't have the vocabulary or the perspective to understand it. The books are set millions of years in the future, when the sun itself is fading as glaciers creep inexorably toward the equator, and the author recklessly overstuffs the narrative with archaic terms, instead of invented ones, to describe things which would be unfamiliar to us. Only slowly do we come to understand the concrete reality behind the archaic terms: "destriers" are genetically engineered riding sabertooths; "voulges" are energy weapons; a hundred long-forgotten professions, from uhlan to heirodule to claviger, make appearances, and their true nature is obscured at first, or forever, by the linguistic veil.

What is more, the author is deeply unreliable. We sometimes find the narrative disjointed, and are forced to deduce what he has left unsaid; or contradictory, and he confesses later that he lied. And most of all, thi

@amacdougall
amacdougall / gist:a2c89daecc3d04a8fd76
Last active January 25, 2016 16:18
Rambling about keyboard input in fighting games

I spent a few hours over the weekend doing challenges and stuff with the keyboard, and I think I've got the hang of it. It will probably take more practice before I can use the keyboard effectively in continuous battle, but I was surprised how quickly I took to it. It's probably because I was already good at vim...

Basic movement feels a bit harder, but I think that's down to familiarity. Switching between standing and crouching block is a bit weird, because holding down the keys just feels different from using the stick. And a few special moves are harder, such as the hcb, f moves: I have to complete the hcb, release the keys entirely, then hit f+attack. But when I look at the results in a keyboard input display, such as https://www.microsoft.com/appliedsciences/KeyboardGhostingDemo.mspx, I can see my error: the hcb is "fds", and if I don't completely release the S key before hitting F again, I'm holding two opposite directions at the same time, and the game system doesn't recognize the forward direction.

@amacdougall
amacdougall / distinct_users.clj
Created January 3, 2016 21:21
Test using Prismatic Schema generated users with distinct email/username
(defn- distinct-users []
(let [step (fn step [users usernames emails]
(lazy-seq
((fn [[u :as users] usernames emails] ; first user, usernames, emails
(when-let [s (seq users)]
(if (or (contains? usernames (:username u))
(contains? emails (:email u)))
(recur (rest s) usernames emails)
(cons u (step (rest s)
(conj usernames (:username u))
@amacdougall
amacdougall / deal.rb
Created December 21, 2015 22:27
Deal With It
# Customize FACE_CARDS, JOKERS, and SUITS however you like. Run this file by
# simply typing this at the command line:
#
# ruby deal.rb number_of_cards
#
# If number_of_cards is omitted, you'll get five. And obviously Ruby has to be
# installed, you have to be in the directory that contains the file (or supply
# the path to it), etc.
class Deck
FACE_CARDS = {
@amacdougall
amacdougall / loading_json_recap.md
Last active September 2, 2015 21:59
Clojure Club Recap: Loading JSON

Loading some JSON from the intertubes

To make libraries available, add them to the :dependencies vector in your project.clj. Remember that you can create a new project folder with lein new [<template-name>] <project-name>. Here are the dependencies used for this JSON loading adventure:

:dependencies [[org.clojure/clojure "1.7.0"]
 [clj-http "2.0.0"]
@amacdougall
amacdougall / json_dataset.json
Last active August 29, 2015 14:24
Random JSON courtesy of json-generator.com
[
{
"_id": "55c907c64caeb310824a048b",
"isActive": true,
"balance": "$1,011.82",
"picture": "http://placehold.it/32x32",
"age": 24,
"eyeColor": "green",
"name": "Hope Willis",
"gender": "female",