Skip to content

Instantly share code, notes, and snippets.

View talentdeficit's full-sized avatar

alisdair sullivan talentdeficit

View GitHub Profile
19:41:20 [ alisdair@charmander ] $ iex
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.5.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule A do
...(1)> def a(), do: true
...(1)> end
{:module, A,
<<70, 79, 82, 49, 0, 0, 3, 96, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 81, 0,
0, 0, 9, 8, 69, 108, 105, 120, 105, 114, 46, 65, 8, 95, 95, 105, 110, 102,
defmodule MyApp.Db.Tests do
use MyApp.Db.Case, async: true
## tests go here
end
function assertNever(x: never): never {
throw new Error("Unexpected object: " + x);
}
function area(s: Shape) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.height * s.width;
case "circle": return Math.PI * s.radius ** 2;
default: return assertNever(s); // error here if there are missing cases
}
defmodule Gateway do
use GenServer
@timeout 5000 # timeout in ms
def init(process), do: %{ process: process, q: :undefined }
def handle_call(call, from, %{ process: process, q: q }) do
# add call to priority queue
newq = add_to_q(q, :call, call, from)
---
AWSTemplateFormatVersion: "2010-09-09"
Description: "cloudtrail logs and topic"
Resources:
Cloudtrail:
DependsOn: [ "CloudtrailBucketPolicy", "CloudtrailTopicPolicy" ]
Type: "AWS::CloudTrail::Trail"
Properties:
EnableLogFileValidation: true
IncludeGlobalServiceEvents: true
---
## aws access roles
##
## roles that can be assumed by users to grant various levels of access to the
## account
AWSTemplateFormatVersion: "2010-09-09"
Description: "account access roles"
Parameters:
AccountId:
Description: "the account id from which permitted user accounts may assume these roles"
defmodule Filter do
require Ecto.Query
@max_id 2147483647
@max_clock 9223372036854775807
@max_limit 1000
defstruct valid?: true, query: nil, limit: 1000, errors: []
@talentdeficit
talentdeficit / roles.yaml
Last active June 16, 2017 19:01
aws iam user self management policies
---
## aws access roles
##
## roles that can be assumed by users to grant various levels of access to the
## account
AWSTemplateFormatVersion: "2010-09-09"
Description: "account access roles"
Parameters:
AccountId:
Description: "the account id from which permitted user accounts may assume these roles"
Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.loads("1e309")
inf
>>> json.loads("1e308")
1e+308
>>> json.loads("1e1")
10.0
@talentdeficit
talentdeficit / provision.sh
Created February 19, 2017 03:13
new macbook setup script
#!/bin/bash
set -e
# changes color of info and then resets back to default
function info {
tput setaf 6; echo $1; tput sgr0
}
# install from brew if not already installed