Skip to content

Instantly share code, notes, and snippets.

View w8r's full-sized avatar
💭
learning

Alexander Milevski w8r

💭
learning
View GitHub Profile
@w8r
w8r / array-intersection.ts
Created July 31, 2021 19:47
Array intersection
function intersection(...lists) {
const result = [];
const resultLUT = {};
for(let i = 0; i < lists.length; i++) {
const currentList = lists[i];
for(let y = 0; y < currentList.length; y++) {
const currentValue = currentList[y];
if(!resultLUT[currentValue]) {
let existsInAll = true;
@w8r
w8r / .ciconfig
Created May 28, 2018 14:23
Ensure SSH keys in Jenkins slave
pipeline {
agent { dockerfile true }
environment {
npm_config_cache = 'npm-cache'
}
stages {
stage('Install') {
steps {
echo 'Ensure SSH keys'
// set the credentials to be able to access private repos
@w8r
w8r / createDataContext.tsx
Created November 20, 2020 22:01
Create data context
import React, { useReducer, Reducer, createContext, ReactNode, Dispatch } from "react";
type Action = <A>(dispatch: Dispatch<A>) => Function;
export default function <S, A extends Action>(
reducer: Reducer<S, A>,
actions: Record<string, A>,
initialState: S
) {
const Context = createContext<S>({} as S);
@w8r
w8r / Readme.md
Last active November 13, 2020 13:07
Spatial hash on morton curve

Spatial hash on morton curve

Virtual grid with that works like a flat spatial index

@w8r
w8r / event_emitter.js
Created July 18, 2018 13:54
Event emitter
var isArray = Array.isArray;
class EventTarget {
/**
* @param {string} name
* @param {function} cb
* @return {EventTarget}
*/
@w8r
w8r / README.md
Created December 14, 2019 22:19 — forked from vprtwn/README.md
Force Editor + Pan/Zoom

Drag from an existing node to add a new node or link. Click to select/deselect nodes/links. Hit the DELETE key to remove the selected node or link. Drag to pan. Scroll to zoom.

Built with D3.js.

@w8r
w8r / sortedArrayToBST.js
Created August 21, 2018 22:05
Non-recursive BST build from sorted array
export default function sortedArrayToBST(data) {
let root = {};
const Q = [root];
const stack = [0, data.length - 1];
while (Q.length !== 0) {
const right = stack.pop();
const left = stack.pop();
const cur = Q.pop();
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@w8r
w8r / .block
Last active August 6, 2019 23:33
Leaflet + mapbox-gl
license: mit
height: 500
border: no
@w8r
w8r / Bunny.js
Created July 30, 2019 09:19 — forked from bberak/Bunny.js
How to use regl in React or React Native
import React, { PureComponent } from "react";
import { StyleSheet } from "react-native";
import ReglView from "./ReglView";
import mat4 from "gl-mat4";
import bunny from "bunny";
export default class Bunny extends PureComponent {
drawCommand = regl => {
return regl({
vert: `