Skip to content

Instantly share code, notes, and snippets.

@jchysk
jchysk / RSA key format conversions
Created November 23, 2013 03:35
RSA key format conversions
def pub_to_e_n(key):
"""
Converts a .pub public key to an exponent and n value
:param key: String. Public key
:return: e as Int
:return: n as Long
"""
import base64
import struct
@jchysk
jchysk / Javascript CSS Loader
Created November 23, 2013 03:33
Javascript CSS Loader
/**
* Framework independent function to load CSS
* @param path To the CSS file
* @returns {HTMLElement}
*/
function loadStyleSheet(path) {
var head = document.getElementsByTagName( 'head' )[0], // reference to document.head for appending/ removing link nodes
link = document.createElement( 'link' ); // create the link node
link.setAttribute( 'id', 'cssLKLoad'); // set ID to check if already loaded
link.setAttribute( 'href', path );
@jchysk
jchysk / shuffler.py
Created October 19, 2013 04:19
Simulate the shuffling of cards
SUITS = ["clubs", "diamonds", "hearts", "spades"]
class Card(object):
one_to_fifty_two = None
number = None
suit = None
positions = None
def __init__(self, number, suit, value):