Skip to content

Instantly share code, notes, and snippets.

alces / signalflow_metrics.go
Created Nov 16, 2022
Getting metrics from SignalFX
View signalflow_metrics.go
package main
import (
. ""
const (
alces /
Created Mar 26, 2021
Call Google Cloud function from command line
gcloud --project my-project-id \
functions call hello-world \
--data '{}' \
--region us-east1
alces /
Created Nov 27, 2020
Print out "creation time" for EC2 instances (in reality, it's the first network interface attachement time)
import boto3
import datetime
# iterator over EC2 instances for region
def ec2_instances(region):
client = boto3.client('ec2', region_name = region)
for reservation in client.describe_instances().get('Reservations', []):
for instance in reservation.get('Instances', []):
yield instance
alces /
Created Oct 1, 2020
Passing a list as a value of an external Ansible variable
ansible-playbook our_playbook.yml -e '{"our_var": ["one", "two", "three",]}'
alces /
Created Jul 6, 2020
Manipulating groups with lenses-cli
# Nice doc is here:
LENSES_CLI_CMD="lenses-cli --host --user admin --pass admin --insecure groups"
# Get the list
$LENSES_CLI_CMD get --output JSON
# Group config file
cat > config.yaml << EOF
name: windows_admins
description: "Admins from AD"
alces /
Last active Jul 3, 2020
Getting list of subset of the commits in a git branch in a reverse order with a custom format
# See git log --help for details
git log --reverse --after='Jan 19' --format='format:%h %an'
alces /
Created Jan 7, 2020
Check all Kerberos keytabs in the current directory
# Check all keytabs in the current directory
for kt in *.keytab
pr=$(klist -k $kt | tail -1 | awk '{print $2}')
echo -n "${kt}: "
kinit -kt $kt $pr > /dev/null 2>&1 && echo OK || echo FAILED
alces /
Created Dec 31, 2019
Print Java RPM version (tested on RedHat 7)
import rpm
for pkg in rpm.TransactionSet().dbMatch('provides', 'java'):
print '%s:%s:%s:%s' % (pkg['name'], pkg['version'], pkg['release'], pkg['epoch'])
alces /
Created Nov 19, 2019
MD5 UN*X password encryption in Python
import crypt
crypt.crypt('my-secret-word', '$1$someSalt$')
alces / summarize_by_day.prometheus
Created Nov 6, 2019
Prometheus expression summarizing message count for a given Kafka topic by day
View summarize_by_day.prometheus
sum(increase(kafka_producer_topic_metrics_record_send_total{topic = "$my_topic_name"}[1d]))