Skip to content

Instantly share code, notes, and snippets.

@byrney
byrney / socket-send.js
Created December 14, 2021 09:38
Testing performance of socket.write in node
const net = require('net');
const stream = require('stream');
function createSource(count, batchSize, sep){
const s = stream.Readable();
let buf = '';
for(let i = 0; i < count; i++){
if(i > 0 && (i % batchSize) == 0) {
s.push(buf + sep);
buf = '';

Keybase proof

I hereby claim:

  • I am byrney on github.
  • I am byrney (https://keybase.io/byrney) on keybase.
  • I have a public key ASD5QvelbmJVtgs4w9A_Z_bm8qSfMCqt1ro0oXqE6bZtjAo

To claim this, I am signing this object:

@byrney
byrney / topdrawer.html
Created April 1, 2017 12:48
Hiding a settings page behind the main screen
<html>
<head>
<style>
#overlay {
}
.transform-delay {
@byrney
byrney / index.html
Created March 31, 2017 13:40
Smooth transitions between map baselayers (maybe suitable for a day to night transition)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Toggling layers</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@byrney
byrney / postgis-layer.py
Created December 15, 2016 23:10
Add a postgis layer with a custom filter to QGIS
host='localhost'
port="5432"
db='rob'
user='rob'
password='password'
filter = "name = 'M5'"
uri = QgsDataSourceURI()
uri.setConnection(host, port, db, user, password)
uri.setDataSource("public", "dft_major_roads", "geom", filter ,"gid")
@byrney
byrney / osrm-route-qgis.py
Created December 15, 2016 22:33
Add a route from OSRM to QGIS memory layer
#
# Paste this into the QGIS python console
#
sx=-3.51249995613522
sy=50.7355583126591
ex=-3.53626387621797
ey=50.7058687562277
host = 'http://router.project-osrm.org'
template = '/route/v1/driving/{},{};{},{}?steps=true'
@byrney
byrney / multi-queue.py
Created December 7, 2016 06:57
Share state between python coprocesses
import time
import random
from multiprocessing import Process, Queue, current_process, freeze_support
#
# Function run by worker processes
#
def worker(state, input, output):
@byrney
byrney / command.py
Created November 14, 2016 06:59
Python docopt example
"""
Usage:
program run [options] [--] (FILE... | --stdin)
program load [options] [--] (FILE... | --stdin)
Options:
-d DATABASE --database=DATABASE Specify database
-v --verbose Be verbose
@byrney
byrney / igraph071.txt
Created August 31, 2016 07:12
R Igraph Route Performance
> for(i in c(1,10,25,50, 100)){ print(system.time(x <- do_work(300, i, 50)))}
user system elapsed
0.03 0.02 0.08
user system elapsed
0.03 0.02 0.05
user system elapsed
0.04 0.00 0.06
user system elapsed
0.03 0.00 0.05
user system elapsed