This file contains hidden or 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
| def reduce(data): | |
| return functools.reduce(lambda v,head: v+head, data) | |
| # The following is even faster | |
| data = image.getdata() | |
| data = [color for pixel in data for color in pixel] |
This file contains hidden or 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
| from nose.tools import * | |
| from random import random | |
| def eval(secretNumber,guessedNumber): | |
| return cmp(guessedNumber, secretNumber) | |
| messages = { | |
| -1 : "Guess bigger!", | |
| 0 : "You won!", |
This file contains hidden or 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
| def identity(name): | |
| return name | |
| def prefix_with(parent, collisions): | |
| def prefix_if_colliding(name): | |
| if name in collisions: | |
| return '_'.join((parent, name)) | |
| return name | |
| return prefix_if_colliding | |
This file contains hidden or 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
| from nose.tools import * | |
| # UNSAUBER?! | |
| def flatten(dictionary, prefix = lambda n: n): | |
| new_dictionary = {} | |
| for key,value in dictionary.iteritems(): | |
| if isinstance(value, dict): | |
| mangle = lambda k: '_'.join((key,k)) | |
| flattened_value = flatten(value, mangle) | |
| new_dictionary.update(flattened_value) |
This file contains hidden or 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
| #coding: utf-8 | |
| reaction_times = [512,122,928,650,9999,612] | |
| def summe_berechnen(): | |
| sum = 0 | |
| for value in reaction_times: | |
| sum += value | |
| return sum | |
| def summe_berechnen_2(): |
This file contains hidden or 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 os | |
| from pathlib import Path | |
| from urllib.parse import urlparse | |
| ''' | |
| Blocks a couple of hosts by adding an entry to Windows' etc/hosts file | |
| that point to 127.0.0.1. I use this script to stop me from procrastinating. | |
| Todo: | |
| [ ] The lines-Abstraction made sense along the way but it broke. Could it |
This file contains hidden or 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 os | |
| import shutil | |
| ROOT = '.' | |
| for dirpath, dirnames, filenames in os.walk(ROOT): | |
| if dirpath == ROOT: | |
| continue | |
| for file in filenames: | |
| source = os.path.join(dirpath, file) | |
| destination = os.path.join(ROOT, file) |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Weyland Yutani UI Theme - GunMetalGray</title> | |
| <link rel="stylesheet" type="text/css" href="wy.css"> | |
| </head> | |
| <body> | |
| <h1>Hello</h1> |
This file contains hidden or 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
| # git config --global alias.<alias> <command> | |
| # https://github.com/cessor/howtolinux/blob/master/git.md | |
| # https://git-scm.com/docs/pretty-formats | |
| [alias] | |
| st = status -s | |
| addrem = add . -A | |
| summary = log --oneline | |
| sum = log --oneline | |
| tl = log --oneline --all --graph --pretty=format:'%C(yellow)%h%Creset - %C(cyan)%cr%Creset [%C(green)%an%Creset] - %Cred%d%Creset %s' --abbrev-commit --date=relative | |
| tree = !git tl |
This file contains hidden or 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
| from django.db import models | |
| class Page(models.Model): | |
| path = models.CharField(max_length=100, blank=False, primary_key=True) | |
| title = models.CharField(max_length=255, blank=False) | |
| rank = models.IntegerField(default=0) | |
| def __str__(self): | |
| return str(self.title) |