Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
🥡

Stepan Kuzmin stepankuzmin

🥡
View GitHub Profile
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
import { authorize } from './reducer';
import { tokenSelector, errorSelector } from './selectors';
class Login extends PureComponent {
constructor(props) {
import { combineReducers } from 'redux'
import { routerReducer } from 'react-router-redux';
export const AUTH_REQUEST = 'AUTH_REQUEST';
export const AUTH_SUCCESS = 'AUTH_SUCCESS';
export const AUTH_FAILURE = 'AUTH_FAILURE';
export const authorize = (login, password) => ({
type: AUTH_REQUEST,
payload: { login, password }
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { Route, Redirect } from 'react-router-dom';
const Main = ({ token }) => {
if (!token) {
return <Redirect to="/login" />;
}
return <div> You are logged in.</div>;
nvm i 4
npm i -g tl mbtiles tilelive-tmstyle tilelive-mapbox tilelive-http tilejson tilelive-vector
export MAPBOX_ACCESS_TOKEN=<token>
tl copy -z 10 -Z 17 -b "36.9829150439 55.5174350218 38.3547996893 55.9613886664" tmstyle://./Mystreet.tm2 mbtiles://./mystreet.mbtiles
const params = {
host: {
description: 'PostgreSQL host',
boolean: false
}
};
// cliParams is a mapping between param keys and a cli param keys
const cliParams = { host: 'host' };
const envParams = { host: 'PGHOST' };
@stepankuzmin
stepankuzmin / koa.re
Created August 11, 2017 20:39
ReasonML Koa interop experiment
module Koa = {
type t;
type ctx = {. body : ref string};
/** [make ()] creates an instance of the Koa class. */
external make : unit => t = "koa" [@@bs.new] [@@bs.module];
external listen : t => int => unit = "listen" [@@bs.send];
external use : t => (ctx => unit) [@bs.uncurry] => unit = "use" [@@bs.send];
};
@stepankuzmin
stepankuzmin / convert.sh
Created September 23, 2017 12:36
How to convert GeoTIFF image into MBTiles
gdal2tiles.py common.tif
mb-util common common.mbtiles
const fs = require('fs');
const iconv = require('iconv-lite');
const buffer = fs.readFileSync(process.argv[2]);
const csv = iconv.decode(buffer, 'win1251');
const rows = csv.toString().split('\n');
const regexp = new RegExp('Заработная плата|Аванс', 'ig');
const result = rows.slice(1).reduce((acc, row) => {
const values = row.split(';');
@stepankuzmin
stepankuzmin / types.js
Created October 12, 2017 11:43
Mapbox GL JS Style Immutable Flowtype
// @flow
import mapboxgl from 'mapbox-gl';
import { Record } from 'immutable';
import type { RecordFactory, RecordOf } from 'immutable';
type MapStyleProps = {
version: number,
name: ?string,
center: ?[number, number],
zoom: ?number,
@stepankuzmin
stepankuzmin / app.js
Created October 26, 2017 14:44
NodeJS server with PostgreSQL streaming
const http = require('http');
const Pool = require('pg-pool');
const bluebird = require('bluebird');
const JSONStream = require('JSONStream');
const QueryStream = require('pg-query-stream');
const pool = new Pool({
user: 'postgres',
host: 'localhost',
database: 'data',