Skip to content

Instantly share code, notes, and snippets.

@vlasky
vlasky / point_in_polygon_using_winding_number.js
Last active June 15, 2025 15:47
JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//Based on C++ implementation of wn_PnPoly() published on http://geomalgorithms.com/a03-_inclusion.html
function pointInPolygon(point, vs) {
const x = point[0], y = point[1];
let wn = 0;
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
let xi = vs[i][0], yi = vs[i][1];
let xj = vs[j][0], yj = vs[j][1];
import numpy as np
import re
import sys
'''
Read a PFM file into a Numpy array. Note that it will have
a shape of H x W, not W x H. Returns a tuple containing the
loaded image and the scale factor from the file.
'''
def read_pfm(file):
@kylemcdonald
kylemcdonald / stylegan.ipynb
Created February 5, 2019 16:57
StyleGAN.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mattdesl
mattdesl / randao-roll.js
Created September 16, 2022 12:45
roll a 6-sided die with the blockchain using Ethereum Proof of Stake RANDAO.
const Web3 = require("web3");
const BN = Web3.utils.BN;
(async () => {
const network = "mainnet";
const web3 = new Web3(
new Web3.providers.HttpProvider(
`https://${network}.infura.io/v3/${process.env.INFURA_API_KEY}`
)
);