Skip to content

Instantly share code, notes, and snippets.

View knoguchi's full-sized avatar

Kenji Noguchi knoguchi

View GitHub Profile
# Most of this was adapted from
# http://matt.might.net/articles/compiling-up-to-lambda-calculus/
# Python's lambda expressions are turing-complete. To show this, we will
# implement the "Lambda calculus" which is another way of saying "We're so manly
# we don't even NEED if statements!" The lambda calculus was invented in the
# 1930s, and it can solve any computable problem just by using anonymous
# functions that each take one argument and return one value, function
# application, and variable references. No jumps or GO TO's needed.
@pv
pv / colorized_voronoi.py
Last active June 27, 2024 22:07
Colorized Voronoi diagram with Scipy, in 2D, including infinite regions
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi
def voronoi_finite_polygons_2d(vor, radius=None):
"""
Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.
Parameters
@pteich
pteich / main.go
Last active May 30, 2024 02:57
Example for using go's sync.errgroup together with signal detection signal.NotifyContext to stop all running goroutines
package main
import (
"context"
"errors"
"fmt"
"os/signal"
"syscall"
"time"
package main
import (
"fmt"
"golang.org/x/net/context"
cc "golang.org/x/oauth2/clientcredentials"
"io/ioutil"
"net/http"
"os"
)
@den-crane
den-crane / MV_alter.txt
Last active September 7, 2021 07:40
MV alter
There are two options - implicit storages in MV (MV without TO) and explicit (table created in advance) (MV with TO).
And I have not been using MV without TO for a long time. Because it’s much more obvious and convenient to stupidly drop MV and create a new one.
# alter MV with implicit storage .inner (without TO)
1. stop ingestion
2. detach table MVX
3. alter table `.inner.MVX` add column .....
4. attach MATERIALIZED VIEW MVX as select new_SELECT_.....
@dragonsinth
dragonsinth / errgroup_withcontext.go
Created February 5, 2020 03:53
Using errgroup.WithContext() in Golang server handlers
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"sync/atomic"
"time"