Skip to content

Instantly share code, notes, and snippets.

function CreateAndSetTags()
exec ':!ctags -R --languages=python -o tags $VIRTUAL_ENV `git rev-parse --show-toplevel`'
set tags=./tags,tags
endfunction
nmap <silent> <F4> :call CreateAndSetTags()<CR>
" C-], tn, tb, F4
@cboddy
cboddy / ffmpeg_concat_cut.py
Created November 9, 2023 22:15
Wrap ffmpeg to concat parts of a video file together using ffmpeg
#!/usr/bin/env python3
import subprocess
from typing import Tuple
import tempfile
import argparse
def to_concat_input(from_to_seconds: Tuple[Tuple[int]], in_path: str) -> str:
#!/bin/bash
set -eu -o pipefail
# Check if your external IP address is in an Openvpn client
# config file.
#
#
# Usage: ./is_connected_via_openvpn.sh [openvpn-vpn-config-path]
# Defaults to checking /etc/openvpn/*.conf
#
@cboddy
cboddy / junit_test_report_time_checker.py
Created March 12, 2021 20:50
A CI check to read a Junit test report and raise an error if the time exceeds a threshold.
#!/usr/bin/env python3
import argparse
import collections
import sys
import glob
from typing import *
from xml.dom import minidom
TestCase = collections.namedtuple("TestCase", ["class_name", "test_name", "time"])
@cboddy
cboddy / uk_covid_tracker.py
Last active July 28, 2020 10:57
Get the historical cases by day for a UK region as used in coronavirus.data.gov.uk (that only displays the latest value for a region)
#!/usr/bin/env python3
import urllib.request
import json
import sys
import argparse
# Used in https://coronavirus.data.gov.uk
URL='https://c19downloads.azureedge.net/downloads/data/ltlas_latest.json'
@cboddy
cboddy / WTF_JAVAC.java
Created August 15, 2019 18:09
Javac Snafu
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class WTF_JAVAC {
private static final Map<String, String> MAP = new HashMap<>();
private static final String HELP = "\n"+ MAP.entrySet().stream()
.sorted()
.map(e -> {
String s = e.getKey() + "\t:\t" + e.getValue();
@cboddy
cboddy / jscript.sh
Last active July 4, 2018 17:15
A utility for compiling and running a single file Java program (for scripting)
#!/bin/bash
# compile a java source file and run it
#
# two options:
# 1. Add to interactive environment
#
# > source jscript.sh.
# (or do the above in ~/.bashrc)
# to make the function jscript available eg.
# > jscript HelloWorld.java
@cboddy
cboddy / with_logger.sh
Created June 30, 2018 09:08
Update a java project that is using System.{out,err} for logging to use java.util.logger.
# usage:
# ./with_logger.sh path_to_project_src
#
for f in `find $1 -type f -name \*java |xargs grep -l System.out`;
do
echo $f
# add import statement after package declaration
sed -i '0,/package.*/s//&\nimport java.util.logging.*;/' $f
# add Logger instance after class declaration
sed -i '0,/.*class [a-zA-Z]\+.*/s//&\n\tprivate static final Logger LOG = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);/' $f
@cboddy
cboddy / print_cbor.sh
Last active June 17, 2018 10:14
A bash function to pretty print a file or cbor-encoded data.
#!/bin/bash
#
# add to ~/.bashrc or similar
#
# usage:
#
# > cbor_print /path/to/my/file.cbor
function cbor_print() {
# pretty print the contents of a file of cbor-encoded data

Keybase proof

I hereby claim:

  • I am cboddy on github.
  • I am cboddy (https://keybase.io/cboddy) on keybase.
  • I have a public key whose fingerprint is 42EC 5971 1C62 640B 1739 7F3C FC8C 3F6C C16B BCCA

To claim this, I am signing this object: