Skip to content

Instantly share code, notes, and snippets.

View macbre's full-sized avatar
🏠
Working from home

Maciej Brencz macbre

🏠
Working from home
View GitHub Profile
@macbre
macbre / .gitignore
Last active March 16, 2024 14:09
farerskiekadry.geo
.idea/
@macbre
macbre / truncate_docker_logs.sh
Created November 2, 2023 11:59
Docker utils
#!/bin/bash
# https://docs.docker.com/engine/reference/commandline/ps/#format
df -h /
for container in $(docker ps --format "{{.Names}}")
do
echo "Truncating logs for the '${container}' container ..."
# https://forums.docker.com/t/how-to-limit-or-rotate-docker-container-logs/112378/9
@macbre
macbre / .gitignore
Last active July 14, 2023 14:52
py-facebook-feed
# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]
*$py.class
*.swp
# C extensions
*.so
@macbre
macbre / example.ts
Created January 23, 2023 13:32
Async fs.exists()
import { fsExists } from './utils';
if ( ! ( await fsExists( folder ) ) ) {
// ...
}
// open any Daft page and go the dev console
clear();
const data = JSON.parse(document.querySelector('script[id="__NEXT_DATA__"]').textContent);
const listing = data.props.pageProps.listing;
console.log( listing.title );
// grab the images
const images = listing.media.images.map( img => img['size1440x960'] );
@macbre
macbre / bygd_2022.tsv
Last active February 12, 2022 20:20
Faroe Islands - IB01030 Population by sex, age, village/city and month(1985-2022)
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 41 columns, instead of 40. in line 3.
"sex" "age" "village/city" "1985 Jan" "1986 Jan" "1987 Jan" "1988 Jan" "1989 Jan" "1990 Jan" "1991 Jan" "1992 Jan" "1993 Jan" "1994 Jan" "1995 Jan" "1996 Jan" "1997 Jan" "1998 Jan" "1999 Jan" "2000 Jan" "2001 Jan" "2002 Jan" "2003 Jan" "2004 Jan" "2005 Jan" "2006 Jan" "2007 Jan" "2008 Jan" "2009 Jan" "2010 Jan" "2011 Jan" "2012 Jan" "2013 Jan" "2014 Jan" "2015 Jan" "2016 Jan" "2017 Jan" "2018 Jan" "2019 Jan" "2020 Jan" "2021 Jan" "2022 Jan"
"Total (sex)" "Total (age)" "Total Faroe Islands" 45347 45677 46240 46880 47570 47772 47347 47203 46735 45259 43640 43323 43745 44226 44760 45342 46127 46941 47648 48146 48299 48120 48262 48302 48603 48485 48431 48178 48029 48122 48590 49099 49791 50462 51273 52103 52899 53664
"Total (sex)" "Total (age)" "Hattarvík" 27 27 27 30 36 37 29 33 40 39 32 30 26 24 22 20 20 18 17 16 17 16 15 16 15 16 17 15 14 14 14 13 13 12 11 11 11 10
"Total (sex)" "Total (age)" "Kirkja" 35 32 32 25 24 24 24 24 24 30 22 21 18 18 19 20 30 30 28 29 28 27 28 26 25 22 22 22 23 28 26 27 32 25 26 27 30
@macbre
macbre / README.txt
Created October 28, 2021 11:38
ts-jest setup
npm remove @types/mocha mocha
npm i --save-dev @types/jest jest
npm i --save-dev ts-jest
npx ts-jest config:init
and provide testRegex entry in jest.config.js file.
@macbre
macbre / fonts.py
Created April 5, 2021 13:48
Font encoder for MAX7129
# fonts are encoded by columns
# first value is the first column from the left
# now, we want to have them encode by rows (starting from the botton one)
# { 0x00, 0xf8, 0x88, 0x88, 0x88, 0x88, 0x88, 0xf8 }, // 0
# see https://github.com/rm-hull/luma.led_matrix/blob/0.2.3/max7219/font.py#L84-L93
CP437_FONT = [
[0x3E, 0x7F, 0x71, 0x59, 0x4D, 0x7F, 0x3E, 0x00], # '0'
[0x40, 0x42, 0x7F, 0x7F, 0x40, 0x40, 0x00, 0x00], # '1'
@macbre
macbre / export_to_pdf.sh
Last active December 16, 2020 19:38
calendar
#!/bin/bash
export TMPDIR="${HOME}/.tmp"
mkdir -p $TMPDIR
FILES=$(ls *.svg | egrep '[0-9]\.')
DPI=400
# inkscape --file=12.svg --export-text-to-path --export-dpi=300 --export-pdf-version=1.5 --export-filename=pdf/12.pdf
for file in $FILES
do