Skip to content

Instantly share code, notes, and snippets.

@behrtam
behrtam / app.py
Created August 19, 2017 09:43
Flask Injecting Request Information – still uses old format
import logging
from flask import Flask, request
from flask.logging import default_handler
class RequestFormatter(logging.Formatter):
def format(self, record):
record.url = request.url
record.remote_addr = request.remote_addr
object Challenges {
def mergeStrings(a: String, b: String): String = {
a.zipAll(b, "", "") map { case (m, n) => m.toString + n } mkString
}
def mergeStringsRec(a: String, b: String): String = {
def loop(first: List[Char], second: List[Char]): String =
(first, second) match {
case (x :: xs, y :: ys) => x.toString + y + loop(xs, ys)
case (f, Nil) => f mkString

Micro Survey 1/2017

Multiple times when working on the Python track, I thought it would be good to know certain things about the users. The last one was about how people actually run our tests. Do they use stock Python or do they install something else ...

So, I created a short 2-5 min survey with surveyplanet.com and posted the link on some exercise submissions in the Python track. I selected the allergies exercise which is number 15 in this track and all submissions from the last 6 months (~ 150).

My expectations about the turnout where not that high because for people to actually participate, they would need to visit the exercism.io site in the last week, discover my comment and than do the survey. ... but I received 35 response!

Note I: The questions where in a different order in the survey. I asked about Python stuff first and later about the demographic/background stuff (bonus – nice but not so relevant to me).

@behrtam
behrtam / ber_kultur.md
Last active April 18, 2017 09:01
Kultur in Berlin vom 14. – 16.04.

AUSSTELLUNGEN

VERLOREN IN BERLIN UND BUKAREST

eine Ausstellung über das Leben jugendlicher auf der Strasse

WANN: 16. März bis 21. Mai 2017, Dienstag bis Sonntag 12 bis 18 Uhr WO: Willy-Brandt-Haus WIE VIEL: Der Eintritt ist frei.

  • mehr
const md5 = require('md5')
let door_id = 'ugkcyxxp'
let password = '--------'.split``
let index = 0
let found = 0
while (found < 8) {
let hash = md5(`${door_id}${index}`)
@behrtam
behrtam / tuple_add_bench.py
Created November 26, 2015 07:53
Let's find out what's the fastest way to add tuple. http://exercism.io/submissions/a508c287053f48cbb9e3754ebcf3346c
'''
Test performance of tuple adding on Macbook Air 2012:
unpacking : 1,598 min | 2,136 max | 1,787 avg (µs)
index : 2,622 min | 5,016 max | 3,402 avg (µs)
map add : 7,849 min | 10,670 max | 8,886 avg (µs)
map sum zip : 11,254 min | 16,354 max | 12,854 avg (µs)
'''
import timeit
def show_result(func, result):
@behrtam
behrtam / asserttest.py
Created November 25, 2015 22:12
"This method is used by default when comparing strings with assertEqual()." https://docs.python.org/2/library/unittest.html?highlight=unittest#unittest.TestCase.assertMultiLineEqual
import unittest
class AssertTests(unittest.TestCase):
def testAssertEqual(self):
self.assertEqual('ABCD', 'ABC')
def testAssertMultiLineEqual(self):
self.assertMultiLineEqual('ABCD', 'ABC')
if __name__ == '__main__':
@behrtam
behrtam / caseless_assertions.py
Created November 21, 2015 10:23
Add support for caseless assertions that also work with unicode through mixin.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import unittest
import unicodedata
''' There is text for which text.lower() != text.upper().lower(), such as "ß":
"ß".lower()
#>>> 'ß'
#!/bin/sh
BVG_CLI_CLIENT_URL="https://raw.githubusercontent.com/behrtam/bvg-cli/master/bvg_cli.py"
BVG_CLI_REQUIREMENTS_URL="https://raw.githubusercontent.com/behrtam/bvg-cli/master/requirements.txt"
echo "BVG CLI – Installation"
cd /usr/local/bin/
rm bvg_cli.py