Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
🥡

Stepan Kuzmin stepankuzmin

🥡
View GitHub Profile
@stepankuzmin
stepankuzmin / extract-from-mbtiles.js
Created October 30, 2024 15:31
Extract tile from mbtiles
/* eslint-disable handle-callback-err */
import fs from 'fs';
import zlib from 'zlib';
import MBTiles from '@mapbox/mbtiles';
const z = 0;
const x = 0;
const y = 0;
// tippecanoe -f -z0 -o admin.mbtiles admin.geojson
@stepankuzmin
stepankuzmin / logOffscreenCanvasContext.js
Created October 15, 2024 15:06
Log OffscreenCanvas rendering Context in the browser console
export function logOffscreenCanvasContext(context, scaleFactor = 1) {
const canvas = document.createElement('canvas');
canvas.width = context.canvas.width;
canvas.height = context.canvas.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(context.canvas, 0, 0);
const displayWidth = canvas.width * scaleFactor;
const displayHeight = canvas.height * scaleFactor;
@stepankuzmin
stepankuzmin / evented.ts
Last active July 10, 2024 15:23
Strongly Typed Evented class with on() and fire()
export type EventData = {
[key: string]: unknown;
};
export class Event<Type extends string = string, Data extends EventData | void = void> {
target: unknown;
readonly type: Type;
/**
* Virtual property to ensure that events with different data types are not compatible.
@stepankuzmin
stepankuzmin / migrate.js
Created June 11, 2024 15:21
Migrate code to `gl-matrix` v4
import babel from '@babel/core';
import traverse from '@babel/traverse';
import generator from '@babel/generator';
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function migrate() {
const input = `
@stepankuzmin
stepankuzmin / index.html
Last active January 30, 2024 14:28
Overlay 3D buildings with the Satellite layer in the Standard Style with Mapbox GL JS v3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Display a map on a webpage</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v3.1.2/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v3.1.2/mapbox-gl.js"></script>
<style>
@stepankuzmin
stepankuzmin / teamlead.md
Last active August 19, 2023 16:20
Для тимлидов

Для тимлидов

С чего начать

Teamlead Roadmap – карта навыков и компетенций тимлидов, которую можно адаптировать для любой компании и команды.

Что почитать

Про работу с командой

@stepankuzmin
stepankuzmin / toxy.js
Created May 26, 2023 13:05
Express request to Toxy
const zlib = require('zlib');
const toxy = require('toxy');
const express = require('express');
const proxy = toxy();
// Gzip CSS file
const cssContent = 'body { background-color: purple; }';
const gzippedCssContent = zlib.gzipSync(cssContent);
Hello, ChatGPT.
@stepankuzmin
stepankuzmin / mapbox-gl-js-oss-licenses.md
Last active March 13, 2023 13:57
Mapbox GL JS OSS licenses
@stepankuzmin
stepankuzmin / mapbox-flow-remove-types.diff
Last active November 22, 2022 15:55
Nove v18 loader for `mapbox-gl`
diff --git a/index.js b/index.js
index f685aa3..7b7ad81 100644
--- a/index.js
+++ b/index.js
@@ -49,7 +49,7 @@ module.exports = function flowRemoveTypes(source, options) {
allowReturnOutsideFunction: true,
allowSuperOutsideMethod: true,
sourceType: 'module',
- plugins: [ '*', 'jsx', 'flow', 'classProperties', 'importMeta' ],
+ plugins: ['*', 'jsx', 'flow', 'classProperties', 'importMeta', 'importAssertions' ],