Skip to content

Instantly share code, notes, and snippets.

@ahl
ahl / gist:cc69a6b267bc04ec48a7dca1b9630578
Created August 24, 2022 21:25
rust for rustaceans (what I learned)
Rust for rustaceans
Ch 1
Uses of multiple lifetime bounds within a single function or type eg a string split iterator
Ch 2
Use trait associated types rather than trait genetics except if you expect multiple implementations of the trait for a given type
You can use impl trait as the value for an associated type and the compiler will infer the specific type from use eg the return from IntoIterator::into_iter()
@ahl
ahl / outposts2022.json
Created February 10, 2022 05:34
aws outposts list-catalog-items
{
"CatalogItems": [
{
"CatalogItemId": "OR-FWTFFXJ",
"Dimensions": "OUTPOST_RACK",
"EC2Capacities": [
{
"Family": "c5",
"MaxSize": "24xlarge",
"Quantity": "1"
@ahl
ahl / hack_slash.rs
Last active September 8, 2021 17:11
/// This function needs to necessarily be conservative. We'd much prefer a
/// false negative than a false positive.
fn schemas_mutually_exclusive(a: &Schema, b: &Schema) -> bool {
match (a, b) {
// If either matches nothing then they are exclusive.
(Schema::Bool(false), _) => true,
(_, Schema::Bool(false)) => true,
// If either matches anything then they are not exclusive.
(Schema::Bool(true), _) => false,
(_, Schema::Bool(true)) => false,
while True:
c = getch.getch()
if c == 'j':
left()
elif c == 'k':
right()
elif c == 'c':
break
white = digitalio.DigitalInOut(board.C1)
black = digitalio.DigitalInOut(board.C0)
black.direction = digitalio.Direction.OUTPUT
black.value = True
white.direction = digitalio.Direction.OUTPUT
white.value = True
def tap(v):
tnext = time.time()
@ahl
ahl / outposts.json
Created December 14, 2019 10:05
AWS Outposts configurations from an unpublished API
{
"NextToken": null,
"PodCatalogItems": [
{
"AvailableEC2Capacities": [
{
"Family": "m5",
"MaxSize": "24xlarge",
"Quantity": "6"
},
@ahl
ahl / spamflow.py
Created October 20, 2019 04:22
Generate a Slack Workflow that spams the shit out of whoever runs it
#!/usr/bin/env python
import uuid
import json
workflow = {
"source_id": "271537071011674362",
"version": "1",
"workflow": {
"name": "spam me please",
SELECT status.updateTime, personName.givenName, personName.familyName FROM google_hire.list_applications AS app
 JOIN google_hire.list_candidates AS can
 ON app.candidate = can.name
 WHERE app.tenant = 'my_tenant'
 AND app.filter='status.state=ACTIVE'
 AND can.tenant = 'my_tenant'
 AND can.filter='applications.status.state=ACTIVE'
 AND job = (SELECT name FROM google_hire.list_jobs
 WHERE tenant='my_tenant'
 AND filter='state=OPEN'
({ http_event }) => {
var moment = require("moment-timezone-with-data.js");
return {
status_code: 200,
headers: { "Content-Type": "application/json" },
body: {
"text": api.run("this.eng_active", {})
.map((x) => moment(x.updateTime).format("YYYY MMMM Do ")
+ x.givenName + " " + x.familyName)
SELECT * FROM google_hire.list_applications AS app
 JOIN google_hire.list_candidates AS can
 ON app.candidate = can.name
 WHERE app.tenant = 'my_tenant'
 AND app.filter='status.state=ACTIVE'
 AND can.tenant = 'my_tenant'
 AND can.filter='applications.status.state=ACTIVE'
 AND job = (SELECT name FROM google_hire.list_jobs
 WHERE tenant='my_tenant'
 AND filter='state=OPEN'