Skip to content

Instantly share code, notes, and snippets.

View Broderick-Westrope's full-sized avatar
🍝
eating spaghetti code

Broderick Westrope Broderick-Westrope

🍝
eating spaghetti code
View GitHub Profile
@tylerl
tylerl / rsa.py
Created September 24, 2011 08:27
RSA Explained in Python
#!/usr/bin/env python
# This example demonstrates RSA public-key cryptography in an
# easy-to-follow manner. It works on integers alone, and uses much smaller numbers
# for the sake of clarity.
#####################################################################
# First we pick our primes. These will determine our keys.
#####################################################################
@mjhea0
mjhea0 / python_blackjack.py
Last active February 5, 2025 14:32
python blackjack
import os
import random
deck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]*4
def deal(deck):
hand = []
for i in range(2):
random.shuffle(deck)
card = deck.pop()
@brazilnut2000
brazilnut2000 / gitignore template.txt
Last active July 21, 2025 03:08
GIT: gitignore template for c# development
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
@goldsborough
goldsborough / sm.cpp
Created January 20, 2015 22:01
Square-and-multiply algorithm for efficient exponentiation
long squareAndMultiply(long base, unsigned short power)
{
// x^0 = 1
if (! power) return 1;
// x^1 = x
if (power == 1) return base;
// if power is odd
if (power % 2)
@cowdinosaur
cowdinosaur / monoalphabetic.py
Last active August 8, 2022 10:45
Monoalphabetic Cipher
# Simple Substitution Cipher
# http://inventwithpython.com/hacking (BSD Licensed)
import sys, random
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def main():
myMessage = 'When you do the common things in life in an uncommon way, you will command the attention of the world'
myKey = 'QWERTYUIOPASDFGHJKLZXCVBNM'
@geocachecs
geocachecs / chess.cpp
Created October 22, 2015 21:53
2 Player Chess Game C++
#include "chess.h"
Square::Square()
{
piece = EMPTY;
color = NONE;
}
void Square::setSpace(Square* space)
@MikeMKH
MikeMKH / setup.cs
Last active March 25, 2024 08:33
How to live with a circular reference with AutoFixture
[TestInitialize]
public void BeforeEach()
{
_fixture = new Fixture();
// client has a circular reference from AutoFixture point of view
_fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
}
// ==UserScript==
// @name EmuParadise Download Workaround - 1.1.1
// @version 1.1.2
// @description Replaces the download button link with a working one
// @author Eptun
// @match https://www.emuparadise.me/*/*/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant none
// ==/UserScript==
@EppuHeilimo
EppuHeilimo / hill.py
Last active October 9, 2022 09:09
Hill cipher in python
import numpy as np
def encrypt(msg):
# Replace spaces with nothing
msg = msg.replace(" ", "")
# Ask for keyword and get encryption matrix
C = make_key()
# Append zero if the messsage isn't divisble by 2
len_check = len(msg) % 2 == 0
@qpwo
qpwo / monte_carlo_tree_search.py
Last active July 13, 2025 13:10
Monte Carlo tree search (MCTS) minimal implementation in Python 3, with a tic-tac-toe example gameplay
"""
A minimal implementation of Monte Carlo tree search (MCTS) in Python 3
Luke Harold Miles, July 2019, Public Domain Dedication
See also https://en.wikipedia.org/wiki/Monte_Carlo_tree_search
https://gist.github.com/qpwo/c538c6f73727e254fdc7fab81024f6e1
"""
from abc import ABC, abstractmethod
from collections import defaultdict
import math