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
#!/usr/bin/python3 | |
# This is a sample bit of code that shows how to draw arbitrary axis-aligned | |
# boxes in 3D space. | |
# based on: https://gist.github.com/binarycrusader/5823716a1da5f0273504 | |
import ctypes | |
import numpy as np | |
import time | |
from OpenGL import GL, GLU, GLUT | |
from OpenGL.GL import shaders |
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
#!/usr/bin/python3 | |
class TicTacToeGame(): | |
def __init__(self): | |
# Our game state is defined by a list of 3 lists, each containing 3 | |
# characters, which can be either ' ' (blank), an 'X', or an 'O'. | |
self.state = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']] | |
self.next_turn_player = 'X' | |
def do_move(self, index): |
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
#!/usr/bin/python | |
# RAID/Distributed FS calculator | |
# Some notes on designing a distributed FS cluster: | |
# - The total space on each machine (each OSD) should be nearly equal. | |
# - Larger drives for the same space means more redundancy but also slower | |
# rebuild times. | |
# - Entire RAID arrays are allowed to fail if the replication policy is > 1. | |
# Just don't let multiple RAID arrays fail at once. |
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
#!/usr/bin/python | |
import numpy as np | |
# Schulze Condorcet voting method: | |
# http://en.wikipedia.org/wiki/Schulze_method | |
def schulze(votes): | |
"""Input: An array of votes. In each row are the candidates' rankings. The | |
index of each entry in the row corresponds to a single candidate. | |
Only the relative rankings of candidates matter. | |
Lower numbers are better.""" |