Skip to content

Instantly share code, notes, and snippets.

View akleemans's full-sized avatar

Adrianus Kleemans akleemans

View GitHub Profile
@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
items = open('todo.txt', 'r').readlines()
for item in items:
item_file = open(item.strip() + '.txt', 'w')
item_file.write(item)
@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
@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()
CREATE DATABASE todolist;
USE todolist;
CREATE TABLE user (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30),
lastname VARCHAR(30)
);
package tasks;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Task {
private int id;
private String description;
private int urgency;
private String user_name;
package tasks;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.naming.Context;
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/todolist" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/todolist"
username="todolist_user" password="J4k-pa3$?%-u" />
<ResourceLink name="jdbc/todolist" global="jdbc/todolist" type="javax.sql.DataSource" />
</Context>
@akleemans
akleemans / web.xml
Last active February 11, 2016 08:28
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>Todolist</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
@akleemans
akleemans / pom.xml
Last active February 11, 2016 10:55
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Todolist</groupId>
<artifactId>Todolist</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>