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
function currentTheme() { | |
const currentTheme = localStorage.getItem("theme") || "auto"; | |
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; | |
if (currentTheme === "auto") { | |
return prefersDark ? "dark" : "light"; | |
} | |
return currentTheme; | |
} |
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
from itertools import count, groupby | |
from typing import Iterable, Tuple | |
def group_consecutive(nums: Iterable[int]) -> Iterable[Tuple[int, ...]]: | |
counter = count() | |
for _, g_it in groupby(nums, lambda n: n - next(counter)): | |
yield tuple(g_it) | |
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
; PlatformIO Project Configuration File | |
; | |
; Build options: build flags, source filter | |
; Upload options: custom upload port, speed and extra flags | |
; Library options: dependencies, extra library storages | |
; Advanced options: extra scripting | |
; | |
; Please visit documentation for the other options and examples | |
; https://docs.platformio.org/page/projectconf.html |
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
void rot18(char *c) | |
{ | |
while (*c) | |
{ | |
if (*c >= 'A' && *c <= 'Z') | |
*c = ('A' + (*c - 'A' + 13) % 26); | |
else if (*c >= 'a' && *c <= 'z') | |
*c = ('a' + (*c - 'a' + 13) % 26); | |
else if (*c >= '0' && *c <= '9') | |
*c = ('0' + (*c - '0' + 5) % 10); |
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
#!/usr/bin/env python | |
""" | |
Fast duplicate file finder. | |
Usage: duplicates.py <folder> [<folder>...] | |
Based on https://stackoverflow.com/a/36113168/300783 | |
Modified for Python3 with some small code improvements. | |
""" | |
import os | |
import sys |
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
#!/bin/sh | |
set -e | |
PIP=pip3 | |
scriptdir=$(dirname "$0") | |
listsdir="$scriptdir/lists" | |
mkdir -p "$listsdir" | |
echo "Update all python packages..." |
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 python 2D vector class based on complex numbers | |
""" | |
import cmath | |
class Vector(complex): | |
@classmethod | |
def fromPolar(cls, r, phi): | |
return cls(cmath.rect(r, phi)) |
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 itertools | |
def lowpass(img): | |
""" | |
A simple pure python low pass (antialiasing) filter. | |
Applies a gaussian blur on a 2D list of floats. | |
""" | |
width = len(img[0]) | |
height = len(img) |
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
// -------------------------------------- | |
// i2c_scanner | |
// | |
// Version 1 | |
// This program (or code that looks like it) | |
// can be found in many places. | |
// For example on the Arduino.cc forum. | |
// The original author is not known. | |
// Version 2, Juni 2012, Using Arduino 1.0.1 | |
// Adapted to be as simple as possible by Arduino.cc user Krodal |
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 cv | |
HAAR_CASCADE_PATH = "/usr/local/Cellar/opencv/2.4.3/share/OpenCV/" \ | |
"haarcascades/haarcascade_frontalface_default.xml" | |
CAMERA_INDEX = 0 | |
def detect_faces(image): | |
faces = [] | |
detected = cv.HaarDetectObjects(image, cascade, storage, 1.2, 2, | |
cv.CV_HAAR_DO_CANNY_PRUNING, (100,100)) |
NewerOlder