Skip to content

Instantly share code, notes, and snippets.

@barryhunter
barryhunter / indexer-wrapper.php
Created Jul 20, 2022
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
View 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 / gist:e42f0c4756e34d5d07db4a170c7ec680
Created May 11, 2019
Basic working implementation of L.TileLayer.refresh()
View gist:e42f0c4756e34d5d07db4a170c7ec680
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 / gist:437b661faa92174eb45a9f578fec4512
Created May 11, 2019
reloading a Leaflet TileLayer, while reducing flicker
View gist:437b661faa92174eb45a9f578fec4512
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 / query.log
Created Dec 13, 2017
Duplicate ids for queries
View query.log
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)
View gist:1a69c46dd5fdb350be6c
# grep -P '^[a-f]{6}$' /usr/share/dict/british-english
accede
beaded
bedded
beefed
cabbed
dabbed
decade
deeded
deface