Skip to content

Instantly share code, notes, and snippets.

View akleemans's full-sized avatar

Adrianus Kleemans akleemans

View GitHub Profile
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''Download the current Spotify Top 50 from Youtube.'''
import urllib.request
import subprocess
# fetch charts
print('Downloading charts...')
req = urllib.request.Request('https://spotifycharts.com/regional/global/weekly/latest/download', headers={'User-Agent': 'Mozilla/5.0'})
import {Component, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http";
@Component({
selector: 'app-root',
template: 'Called API and got: "{{greeting}}"'
})
export class AppComponent implements OnInit {
public greeting: string;
package ch.kleemans.demoapp;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@akleemans
akleemans / README
Last active January 15, 2020 12:31
Simple flask web server
# install flask
sudo pip3 install flask
# run script
python3 server.py
@akleemans
akleemans / dice_throw.py
Created January 13, 2018 23:06
Simulate throwing a dice and waiting until all numbers appear
''' Simple script for throwing a dice over and over until all numbers appeared at least once. '''
from __future__ import division
import random
import time
n = 10**5
r = random.SystemRandom()
def number_of_dice_throws():
count = 0
@akleemans
akleemans / route.js
Created November 9, 2016 09:31
Routing configuration for vocabulario app
angular.module('VociTrainer', ['ngRoute'])
.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$routeProvider
.when('/home', {
templateUrl: 'views/home/home.html',
controller: 'HomeCtrl',
controllerAs: 'home'
})
.when('/impressum', {
@akleemans
akleemans / example-controller.spec.js
Created November 9, 2016 06:08
Tests for example controller
describe("ExampleController", function () {
var exampleCtrl, $httpBackend, $filter;
beforeEach(module('myapp'));
beforeEach(inject(function ($controller, _$httpBackend_, _$filter_, _Users_) {
$filter = _$filter_;
$httpBackend = _$httpBackend_;
// respond with some mocked data
$httpBackend.whenGET(/...\/users/).respond([{ username: "foo", email: "foo@gmail.com" }, { username: "bar", email: "bar@aol.com" }]);
exampleCtrl = $controller('ExampleController', { Users: _Users_ });
@akleemans
akleemans / index.html
Last active November 8, 2016 13:02
An example AngularJS page with some basic angular components
<html>
<head>
<title>Example page</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-resource.min.js"></script>
</head>
<body ng-app="ExampleApp">
<div ng-controller="ExampleController as exampleCtrl">
<h2>Users</h2>
<p>Here's a list of users and their email providers.</p>
@akleemans
akleemans / server.py
Last active January 15, 2020 12:25
Simple development web in Python for serving static files
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/<path:path>')
def send_files(path):
return send_from_directory('static', path)
if __name__ == "__main__":
app.run()
import Tkinter
import tkMessageBox
total = 0
EasyBox1 = Tkinter.Tk()
EasyBox1.geometry("250x200")
EasyBox1.title("Quesion 1")
EasyBox2 = Tkinter.Tk()
EasyBox2.geometry("250x200")