Skip to content

Instantly share code, notes, and snippets.

View mplewis's full-sized avatar
🐕
柴犬

Matt Lewis mplewis

🐕
柴犬
View GitHub Profile
@mplewis
mplewis / chat.go
Created September 23, 2022 21:14
Demo "chat" app which shows how to use Go and carraige returns to show live messages alongside an editable chat input line
package main
import (
"fmt"
"math/rand"
"time"
"github.com/eiannone/keyboard"
)
@mplewis
mplewis / shenv.sh
Created September 18, 2022 21:16
Put this in your path as `shenv` to source .env file variables and run specific commands: `shenv development.env my-command`
#!/bin/bash
set -euo pipefail
set -a; source "$1"; set +a
"${@:2}"
@mplewis
mplewis / aoc-2019-day-1.ts
Created December 6, 2019 21:09
Advent of Code stuff
const input = `
106404
140515
142745
120767
79665
54235
127391
72207
70799

How to Run a Fargate Task from AWS CLI

AWS_PROFILE=mplewis \
AWS_DEFAULT_REGION=us-west-1 \
aws ecs run-task \
  --launch-type FARGATE \
  --task-definition http-hello-world \
  --network-configuration '<CONFIG>'
  --overrides '<OVERRIDES>'
@mplewis
mplewis / iam_sam_policy.json
Created April 5, 2019 16:30
Perms needed to successfully deploy a Lambda via AWS SAM
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudformation:*",
"iam:CreateRole",
"iam:AttachRolePolicy"
@mplewis
mplewis / ceto.rb
Created March 22, 2019 03:26
inspect a docker image's commands without having its dockerfile
#!/usr/bin/env ruby
# ceto
# from cetology: the scientific study of whales
# inspect a docker image's commands without having its dockerfile
# bash scripting stuff that probably needs to be broken up for visibility
SPECIALS = %w(
$\(
\)
/**
* @license
REI-Gearmail 0.1.0 2013-06-03 14:10 */
'use strict';
if ("undefined" == typeof console) {
window.console = {
log : function() {
},
error : function() {
}

A type system is good when it not only guardrails you from doing the wrong thing, but reminds you to do the right thing. A type system is excellent when it guides you toward doing the right thing without you having to tell it what you wanted.

Here are some examples of type systems I like and love:

Java: It's very hard to compile any Java at all. Because it's so strict about the types. If someone gives you a PayPal API JAR, you plug it in and say "oh, this #pay method takes a Recipient, an Amount, and a Details object. I better fill those in." If you don't provide exactly those three, you don't get to pay anyone.

C#: Instead of having to type out Map<String, Integer> recipients = new HashMap<>() like in Java, you can just let recipients, much like auto in C++. Inferring your type at creation is great. Less typing, I can already tell what the thing is.

JS Flow: JavaScript is the loosest (baylor inserts joke here) language known to man, besides maybe Lisp. See the wat talk. [1] Facebook engineers disco

Keybase proof

I hereby claim:

  • I am mplewis on github.
  • I am mplewis (https://keybase.io/mplewis) on keybase.
  • I have a public key ASB-0oi8GsJR5AnFzVqHDzlbud5P7W9JikrEx1deugi93wo

To claim this, I am signing this object:

046f9979d118412339318d89c60da9261acd79b0a956b84c4331916ee11912c4a5569f5406cb3f34e3c1244a3e7d236a6117b69f1c9422364d53fbf3138b865f03