Skip to content

Instantly share code, notes, and snippets.

View eliheuer's full-sized avatar

Eli Heuer eliheuer

View GitHub Profile
# modified from https://gist.github.com/simoncozens/699aa96e98321e19a0a2cccbce994c47
# python3 activity.py DDMMYY DDMMYY
import sys
import requests
from dateutil.parser import parse
from dateutil.relativedelta import relativedelta, FR
from datetime import datetime
import os
@m4rc1e
m4rc1e / metrics_compatible.py
Created April 14, 2023 10:08
Check whether two fonts are metrics compatible by testing on random strings
import random
import string
import uharfbuzz as hb
import sys
from fontTools.ttLib import TTFont
def generate_random_string(fp):
f = TTFont(fp)
cmap = f.getBestCmap()
length = random.randint(3, 100)
@arrowtype
arrowtype / draw-glyph-outline.drawbot.glyphsapp.py
Last active March 29, 2024 16:51
For DrawBot in GlyphsApp: Draw a glyph's outlines & nodes, for presentation / social media purposes
"""
Script to create an image of a glyph in the current layer.
Instructions:
- Use within the Drawbot plugin of GlyphsApp.
- Get this plugin via Window > Plugin Manager, then search for "Drawbot" and install it.
- Then, go to File > New Drawbot, and paste in this code and run it.
- You may need to restart glyphs for the Plugin to work.
let widget = await createWidget()
if (config.runsInWidget) {
Script.setWidget(widget)
} else {
widget.presentMedium()
}
Script.complete()
@justinpenner
justinpenner / clearglyphs.py
Created February 28, 2022 19:21
Remove glyph outlines from a font while preserving everything else (advance widths, OT features)
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._g_l_y_f import Glyph
f = TTFont('Font.ttf')
assert 'glyf' in f and 'gvar' not in f, 'Must be a static font with a `glyf` table.'
for name in f['glyf'].keys():
if not f['glyf'][name].isComposite():
f['glyf'][name] = Glyph()
f.save('Font-Regular-Blank.ttf')
@simoncozens
simoncozens / gh-timesheet.py
Created February 8, 2022 07:28
gh-timesheet.py
import requests
from dateutil.relativedelta import relativedelta, FR
from datetime import datetime
lastweek = datetime.utcnow().replace(hour=0,microsecond=0) + relativedelta(weekday=FR(-1))
headers = {"Authorization": "bearer "+GITHUB_TOKEN}
def run_query(query):
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
@justvanrossum
justvanrossum / bezier_drawbot.py
Last active April 10, 2023 11:09
Bezier demo for DrawBot
# See this Twitter thread:
# https://twitter.com/MauriceMeilleur/status/1488347208709718021
def lerp(v1, v2, t):
return v1 + t * (v2 - v1)
def lerpPoint(p1, p2, t):
return lerp(p1[0], p2[0], t), lerp(p1[1], p2[1], t)
@simoncozens
simoncozens / hands-face-space.ipynb
Last active February 15, 2023 00:39
Hands, Face, Space
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steveruizok
steveruizok / getPerfectDashProps.ts
Last active February 19, 2024 00:38
Get balanced stroke dash array and stroke dash offset for an ellipse.
/**
* Get balanced dash-strokearray and dash-strokeoffset properties for a path of a given length.
* @param length The length of the path.
* @param strokeWidth The shape's stroke-width property.
* @param style The stroke's style: "dashed" or "dotted" (default "dashed").
* @param snap An interval for dashes (e.g. 4 will produce arrays with 4, 8, 16, etc dashes).
*/
export function getPerfectDashProps(
length: number,
@arrowtype
arrowtype / abc-grid-flipped.drawbot.py
Created March 26, 2021 02:10
Make a cool reflected alphabet pattern in Drawbot.
"""
Make a cool reflected alphabet pattern.
Inspired by Klaus Burkhardt and Reinhard Döhl, Rot 40:
Poem Structures In the Looking Glass, Edition Rot, Stuttgart, 1969.
https://twitter.com/Lett_Arc/status/1375252819620466688
"""
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"