Skip to content

Instantly share code, notes, and snippets.

View muety's full-sized avatar
🤓

Ferdinand Mütsch muety

🤓
View GitHub Profile
@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)
@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 / 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 = ''
# Inspired by https://keon.io/deep-q-learning/
import random
import gym
import math
import numpy as np
from collections import deque
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
import time
import multiprocessing
import numpy as np
from sklearn.model_selection import ParameterGrid
import qcartpole
N_RUNS = 10
grid_params = {
# Inspired by https://medium.com/@tuzzer/cart-pole-balancing-with-q-learning-b54c6068d947
import gym
import numpy as np
import math
from collections import deque
class QCartPoleSolver():
def __init__(self, buckets=(1, 1, 6, 12,), n_episodes=1000, n_win_ticks=195, min_alpha=0.1, min_epsilon=0.1, gamma=1.0, ada_divisor=25, max_env_steps=None, quiet=False, monitor=False):
self.buckets = buckets # down-scaling feature space to discrete range
@muety
muety / simple_nn.go
Last active August 24, 2017 12:30
Simple Neural Network in Go
/* Simple neural net with one hidden layer consisting of one neuron */
/* Inspired by https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1 */
package main
import (
"fmt"
"math/rand"
"math"
)
@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'
@muety
muety / chan_example.go
Created May 16, 2017 19:07
Example for channels, inspired by vansimke's YouTube tutorial
// https://play.golang.org/p/Y8eaSkYNgG
package main
import (
"fmt"
)
const (
logDebug = "DEBUG"
@muety
muety / largest_prime_factor.go
Last active April 26, 2017 19:23
Delta Karlsruhe Gewinnspiel
package main
import (
"fmt"
"time"
)
func main() {
N := int64(751395478255)
n := N