Skip to content

Instantly share code, notes, and snippets.

View maxcountryman's full-sized avatar
🦀

Max Countryman maxcountryman

🦀
View GitHub Profile
@maxcountryman
maxcountryman / terminal.py
Created January 15, 2012 02:02
A "point of price" terminal simulator (expects Python 2.7.x)
'''
terminal
--------
A simple checkout simulator.
'''
class Terminal(object):
'''A "point of sale" terminal object.'''
@maxcountryman
maxcountryman / bf.c
Created January 29, 2012 17:20
A simple brainfuck interpreter in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// initialize the tape with 30,000 zeroes
unsigned char tape[30000] = {0};
// set the pointer to point at the left-most cell of the tape
unsigned char* ptr = tape;
@maxcountryman
maxcountryman / bf_redux.c
Created February 1, 2012 01:13
A brainfuck interpreter in C with dynamic memory allocation
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char* add_cell(char* tape, size_t *tape_size) {
char* tmp = (char*)realloc(tape, (++*tape_size) * sizeof(char));
if (tmp == NULL) {
printf("FATAL: Could not reallocate tape memory!");
@maxcountryman
maxcountryman / markov.py
Created March 10, 2012 15:47
Markov Chain bot utilizing IrcTK
mport re
import os
import random
from irctk import Bot
_DEFAULT_CHAIN_LEN = 2
_DEFAULT_WORD_RANGE = 26
PUNCTUATION = '.\?|.!|.\.'
TALKATIVE = 0.3
@maxcountryman
maxcountryman / weasel.clj
Created March 18, 2012 13:11
Weasel in Clojure
;; weasel
(def TARGET "ME THINKS IT IS LIKE A WEASEL")
(def ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZ ")
(def RATE 0.05)
(def rand-seed
"Generate a random seed as long as the target."
(take (count TARGET) (repeatedly #(rand-nth ALPHABET))))
diff --git a/test_classy/test_blueprints.py b/test_classy/test_blueprints.py
index 6ea0284..71f079c 100644
--- a/test_classy/test_blueprints.py
+++ b/test_classy/test_blueprints.py
@@ -65,8 +65,10 @@ def test_bp_custom_http_method():
resp = client.post("/basic/route3/")
eq_("Custom HTTP Method", resp.data)
+def test_bp_url_prefix():
+ foo = Blueprint('foo', __name__)
@maxcountryman
maxcountryman / request.py
Created February 12, 2013 21:00
Forthcoming Requests v1.x support in Rauth.
# -*- coding: utf-8 -*-
'''
rauth.request
-------------
Provides a wrapper around the requests.Request object for OAuth and Ofly
parameter injection.
'''
import time
def request(self,
method,
uri,
access_token=None,
access_token_secret=None,
header_auth=False,
allow_redirects=False,
**kwargs):
'''Makes a proper OAuth 1.0/a request.
@maxcountryman
maxcountryman / test_service.py
Created February 21, 2013 15:41
Improved test suite for rauth.service.
# -*- coding: utf-8 -*-
'''
rauth.test_service
------------------
Test suite for rauth.service.
'''
from base import RauthTestCase
@maxcountryman
maxcountryman / oo.py
Created February 22, 2013 02:22
A snippet from the rauth 0.5.0 test_service test suite.
class OflyServiceTestCase(RauthTestCase, HttpMixin):
app_id = '000'
def setUp(self):
RauthTestCase.setUp(self)
self.authorize_url = 'http://example.com/authorize'
self.base_url = 'http://example.com/api/'
self.service = OflyService('000',