This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_SSD1306.h> | |
#include <Adafruit_GFX.h> | |
#define OLED_ADDR 0x3C | |
#define SCREEN_WIDTH 128 // OLED display width, in pixels | |
#define SCREEN_HEIGHT 64 // OLED display height, in pixels | |
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) | |
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // -1 = no reset pin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read line; do | |
echo $(date "$@") - $line | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def memo(f): | |
cache = {} | |
def wrapper(*a): | |
try: | |
return cache[a] | |
except KeyError: | |
r = cache[a] = f(*a) | |
return r | |
return wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomRange(start, end) { | |
return start + (end - start) * Math.random(); | |
} | |
function spreadAround(centre, spread) { | |
return randomRange(centre - spread, centre + spread); | |
} | |
function setup() { | |
createCanvas(400, 400); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import random | |
from p5 import * | |
def setup(): | |
no_loop() | |
size(300, 300) | |
no_stroke() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StaticTypes(type): | |
def __new__(mcl, name, bases, namespace): | |
return dict((k, v) for (k, (v, _type)) in namespace.dict.items()) | |
def __prepare__(name, bases): | |
class Proxy: | |
def __init__(self): | |
self.dict = dict() | |
def __setitem__(self, key, value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
@dataclass | |
class Pos: | |
x: int | |
y: int | |
def __add__(self, other): | |
return Pos(self.x + other.x, self.y + other.y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkedList(type): | |
def __repr__(self): | |
return "(" + ' '.join(self.to_list()) + ")" | |
def to_list(self): | |
result = [] | |
ptr = self | |
while ptr is not nil: | |
result.append(car(ptr)) | |
ptr = cdr(ptr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import math | |
import turtle | |
# An entire polygon. | |
def line(length, depth=0, sides=3): | |
if depth >= 1: | |
line(length / 3, depth-1, sides - 1) | |
turtle.right(180 - 360 / sides) | |
for _ in range(sides - 1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
if [ "$#" -eq 0 ]; then | |
ARGS="$(fzf)" | |
elif [ "$1" == "-t" ]; then | |
ARGS="$*"; |
NewerOlder