Skip to content

Instantly share code, notes, and snippets.

View pracucci's full-sized avatar

Marco Pracucci pracucci

View GitHub Profile
@pracucci
pracucci / hub-next-pr-number.sh
Last active June 23, 2021 12:01
Run this script in any location containing a GitHub repository checkout/clone and it will guess the next PR number if you're going to open it shortly
#!/bin/bash
LAST_PR=$(hub pr list --state all -L 1 --format '%I')
LAST_ISSUE=$(hub issue --format '%I' -L 1)
if [ "$LAST_PR" == "" -a "$LAST_ISSUE" == "" ]; then
echo "Unable to get last PR and/or Issue number. Is your current working directory a public GitHub repository?"
exit 1
elif [ "$LAST_PR" -gt "$LAST_ISSUE" ]; then
echo `expr $LAST_PR + 1`

Keybase proof

I hereby claim:

  • I am pracucci on github.
  • I am pracucci (https://keybase.io/pracucci) on keybase.
  • I have a public key ASCVBazMo7Xgos06mnl6wk-eV9jJfMEpzDDzwIuQx3vdiwo

To claim this, I am signing this object:

@pracucci
pracucci / aws-ec2-nitro-instance-halt.md
Created August 12, 2019 16:44
Notes on differences on the "halt" command on AWS EC2 Nitro instances

The halt command on EC2 Nitro instances doesn't poweroff the instance, so the OS will shutdown but the instance will be in the running state indefinitely (until you force a "stop" or "termination" via EC2 console / API). This is because the hypervisor has changed and the shutdown signaling between OS and the hypervisor behaves differently.

Works (the instance switches to "stopped" or "terminated"):

  • halt --poweroff
  • shutdown now (defaults to --poweroff)

Doesn't work (the instance hungs into a "running" state):

  • halt
  • shutdown --halt
@pracucci
pracucci / spark-job-server-bootstrap.sh
Created May 23, 2018 17:16
Installation script for Spark JobServer on EMR
#!/bin/bash
#
# This is the script run on master as bootstrap action.
#
set -e
# Config
SJS_VERSION=0.8.0
EMR_VERSION=5.13.0
@pracucci
pracucci / Dockerfile
Created May 23, 2018 16:29
Compile and run Spark JobServer for Amazon EMR
FROM ubuntu:16.04
# Config
ARG SBT_VERSION=0.13.12
ARG SJS_VERSION=0.8.0
ARG EMR_VERSION=5.13.0
ARG SPARK_VERSION=2.3.0
# Install JDK 8 and some dependencies
RUN apt-get update -qq && apt-get install -y -qq openjdk-8-jdk wget python python-pip
@pracucci
pracucci / monitoring-web-workers-with-prometheus.md
Last active February 19, 2018 14:35
Monitoring Web Workers with Prometheus

Design

Web workers can use the Prometheus PHP client to track metrics. Such metrics are stored in memory and also copied to a shared memory from which another process in the same SysV IPC namespace can read. This design allows us to run a micro webserver in a sidecar container from which we can export Prometheus metrics collected in the worker's cli app.

IPC namespace: when deployed on K8S, two containers of the same Pod run in the same IPC namespace, while two different pods on the same host run on a different IPC namespace unless explicitly configured to all share the host's IPC running the pod with hostIPC: true.

Why this design

There are three options to export metrics to Prometheus from a cli app:

@pracucci
pracucci / kubectl-rollout-configmap
Created April 30, 2017 08:00
An hacky way to replace K8S configmap from file, optionally signaling a deployment's containers once done. Be aware that a configmap is updated on containers asynchronously and could take some time: a signal delivered before will be totally useless. I still didn't find a way to watch for a configmap update complete event, and a sleep looks even …
#!/bin/bash
# Init
OPT_FROM_FILES=
OPT_DEPLOYMENT=
OPT_CONTAINER=
OPT_SIGNAL=
OPT_YES=0
# Helper to print usage