Skip to content

Instantly share code, notes, and snippets.

View mattdodge's full-sized avatar
😺
Oh look! A status that I'll never change again!

Matt Dodge mattdodge

😺
Oh look! A status that I'll never change again!
View GitHub Profile
@mattdodge
mattdodge / block_decorator.py
Created October 24, 2018 14:59
A proposed syntax for defining blocks
from nio.block import blockify
@blockify
def my_custom_block(signals):
for signal in signals:
setattr(signal, 'matt', 'dodge')
return signals
@mattdodge
mattdodge / status_block.py
Last active January 28, 2019 22:42
nio Block for setting status
from nio.block.base import Block
from nio.command import command
@command('set_warning')
@command('set_error')
@command('set_ok')
class StatusBlock(Block):
def set_warning(self):
@mattdodge
mattdodge / unused_blocks.py
Created January 31, 2019 00:14
Clean up unused blocks in your nio projects
# Usage:
# From your nio project directory:
# >>> python unused_blocks.py
#
# Or, to delete the unused blocks:
# >>> python unused_blocks.py --delete
import json
import os
from os.path import join
import sys
@mattdodge
mattdodge / duplicate_blocks.py
Created January 31, 2019 17:56
Find duplicate blocks in a nio project
# Usage: From your nio project root run:
#
# python duplicate_blocks.py
from copy import copy
import json
import os
from os.path import join
blocks = {}
@mattdodge
mattdodge / liars.pl
Last active February 23, 2019 07:02
A Prolog solution to the FiveThirtyEight island liars Riddler (2/22/19)
% import our CLP library for constraint declarations
:- use_module(library(clpfd)).
% A Claimant is a liar if their age is over the threshold. We also
% explicitly declare the "not liar" condition here since `not` seems
% to behave weirdly with constraints
liar(Claimant, LieThreshold) :- Claimant #>= LieThreshold.
not_liar(Claimant, LieThreshold) :- Claimant #< LieThreshold.
% A Person is older than an Age if the Claimaint is not a liar, otherwise
@mattdodge
mattdodge / solutions.md
Last active May 12, 2023 12:30
Solutions to the game 24
Target (originally 24) Number of Solutions
2 479
3 469
6 462
1 462
5 459
4 457
7 454
9 448