Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
learning

Alexander Milevski w8r

💭
learning
View GitHub Profile
View event_emitter.js
var isArray = Array.isArray;
class EventTarget {
/**
* @param {string} name
* @param {function} cb
* @return {EventTarget}
*/
@w8r
w8r / README.md
Created Dec 14, 2019 — forked from benzguo/README.md
Force Editor + Pan/Zoom
View README.md

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 Aug 21, 2018
Non-recursive BST build from sorted array
View sortedArrayToBST.js
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();
View napoleon.geojson
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 Aug 6, 2019
Leaflet + mapbox-gl
View .block
license: mit
height: 500
border: no
@w8r
w8r / Bunny.js
Created Jul 30, 2019 — forked from bberak/Bunny.js
How to use regl in React or React Native
View Bunny.js
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: `
@w8r
w8r / .gitignore
Last active Apr 29, 2019
Namespaces vs. classes
View .gitignore
node_modules
dist
@w8r
w8r / welzl.js
Created Nov 12, 2018
welzl algorithm
View welzl.js
function shuffle(arr) {
for (let i = arr.length - 1; i >= 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
j = Math.max(Math.min(j, i), 0);
const tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
return arr;
}
View turf_intersect_issue.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@w8r
w8r / heapset.js
Created Sep 19, 2018
HeapSet - unordered heap with random access and pop() and unshift()
View heapset.js
export default class HeapSet {
constructor (values) {
this._values = values;
this._list = new Array(values.length * 3);
this._idToIndex = {};
const list = this._list;
for (let i = 0, prev = -1; i < values.length; i++) {
You can’t perform that action at this time.