Skip to content

Instantly share code, notes, and snippets.

View mjs's full-sized avatar
💭
curl -s http://104.196.37.21/|grep -Eo '^\S+'

Menno Finlay-Smits mjs

💭
curl -s http://104.196.37.21/|grep -Eo '^\S+'
View GitHub Profile
@mjs
mjs / mmap-mp.py
Created January 18, 2023 09:18
Example of how to use a anonymous mmap block with the multiprocessing module
from multiprocessing import Pool
import mmap
mm = mmap.mmap(-1, 12, flags=mmap.MAP_SHARED|mmap.MAP_ANONYMOUS)
n = mm.write(b"lots of data")
mm.seek(0)
print(mm.read().decode('ascii'))
mm.seek(0)
@mjs
mjs / chat.html
Created July 7, 2020 09:49
BBB chat log from the July 2020 Christchurch Python meetup
[19:59] Welcome to <b>chch-python-2020-07</b>!<br><br>For help on using BigBlueButton see these (short) <a href="http://www.bigbluebutton.org/html5" target="_blank"><u>tutorial videos</u></a>.<br><br>To join the audio bridge click the phone button. Use a headset to avoid causing background noise for others.<br><br>This server is running <a href="http://docs.bigbluebutton.org/" target="_blank"><u>BigBlueButton</u></a>.
[20:00] Jimmy : https://git.1248.nz/python/docker
[20:01] Jimmy : Not yet
[20:08] Jimmy : I have venue that could be used
[20:11] Farzad : nope
[20:11] Tae : virtual laugh (hahaha)
[20:34] Menno FInlay-Smits : https://sylabs.io/
[20:34] Menno FInlay-Smits : https://podman.io/
[20:41] Menno FInlay-Smits : https://caddyserver.com/
[20:41] Mike : thanks for that.
@mjs
mjs / predictive_tracking_V2.py
Created June 19, 2019 23:54
Black formatted version
"""
Predictive Predator Tracker
Author: Ben McEwen
The class predator tracker takes mp4 file input (standard extract.py format).
The centroid of the animal is determined (find_center()) and a Kalman filter is used to smooth the
movement and reduce noise introduced by occlusion (kalman_filter()).
A moving average filter and Kalman filter is used to find the average velocity and this is used to
calculate the future position of the animal at a given time (predict_location()).
"""
@mjs
mjs / yaml-time.go
Created May 13, 2019 10:31
Demonstration of time marshalling and unmarshalling in Go
package main
import (
"fmt"
"time"
yaml "gopkg.in/yaml.v2"
)
type Data struct {
<!DOCTYPE html>
<html lang="en">
<head>
<title>Cacophonator Setup</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
</head>
@mjs
mjs / scpj
Created August 1, 2018 23:22
Helper for using scp through a jump host
#!/bin/sh
if [ $# -lt 3 ]; then
echo "usage: sshj <jump_host> <source> <target>"
exit 1
fi
jump=$1
shift
@mjs
mjs / sshj
Created August 1, 2018 03:21
SSH jump host helper
#!/bin/sh
if [ $# -ne 2 ]; then
echo "usage: sshj <jump_host> <target>"
exit 1
fi
exec ssh -o ProxyCommand="ssh -W %h:%p $1" "$2"
@mjs
mjs / slow-influxd.go
Created April 24, 2018 11:01
A fake influxd that is slow to respond
package main
import (
"fmt"
"log"
"net/http"
"time"
)
import "flag"
package perf_test
import (
"bytes"
"fmt"
"strconv"
"testing"
)
var (
package b
import (
"bytes"
"testing"
)
var needsEscape = []byte(`foo\ bar\"sne`)
func BenchmarkOrig(b *testing.B) {