Skip to content

Instantly share code, notes, and snippets.

View dbader's full-sized avatar

Dan Bader dbader

View GitHub Profile
@dbader
dbader / fontdemo.py
Last active August 2, 2021 12:31
For my Raspberry Pi internet radio project I needed a way to render text suitable for a low resolution monochrome LCD. This article describes how to render 1-bit text using FreeType and Python. See http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Needs freetype-py>=1.0
# For more info see:
# http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
# The MIT License (MIT)
#
# Copyright (c) 2013 Daniel Bader (http://dbader.org)
# LetterStart python script
import uno, datetime
#from datetime import date
# a UNO struct later needed to create a document
###############################################################################
def createDoc():
"""creates a new writer document and prints my name and address at the top right """

Keybase proof

I hereby claim:

  • I am dbader on github.
  • I am dbader (https://keybase.io/dbader) on keybase.
  • I have a public key whose fingerprint is 12AC D215 8A24 4231 3896 2DC4 9620 F0F0 BD62 F215

To claim this, I am signing this object:

import concurrent.futures
import functools
import operator
import time
from pprint import pprint
TEXT = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis.
Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris
from abc import ABCMeta, abstractmethod
class Base(metaclass=ABCMeta):
def __init__(self):
self.my_attrib = 42
@abstractmethod
def foo(self):
pass
@dbader
dbader / gist:3f9adca03e655b90c2b8
Created December 8, 2014 16:57
Dynamic favicons
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 16;
canvas.height = 16;
ctx.fillStyle = '#F00'; // <- Pick a colour.
ctx.fillRect(0, 0, canvas.width, canvas.height);
var favicon = document.getElementsByTagName('link')[0];
<!DOCTYPE html>
<html>
<head>
<plaintext>
</head>
<body>
<!--
@dbader
dbader / chrome-ios-minimal-testcase.html
Last active August 29, 2015 13:56
Broken on Chrome iOS: 32.0.1700.20, latest known good is Chrome iOS: 21.0.1180.82
<!DOCTYPE html>
<html>
<head>
<script>document.write('<plaintext>');</script>
</head>
<body>
<!--