Skip to content

Instantly share code, notes, and snippets.

View dblume's full-sized avatar

David Blume dblume

View GitHub Profile
@dblume
dblume / fathers_day_puzzle3.py
Last active July 5, 2018 16:49
Father's Day Puzzle #3, sort of like a magic square, but not a square.
#!/usr/bin/env python
#
# Father's Day card puzzle #3:
# In the figure below, fill in each of the sixteen numbers from 1 to 16 such
# that the four rows and three columns add up to 29.
#
# ( )---( )---( )
# | |
# ( )---( )---( )---( ) ( )
# | | |
@dblume
dblume / confluence_markup.lua
Last active April 5, 2017 17:25
Script for converting to Atlassian Confluence's markup with Pandoc.
-- confluence_markup.lua
-- A Pandoc Atlassian Confluence Markup Writer
--
-- Invoke with: pandoc -to confluence_markup.lua
--
-- Based on pandoc/data/sampsdfsle.lua and zhzhxtrrk's "pandoc confluence markup writer"
-- Fixes tables and lists of lists
local image_index = 0
@dblume
dblume / first_attempt.py
Last active August 29, 2015 14:22
Ways to Break a Dollar into Change
def ways_to_break(amount, coins):
"""
:param amount: the monetary value to break into some number of coins
:param coins: a container of descending coin denominations
:return: the number of different ways to break amount into coins
"""
this_coin = coins[0]
# If this is the only coin, there's one way to break it.
if len(coins) == 1:
@dblume
dblume / gist:f1356788354e4fe684d0
Created May 13, 2015 19:37
Username squatting at onename.com
Verifying I am +dblume on my passcard. https://onename.com/dblume
@dblume
dblume / acid_write_file.py
Last active September 25, 2015 08:29
Cross-platform nearly ACID file updates
import platform
import tempfile
import ntpath
import filelock # https://github.com/dmfrey/FileLock
# It's interesting to see what's different between Windows and Linux.
# On Windows, you can't rename to an existing file, and you can't
# use os.fdatasync().
# Also see: http://blog.gocept.com/2013/07/15/reliable-file-updates-with-python/
@dblume
dblume / menus.plugin.php
Created January 23, 2014 08:48
The version of system/plugins/menus/menus.plugin.php that I got today from Habari
<?php
/**
* Menus
*
* @property Vocabulary $vocabulary The Vocabulary object used to hold the menu
*
* @todo allow renaming/editing of menu items
* @todo style everything so it looks good
* @todo show description with name on post publish checkboxes
* @todo PHPDoc