Skip to content

Instantly share code, notes, and snippets.

💭
learning

Alexander Milevski w8r

💭
learning
Block or report user

Report or block w8r

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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++) {
@w8r
w8r / point_in_polygon_wn.js
Created Sep 19, 2018
Point in polygon by winding number
View point_in_polygon_wn.js
function isLeft (x0, y0, x1, y1, x2, y2) {
return ((x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0));
}
export default function pointInPoygon (x, y, V) {
let wn = 0; // winding number
for (let i = 0; i < V.length - 1; i++) { // edge from V[i] to V[i+1]
const vi = V[i], vj = V[i + 1];
if (vi.y <= y) { // start y <= P.y
if (vj.y > y) { // an upward crossing
View iphone_parts.json
{
"nodes": [
{
"id": 0,
"data": {
"type": "device",
"name": "iPhone"
}
},
{
@w8r
w8r / mindisc.js
Created Aug 27, 2018
Minimum enclosing disc
View mindisc.js
function circleContainsCircle(cx, cy, cr, x, y, r) {
const dx = cx - x;
const dy = cy - y;
const dr = cr - r;
// reduce precision not to deal with square roots
return (dx * dx + dy * dy) < (dr * dr + 1e-6);
}
function from2discs(ax, ay, bx, by, ar, br) {
const dx = bx - ax;
You can’t perform that action at this time.