Skip to content

Instantly share code, notes, and snippets.

<html>
<body>
<h1 id="h">Hi 3</h1>
<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<script>
function enterFullscreen() {
var element = document.documentElement;
@robshep
robshep / test_celery_mongo.py
Last active June 2, 2025 06:08
Quick test of Celery with MongoDB broker using mongo in docker
"""
Self-contained test for a simple Celery task interaction using an ephemeral MongoDB broker.
* MongoDB is created using docker with a temporary directory for storage.
* Celery broker is designated with the above containers random host-port.
* Celery worker is created using python Multi-process and managed.
* Triggers a distributed task
* Stops celery workers
* Stops mongodb container
* Removes temp directory.
@robshep
robshep / box_in_pipe.scad
Last active April 26, 2019 14:46
box in pipe
OD = 106; // outer diameter
PLATE_TH = 2; // base plate thickness
RING_TH = 5; // ring thickness
RING_DEPTH = 12; // depth of outer fixing ring
BOX_W = 35; // width of supplied enclosure
BOX_L = 50; // length of supplied enclosure
BOX_D = 12; // height of box grab. (20mm deep box)
@robshep
robshep / gen_weeknotes.py
Last active April 24, 2019 16:01
Hugo Blog: Generate weekly blog content file
"""
Generate a year's worth of \"Week notes\" blog content files using ISO week format.
Usage: cd <hugo content sub-folder> && python3 <year>
E.g. $ cd ~/hugo/content/blog
$ python3 ~/hugo/scripts/gen_weeknotes.py 2019
Produces a folder for each week for publication on a Sunday:
20190106-weeknotes-2019W01 to 20191229-weeknotes-2019W52
Each with an index.md having suitable frontmatter: E.g. week 31 of 2019 looks like:
@robshep
robshep / tct.html
Created April 14, 2019 11:22
Testing out Hugo's image finding routine in the twitter_card shortcode
<!-- save in /layouts/shortcodes/tct.html -->
<!-- usage: {{< tct >}} -->
<div>
{{- with $.Page.Params.images -}}
<span>Image: page.params.images[0]: <code>{{ index . 0 | absURL }}</code> </span>
{{ else -}}
{{- $images := $.Page.Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- $featured := cond (ne $featured nil) $featured ($images.GetMatch "{*cover*,*thumbnail*}") -}}
{{- with $featured -}}
@robshep
robshep / hl.bash
Created March 17, 2019 16:23
Highlight a character at a position
#!/bin/bash
# Inserts a single Red background highlight at the chosen character position
# usage: hl -c <pos> <file>
#
# E.g. /usr/local/bin/hl -c 384 /tmp/query.sql
head $1 $2 $3; \
gecho -e -n "\e[41m"; \
@robshep
robshep / build.sh
Created February 13, 2019 11:14
Building ovpn
# OVPN local build
export GOPATH=/root/gocode
cd /root/gocode
go get -u github.com/cad/ovpm/...
go get -u github.com/jteeuwen/go-bindata/...
cd ~/gocode/src/github.com/cad/ovpm
@robshep
robshep / CompareRoundingImplementations.java
Created November 27, 2018 14:21
Testing Java against Javascript implemenations
import static org.assertj.core.api.Assertions.assertThat;
import java.io.InputStreamReader;
import java.util.Random;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.junit.Test;
@robshep
robshep / README.md
Last active July 7, 2018 22:33
Hotswap Agent for JVM on MacOS
@robshep
robshep / AccessLogToMainLogAppender.java
Last active May 10, 2018 14:07
Logging Logback-access messages via another logger
package net._95point2.common.logging;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.OutputStreamAppender;
import ch.qos.logback.core.encoder.Encoder;
import ch.qos.logback.core.encoder.LayoutWrappingEncoder;