Skip to content

Instantly share code, notes, and snippets.

View mikeckennedy's full-sized avatar

Michael Kennedy mikeckennedy

View GitHub Profile
@mikeckennedy
mikeckennedy / server-hot-reload.js
Last active August 20, 2023 18:55
Server-side hot reload checker by Michael Kennedy. When the contents of the page change in any way, the page will be reloaded.
// *************************************************************************
// server-hot-reload.js v1.0.5
//
// Server-side hot reload check by Michael Kennedy (https://mkennedy.codes).
// Released under the MIT open source license, 2023.
//
// When the contents of the page change in any way, the page will be reloaded.
//
// Usage:
//
import datetime
import sys
from typing import Optional
import colorama
import pyramid.config
from loguru import logger
from pyramid.request import Request
from pyramid.response import Response
@mikeckennedy
mikeckennedy / asset_bundler_watcher.py
Last active October 15, 2024 18:07
Example of livereload in python: Creates a file watcher that runs `python build_assets.py`, a utility based on webassets package whenever a css or js file is edited. It bundles a bunch of our CSS files into a single minified one and does the same for our JS files.
from pathlib import Path
# Creates a file watcher that runs `python build_assets.py`, a utility based on
# webassets package whenever a css or js file is edited. It bundles a bunch of
# our CSS files into a single minified one and does the same for our JS files.
def main():
# Only import this if we run it, don't let the webframework try to pull it in prod.
import livereload.server