Skip to content

Instantly share code, notes, and snippets.

View dmdavis's full-sized avatar

Dale Davis dmdavis

  • San Jose, CA
View GitHub Profile
@dmdavis
dmdavis / Vault Git Setup.md
Created September 17, 2026 16:22
Vault Git Setup

Setup

1. Init — plain, no --separate-git-dir

cd /path/to/work-vault
git init

No remote yet — if one gets added later (internal GitLab/Bitbucket/etc.), that's just git remote add, no re-init needed.

2. .gitignore

@dmdavis
dmdavis / Claude at Work.md
Created September 3, 2026 19:41
Claude at Work

Budget the artifact numerically

"Be concise" is the least effective instruction you can give a model — it's a vibe, and it gets traded away against every other goal in the prompt. Numbers and prohibitions survive.

  • State a hard count: "Max 200 words. Three bullets. No headings. No preamble."
  • Name the audience and their time: "Six staff engineers will read this once, in a meeting." This does real work — it changes what gets cut
  • Give the template with slot counts, so there's nothing to invent: Problem (2 sentences) · Approach (3 bullets) · Risk (1 sentence) · Test plan (2 bullets)
  • Prohibit the tells explicitly (list below). A model will strip what it's told to strip and will not self-diagnose
  • Ask for the cut, separately: "Now remove 40% without losing a decision." A second pass over finished text cuts far better than a first pass tries to be brief

The tells your reviewers are actually reacting to

Paste this into your AGENTS.md as a prohibition list. It's the rec

@dmdavis
dmdavis / utc_to_local.py
Created March 20, 2014 18:31
Example of converting UTC to local time using python-dateutil
#!/usr/bin/env python
# encoding: utf-8
"""
utc_to_local.py
Example of converting UTC to local time using python-dateutil.
https://pypi.python.org/pypi/python-dateutil
"""
from datetime import datetime
@dmdavis
dmdavis / human_readable_time_delta.py
Created June 25, 2013 20:27
Human-readable time delta.
from collections import namedtuple
human_delta = namedtuple('human_delta',
['days', 'hours', 'minutes', 'seconds'])
human_delta.__str__ = lambda self: \
'%d days, %d hours, %d minutes, %d seconds' % \
(self.days, self.hours, self.minutes, self.seconds)
def convert_timedelta(duration):
days, seconds = duration.days, duration.seconds
@dmdavis
dmdavis / dice_probabilities.csv
Created April 3, 2013 19:32
Output of swdiceprob.py as a CSV file.
Exploding Die
Target d4 d6 d8 d10 d12
1 1 1 1 1 1
2 0.75 0.833333333 0.875 0.9 0.916666667
3 0.5 0.666666667 0.75 0.8 0.833333333
4 0.25 0.5 0.625 0.7 0.75
5 0.25 0.333333333 0.5 0.6 0.666666667
6 0.1875 0.166666667 0.375 0.5 0.583333333
7 0.125 0.166666667 0.25 0.4 0.5
8 0.0625 0.138888889 0.125 0.3 0.416666667
@dmdavis
dmdavis / swdiceprob.py
Created April 3, 2013 19:29
Functions for calculating Savage Worlds dice probabilities.
#!/usr/bin/env python
# encoding: utf-8
"""
swdiceprob.py
Functions for calculating Savage Worlds dice probabilities.
Copyright (c) 2012-2013 Dale Davis. All rights reserved.
Redistribution and use in source and binary forms, with or without
@dmdavis
dmdavis / utf-8_gzip.py
Created August 22, 2012 15:18
Python: Compress a UTF-8 file using GZIP compression
def compress_utf8_file(fullpath, delete_original = True):
"""Compress a UTF-8 encoded file using GZIP compression named *.gz. If `delete_original` is `True` [default: True],
the original file specified by `delete_original` is removed after compression."""
with codecs.open(fullpath, 'r', 'utf-8') as fin:
with gzip.open(fullpath + '.gz', 'wb') as fout:
for line in fin:
fout.write(unicode(line).encode('utf-8'))
if delete_original:
os.remove(fullpath)
@dmdavis
dmdavis / peg_dice.js
Created June 4, 2012 21:35
Simple PEG.js dice roller
start
= additive
additive
= left:dice "+" right:additive { return left + right; }
/ left:dice "-" right:additive { return left - right; }
/ dice
dice
= left:primary "d" right:primary { var s = 0; for(var i = 0; i < left; i++ ) { s += Math.floor(Math.random() * right) + 1; } return s; }
@dmdavis
dmdavis / mysql_time_format.php
Created May 29, 2012 20:39
DateInterval to MySQL TIME format string
$dateInterval->format('%H:%I:%S');
@dmdavis
dmdavis / remove_on_update.sql
Created May 25, 2012 19:52
Remove ON UPDATE from MySQL Timestamp column
-- From http://www.fakebeing.com/projects/remove-on-update-from-mysql-timestamp-column/
ALTER TABLE mytable CHANGE columnName columnName TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP