Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bufio"
"encoding/binary"
"flag"
"fmt"
"io"
"log"
"math"
@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
@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
@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;
}
@jbenet
jbenet / gist:8f000606f2009495c56177f6ca2c19b7
Last active February 13, 2023 02:29
some notes on ideas

When people come up with ideas, they often assume that:

  • coming up with an idea is the same thing as coming up with an idea first (it isn't, read existing literature)
  • coming up with an idea first is dramatically more special than coming up with an idea (it isn't)
  • the wealth of existing literature does not include their idea (almost always it does)
  • unpublished ideas do not count (they do, lots of important discoveries happen verbally, and unfortunately sometimes only verbally :( )
  • coming up with it first is more important than fleshing out a body of work (it isn't)

And these assumptions tend to make people very unhappy. I repeatedly see people succumbing to sadness over multiple discovery. It shouldn't be sad, it should be a happy event, as it confirms our thoughts and presents an opportunity for collaborations.

@jamesnvc
jamesnvc / things.sh
Created January 27, 2017 17:14
Shell script template to only act on "clean" git repos
#!/bin/bash
set -euo pipefail
set +e
if ! git diff-files --quiet --ignore-submodules ; then
echo "Uncommited changes; stash or commit before deploying"
exit 1
fi
if ! git diff-index --cached --quiet HEAD --ignore-submodules ; then
@Brainiarc7
Brainiarc7 / skylake-tuning-linux.md
Last active April 16, 2025 15:07
This gist will show you how to tune your Intel-based Skylake, Kabylake and beyond Integrated Graphics Core for performance and reliability through GuC and HuC firmware usage on Linux.

Tuning Intel Skylake and beyond for optimal performance and feature level support on Linux:

Note that on Skylake, Kabylake (and the now cancelled "Broxton") SKUs, functionality such as power saving, GPU scheduling and HDMI audio have been moved onto binary-only firmware, and as such, the GuC and the HuC blobs must be loaded at run-time to access this functionality.

Enabling GuC and HuC on Skylake and above requires a few extra parameters be passed to the kernel before boot.

Instructions provided for both Fedora and Ubuntu (including Debian):

Note that the firmware for these GPUs is often packaged by your distributor, and as such, you can confirm the firmware blob's availability by running:

@kennwhite
kennwhite / https.go
Last active December 24, 2023 22:06
Simple https http/2 static web server with HSTS & CSP (A+ SSLLabs & securityheaders.io rating) in Go using LetsEncrypt acme autocert
package main
import (
"crypto/tls"
"golang.org/x/crypto/acme/autocert"
"log"
"net"
"net/http"
)
@gaieges
gaieges / subtree.sh
Created April 5, 2017 21:57
easier way to use subtrees
#!/bin/bash
set -e
REPOS="$(cat $(dirname $0)/.subtree)"
usage() {
echo "usage: $(basename $0) <command>"
echo "commands are: "
echo " init sets up all remotes and subtrees locally"
@ErikAugust
ErikAugust / spectre.c
Last active January 5, 2025 07:01
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif