Skip to content

Instantly share code, notes, and snippets.

@11Firefox11
11Firefox11 / CleverImg.astro
Last active May 12, 2023 16:00
CleverImage Astro component for my responsive images
---
import { ImageGenerator } from "ImageGenerator";
interface Props {
imgPath: string,
alt: string,
sizes: { width: number; height: number }[],
withWebp?: boolean,
loading?: "eager" | "lazy" | null,
breakpoints?: {maxWidth: number, imgWidth: number}[]
@11Firefox11
11Firefox11 / ImageCompressorIntegration.ts
Created May 12, 2023 15:17
Responsive image generation with an astro hook
import type { AstroIntegration } from "astro";
import sharp from 'sharp';
import path from 'path';
import fs from 'fs';
type imageSize = { width: number, height: number };
export default function createPlugin(): AstroIntegration {
return {
name: "ImageCompressorIntegration",
@11Firefox11
11Firefox11 / alarm_runner.py
Created April 29, 2023 09:14
Parse and run schema to create a sunrise
# This script is part of my blog post: https://tomoviktor.com/posts/pialarm-alarmrunner
CLEVER_SLEEP_SECS_SEGMENTS = 1
from numexpr import evaluate as ne_eval
from json import load
from os import environ
from time import sleep as time_sleep
from led_controller import LedController
@11Firefox11
11Firefox11 / generate_passcodes.py
Created April 28, 2023 20:25
Generate 31 passcodes
# This script is part of my blog post: https://tomoviktor.com/posts/pialarm-passcodes
PASSCODES_JSON_PATH = "passcodes.json"
from secrets import token_urlsafe as secrets_token_urlsafe
from hashlib import sha1
passcodes_file = open(PASSCODES_JSON_PATH, "w")
passcodes_file.write("[")
hashes_generated = []
for day_num in range(31):
@11Firefox11
11Firefox11 / pialarm-test.py
Created April 28, 2023 19:21
Test your RGB LED strip with the LedController
# This script is part of my blog post: https://tomoviktor.com/posts/pialarm-physical
from time import sleep
from led_controller import LedController
controller = LedController()
controller.red = 255
color_sequence = [
(255, 255, 0),
@11Firefox11
11Firefox11 / led_controller.py
Created April 28, 2023 18:24
Control an RGB LED strip on a raspberry pi
# This script is part of my blog post: https://tomoviktor.com/posts/pialarm-ledcontroller
DEV_MODE = True
RGB_PINS = {"red": 17, "green": 22, "blue": 24}
from colour import Color
if not DEV_MODE: from pigpio import pi
if DEV_MODE:
import PySimpleGUI as sg
from threading import Thread