Skip to content

Instantly share code, notes, and snippets.

View nathan-yan's full-sized avatar
🏠
Working from home

Nathan Yan nathan-yan

🏠
Working from home
View GitHub Profile
@nathan-yan
nathan-yan / cache_sim.py
Created November 29, 2021 19:08
A simple cache simulator in python
import math
import time
import enum
class WRITE_HIT(enum.Enum):
WRITE_THROUGH = 0
WRITE_BACK = 1
class WRITE_MISS(enum.Enum):
const { NONAME } = require("dns");
const constants = require("./constants");
const rrule = require("rrule");
const chrono = require("chrono-node");
const { equal } = require("assert");
const strftime = require('strftime');
const { clear } = require("console");
const strptime = require('./strptime');
//console.log_real = console.log;
/*!
* matter-js 0.17.1 by @liabru
* http://brm.io/matter-js/
* License MIT
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Matter",[],t):"object"==typeof exports?exports.Matter=t():e.Matter=t()}(this,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));retur
from os import write
from bs4 import BeautifulSoup as bs
import re
import numpy as np
shapes = ['test_ellipse', 'test_ellipse2', 'test_ellipse3']
write_to_file = "bodies = {\n"
for s in shapes:
# pip install requests
import requests as r
from requests import Session
import os
import getpass
import datetime
from numba import jit
import random
import numpy as np
import pygame
import pygame.gfxdraw
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((1000, 1000))
def didComputerWin(game):
if (game[0] == 0 and game[1] == 0):
return 1
elif (game[0] == 0 and game[1] == 1):
return -1
return 0
class GameState:
def __init__(self, game):
import os
import copy
board = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
def checkWin(board):
mul = 1
for row in range (3):
stages = [
"""
_____
|
|
|
|
|
-------------
import os
import copy
import colorama
from colorama import init
from colorama import Fore, Back, Style
init()
board = [[0, 0, 0],
[0, 0, 0],