Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
sebastiancarlos / quasiquotation-on-lisp-bawden-apendix-a-algorithm.md
Last active March 1, 2025 04:52
Quasiquotation in Lisp (Bawden) - Appendix A Algorithm. (Plaintext OCR from PDF)

"Quasiquotation in Lisp" (Bawden) - Appendix A

This appendix contains a correct S-expression quasiquotation expansion

@sebastiancarlos
sebastiancarlos / girls_and_boys.pro
Last active January 8, 2025 03:40
Blur's "Girls and Boys" lyrics generator in Prolog
#!/usr/bin/env swipl --quiet
% All my gist code is licensed under the MIT license.
:- use_module(library(clpfd)).
% ORIGINAL LYRICS:
% Looking for
% Girls who want boys
% Who like boys to be girls
@sebastiancarlos
sebastiancarlos / gutenberg-dl.bash
Created March 28, 2024 19:56
gutenberg-dl - download text books from Project Gutenberg
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
# gutenberg-dl <search-term>
# - Download books from Project Gutenberg in plain text format
# - Actually uses "gutendex" to search for the download link. It seems to be
# the current best third-party Gutemberg API
# - Source: https://github.com/garethbjohnson/gutendex
@sebastiancarlos
sebastiancarlos / bkp.bash
Last active March 9, 2024 14:38
bkp - toggle ".bkp" extension
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
# Add this somewhere in your .bashrc
# bkp
# - toggle a ".bkp" extension to a file(s)
function bkp () {
# print usage on -h/--help or no arguments
@sebastiancarlos
sebastiancarlos / term2plain.bash
Last active January 25, 2025 15:10
term2plain - Record an interactive terminal session, and convert it to plain text.
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
# term2plain
# - Convert a text file containing terminal escape sequences to plain text.
# - This plain text is close to the visual result of running the file in a
# terminal.
# - This is achieved by running the file in a virtual terminal (tmux) and
# capturing it's buffer output.
@sebastiancarlos
sebastiancarlos / sqlite3h
Last active January 25, 2025 15:10
sqlite3h - Wrapper around sqlite3 which saves interactive session to a history file
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
### UPDATE!
# I noticed that this entire solution is unnecessary, as the following
# produces the same result, and can be put in the sqlite start file.
# ```
# .echo on
# .output "| tee -a history.txt"
@sebastiancarlos
sebastiancarlos / minimal_dir.py
Last active August 8, 2024 04:17
Like dir(), but filters out __*__ attributes, standard library packages, and built-ins, to give a better idea of the object's custom attributes.
# explicitly define the interface
__all__ = ["minimal_dir"]
from functools import cache
@cache
def get_stdlib_packages():
""" Get list that should include all stdlib package/module names.
Not perfect. Has false positives.
@sebastiancarlos
sebastiancarlos / pretty_print.py
Created January 19, 2024 15:30
Pretty printer with color, label and value (value defaults to evaluation of label)
# explicitly define the interface
__all__ = ["pretty_print"]
def is_package_available(package_name):
import importlib.util
package_spec = importlib.util.find_spec(package_name)
return package_spec is not None
def pretty_print(label: str, value: any = "") -> None:
""" Prints "label". Followed by pretty printed "value".
@sebastiancarlos
sebastiancarlos / groff-preview.bash
Last active August 7, 2024 19:13
groff-preview
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
# Add this somewhere in your .bashrc
# groff-preview-terminal
# - previews roff file in the terminal
# - uses grog to figure out needed preprocessor and macros
# - sends to terminal output by passing -Tutf8 and then to a pager
@sebastiancarlos
sebastiancarlos / sway-popup-listener.bash
Last active December 18, 2023 17:30
sway-popup-listener
#!/usr/bin/env bash
# This script listens for new windows and makes them floating if it thinks they
# are popups. Meant to be used when regular i3 criteria are not enough to
# identify popup windows. It uses hardcoded dimensions.
# print usage on --help/-h
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "Usage: $0"
echo "This script listens for new windows and makes them floating if it thinks they"