This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from __future__ import with_statement | |
import LCD | |
import threading | |
import time | |
import re | |
import textwrap | |
class PeriodicUpdateManager(threading.Thread): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cached_execution(cache, f, *args): | |
key = (f, args) | |
if key not in cache: | |
cache[key] = f(*args) | |
return cache[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
OlderNewer