This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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.