Skip to content

Instantly share code, notes, and snippets.

@KaiSmith
KaiSmith / Arduino counter
Last active December 24, 2015 14:59
Uses a buttons set a value and then decrement it on two multiplexed seven segment displays.
byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 }, // = 0
{ 1,0,0,1,1,1,1 }, // = 1
{ 0,0,1,0,0,1,0 }, // = 2
{ 0,0,0,0,1,1,0 }, // = 3
{ 1,0,0,1,1,0,0 }, // = 4
{ 0,1,0,0,1,0,0 }, // = 5
{ 0,1,0,0,0,0,0 }, // = 6
{ 0,0,0,1,1,1,1 }, // = 7
{ 0,0,0,0,0,0,0 }, // = 8
{ 0,0,0,1,1,0,0 } // = 9
@KaiSmith
KaiSmith / crypto.py
Last active December 19, 2015 02:59
Python implementation of RSA (also uses Huffman compression and the Miller-Rabin test for primality).
import random, operator
class Person:
def __init__(self):
#From my testing so far, using primes in the range of 10e200 takes about 2 seconds for 2 people and 10e300 takes about 5 seconds.
self.p1 = random_prime(10e200,10e201)
self.p2 = random_prime(10e200,10e201)
self.n = self.p1 * self.p2
self.phi = (self.p1-1)*(self.p2-1)
self.e = random_prime(10, 100)
@KaiSmith
KaiSmith / fbnotify.sh
Created August 22, 2012 06:30
Creates a notification bubble when you receive a Facebook message.
#!/usr/bin/bash
#Dependencies: fbcmd
#Only tested for version 1.x
#Make sure to create file ~/Documents/LatestMessage.txt first
#Very useful to set as a program to run on startup
#!/usr/bin/bash
while true; do