Skip to content

Instantly share code, notes, and snippets.

View massenz's full-sized avatar
🏠
Working from home

Marco Massenzio massenz

🏠
Working from home
View GitHub Profile
@massenz
massenz / README.rst
Last active August 8, 2017 22:18
Apache Mesos build and install scripts; optionally runs the Master/Slave locally and executes a demo (C++) framework against it, to validate it all went according to plan

Apache Mesos Build scripts

The Getting started instructions are a good start (no surprise there!) but are somewhat incomplete and currently look a bit outdated (I plan to fix them soon): however, the outcome has been that I have struggled more than I felt necessary in building and running Mesos on a dev VM (Ubuntu 14.04 running under VirtualBox).

Some of the issue seem to arise from the unfortunate combination of Mesos Master trying to guess its own IP address, the VM being (obviously) non-DNS resolvable and, eventually, the Slave and the Framework failing to properly communicate with the Master.

In the process of solving this, I ended up automating all the dependencies installation, building and running the framework; I have then broken it down into the following modules to make it easier to run only parts of the process.

@massenz
massenz / grep-images.py
Created August 10, 2017 18:04
List all Docker images in a Shell-friendly format (optionally, JSON too)
#!/usr/bin/env python
#
# Created by M. Massenzio (c) 2017.
# The output of `docker images` is easy on the eye, but not
# terribly helpful if you want to pipe it into further shell
# commands; and using `cut` only gets you so far (in fact,
# not very far at all).
#
# This script emits the list of Docker images on your system
@massenz
massenz / auth_server.py
Last active December 24, 2017 15:15
Simple Flask server to demonstrate how to use LaunchKey (http://www.launchkey.com) to authenticate users
# Copyright AlertAvert.com (c) 2013. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@massenz
massenz / hiddenToggle
Created September 27, 2018 20:56
MacOS Finder - toggle Hidden Files in Finder
#!/bin/bash
ENABLE=${1:-TRUE}
defaults write com.apple.finder AppleShowAllFiles ${ENABLE}
killall Finder
@massenz
massenz / simpleprocess.cpp
Last active February 13, 2019 14:22
libprocess simple HTTP server
/*
* simpleprocess.cpp
*
* Created on: Jun 26, 2015
* Author: Marco Massenzio
*/
#include <iostream>
#include <process/dispatch.hpp>
@massenz
massenz / minikube-install.sh
Created September 29, 2018 21:37
Kubernetes Minikube install on MacOS
#!/bin/bash
#
# Installs minikube on MacOS
# See: https://github.com/kubernetes/minikube/releases
declare -r VERSION=${1:-}
if [[ -z ${VERSION} ]]; then
echo "Please specify a version"
exit 1
@massenz
massenz / font.py
Last active September 10, 2019 21:06
How to load fonts via Python PIL.
# How to load fonts via Python PIL.
# See Stack OF question: https://stackoverflow.com/questions/24085996/how-i-can-load-a-font-file-with-pil-imagefont-truetype-without-specifying-the-ab/41887497#41887497
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
massenz / install_jdk_10.sh
Last active December 12, 2019 11:18
Install OpenJDK 10 on MacOS
#!/bin/bash
#
# Installs the OpenJDK 10 from java.net.
VERSION=10.0.2
DOWNLOAD_URL="download.java.net/java/GA/jdk10"
JDK="openjdk-${VERSION}_osx-x64_bin.tar.gz"
INSTALL_DIR="/Library/Java/JavaVirtualMachines"
wget https://${DOWNLOAD_URL}/${VERSION}/19aef61b38124481863b1413dce1855f/13/${JDK} -O /tmp/${JDK}
@massenz
massenz / delete-iam-role
Last active July 25, 2021 20:44
To delete an AWS IAM Role, Policies need to be detached first: this script automates the tedious necessary steps.
#!/usr/bin/env bash
#
set -eu
ROLE=${1:-}
if [[ -z ${ROLE} ]]; then
printf "Usage: delete-iam-role ROLE\n\nERROR: ROLE must be specified\n"
exit 1
fi
@massenz
massenz / UserController.java
Last active August 25, 2021 17:25
OpenAPI Codex-generated Rest Controller for Spring Data
@RestController
@RequestMapping("/api/users")
public class UserController {
@Autowired
private UserRepository userRepository;
@Autowired
private UserService userService;