Skip to content

Instantly share code, notes, and snippets.

View apparentlymart's full-sized avatar
⌨️
I may be slow to respond.

Martin Atkins apparentlymart

⌨️
I may be slow to respond.
View GitHub Profile
@apparentlymart
apparentlymart / generic_set.go
Created July 27, 2019 17:11
A prototype Set implementation using the second round of Go Generics proposal with contracts
// Package set is an adaptation of an existing Set implementation I wrote (that
// originally used interface{} as its underlying type) to the current Go 2
// Generics proposal at the time of this writing:
// https://go.googlesource.com/proposal/+/4a54a00950b56dd0096482d0edae46969d7432a6/design/go2draft-contracts.md
//
// This adaptation retains the existing feature that a set can be of any type,
// without that type needing to be extended with any additional methods, as long
// as the caller can provide a separate Rules type that provides the necessary
// additional operations. Generics allows the compiler to check the requirement
// that only sets with the same rules can be used together, which was previously
@apparentlymart
apparentlymart / go-here.sh
Created April 1, 2017 15:46
Helper bash script for creating and activating GOPATHs
# Note: this is written for and tested only in bash
function _go-here {
DIR="$1"
export GOPATH="$DIR"
export PATH="$GOPATH/bin":$PATH
echo Activating GOPATH="$GOPATH"
}
function go-here {
@apparentlymart
apparentlymart / diverge.js
Last active October 19, 2016 04:33
Highland Diverge Stream, pull edition
var _ = require('highland');
var items = [
'a',
'b',
'c',
'd',
'e',
'f',
@apparentlymart
apparentlymart / keybase.md
Created September 21, 2016 23:40
Keybase Claim

Keybase proof

I hereby claim:

  • I am apparentlymart on github.
  • I am apparentlymart (https://keybase.io/apparentlymart) on keybase.
  • I have a public key whose fingerprint is BBE3 1AF5 8D12 1501 A495 FE10 6D98 B19B CF7A CB7A

To claim this, I am signing this object:

@apparentlymart
apparentlymart / NOTES.md
Last active July 26, 2016 16:57
AWS Describe/Get actions as Terraform Data Sources

AWS Describe and Get actions as Terraform Data Sources

Beyond the read-only resources that existed in Terraform before data resources were an official feature, I'd like to make room for a new pattern for re-usable modules where they accept only the minimum set of ids they need as variables and look up other data via data sources.

Here's a motivating example:

variable "aws_subnet_id" {
    description = "Id of the subnet where the EC2 instance will be created"
}
@apparentlymart
apparentlymart / .padstone.hcl
Last active May 23, 2016 03:38
Padstone v2: Multiple targets, like a Makefile
# Variables are set on the command line:
# padstone build version=v0.0.1 ami
variable "version" {
default = "dev"
}
provider "aws" {
region = "us-west-2"
}
@apparentlymart
apparentlymart / closures.c
Created January 4, 2014 04:07
Fat function pointers in C, to implement closures and object-bound methods
#include <stdio.h>
// we'd generate one of these for each distinct function signature
typedef struct {
void (*func)();
void *env;
} Callable;
// we'd generate an environment struct for each function that needs one
@apparentlymart
apparentlymart / clock.ala
Created November 11, 2013 01:49
Alamatic Clock Example
import time
import coll
enum HourType:
#: A 12-hour time in the morning.
AM
#: A 12-hour time in the afternoon/evening.
PM
#: A 24-hour time
@apparentlymart
apparentlymart / gist:7283209
Created November 2, 2013 20:36
Prototype circuit definition language. Just brainstorming so far.
import max1234
part MAX1 is max1234
interface I2C:
pin DATA
pin CLOCK
interface SPIBus:
@apparentlymart
apparentlymart / blink.ala
Last active December 22, 2015 03:18
Alamatic Examples