Skip to content

Instantly share code, notes, and snippets.

View mdenson-dayspring's full-sized avatar

Matthew Denson mdenson-dayspring

View GitHub Profile
@mdenson-dayspring
mdenson-dayspring / spell_number.py
Last active March 31, 2022 19:53
A program that takes an array of numbers and returns the spelled-out cardinal and ordinal forms of those numbers.
#
# A program that takes an array of numbers and returns the spelled-out cardinal and ordinal forms of those numbers.
# Includes framework to allow use as a Lambda function.
#
# Example usage:
# $ echo "{"numbers": [0, 1, 2, 3, 4, 5, 11, 65, 100, 101, 277, 23456, 8007006005004003]}" | python3 spell_number.py
# {"ordinals": ["zero", "one", "two", "three", "four", "five", "eleven", "sixty five", "one hundred", \
# "one hundred and one", "two hundred seventy seven", "twenty three thousand four hundred fifty six", \
# "eight quadrillion seven trillion six billion five million four thousand and three"], \
# "cardinals": ["zeroth", "first", "second", "third", "fourth", "fifth", "eleventh", "sixty fifth", "one hundredth", \
@mdenson-dayspring
mdenson-dayspring / bowling.py
Last active March 30, 2022 07:09
An a little over the top Bowling Score app.
#
# An a little over the top Bowling Score app.
# Copyright 2022 by Matthew Denson <mdenson@dayspringpartners.com>
#
# Example Usage:
# To score a set of bowls provided in JSON format in stdin.
# $ echo "[1,4,4,5,6,4,5,5,10,0,1,7,3,6,4,10,2,8,9]" | python3 bowling.py stdin
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
# | 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Inspired by Hack-A-Day article http://hackaday.com/2012/01/25/very-accurate-clock-cant-be-read-accurately/.
#
# Author: Matthew Denson <mdenson AT dayspring-tech DOT com>
# Originally written for Processing: Feb 2, 2012
# Rewritten in Python/Tk: Oct 24, 2014
#
# Copyright (c) 2014 Dayspring Technologies, Inc.
@mdenson-dayspring
mdenson-dayspring / ClientEnvironmentListener.php
Created January 18, 2014 01:45
Pieces parts used to retrieve the browser time zone to a Symfony 2.3/Propel web application. By using these pieces you can get and display dates and times in the users timezone and store them in them correctly so that they can be displayed correctly in another users timezone.
<?php
namespace MyApp\MyBundle\EventListener;
use DateTimeZone;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ClientEnvironmentListener {