Skip to content

Instantly share code, notes, and snippets.

View CodeDrome's full-sized avatar

Chris Webb CodeDrome

View GitHub Profile
@CodeDrome
CodeDrome / nac.py
Created August 1, 2020 11:58
nac.py
import random
from enum import Enum
class NaC(object):
class Levels(Enum):
IDIOT = 0
AVERAGE = 1
GENIUS = 2
@CodeDrome
CodeDrome / nacconsole.py
Created August 1, 2020 12:01
nacconsole.py
import curses
import nac
class NaCConsole(object):
def __init__(self):
self.screen = curses.initscr()
@CodeDrome
CodeDrome / numpymatrices.py
Created August 1, 2020 16:10
numpymatrices.py
import numpy
def main():
print("------------------")
print("| codedrome.com |")
print("| NumPy Matrices |")
print("------------------\n")
@CodeDrome
CodeDrome / matrix.py
Created August 1, 2020 16:14
matrix.py
class Matrix:
def __init__(self, entries=None, rowcount=0, columncount=0):
"""
Create a Matrix object either with the supplied values
or with the specified number of rows and columns of 0 values.
"""
if entries is not None:
@CodeDrome
CodeDrome / matrix_main.py
Created August 1, 2020 16:17
matrix_main.py
import matrix
def main():
print("----------------------")
print("| codedrome.com |")
print("| Exploring Matrices |")
print("----------------------\n")
@CodeDrome
CodeDrome / cursesdemo.py
Created August 2, 2020 11:44
cursesdemo.py
import curses
def main():
"""
The curses.wrapper function is an optional function that
encapsulates a number of lower-level setup and teardown
functions, and takes a single function to run when
the initializations have taken place.
@CodeDrome
CodeDrome / polarplots_1.py
Created August 5, 2020 15:00
polarplots.py part 1
import turtle
import math
def main():
print("--------------------")
print("| codedrome.com |")
print("| Polar Plots with |")
print("| Turtle Graphics |")
@CodeDrome
CodeDrome / polarplots_1.py
Created August 5, 2020 15:00
polarplots.py part 1
import turtle
import math
def main():
print("--------------------")
print("| codedrome.com |")
print("| Polar Plots with |")
print("| Turtle Graphics |")
@CodeDrome
CodeDrome / polarplots.py part 2
Created August 5, 2020 15:03
polarplots.py part 2
def plot(title, radius, start_degrees, end_degrees, function):
"""
Draw a polar plot with the given radius
from/to the given angles.
The plot positions are calculated by
the supplied function.
Any function can be used but it must
@CodeDrome
CodeDrome / polarplots_3.py
Created August 5, 2020 15:06
polarplots.py part 3
def cardioid_function(radians, radius):
"""
Calculate the distance from the origin
for the given angle, then calculate
its coordinates.
"""
distance = (1 + math.cos(radians)) * radius