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
Panic: apt update && apt upgrade -y | |
SD: practically unmodified (enable uart, wifi configuration) | |
Connected Peripherals: | |
* UART via FTDI TTL-232R | |
* (using internal wifi) | |
[ 1316.502504] 8<--- cut here --- | |
[ 1316.507168] Unable to handle kernel paging request at virtual address bf8447b8 | |
[ 1316.516107] pgd = 9d6bdbd4 | |
[ 1316.520427] [bf8447b8] *pgd=00000000 |
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 Any, Iterable, Tuple | |
def partition_by_type(iterable: Iterable[Any], *args: Tuple[type], with_rest=False): | |
"""Partitions iterable by types. | |
Creates as many iterators as type tuples have been given and optionally | |
returns another iterator for all non-matching instances.""" | |
iterator = iter(iterable) | |
types_map = { | |
types: collections.deque() | |
for types in args |
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
__license__ = "MIT" | |
__copyright__ = "Copyright 2020, Konrad Mohrfeldt" | |
from functools import partial | |
from typing import Callable, Iterable, Union | |
from django.db import migrations | |
from django.db.migrations.state import StateApps | |
from django.db.models.base import ModelBase | |
from wagtail.core.blocks.stream_block import StreamValue |
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
(function (draftail) { | |
const registeredPlugins = [] | |
const initEditor = draftail.initEditor | |
draftail.registerDraftPlugin = function (plugin) { | |
registeredPlugins.push(plugin) | |
} | |
draftail.initEditor = function (selector, options, currentScript) { | |
const plugins = (options.plugins || []).concat(registeredPlugins) | |
const newOptions = Object.assign({}, options, { plugins: plugins }) |
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
#!/bin/sh | |
set -eu | |
# we only want to run this script as root | |
if [ ! "$(id -u)" = 0 ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi |
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 sys | |
from PIL import Image | |
def calculate_brightness(image): | |
greyscale_image = image.convert('L') | |
histogram = greyscale_image.histogram() | |
pixels = sum(histogram) | |
brightness = scale = len(histogram) |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
def weirdness_happens(foo = []): | |
foo.append(1) | |
return foo | |
print(weirdness_happens()) # [1] | |
print(weirdness_happens()) # [1, 1] |
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
const create_object = (obj = {}) => obj | |
console.log(create_object() === create_object()) // false |