Skip to content

Instantly share code, notes, and snippets.

@kevinmehall
kevinmehall / copy-to-maven.sh
Created July 28, 2020 00:55
Hack to copy a local ivy package from `sbt publishLocal` to a directory on a web server that can be accessed as a maven repository
#!/bin/bash
set -euo pipefail
group=$1
artifact=$2
version=$3
repohost=sshuser@serverhost
repo=/srv/www/maven/repo-name
srcbase=$HOME/.ivy2/local/$group/$artifact/$version
destbase=$repo/$(echo $group | tr . /)/$artifact/$version
@kevinmehall
kevinmehall / replace_ecs_cluster_instances.py
Last active February 20, 2022 23:24
Script to drain and replace EC2 instances in an ECS cluster auto-scaling group after changing the AMI or instance type
#!/usr/bin/env python3
#
# Script to replace EC2 instances in an ECS cluster's auto-scaling group after
# changing the AMI or instance type in the launch configuration. It
# checks for instances with the incorrect AMI or type, scales up the
# auto-scaling group with replacement instances, then drains the tasks
# from the old instances.
#
# Usage: aws-vault exec profile-name -- python3 replace_ecs_cluster_instances.py --group=asg-name --cluster=ecs-cluster-name --count=3
#
@kevinmehall
kevinmehall / Readme.md
Created March 12, 2018 07:17
Loading 3DEP elevation data in C++ with GDAL
extern crate soapysdr;
extern crate num_complex;
use num_complex::Complex;
use soapysdr::Direction::{Rx, Tx};
fn main() {
let dev = soapysdr::Device::new("driver=lime").expect("Failed to open device");
dev.set_sample_rate(Tx, 0, 5_000_000.).unwrap();
dev.set_sample_rate(Rx, 0, 5_000_000.).unwrap();
dev.set_frequency(Tx, 0, 915_000_000., ()).unwrap();
### Keybase proof
I hereby claim:
* I am kevinmehall on github.
* I am kevinmehall (https://keybase.io/kevinmehall) on keybase.
* I have a public key whose fingerprint is D66E 018F 8E06 7143 012E 4732 577E C92C 94B6 A2FC
To claim this, I am signing this object:
import sys
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
f = open(sys.argv[1])
f.next()
f.next()
/*
Copyright (C) 2015 3D Robotics
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
# Decode UAVCAN transfers from a CAN dump CSV exported from Saleae Logic
import argparse
import csv
import uavcan
from uavcan.transport import TransferManager, Frame, Transfer
def parsecsv(f):
manager = TransferManager()
reader = csv.reader(f, delimiter=',')
import os
def randid():
r = bytearray(os.urandom(16))
s = ""
for i in range(24):
idx, pos = (i*5)/8, (i*5)%8
val = ((r[idx] >> pos) | (r[idx+1] << (8-pos))) & ((1<<5)-1)
@kevinmehall
kevinmehall / testing.md
Last active August 29, 2015 14:25
Tessel wifi testing

Install: on both Tessels

opkg update
opkg install tcpdump
wget https://kevinmehall.net/tmp/packetspammer -O /usr/bin/packetspammer
chmod +x /usr/bin/packetspammer

Setup: on both Tessels