Skip to content

Instantly share code, notes, and snippets.

@yurivish
yurivish / venn-diagrams.js
Last active December 26, 2020 03:20
Area-proportional Venn Diagrams
// Since `overlapArea` function is monotonic increasing, we can perform a
// simple bisection search to find the distance that leads to an overlap
// area within epsilon of the desired overlap.
function distanceForOverlapArea(r1, r2, desiredOverlap) {
// Ensure r1 <= r2
if (r1 > r2) {
var temp = r2;
r2 = r1;
r1 = temp;
}
@phosphoer
phosphoer / SimpleGeo.cs
Last active December 2, 2024 16:13
Simple Geometry Painter for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
@andkon
andkon / outdoors.md
Last active September 22, 2020 18:21
Toronto Outdoors

Spring/summer/fall (in order of distance)

  • Daytrip list
  • Tobermory swimming holes/grotto
  • Bruce Peninsula National Park - you can book backcountry sites here. Very chill hike, but really beautiful. I came from the east parking lot and then got a ride back to my car, but you could definitely just park at the main campground, camp at site HD6 (or thereabouts), and then hike back the next day, as it was only about 12km from there to the main camp.
  • Algonquin Provincial Park - I've only ever carcamped here, but there's a loo
package main
import (
"bufio"
"encoding/binary"
"flag"
"fmt"
"io"
"log"
"math"
@wolever
wolever / test_tsquery_escape.py
Last active October 3, 2022 09:47
Parse and escape a query string so it's safe to use with Postgres' `to_tsquery(…)`
import re
from nose.tools import assert_equal
from nose_parameterized import parameterized
from tsquery_escape import tsquery_escape
@parameterized([
("1 OR 2", "1 | 2"),
("(1) 2", "( 1 ) & 2"),
("&", "'&':*"),
@mmchugh
mmchugh / obj_loader.py
Last active August 29, 2015 14:26
loads a wavefront .obj file and returns vertices and indices (if indices requested)
def load_obj(filename, indexed=True):
vertices = []
textures = []
normals = []
out_vertices = []
out_indices = []
vertex_map = {}
with open(filename) as obj_file:
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
@wolever
wolever / Conly.vim
Created February 3, 2015 20:50
:Conly Vim command to close all windows in the current column.
" :Co[nly] closes all other windows in the current column.
" For example, if the cursor is in the "cur" window, below, windows 1, 2, and
" 4 will be closed:
" +-------+ +-------+
" | win 1 | | |
" +-------+ | |
" | win 2 | | |
" +-------+ --> :Conly --> | cur |
" | cur | | |
" +-------+ | |
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@jpillora
jpillora / sshd.go
Last active March 28, 2025 03:25
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client: