Skip to content

Instantly share code, notes, and snippets.

View osoleve's full-sized avatar
🐙

osoleve

🐙
View GitHub Profile
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
rgb_noise_mask = np.random.randint(0, 256, size=frame.shape, dtype=np.uint8)
rgb_noise_mask = cv2.resize(
cv2.resize(rgb_noise_mask, (rgb_noise_mask.shape[1] // 25, rgb_noise_mask.shape[0] // 25),),
@osoleve
osoleve / aocd6.py
Last active December 6, 2019 23:44
orbits = {y:x for x,y in [x.split(')') for x in ip.split("\n")]}
def indirect_orbits(obj, orbits):
if obj not in orbits:
return []
return [orbits[obj]] + indirect_orbits(orbits[obj], orbits)
def orbital_swaps_setbased(start, end, orbits):
from typing import List, Any, Callable
import time
import functools
import csv
def run_in_chunks_with(after_chunk: Callable, size: int) -> Callable:
"""
Function decorator. Applies to any function that
both consumes and produces a list.
@osoleve
osoleve / gist:4644547
Created January 26, 2013 20:53
Via Google Translate
(define (%shunting-yard stmt stack)
"Converts infix-notation mathematical equations into
postfix-notation mathematical equations, using an
implementation of Dijkstra's Shunting-yard Algorithm."
(cond ((null? stmt)
(stack-operations stack))
((number? (car stmt))
(cons (car stmt) (%shunting-yard (cdr stmt) stack)))
((operator? (car stmt))
(operator-actions stmt stack))
@osoleve
osoleve / Vector.hs
Created March 30, 2011 19:06
Small 3D Vector Math Library
-- file: Vectors.hs
--
-- Contains vector functions
data Vector a = Vector a a a
deriving (Show)
vecPlus3D :: (Num t) => Vector t -> Vector t -> Vector t
(Vector i j k) `vecPlus3D` (Vector l m n) = Vector (i+l) (j+m) (k+n)
@osoleve
osoleve / Sine in Scheme
Created March 18, 2011 04:44
Simple function (and helper function) to calculate Sine using Scheme
(define (factorial n)
(if (= n 0)
1
(* n (factorial (- n 1)))))
(define (sine x . n)
(cond ((not (null? n))
(cond ((< 13 (car n))
0)
(else (- (/ (expt x (car n)) (factorial (car n)))
@osoleve
osoleve / TicTacToe.lisp
Created October 30, 2010 18:53
A simple two player textual implementation of Tic Tac Toe.
;;;; tictactoe.lisp
;;;;
;;;; Andrew Levenson
;;;; 10/27/10
;;;;
;;;; Simple two player ASCII Tic Tac Toe Game
;;; First player is X, so initialize the marker to X
(setf *marker* :X)
(setf *player* "Player 1")