Skip to content

Instantly share code, notes, and snippets.

View blais's full-sized avatar
:octocat:
Definitely not working from home

Martin Blais blais

:octocat:
Definitely not working from home
View GitHub Profile
@blais
blais / slice
Created April 28, 2024 18:09
Slice text output to columns and convert to equivalent CSV
#!/usr/bin/env python3
"""Slice ascii output along columns of empty space into a table.
Any vertical column of whitespace spanning the entire height of the input
generates a column separator.
Ideas:
- We could enhance this to detect 2+ spaces in the header field names as the
only legitimate places for separation (to avoid false positives).
- Handle tabs.
@blais
blais / apt-tree
Last active July 7, 2023 03:22
apt-tree
#!/usr/bin/env python3
"""Display a graph of dependencies between Ubuntu packages.
Reads a list of packages from either a file or stdin.
Outputs a PDF.
"""
__author__ = "Martin Blais <blais@furius.ca>"
import argparse
import logging
import random
;; FIXME: This is missing from the stdlib.
(defn split-extension [filename]
(let [index (.lastIndexOf filename ".")]
(list (.substring filename 0 index) (.substring filename index))))
(defn get-basename [filename]
(let [index (.lastIndexOf filename ".")]
(.substring filename 0 index)))
(defn get-extension [filename]
@blais
blais / gist.el
Created September 20, 2010 04:45
(when (not token)
(setq token (read-string "GitHub API token: "))
(github-set-config "token" token))