Skip to content

Instantly share code, notes, and snippets.

View akleemans's full-sized avatar

Adrianus Kleemans akleemans

View GitHub Profile
@akleemans
akleemans / progressbar.py
Last active August 29, 2015 14:24
Simple progress bar in Python
import time
import sys
def update_progress(progress):
progress = round(progress*100, 1)
barLength = 20
block = int(round(barLength*progress/100))
text = "\rProgress: [{0}] {1}%".format( "#"*block + "-"*(barLength-block), progress)
sys.stdout.write(text)
sys.stdout.flush()
@akleemans
akleemans / panini.py
Created June 19, 2014 11:47
Simulation, how many Panini packages have to be bought to get a full album.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Simulates how many packages of Panini pictures have to be bought to get a certain amount of pictures.
@author: Adrianus Kleemans
@date: 19.06.2013
'''
import random
items = open('todo.txt', 'r').readlines()
for item in items:
item_file = open(item.strip() + '.txt', 'w')
item_file.write(item)
@akleemans
akleemans / download.py
Created May 1, 2013 20:20
Simple download of a PDF file.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Downloads a sample PDF file.
'''
import urllib2
def download(url):
print 'Starting download of', url