Skip to content

Instantly share code, notes, and snippets.

View rapkin's full-sized avatar
🐍
no step on snek

Mikola Parfenyuck rapkin

🐍
no step on snek
View GitHub Profile
@rapkin
rapkin / polar_and_mercator_projection.py
Created May 15, 2020 13:52
Example how to project geojson file from polar (EPSG:4326 or WGS84) coordinate system to mercator (EPSG:3857) and vise versa (original article: https://rapkin.com.ua/python/geojson-projection/)
import json
import codecs
import pyproj
import numbers
# Define projections
polar = pyproj.Proj(init='epsg:4326')
mercator = pyproj.Proj(init='epsg:3857')
@rapkin
rapkin / measure.py
Created December 17, 2018 23:23
Decorator to measure function execution time in python
import time
def measure(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
name = kw.get('log_name', method.__name__.upper())
kw['log_time'][name] = int((te - ts) * 1000)
@rapkin
rapkin / copy.js
Created December 7, 2017 14:47
Script to copy files recursively
const fs = require('fs')
const path = require('path')
const mkdir = require('mkdirp')
const src = path.join(__dirname, 'source')
const dest = path.join(__dirname, 'destination')
function copyFile(src, dest) {
return new Promise(function (resolve, reject) {
let hasFinished = false