Skip to content

Instantly share code, notes, and snippets.

@exallium
exallium / millerrabin.py
Created May 26, 2011 02:01
Modular Exponential and Miller Rabin Algorithms
# Please note, this is not my work, but the work of a fellow redditer.
# I am simply placing it here for future use.
def MillerRabin(n,k=5):
'''
Performs the Miller-Rabin primality test on n to an error bound of 4^-k
(i.e. performs the test k times). True indicates a probable prime while a
false result indicates a definite composite number.
Inputs:
n - Number to be tested for primality
@exallium
exallium / slider.html
Created June 2, 2011 11:36
Opacity Slider in HTML5/CSS3/JQuery
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#range').change(function() {
$('#page_contents').attr('style', 'opacity:' + $('#range').attr('value')/100);
});
});
</script>
<input id="range" type="range" max='100' min='0' value='100' />
@exallium
exallium / coffee.json
Created June 17, 2011 15:25 — forked from minichate/coffee.json
Timmys Run
{
"Christopher Troup": {
"1x": "Large Double-Double",
"1x": "24 Timbits"
}
}
@exallium
exallium / coffee.json
Created June 17, 2011 15:25 — forked from minichate/coffee.json
Timmys Run
{
"Christopher Troup": {
"1x": "Large Double-Double",
"1x": "24 Timbits"
},
"Alex Hart": {
Drink: {
"type": "Coffee",
"size": "XL",
@exallium
exallium / xor.py
Created June 20, 2011 02:35
XOR Cipher in Python
INFILE="input.txt"
OUTFILE="output.txt"
key = "asdf"
fin = open(INFILE, "rb")
x = fin.read()
l = len(x)
key = key * (l/len(key))
o = ""
@exallium
exallium / hello.cpp
Created July 23, 2011 23:56
Simple C++0x Thread example
// Author: Alex Hart
// Compiling: g++ -o hello hello.cpp -lpthread --std=c++0x
#include<iostream>
#include<thread>
#include<cstdlib>
using namespace std;
mutex a;
@exallium
exallium / .vimrc
Created July 24, 2011 23:02
My Current .vimrc and .zshrc
filetype plugin on
filetype plugin indent on
syntax on
set t_Co=256
set bg=dark
colorscheme solarized
set backspace=indent,eol,start
@exallium
exallium / Makefile
Created July 30, 2011 18:32
Generalized Makefile for basically any C/C++ project
CC=
CFLAGS=
LDFLAGS=
SOURCE=
OBJECTS=$(SOURCE:.cpp=.o)
TARGET=
all: $(SOURCE) $(TARGET)
$(TARGET): $(OBJECTS)
@exallium
exallium / itself.py
Created September 16, 2011 15:31
Make any function recursive!
def itself():
return 4
@exallium
exallium / index.html
Created January 5, 2012 19:18
Tab Layout in HTML/CSS/Javascript
<head>
<link rel="stylesheet" type="css" href="css/tab.css" />
<script src="js/tab.js" type="text/javascript"></script>
</head>
<body>
<div class="tab-wrapper">
<div class="tab-button-wrapper">
<ul>
<li><a class="tab-button-first"
id="tab-button1"