Skip to content

Instantly share code, notes, and snippets.

miguelgrinberg / undercurl
Created July 27, 2023 23:17
Tiny script to test if the undercurl control codes work in your terminal.
View undercurl
printf 'This is \e[4:3mmono undercurl\e[0m,\n'
printf 'and this is \e[4:3m\e[58:2:206:64:51mcolor undercurl\e[0m.\n'
miguelgrinberg /
Last active October 9, 2022 22:32
JWT support for MicroPython
import binascii
import hashlib
import hmac
import json
from time import time
def _to_b64url(data):
return (
miguelgrinberg /
Last active July 17, 2023 15:15
Eventlet running on top of asyncio proof-of-concept
import asyncio
import atexit
import functools
import os
import random
import eventlet
from eventlet.greenpool import GreenPool
from eventlet.hubs import hub, use_hub, get_hub
miguelgrinberg / .tmux.conf
Last active March 15, 2022 11:39
My .tmux.conf file for working with tmux
View .tmux.conf
# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
miguelgrinberg / .vimrc
Last active May 31, 2023 23:55
My .vimrc configuration for working in Python with vim
View .vimrc
" plugins
let need_to_install_plugins = 0
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
let need_to_install_plugins = 1
call plug#begin()
Plug 'tpope/vim-sensible'
miguelgrinberg /
Created October 28, 2019 23:44
Example code from my "MicroPython Heats My Home" presentation.
DHT22_PIN = 4 # D2 pin / GPIO4
LED_PIN = 2 # D4 pin / GPIO2
WIFI_ESSID = 'your-wifi-network-name'
WIFI_PASSWORD = 'your-wifi-password'
INTERVAL = 5 * 60
miguelgrinberg /
Last active October 18, 2022 06:51
A little SQLAlchemy challenge. See blog post at for details!
#!/usr/bin/env python
# Before you run this script make sure Flask-SQLAlchemy is installed in
# your virtual environment
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' # in-memory
View .vimrc
" plugins
set nocompatible
filetype off
let need_to_install_plugins=0
if empty(system("grep lazy_load ~/.vim/bundle/vundle/autoload/vundle.vim"))
echo "Installing Vundle..."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !rm -rf ~/.vim/bundle/vundle
silent !git clone ~/.vim/bundle/vundle
#!/bin/env python
# -------------------------------------------------------------------------------
# This is a basic implementation of comments with a flat structure,
# as described in my article:
# -------------------------------------------------------------------------------
from datetime import datetime
from flask import Flask
View softcover-dockerfile
FROM phusion/baseimage:latest
MAINTAINER Nick Merwin <>
ENV HOME /root
RUN /etc/my_init.d/
CMD ["/sbin/my_init"]
# ==============================================================================
# install deps