Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
🥡

Stepan Kuzmin stepankuzmin

🥡
View GitHub Profile
@stepankuzmin
stepankuzmin / docker-compose.yml
Last active November 12, 2017 14:22
Example project with Nginx + Redis
version: '3'
services:
nginx:
image: stepankuzmin/nginx-with-redis
ports:
- 8080:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
@stepankuzmin
stepankuzmin / shallowCompareChildren.js
Last active November 20, 2017 14:07
shallowCompare React Children
// @flow
import { Children } from 'react';
import type { Node } from 'react';
const childrenKeys = (children: Node): string[] =>
Children.map(children, child => child.key);
const shallowCompareChildren = (prevChildren: Node, newChildren: Node): boolean => {
if (Children.count(prevChildren) !== Children.count(newChildren)) {
@stepankuzmin
stepankuzmin / docker-with-host-network.sh
Created December 14, 2017 14:36
Docker with host network
docker run -d \
--name studio \
--restart=always \
--network="host" \
--add-host 10.10.42.2:10.10.42.2 \
-p 3000:3000 \
-v $(pwd):/root \
stepankuzmin/mapbox-studio-classic
use std::borrow::Cow;
struct A<'a> {
geometry_column: &'a str,
}
impl<'a> A<'a> {
fn geometry_column_mercator(&self, flag: bool) -> Cow<str> {
if flag {
self.geometry_column.into()
} else {
@stepankuzmin
stepankuzmin / index.js
Last active July 29, 2019 10:31
PostGIS ST_AsMVT JSONB properties encoding bug
const fs = require("fs");
const geobuf = require("geobuf");
const Protobuf = require("pbf");
const pgp = require("pg-promise")();
const vt = require("vector-tile");
const db = pgp(process.env.DATABASE_URL);
const tile_with_properties_as_jsonb = `WITH data AS (
SELECT * FROM (VALUES
@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;
}
@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 / 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 / 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 / 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,