Skip to content

Instantly share code, notes, and snippets.

View Katharine's full-sized avatar

Katharine Berry Katharine

View GitHub Profile
# encoding: utf-8
from __future__ import with_statement
import LCD
import threading
import time
import re
import textwrap
class PeriodicUpdateManager(threading.Thread):
#include <string.h> //declares strcpy and strlength and strcmp
#include <stdio.h>
int CodeBook_check(char[], int, char[][6], int); /*function declaration*/
int main (int argc, char *argv[])
{
FILE * myfile;//make a file name variable
if (argv==0) //choosing between stdin and file
{
balance = float(raw_input("Enter the outstanding amount on your credit card: "))
interest_rate = float(raw_input("Enter the annual credit card interest rate as a decimal: "))
payment_rate = float(raw_input("Enter the minimum monthly payment rate as a decimal: "))
total_payment = 0
for month in xrange(1, 13): # (xrange? like range, but usually better.)
payment = round(payment_rate * balance, 2)
interest_paid = round((interest_rate / 12.0) * balance, 2)
principal_paid = payment - interest_paid
def calc_paid_off(balance, interest_rate, payment):
for month in xrange(12):
balance = round(balance * (1 + interest_rate / 12.0) - payment, 2)
return balance
initial_balance = float(raw_input("Enter the outstanding balance on your credit card: "))
interest_rate = float(raw_input("Enter the annual credit card interest rate as a decimal: "))
print "RESULT"
lower = initial_balance / 12.0
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
/**
* Decides if a point at a specific location is filled or not.
* @param x is the x coordinate of the point being checked
def cached_execution(cache, f, *args):
key = (f, args)
if key not in cache:
cache[key] = f(*args)
return cache[key]
def cached(f):
def wrapper(*args):
if args not in wrapper.cache:
wrapper.cache[args] = f(*args)
return wrapper.cache[args]
wrapper.cache = {}
return wrapper
@cached
def factorial(n):
def cached(f):
def wrapper(*args):
if args not in wrapper.cache:
wrapper.cache[args] = f(*args)
return wrapper.cache[args]
wrapper.cache = {}
return wrapper
def factorial(n):
print "Running factorial"
def get_interfaces(fname):
interfaces = []
current = []
with open(fname) as f:
for line in f:
line = line.strip()
if line == '!':
if current:
interfaces.append(current)
current = []
# Because urllib's doesn't like multibyte unicode.
def escapeurl(url):
safe = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'
output = ''
for char in url:
if char in safe:
output += char
else:
code = hex(ord(char))[2:]
while len(code) > 0: