Skip to content

Instantly share code, notes, and snippets.

Working from home

Marco Massenzio massenz

Working from home
View GitHub Profile
massenz /
Created Mar 26, 2022
FizzBuzz in less than 5 minutes, as described at
#!/usr/bin/env python
# FizzBuzz -- created by M. Massenzio, 2022-03-26
import sys
n = sys.argv[1]
for i in range(3, int(n) + 1):
out = ""
if i % 3 == 0:
massenz / babies.go
Last active Mar 20, 2022
Serialize data to/from Redis in a custom type
View babies.go
package main
import (
massenz / contains.go
Created Mar 20, 2022
Go does not have a built-in `in` operator for slices
View contains.go
package main
import "fmt"
// Tempting, but this will NOT compile
//func (arr []interface{}) Has(x interface{}) bool {
// for _, val := range arr {
// if val == x {
// return true
massenz /
Last active Aug 25, 2021
OpenAPI Codex-generated Rest Controller for Spring Data
public class UserController {
private UserRepository userRepository;
private UserService userService;
massenz / ErrorStateMachine.json
Last active Aug 19, 2021
Demonstrates how to generate different types of errors for AWS Lambda Step Functions, so that Retry/Catch can distinguish between different kinds of errors.
View ErrorStateMachine.json
"Comment": "A state machine to experiment with errors",
"StartAt": "Error Handler",
"States": {
"Error Handler": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
massenz / delete-iam-role
Last active Jul 25, 2021
To delete an AWS IAM Role, Policies need to be detached first: this script automates the tedious necessary steps.
View delete-iam-role
#!/usr/bin/env bash
set -eu
if [[ -z ${ROLE} ]]; then
printf "Usage: delete-iam-role ROLE\n\nERROR: ROLE must be specified\n"
exit 1
massenz /
Last active Sep 10, 2019
How to load fonts via Python PIL.
# How to load fonts via Python PIL.
# See Stack OF question:
from PIL import Image, ImageDraw, ImageFont
# sample text and font
unicode_text = u"Arial Font, size 28px"
font = ImageFont.truetype("/Library/Fonts/Arial.ttf", 28, encoding="unic")
# get the line size
massenz /
Created Sep 29, 2018
Kubernetes Minikube install on MacOS
# Installs minikube on MacOS
# See:
declare -r VERSION=${1:-}
if [[ -z ${VERSION} ]]; then
echo "Please specify a version"
exit 1
massenz / hiddenToggle
Created Sep 27, 2018
MacOS Finder - toggle Hidden Files in Finder
View hiddenToggle
defaults write AppleShowAllFiles ${ENABLE}
killall Finder
massenz /
Last active Dec 12, 2019
Install OpenJDK 10 on MacOS
# Installs the OpenJDK 10 from
wget https://${DOWNLOAD_URL}/${VERSION}/19aef61b38124481863b1413dce1855f/13/${JDK} -O /tmp/${JDK}