Skip to content

Instantly share code, notes, and snippets.

Dustin King dmoney

Block or report user

Report or block dmoney

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View alertme.py
#!/usr/bin/env python3
import sys, os
def alert():
os.system('say -v Tessa "Your task has been completed."')
def alert_on_pipe_close():
try:
while True:
View groupcities.js
// groupcities.js
// An alternative solution to:
// https://dev.to/albinotonnina/how-to-lose-a-it-job-in-10-minutes-35pi
//
// Given an array of city names, group the ones that are rotations of
// each other together. e.g.:
//
// input: ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris']
// output:
// [
View rand9999.py
# python 3.6+
# written for: https://dev.to/r0f1/write-a-simple-but-impactful-script-7ba
import sys, random, argparse
parser = argparse.ArgumentParser(
description='Print the numbers from 0000 to 9999 in random order.')
parser.add_argument('FILENAME',
type=str,
default=None,
View neurochromohexonics.html
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>Neurochromohexonics</title>
<!-- Synaptic neural net library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/synaptic/1.1.4/synaptic.js"></script>
<!-- fight me -->
View primes.py
from itertools import islice
def ints_from(start=2, step=1):
next = start
while True:
next += step
yield next
def take(n, iterable):
"""Return first n items of the iterable as a list
View _div.html.erb
<table>
<thead>
<tr>
<th>Item</th>
</tr>
</thead>
<tbody>
View bitsnake.rb
# bitsnake.rb
# A solution to the Ancient City Ruby 2016 programming challenge:
# http://www.ancientcityruby.com/snake_case/
#
# Dustin King ( cathodion@gmail.com / @cathodion )
#
# Counts the number of paths through an 10x10 grid of city blocks
# moving only East and South.
EAST_BLOCKS = 10
View funvert.py
# funvert.py
# A hack to enable calling functions as if they were methods
#
# Author: Dustin King (cathodion@gmail.com)
# Grown from this tweet by Zygmunt Zając:
# https://twitter.com/zygmuntzajac/status/685161914117296128
#
# Superseded by: https://github.com/dmoney/funvert
class Funverted:
View sPickle.py
'''Streaming pickle implementation for efficiently serializing and
de-serializing an iterable (e.g., list)
Created on 2010-06-19 by Philip Guo
Mostly rewritten 2015-01-16 by Dustin King for Python 3.4
Not backwards compatible.
2.7 version here: https://archive.is/5RZ24
'''
View reversed.py
import unittest
TREE = (1, (2, None, None), (3, (4, None, None), (5, None, None)))
EXPECTED_REVERSED = (1, (3, (5, None, None), (4, None, None)), (2, None, None))
def reversed(tree):
if tree is None:
return None
else:
val, left, right = tree
You can’t perform that action at this time.