Nono.MA

JUNE 19, 2022

Here's a simple command to get human-readable sizes of files and folders inside of the current directory. (I've tested it on macOS' Terminal and Linux.)

du -sh -- *
# 124M	backups
# 523M	downloads
# 1.8G	recordings-hijack
# 673M	recordings-obs
# 392K	recordings-zoom
# 403M	settings

Note that you may have to sudo if you're trying to get sizes for files that require sudo permissions.

APRIL 15, 2021

After downloading a website as HTML with cURL or any other workflow, you can convert the HTML code to the Markdown syntax with pandoc.

pandoc -o output.md input.html

APRIL 15, 2021

You can download any website as an HTML file (without the site's assets) using cURL in the command line, using the -L flag to follow any existing redirects.

curl -L https://nono.ma --output nono-ma.html

The manual alternative is to right-click on a website on your browser of choice (say, Google Chrome or Firefox), select Save As.., and save the site as HTML with some of its assets in a subfolder.

Afterwards, you can convert the downloaded HTML page into a Markdown document with pandoc.

MARCH 28, 2021

I got a sudden fan shut down every time I would switch on my MacBook Pro (16-inch, 2019) after I upgraded macOS from Catalina to Big Sur. Here's how I fixed it.

  • CMD + R - Press on reboot to enter Rescue Mode
  • Login as a user you know the password for.
  • Utilities › Terminal
  • Run kmutil trigger-panic-medic --volume-root /Volumes/Macintosh\ HD
  • Start the computer normally

This is the Kext extension that, apparently, was causing the issue.

cd /System/Library/Extensions/AppleThunderboltNHI.kext

FEBRUARY 25, 2021

Batch-Export PowerPoint Slides to Images Programmatically

unoconv is a tool to "convert between any document format supported by OpenOffice," available to install via Homebrew on macOS. You can convert, for instance, ppt files to png images (or to a multi-page PDF files) by running a command with this command-line interface program. The project is open source and you can browse its code on GitHub.

Install unoconv with Homebrew

brew install unoconv

Common issues: LibreOffice not found on your system

I ran into this issue when I first ran the unoconv command.

unoconv
# unoconv: Cannot find a suitable office installation on your system.
# ERROR: Please locate your office installation and send your feedback to:
#        http://github.com/dagwieers/unoconv/issues

That's because unoconv can't find libreoffice. You can install its Homebrew Cask.

brew install --cask libreoffice

After doing that, unoconv can find the libreoffice installation.

unoconv
# unoconv: you have to provide a filename or url as argument
# Try `unoconv -h' for more information.

Export PowerPoint Slides to PDF

unoconv slides.pptx -f pdf

Convert PDF to PNG or JPG Images

Even though you can directly export a PowerPoint presentation to JPEG or PNG format, unoconv exports only the first page by default.

You can use ImageMagick's convert tool to rasterize the PDF pages as images.

convert -density 300 slides.pdf image%d.jpg

Batch-convert Presentations to Images

Here's a bash script that will convert all ppt presentations in a folder to jpg images by folders.

# Convert all pptx files to multi-page pdf files
unoconv -f pdf *.pptx

# Loop through pptx files
for f in *.pptx
do
    echo "${f}.."
    mkdir -p ${f}-jpg
    convert -density 20 ${f%.*}.pdf "./${f}-jpg/image%d.jpg"
done

Available formats

You can see the extensive list of supported input and output formats on unoconv's documentation and read more about how to use unoconv in its help manual page or by running unoconv -h.

OCTOBER 1, 2020

Note: This document is incomplete and work-in-progress.

Here are different ways to convert (or rasterize) SVG graphics to PNG.

Librsvg

brew install librsvg

Then the rsvg-convert command should be available in your terminal.

rsvg-convert --help

# Usage:
#   rsvg-convert [OPTION…] [FILE...] - SVG Converter
# 
# Help Options:
#   -?, --help                                                  Show help options
# 
# Application Options:
#   -d, --dpi-x=<float>                                         pixels per inch [optional; defaults to 90dpi]
#   -p, --dpi-y=<float>                                         pixels per inch [optional; defaults to 90dpi]
#   -x, --x-zoom=<float>                                        x zoom factor [optional; defaults to 1.0]
#   -y, --y-zoom=<float>                                        y zoom factor [optional; defaults to 1.0]
#   -z, --zoom=<float>                                          zoom factor [optional; defaults to 1.0]
#   -w, --width=<int>                                           width [optional; defaults to the SVG's width]
#   -h, --height=<int>                                          height [optional; defaults to the SVG's height]
#   -f, --format=[png, pdf, ps, eps, svg, xml, recording]       save format [optional; defaults to 'png']
#   -o, --output                                                output filename [optional; defaults to stdout]
#   -i, --export-id=<object id>                                 SVG id of object to export [optional; defaults to exporting all objects]
#   -a, --keep-aspect-ratio                                     whether to preserve the aspect ratio [optional; defaults to FALSE]
#   -b, --background-color=[black, white, #abccee, #aaa...]     set the background color [optional; defaults to None]
#   -s, --stylesheet                                            Filename of CSS stylesheet
#   -u, --unlimited                                             Allow huge SVG files
#   --keep-image-data                                           Keep image data
#   --no-keep-image-data                                        Don't keep image data
#   -v, --version                                               show version information

ImageMagick

InkScape

brew cask install inkscape
inkscape --action-list

# action-list         :  Print a list of actions and exit.
# convert-dpi-method  :  Import DPI convert method.
# export-area         :  Export area.
# export-area-drawing :  Export drawing area.
# export-area-page    :  Export page area.
# export-area-snap    :  Export snap area to integer values.
# export-background   :  Export background color.
# export-background-opacity:  Export background opacity.
# export-do           :  Do export.
# export-dpi          :  Export DPI.
# export-filename     :  Export file name.
# export-height       :  Export height.
# export-id           :  Export id(s).
# export-id-only      :  Export id(s) only.
# export-ignore-filters:  Export ignore filters.
# export-latex        :  Export LaTeX.
# export-margin       :  Export margin.
# export-overwrite    :  Export over-write file.
# export-pdf-version  :  Export PDF version.
# export-plain-svg    :  Export as plain SVG.
# export-ps-level     :  Export PostScript level.
# export-text-to-path :  Export convert text to paths.
# export-type         :  Export file type.
# export-use-hints    :  Export using saved hints.
# export-width        :  Export width.
# file-close          :  Close active document.
# file-new            :  Open new document using template.
# file-open           :  Open file.
# inkscape-version    :  Print Inkscape version and exit.
# no-convert-baseline :  Import convert text baselines.
# object-set-attribute:  Set or update an attribute on selected objects. Usage: object-set-attribute:attribute name, attribute value;
# object-set-property :  Set or update a property on selected objects. Usage: object-set-property:property name, property value;
# object-to-path      :  Convert shapes to paths.
# object-unlink-clones:  Unlink clones and symbols.
# open-page           :  Import page number.
# query-all           :  Query 'x', 'y', 'width', and 'height'.
# query-height        :  Query 'height' value(s) of object(s).
# query-width         :  Query 'width' value(s) of object(s).
# query-x             :  Query 'x' value(s) of selected objects.
# query-y             :  Query 'y' value(s) of selected objects.
# quit-inkscape       :  Immediately quit Inkscape.
# select              :  Select by ID (Deprecated)
# select-all          :  Select all. Options: 'all' (every object including groups), 'layers', 'no-layers' (top level objects in layers), 'groups' (all groups including layers), 'no-groups' (all objects other than groups and layers, default).
# select-by-class     :  Select by class
# select-by-element   :  Select by SVG element (e.g. 'rect').
# select-by-id        :  Select by ID
# select-by-selector  :  Select by CSS selector
# select-clear        :  Selection clear
# select-invert       :  Invert selection. Options: 'all', 'layers', 'no-layers', 'groups', 'no-groups' (default).
# select-list         :  Print a list of objects in current selection.
# system-data-directory:  Print system data directory and exit.
# transform-remove    :  Remove any transforms from selected objects.
# transform-rotate    :  Rotate selected objects by degrees.
# transform-scale     :  Scale selected objects by scale factor.
# transform-translate :  Translate selected objects (dx,dy).
# unselect            :  Unselect by ID (Deprecated)
# unselect-by-id      :  Unselect by ID
# user-data-directory :  Print user data directory and exit.
# vacuum-defs         :  Remove unused definitions (gradients, etc.).
# verb                :  Execute verb(s).
# verb-list           :  Print a list of verbs and exit.
# window-close        :  Close the active window.
# window-open         :  Open a window for the active document. GUI only.
inkscape --export-format="png" in.svg

svgexport

npm install -g svgexport
svgexport infile.svg outfile.png

Cairo

cairosvg

dom-to-image

To-do.

Want to see older publications? Visit the archive.

Listen to Getting Simple .