Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
🥡

Stepan Kuzmin stepankuzmin

🥡
View GitHub Profile
@stepankuzmin
stepankuzmin / vt.js
Created June 26, 2018 11:00
Reading vector tiles from PostGIS
const zlib = require("zlib");
const Protobuf = require("pbf");
const postgis = require("tilelive-postgis");
const tilelive = require("@mapbox/tilelive");
const VectorTile = require("@mapbox/vector-tile").VectorTile;
postgis.registerProtocols(tilelive);
const uri =
"postgis://postgres@localhost/test?table=test&layerName=myLayer&geometry_field=geom";
@stepankuzmin
stepankuzmin / debian-mysql-client-8.sh
Last active February 1, 2019 03:03
Install mysql-client 8 on Debian
wget https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb
dpkg -i mysql-apt-config_0.8.10-1_all.deb # choose OK
apt-get update
apt-get install mysql-client

Count features in MVT tile

Usage:

npm i @mapbox/vector-tile
node count-features-in-tile.js tile.pbf
@stepankuzmin
stepankuzmin / docker-compose.yml
Created May 11, 2018 14:03
traefik docker-compose.yml
version: '3.6'
services:
traefik:
image: traefik:1.6-alpine
container_name: traefik
restart: always
ports:
- 80:80
- 443:443

macOS setup

defaults write -g ApplePressAndHoldEnabled -bool false
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
brew tap homebrew/cask-fonts
brew cask install font-fira-code
@stepankuzmin
stepankuzmin / docker.js
Created May 5, 2018 11:31
Example docker usage from NodeJS
const request = require("request-promise");
const main = async () => {
try {
const { Id, Warnings } = await request({
method: 'POST',
uri: 'http://unix:/var/run/docker.sock:/v1.24/containers/create',
body: { Image: 'bfirsh/reticulate-splines' },
headers: {
'Host': null,
@stepankuzmin
stepankuzmin / mount.sh
Created April 26, 2018 12:33
Mount remote folder using sshfs
sudo sshfs -d -o allow_other -o reconnect -o IdentityFile=/home/stepan/.ssh/id_rsa -o ServerAliveInterval=15 [email protected]:/root/gitlab-backups /srv/gitlab/data/backups
@stepankuzmin
stepankuzmin / get-first-features.js
Last active April 17, 2018 08:50
Returns FeatureCollection with first features in some dir
const fs = require("fs");
const path = require("path");
const argv = process.argv.slice(2);
const dir = argv[0];
if (!dir) {
console.log("Usage: node get-first-features.js [dir]");
process.exit(-1);
}
@stepankuzmin
stepankuzmin / check.sql
Created February 26, 2018 09:54
PostGIS check 4326 geometry for bounds
select
ST_XMax(geom),
ST_YMax(geom),
*
from gamma.cores_boundaries
where ST_XMax(geom) > 180 OR ST_XMax(geom) < -180 OR ST_YMax(geom) > 90 OR ST_YMax(geom) < -90;
@stepankuzmin
stepankuzmin / shouldUpdateImmutable.js
Last active February 13, 2018 15:11
shouldUpdateImmutable
import { is, isImmutable } from 'immutable';
import { shouldUpdate, shallowEqual } from 'recompose';
const shouldUpdateImmutable = shouldUpdate((props, nextProps) => {
const keys = Object.keys(props);
const nextKeys = Object.keys(nextProps);
if (keys.length !== nextKeys.length) {
return true;
}