Skip to content

Instantly share code, notes, and snippets.

View muety's full-sized avatar
🤓

Ferdinand Mütsch muety

🤓
View GitHub Profile
@muety
muety / zar-watcher.py
Created October 3, 2017 20:28
Watch for exam results announcement and notify via telegram-middleman-bot (run as Cronjob)
import requests
import os
url = 'http://www.zar.kit.edu/rss/feed.rss'
keywords = ['steuerrecht']
cache_file = 'cache.txt'
hook_url = 'http://middleman.ferdinand-muetsch.de/api/messages'
hook_sender_id = 'Watcher'
hook_recipient_id = ''
@muety
muety / wsgi.py
Last active November 8, 2017 09:01
Sample WSGI web server with Flask
# gunicorn --bind 0.0.0.0:8000 --workers 4 wsgi:app
# gunicorn --bind 0.0.0.0:8000 --workers 1 --threads 12 wsgi:app
import time
from flask import Flask
app = Flask(__name__)
# Requests from one client are not blocked by long-lasting requests from another client, as long as there are workers available
@app.route('/sleep')
@muety
muety / apriori.py
Last active February 14, 2018 09:36
Naive implementation of the Apriori algorithm in Python
# Naive implementation of the Apriori algorithm in Python
# Example 2 from https://en.wikipedia.org/wiki/Apriori_algorithm
data = [
{1,2,3,4},
{1,2,4},
{1,2},
{2,3,4},
{2,3},
{3,4},
@muety
muety / android_fullheight_gridview.java
Created May 22, 2018 14:03
A helper method that enables an Android GridView to be used inside a vertical ScrollView
/* Inspired by https://stackoverflow.com/a/27818661/3112139 */
public static void justifyListViewHeightBasedOnChildren (GridView listView) {
ListAdapter adapter = listView.getAdapter();
if (adapter == null) {
return;
}
ViewGroup vg = listView;
int totalHeight = 0;
for (int i = 0; i < adapter.getCount(); i++) {
@muety
muety / mlp.py
Created August 16, 2017 12:13
MNIST with Scikit Learn's Multi-Layer Perceptron
import numpy as np
from scipy.ndimage import convolve
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import fetch_mldata
from sklearn.model_selection import train_test_split, cross_val_score, GridSearchCV
from sklearn.externals import joblib
import os.path
PATH = 'mlp_model.pkl'
import scala.io.Source
object Advent {
def main(args: Array[String]): Unit = {
val data = Source.fromFile("data/day1.txt").getLines.map(_.toInt).toList
println(f"Part 1: ${data.sum}")
/* Can someone help me get this second part a littler more Scala-like (more functional, less procedural)? Please let me know! */
var seen: Set[Int] = Set()
@muety
muety / TwoSum.scala
Created March 27, 2019 08:45
LeetCode TwoSum Solution Scala
// https://leetcode.com/problems/two-sum
object TwoSum {
def apply(nums: Array[Int], target: Int): Array[Int] = {
nums.view.zipWithIndex.map(x => {
val el = nums.view.zipWithIndex.drop(x._2 + 1).collectFirst {
case y if y._1 + x._1 == target => y
}
Array(Option(x), el)
}).collectFirst {
@muety
muety / tripadvisor_scraper.py
Last active July 27, 2019 00:22
A scraper for restaurant reviews from Tripadvisor
'''
A script to scrape restaurant reviews from tripadvisor.com or tripadvisor.de using Selenium.
Author: Ferdinand Mütsch <mail@ferdinand-muetsch.de>
License: MIT
Updated: January, 09 2018
Installation:
- Install `selenium` and `pandas` using pip
- Install PhantomJS or get Chrome- or Firefox webdriver binaries and add them to your PATH (see http://selenium-python.readthedocs.io/installation.html#drivers)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.