Skip to content

Instantly share code, notes, and snippets.

View davep's full-sized avatar
👁️‍🗨️
Nothing like the eve of extinction to bring focus to the mind.

Dave Pearson davep

👁️‍🗨️
Nothing like the eve of extinction to bring focus to the mind.
View GitHub Profile
@davep
davep / ollamawopr.md
Created May 2, 2024 16:36
That time Ollama went all WOPR on me

User

give me some wargames quotes

Agent

Here are some famous quotes from WarGames (1983):

  1. "The only winning move is to use the force, Luke." - David Lightman (Matthew Broderick)
  2. "You can't win. You can't even break even." - Joshua (Dabney Coleman)
Screen {
layout: vertical;
background: #444444
}
Horizontal {
height: 20%
}
GameHeader {
@davep
davep / rich_dos_colour.py
Created September 22, 2022 09:25
Function to turn a MS/PC-DOS colour code into a Rich colour style markup string
def rich_dos_colour( color: int ) -> str:
"""Convert a MS/PC-DOS colour attribute to Rich style text.
:param int colour: The MS/PC-DOS colour attribute.
:returns: A Rich BBCode-style markup string for the colour.
:rtype: str
"""
assert 0 <= color <= 0xFF, "DOS colour codes must be 0 to 255 inclusive"
return "[color({}) on color({})]".format(
*reversed( divmod( color, 0x10 ) )
@davep
davep / macosx-configure-postfix-as-relay.md
Created April 14, 2022 21:14 — forked from loziju/macosx-configure-postfix-as-relay.md
Configure postfix as relay for OS X
@davep
davep / Makefile
Created November 15, 2021 15:20
Handy self-help facility for a Makefile
##############################################################################
# Self help
helper = @grep -Eh "^[a-z]+:.+\# " $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.+\# "}; {printf "$(1)%-20s$(2)%s$(3)\n", $$1, $$2}'
.PHONY: help
help: # Display this help
$(call helper,, )
.PHONY: helpmd
helpmd: # Display this help as a markdown table
@davep
davep / .zshrc
Created February 17, 2020 15:16
# If we're a dumb terminal give up on using zsh and just go with the default
# system shell. This might seem a bit OTT but it really helps with all sorts
# of issues with tramp on GNU emacs.
if [[ "$TERM" == "dumb" ]]
then
exec /bin/sh -l
fi
@davep
davep / gh.fish
Created October 16, 2019 08:59
Quick and simple fish function to open a current repo's "forge" in the web browser
##############################################################################
# Attempt go visit the origin hub for the current repo.
function gh -d "Visit the repo in its origin hub"
# Check that there is some sort of origin.
set origin (git config --get remote.origin.url)
# If we didn't get anything...
if not test "$origin"
@davep
davep / feedparser_django_datetime.py
Created August 1, 2019 13:24 — forked from yaph/feedparser_django_datetime.py
A snippet that shows how to convert a feedparser time.struct_time object to a Django datetime with timezone support.
from django.utils import timezone
import time
# feed = object from DB
# doc = parsed feedparser object
feed.updated_at = doc.feed.get('updated_parsed', timezone.now())
if isinstance(feed.updated_at, time.struct_time):
feed.updated_at = timezone.make_aware(
timezone.datetime(*feed.updated_at[:-3]),
@davep
davep / intersphinx_mappings.txt
Created June 4, 2019 12:02 — forked from bskinn/intersphinx_mappings.txt
Various intersphinx mappings
Python 3.5: ('https://docs.python.org/3.5', None)
NumPy [latest]: ('http://docs.scipy.org/doc/numpy/', None)
SciPy [latest]: ('http://docs.scipy.org/doc/scipy/reference', None)
matplotlib [latest]: ('http://matplotlib.org', None)
h5py [latest]: ('http://docs.h5py.org/en/latest/', None)
Sphinx [stable]: ('http://www.sphinx-doc.org/en/stable/', None)
Django [latest?]: ('http://docs.djangoproject.com/en/dev/', 'https://docs.djangoproject.com/en/dev/_objects/')
sarge [latest]: ('http://sarge.readthedocs.io/en/latest/', None)
attrs [stable]: ('http://www.attrs.org/en/stable/', None)
@davep
davep / zsh_to_fish.py
Created May 8, 2019 13:39 — forked from dvdbng/zsh_to_fish.py
Migrate zsh history to fish
import os
import re
def zsh_to_fish(cmd):
return (cmd.replace('&&', '; and ')
.replace('||', '; or '))
def is_valid_fish(cmd):