This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// Typealias used in case we need to use some BigInt type | |
/// for counting, but for games to 21, a 64-bit Int is sufficient | |
typealias CountingInt = Int | |
struct DiracDie { | |
/// index is sum of three rolls of 3-sided die, | |
/// value is the number of combinations that generate that sum | |
static let threeRollCombinations: [Int] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Foo { } | |
protocol Bar { } | |
protocol Baz { } | |
struct FooStruct: Foo, Bar {} | |
/// Test covariance of return type | |
let block: () -> FooStruct = { FooStruct() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import argparse | |
import traceback | |
import dateutil.parser | |
import dateutil.tz | |
from datetime import datetime, timedelta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
import sublime_plugin | |
# An alternative to the builtin "join_lines" command, | |
# which contains an idiosyncracy that I consider a bug. | |
class JoinLinesAltCommand(sublime_plugin.TextCommand): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/4145515 | |
# | |
# All-purpose gist tool for Pythonista. | |
# | |
# When run directly, this script sets up four other scripts that call various | |
# functions within this file. Each of these sub-scripts are meant for use as | |
# action menu items. They are: | |
# | |
# Set Gist ID.py - Set the gist id that the current file should be | |
# associated with. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WakeOnLan | |
# | |
# Sends a wake-on-lan magic packet for the given MAC address | |
# to either the broadcast address of the local subnet, or, | |
# if provided, some other hostname. | |
# An alternate port can also be optionally provided. | |
import struct, socket | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
import sublime, sublime_plugin | |
import re | |
# Utility function for shortening text. | |
# From: http://www.leancrew.com/all-this/2012/08/more-markdown-reference-links-in-bbedit/ | |
def shorten(str, n): | |
'Truncate str to no more than n chars' | |
return str if len(str) <= n else str[:n-1] + u'…' |