Skip to content

Instantly share code, notes, and snippets.

Miguel Grinberg miguelgrinberg

Block or report user

Report or block miguelgrinberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@miguelgrinberg
miguelgrinberg / config.py
Created Oct 28, 2019
Example code from my "MicroPython Heats My Home" presentation.
View config.py
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
View sqlalchemy-challenge.py
#!/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 https://github.com/gmarik/vundle ~/.vim/bundle/vundle
View basic_comments.py
#!/bin/env python
# -------------------------------------------------------------------------------
# This is a basic implementation of comments with a flat structure,
# as described in my article:
# https://blog.miguelgrinberg.com/post/implementing-user-comments-with-sqlalchemy
# -------------------------------------------------------------------------------
from datetime import datetime
from flask import Flask
View softcover-dockerfile
FROM phusion/baseimage:latest
# https://github.com/phusion/baseimage-docker
MAINTAINER Nick Merwin <nick@softcover.io>
ENV HOME /root
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
CMD ["/sbin/my_init"]
# ==============================================================================
# install deps
@miguelgrinberg
miguelgrinberg / app.py
Created Jul 13, 2017
datetimepicker-example
View app.py
from flask import Flask, render_template
from flask_bootstrap import Bootstrap
from flask_wtf import Form
from wtforms.fields import DateField
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'
Bootstrap(app)
View keybase.md

Keybase proof

I hereby claim:

  • I am miguelgrinberg on github.
  • I am miguelgrinberg (https://keybase.io/miguelgrinberg) on keybase.
  • I have a public key whose fingerprint is 2488 9E35 E9BC 5DDD D3D6 C648 EE0C 3C4C F171 F9A3

To claim this, I am signing this object:

View asyncio-async-await.py
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
View retry_simulation.py
#!/bin/python
# This simple Python script runs simulations for different retry algorithms
# The results are printed as CSV data to the console
# See this article on my blog for details:
# https://blog.miguelgrinberg.com/post/how-to-retry-with-class
from random import random, choice
View heat_3a.yaml
heat_template_version: 2013-05-23
description: Template that installs a wordpress server and supporting MySQL database running on separate servers
parameters:
image:
type: string
label: Image name or ID
description: Image to be used for server. Please use an Ubuntu based image.
default: trusty-server-cloudimg-amd64
You can’t perform that action at this time.