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 <stdint.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <windows.h> | |
#pragma comment( lib, "user32.lib" ) | |
#pragma comment( lib, "gdi32.lib" ) | |
#define SCRW 640 | |
#define SCRH 480 |
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 cv2 | |
import numpy as np | |
import itertools as it | |
import tkinter as tk | |
from tkinter import ttk, font as tkfont | |
from typing import List, Dict, Any | |
import functools as ft | |
import time | |
def image_to_ascii(img: np.ndarray, width: int, height: int, ramp: str) -> str: |
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 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),), |
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
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): |
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 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. |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Jul 12 20:34:48 2019 | |
Code adapted from http://stackoverflow.com/q/55250990 | |
""" | |
import csv | |
from typing import List, Tuple | |
from timeit import default_timer as time |
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
(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)) |
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
-- 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) |
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
(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))) |
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
;;;; 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") |