Skip to content

Instantly share code, notes, and snippets.

@DanielBerns
DanielBerns / pelican-tailwind-css.md
Created September 6, 2023 18:30 — forked from jorritfolmer/pelican-tailwind-css.md
Pelican with Tailwind CSS

How to use Tailwind CSS with Pelican

These steps show how to install Tailwind CSS in a Pelican project, purge and minify it so you don't have to reference a 3+ MB CSS file but only several kB.

  1. virtualenv venv
  2. . venv/bin/activate
  3. pip install nodeenv
  4. nodeenv env
  5. . env/bin/activate
  6. npm install postcss postcss-cli autoprefixer tailwindcss purgecss cssnano
@DanielBerns
DanielBerns / extract_common_substrings.py
Created July 19, 2023 18:47
Extract common substrings from two strings, with a bug
# I need to extract common substrings from two strings named red and blue,
# also with their positions in the blue string.
# So, I wrote the function extract_common_substrings from scratch.
# There is a bug in this function I can not solve.
# Look at the function main:
# If you remove the extra characters start_red, stop_red, start_blue, and stop_blue
# then the last common substrings is missing.
# However, including the extra characters you get the expected result.
# Is it possible to change the function extract_common_substrings in such a way that
# the extra characters are not needed?
@DanielBerns
DanielBerns / write_frames_with_threads.py
Last active June 4, 2020 01:00
Demo threading.Thread with opencv: grabbing frames from a camera and saving to disk
from threading import Thread
from pathlib import Path
from queue import Queue
import time
import cv2
class Source:
def __init__(self, name, stream):
self._stream = stream
@DanielBerns
DanielBerns / blockchain.ipynb
Created December 12, 2019 12:23
Blockchain.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DanielBerns
DanielBerns / tf_mnist.py
Created September 21, 2017 18:47
Problem with this program (MNIST with Tensorflow)
"""
Neural MNIST with tensorflow
"""
# Extracted from
# https://medium.com/@awjuliani/visualizing-neural-network-layer-activation-tensorflow-tutorial-d45f8bf7bbc4
# import the libraries
import numpy as np
import matplotlib as mp
import matplotlib.pyplot as plt
@DanielBerns
DanielBerns / process_video_v2.py
Created October 8, 2015 16:04
Out of memory error
import cv2
import numpy as np
import argparse # https://docs.python.org/2/howto/argparse.html
import gc # https://docs.python.org/2/library/gc.html
# We process color images
CHANNELS = 3
import cv2
import numpy as np
import argparse # https://docs.python.org/2/howto/argparse.html
# We process color images
CHANNELS = 3
# Normalization constant
MAX_IMAGE = 256.0
class Operator(object):