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 time | |
import statistics | |
import unittest | |
from unittest import TextTestRunner | |
from django.test.runner import DiscoverRunner | |
class StopwatchTestResult(unittest.TextTestResult): | |
""" | |
Times test runs and formats the result |
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
.DEFAULT_GOAL := help | |
.PHONY: help | |
# Source (So cool, thanks): https://daniel.feldroy.com/posts/autodocumenting-makefiles | |
define HELP_TEXT | |
import re,sys; | |
tasks = [] | |
for line in sys.stdin: | |
match = re.match(r'^([a-zA-Z0-9_\.\-]+):.*?##(.*)$$', line) | |
if not match: continue | |
tasks.append("%-10s %s" % match.groups()) |
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 argparse | |
import curses | |
import string | |
import sys | |
from curses import wrapper | |
from curses.textpad import rectangle | |
from pathlib import Path | |
class HexDisplay: |
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
with open('png.png', 'rb') as file: | |
content = file.read() | |
for i in range(0 , len(content), 16): | |
# row offset | |
print(f'{i:08X}', end=' ') | |
# byte display | |
row = content[i:i + 16] |
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
class Duration(object): | |
''' | |
Calculate duration with 60 FPS (16.66 ms per frame) | |
Make it so that the duration can be compared using >=, | |
so that the NEXT Frame will actually display a stimulus. | |
Example: | |
Suppose you want to display a stimulus after 225 ms. This is technically impossible on a 60hz screen with a synchronized display because each frame takes 0.0167 seconds (16.7ms) to render, and so the stimulus can either draw for 216.7ms or 233.3ms. I discussed with the product owner (Jan Rummel) that we should opt for the earlier stimulus, because otherwise the milliseconds add up. | |
During each frame, an update is sent to the system whether the next |
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
/* | |
1. Place this file in <profile dir>/chrome/userChrome.css (about:support) | |
2. Enable `toolkit.legacyUserProfileCustomizations.stylesheets` (about:config) | |
3. Source https://amitp.blogspot.com/2021/06/firefox-89-tab-appearance.html?m=1 | |
*/ | |
.tab-background { | |
background: #585060; | |
border-radius: 5px 5px 0 0 !important; | |
margin-bottom: 0px !important; |
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 typing import Callable | |
from django.core import checks | |
from django.db import models | |
from django.utils.functional import cached_property | |
from django.utils.text import slugify | |
from django.utils.translation import gettext_lazy as _ | |
class AutoSlugField(models.SlugField): | |
""" |
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
""" | |
Mit __iter__ kann man komplexe Iterationen abstrahieren | |
- Iteratoren sind Zustandsautomaten. | |
- Dadurch lässt sich das iterieren vom prozessieren trennen. | |
- So kann man den gleichen Iterator seriell oder parallel umsetzen | |
""" | |
import json | |
import time | |
import requests | |
import multiprocessing |
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
""" | |
Reads PNG Chunk Data. | |
http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html | |
http://www.libpng.org/pub/png/spec/1.2/PNG-Compression.html | |
""" | |
import sys | |
import datetime | |
import pathlib |
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 ast | |
ast = ast.parse('a = (1 + 2)\n', filename='<string>', mode='single') | |
statement, *_ = ast.body | |
def walk(node, field='', depth=0): | |
indent = depth * ' ' | |
name = node.__class__.__name__ | |
if isinstance(node, list): |
NewerOlder