Skip to content

Instantly share code, notes, and snippets.

View ear7h's full-sized avatar
🚲
now on a bike

Julio ear7h

🚲
now on a bike
View GitHub Profile
@ear7h
ear7h / newtodos.sh
Created March 12, 2020 19:27
check if there are new todos about to be committed
#!/usr/bin/env bash
git diff -S 'TODO' HEAD | \
grep -i '^+++\|^@@' | \
sed -E 's/\+{3} b\///' | \
sed -E 's/^@@ -[0-9]+,([0-9]+) \+[0-9]+,([0-9]+) @@$/\1 \2/' | \
awk '
{
# NR starts at 1
if (NR % 2 == 1) {
dlv debug $GOPATH/src/github.com/go-delve/delve/cmd/dlv -- debug main.go --init dlvscript.txt
Type 'help' for list of commands.
(dlv) b proc/variables.go:840
Breakpoint 1 set at 0x145e9e7 for github.com/go-delve/delve/pkg/proc.(*Variable).structMember() ./lib/go/src/github.com/go-delve/delve/pkg/proc/variables.go:840
(dlv) c
WARN[0000] CGO_CFLAGS already set, Cgo code could be optimized. layer=dlv
Type 'help' for list of commands.
Breakpoint 1 set at 0x1057f66 for main.main() ./main.go:13
> main.main() ./main.go:13 (hits goroutine(1):1 total:1) (PC: 0x1057f66)
8: }
@ear7h
ear7h / timely_table.sql
Last active January 23, 2020 20:08
a postgres table with created, modified, deleted
-- https://stackoverflow.com/questions/9556474/how-do-i-automatically-update-a-timestamp-in-postgresql/9556527#9556527
-- https://dba.stackexchange.com/questions/9759/postgresql-multi-column-unique-constraint-and-null-values
-- this might be better as a view...
BEGIN;
CREATE OR REPLACE FUNCTION set_modified_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.modified = now();
RETURN NEW;
@ear7h
ear7h / main.go
Created November 8, 2019 01:00
mvt2wkt
package main
import (
"fmt"
"os"
"github.com/go-spatial/geom/encoding/mvt"
"github.com/go-spatial/geom/encoding/wkt"
)
@ear7h
ear7h / epsilons_imposm.txt
Last active November 8, 2019 00:04
Epsilons currently (7-NOV-2019) used in tegola
z | ε
0 | 156543.03
1 | 78271.52
2 | 39135.76
3 | 19567.88
4 | 9783.94
5 | 4891.97
6 | 2445.98
7 | 1222.99
8 | 611.50
%d!p/�T�!pHT6!pH�!t%�1!p t
@ear7h
ear7h / tegola_client.sh
Created October 4, 2019 20:22
tegola remote control
#!/bin/sh
PORT=8888
echo "$@" | nc localhost $PORT
sleep 1
nc localhost $PORT
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x467a656]
goroutine 407 [running]:
github.com/go-spatial/tegola/atlas.Map.Encode.func1.1.1(0xc0002e1aa0, 0xc000c67e00, 0xc0070f7358)
/Users/julio/lib/go/src/github.com/go-spatial/tegola/atlas/map.go:215 +0x505
panic(0x49c0580, 0x527c920)
/usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/go-spatial/geom/planar/triangulate/quadedge.(*QuadEdge).Sym(...)
@ear7h
ear7h / wkt_conv.go
Last active August 28, 2019 21:31
golang "script" for converting wkt into github.com/go-spatial/goem types
/*
* can be run as like so:
* psql -d natural_earth -t -c "select 'CoastLine', ST_AsText(wkb_geometry) from ne_10m_coastline limit 1 offset 1;" | go run wkt_conv.go >> natural_earth.go
*/
package main
import (
"fmt"
"os"
"strings"
@ear7h
ear7h / conn.go
Created July 18, 2019 08:14
client side WebSocket as a net.Conn (wasm)
// +build js
package websocket
import (
"fmt"
"io"
"net"
"syscall/js"
"time"