This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Save all gists from GitHub, including comments. | |
Requires the PyGithub library (``pip install PyGithub>=1.47``). | |
Pass a personal access token with the scope "gist" as the first | |
argument. | |
This probably won't work for large files (+10MiB), since they aren't | |
returned by the GitHub API, and must be cloned instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6sbix.html | |
# requires fonttools lib (`pip install fonttools>=4.7.0`) | |
import sys | |
from fontTools.ttLib import TTFont | |
font = TTFont(sys.argv[1]) | |
sbix = font["sbix"] | |
max_ppem = max(sbix.strikes.keys()) | |
strike = sbix.strikes[max_ppem] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multipass: true | |
plugins: | |
- removeDoctype | |
- removeXMLProcInst | |
- removeComments | |
- removeMetadata | |
- removeXMLNS | |
- removeEditorsNSData | |
- cleanupAttrs | |
- minifyStyles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
create_commit() { | |
git checkout "$1" | |
echo "$2" > src.txt | |
git commit -am "$2" | |
git log --graph --pretty=format:'%s %C(yellow)%d%Creset' | |
sleep 2 # make the commits distinctive in time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function, unicode_literals | |
import boto3 | |
def clean_old_lambda_versions(): | |
client = boto3.client('lambda') | |
functions = client.list_functions()['Functions'] | |
for function in functions: | |
versions = client.list_versions_by_function(FunctionName=function['FunctionArn'])['Versions'] | |
for version in versions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import print_function, unicode_literals | |
from itertools import product | |
import sys | |
try: | |
encoding = sys.argv[1] | |
except IndexError: | |
encoding = 'utf-8' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
with open('test.csv', 'w', encoding='utf-8-sig', newline='') as fp: | |
writer = csv.writer(fp) | |
writer.writerow(['Row', 'Emoji']) | |
for i, emoji in enumerate(['🎅', '🤔', '😎']): | |
writer.writerow([str(i), emoji]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from backports import csv | |
from io import open | |
with open('test.csv', 'w', encoding='utf-8-sig', newline='') as fp: | |
writer = csv.writer(fp) | |
writer.writerow(['Row', 'Emoji']) | |
for i, emoji in enumerate(['🎅', '🤔', '😎']): | |
writer.writerow([str(i), emoji]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import BytesIO | |
import gzip | |
import shutil | |
def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'): | |
"""Compress and upload the contents from fp to S3. | |
If compressed_fp is None, the compression is performed in memory. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xeuo pipefail | |
IFS=$'\n\t' | |
PREFIX="${1:-/usr/local/dvisvgm}" | |
TEX="$(kpsewhich -var SELFAUTOLOC)" | |
echo "$PREFIX, $TEX" | |
brew install automake freetype ghostscript potrace |
NewerOlder