Skip to content

Instantly share code, notes, and snippets.

View theqabalist's full-sized avatar

Brandon Keown theqabalist

View GitHub Profile
---
- name: Find ubuntu ami_id
ec2_ami_search:
distro: ubuntu
release: trusty
region: "{{ aws_region }}"
store: ebs-ssd
virt: hvm
register: ubuntu
when: not aws_ami_id is defined
TAGS = [
{ tags: [{ key: 'Purpose', value: 'pairing' }] },
{ tags: [{ key: 'Purpose', value: 'pairing' }, { key: 'Color', value: 'blue' }] }
]
def do_tags_exist(kvs)
lambda do |instance|
kvs.all? do |k, v|
instance[:tags].any? { |tag| tag[:key] == k.to_s && tag[:value] == v }
end
(function () {
"use strict";
var pair = (function () {
function cons(x, y) {
return function (pick) {
return pick ? x : y;
};
}
function car(pair) {
@theqabalist
theqabalist / solution01.js
Last active December 24, 2016 23:32
AOC Day 1 Solution
/*eslint no-confusing-arrow: off*/
const {map, pipe, split, head, tail, reduce, last, range, add, repeat, chain, equals} = require('ramda');
const input = 'R3, L5, R1, R2, L5, R2, R3, L2, L5, R5, L4, L3, R5, L1, R3, R4, R1, L3, R3, L2, L5, L2, R4, R5, R5, L4, L3, L3, R4, R4, R5, L5, L3, R2, R2, L3, L4, L5, R1, R3, L3, R2, L3, R5, L194, L2, L5, R2, R1, R1, L1, L5, L4, R4, R2, R2, L4, L1, R2, R53, R3, L5, R72, R2, L5, R3, L4, R187, L4, L5, L2, R1, R3, R5, L4, L4, R2, R5, L5, L4, L3, R5, L2, R1, R1, R4, L1, R2, L3, R5, L4, R2, L3, R1, L4, R4, L1, L2, R3, L1, L1, R4, R3, L4, R2, R5, L2, L3, L3, L1, R3, R5, R2, R3, R1, R2, L1, L4, L5, L2, R4, R5, L2, R4, R4, L3, R2, R1, L4, R3, L3, L4, L3, L1, R3, L2, R2, L4, L4, L5, R3, R5, R3, L2, R5, L2, L1, L5, L1, R2, R4, L5, R2, L4, L5, L4, L5, L2, L5, L4, R5, R3, R2, R2, L3, R3, L2, L5';
const headings = [[1, 0], [0, -1], [-1, 0], [0, 1]];
const bear = (heading, dir) => headings[(4 + headings.indexOf(heading) + dir) % 4];
const bearings = {R: 1, L: -1};
const scaleV2 = ([[a
@theqabalist
theqabalist / solution02.js
Last active December 24, 2016 23:31
AOC Day 2 Solution
const fs = require('fs');
const {split, pipe, map, reduce, filter, identity} = require('ramda');
const transitions1 = {
1: {R: 2, D: 4},
2: {R: 3, L: 1, D: 5},
3: {L: 2, D: 6},
4: {R: 5, U: 1, D: 7},
5: {U: 2, D: 8, L: 4, R: 6},
6: {U: 3, D: 9, L: 5},
7: {U: 4, R: 8},
@theqabalist
theqabalist / solution03.js
Last active December 24, 2016 23:31
AOC Day 3 Solution
//eslint-disable-next-line no-sync
const input = require('fs').readFileSync(process.argv[2]).toString();
const {pipe, split, map, sort, flip, subtract, filter, splitEvery, transpose, take, concat, lt, __, prop, reduce, head, tail, identity} = require('ramda');
const numericalMatrix = pipe(
split('\n'),
filter(identity),
map(split(/\s/)),
map(filter(identity)),
@theqabalist
theqabalist / solution04.js
Last active December 24, 2016 23:30
AOC Day 4 Solution
const input = require('./input');
const {pipe, split, map, join, last, init, filter, sort, curry, compose, converge, add, find, prop, equals, take, over, sortBy, reduce, head, identity, lensIndex} = require('ramda');
const roomRegex = /^(\d+)\[(.+)\]$/;
const roomParse = s => {
//eslint-disable-next-line no-unused-vars
const [_, sector, checksum] = roomRegex.exec(s);
return [parseInt(sector, 10), checksum];
};
const firstLens = lensIndex(0);
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
@theqabalist
theqabalist / solution05.js
Last active December 24, 2016 23:30
AOC Day 5 Solution
const input = 'abbhdwsy';
const {Seq: seq, Set: set, Range: range} = require('immutable');
const md5 = require('md5');
const {equals, compose, take, complement, gt, head, prop} = require('ramda');
function logger(x) {
console.log(x);
return x;
}
@theqabalist
theqabalist / solution06.js
Last active December 24, 2016 23:30
AOC Day 6 Solution
const input = require('./input');
const {histogram} = require('./helper');
const {pipe, split, transpose, map, join, head, invoker, sort, prop, sortBy} = require('ramda');
const histogramFrequency = pipe(
split('\n'),
transpose,
map(join('')),
map(sort((x, y) => x.localeCompare(y))),
map(histogram),
@theqabalist
theqabalist / solution07.js
Last active December 24, 2016 23:29
AOC Day 7 Solution
const input = require('./input');
const {pipe, split, intersection, converge, compose, prop, concat, map, length, join, or, filter, any, none, aperture, dissoc, over, curry, invoker, reduce, assoc, lensProp} = require('ramda');
const removeNets = curry((nets, original) =>
reduce((final, hypernet) => final.replace(hypernet, ' '), original, nets));
const slice2 = invoker(2, 'slice');
const isAbba = s => s[0] !== s[1] && s[0] === s[3] && s[1] === s[2];