Skip to content

Instantly share code, notes, and snippets.

@barryhunter
barryhunter / gist:1a69c46dd5fdb350be6c
Created December 12, 2014 20:24
Words as HTML colours
# grep -P '^[a-f]{6}$' /usr/share/dict/british-english
accede
beaded
bedded
beefed
cabbed
dabbed
decade
deeded
deface
@barryhunter
barryhunter / query.log
Created December 13, 2017 12:36
Duplicate ids for queries
sphinxQL>insert into pq (id,query) VALUES (12345, 'full text query terms');
Query OK, 0 rows affected (0.01 sec)
sphinxQL>pager grep 'full text query terms'
PAGER set to 'grep 'full text query terms''
sphinxQL>select * from pq;
| 1 | full text query terms | | |
| 12345 | full text query terms | | |
10024 rows in set (0.02 sec)
@barryhunter
barryhunter / gist:437b661faa92174eb45a9f578fec4512
Created May 11, 2019 19:35
reloading a Leaflet TileLayer, while reducing flicker
var layerUrl='https://t0.geograph.org.uk/tile/tile-density.php?z={z}&x={x}&y={y}&match=&l=1&6=1';
overlayMaps["Coverage - Dots"] = new L.TileLayer(layerUrl, {user_id: 0, minZoom: 5, maxZoom: 19, attribution: layerAttrib, bounds: bounds});
function j() { //L.template can use callback function.
return (map.getZoom()>16 && overlayMaps["Coverage - Dots"] && map.hasLayer(overlayMaps["Coverage - Dots"]))?1:0;
}
var layerUrl='https://t0.geograph.org.uk/tile/tile-viewpoint2.php?z={z}&x={x}&y={y}&match=&l=1&6=1&j={j}';
@barryhunter
barryhunter / gist:e42f0c4756e34d5d07db4a170c7ec680
Created May 11, 2019 21:19
Basic working implementation of L.TileLayer.refresh()
L.TileLayer2 = L.TileLayer.extend({
_refreshTileUrl: function(tile, url) {
//use a image in background, so that only replace the actual tile, once image is loaded in cache!
var img = new Image();
img.onload = function() {
L.Util.requestAnimFrame(function() {
tile.el.src = url;
});
}
img.src = url;
@barryhunter
barryhunter / indexer-wrapper.php
Created July 20, 2022 11:49
A conventient system to automate automatic rebuilding of sphinx/manticore indexed. A distilled and simplified version of https://github.com/geograph-project/geograph-project/blob/british-isles/system/docker/manticore/usr/local/bin/indexer-wrapper.php
#!/usr/bin/php
<?php
$db = mysqli_connect($_SERVER['MYSQL_HOST'],$_SERVER['MYSQL_USER'],$_SERVER['CONF_DB_PWD'],$_SERVER['MYSQL_DATABASE']);
if (mysqli_connect_errno()) {
throw new RuntimeException('mysqli connection error: ' . mysqli_connect_error());
}
$server_id = db_Quote(trim(`hostname`));
@barryhunter
barryhunter / README
Created March 20, 2024 14:04
Meshtastic Protocol Buffer class for https://github.com/T0ha/uprotobuf
pip install protobuf
wget https://github.com/protocolbuffers/protobuf/releases/download/v26.0/protoc-26.0-linux-x86_64.zip
unzip protoc-26.0-linux-x86_64.zip
git clone https://github.com/T0ha/uprotobuf
git clone https://github.com/meshtastic/protobufs
cd protobufs/
mkdir output
../bin/protoc --plugin=protoc-gen-custom=../uprotobuf/scripts/uprotobuf_plugin.py --custom_out=output/ meshtastic/mesh.proto