Skip to content

Instantly share code, notes, and snippets.

View matthewpoer's full-sized avatar

Matthew Poer matthewpoer

View GitHub Profile

Using Weasyprint with AWS Lambda on Python 3.8

A tedious because Lambda's Python 3.8 runtime does not include all of the typical build tools to generate Weasyprint's dependencies.

Also included here are steps to generate fonts, because Lambda doesn't have any and while it is interesting to look at a fully formatted document where all of the characters are .notdef glyphs, it's more productive to be able to read your pretty new PDF file.

The files in this gist are "flat" because gist does not allow us to show directories, so note the following dir structure:

@matthewpoer
matthewpoer / counting.py
Created April 23, 2021 13:57
Progress counting tracking python
import time
some_list = [1,2,3,4,5,6]
counter = 0
for file in some_list:
counter += 1
percent = round((counter/len(some_list))*100, 2)
message = "==== Progress: " + str(percent) + "% ===="
if percent < 100:
# this line ending and buffer-flush allow us to re-write over this line again
print(message, end='\r', flush=True)
for fn in *; do printf "$fn::" ; cat $fn ; printf "\n"; done
# curl https://gist.githubusercontent.com/matthewpoer/5b09ea547bbdd7cdc304deb778465344/raw/93154518e28736d6e71a09dbb4176d6b0d5fac91/conky.conf --output ~/.config/conky/conky.conf
conky.config = {
alignment = 'top_right',
background = false,
border_width = 0.5,
cpu_avg_samples = 4,
default_color = 'white',
default_outline_color = 'grey',
default_shade_color = 'black',
@matthewpoer
matthewpoer / array_push.php
Created July 7, 2020 14:12
Merging arrays with array_push()
<?php
$a = array(
'one',
'two',
'three',
);
$b = array(
'four',
'five',
#!/usr/bin/env bash
set -e
# You'll need to set these variables here or with an environment variable
# mysqlPassword
# mysqlHostname
# mysqlUsername
# mysqlDatabase
# List out the tables you want to copy down,
<?php
$input = null;
$handle = fopen("php://stdin","r");
while($input != 'You are pretty') {
echo 'Tell me I\'m pretty.' . PHP_EOL;
$input = trim(fgets($handle));
}
echo 'You don\'t mean it' . PHP_EOL;
die(1);
@matthewpoer
matthewpoer / shebang.md
Last active February 21, 2020 13:32
Bash echo handles newlines based on shebang lines and POSIX compliance

How echo handles newlines based on shebang lines and Bash settings

The problem

Why would sh and bash perform differently on a system where they map to the same binary executable?

Consider such an environment:

> which sh && which bash
/bin/sh
@matthewpoer
matthewpoer / slowCount.php
Last active February 12, 2020 14:56
Demonstrates how line endings affect echo output
<?php
echo "Counting to 10" . PHP_EOL;
for($i = 0; $i < 10; $i++) {
echo "Count is at {$i}\r";
usleep(500000); // half of one second
}
echo "Count is at {$i}" . PHP_EOL;