Skip to content

Instantly share code, notes, and snippets.


Devvyn P M devvyn

View GitHub Profile
# readable, but not DRY
def fb1(number):
return ''.join((
('fizz' if (not number % 3) else ''),
('buzz' if (not number % 4) else ''))) or str(number)
# fully DRY, easy to maintain
def fb2(number):
a = {3: 'fizz',
devvyn / philips-hue-lets-play.ipynb
Last active Jan 9, 2018
Philips Hue API - let's play
View philips-hue-lets-play.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
devvyn / matias-like one-handed qwerty for karabiner.xml
Created Jan 31, 2017 — forked from emory/matias-like one-handed qwerty for karabiner.xml
A Karabiner config to mimic the half-handed QWERTY behavior and layout of the Matias one-handed keyboards.
View matias-like one-handed qwerty for karabiner.xml
<!-- a brief discussion about this config was originally posted here I lifted it and changed the Name -->
<name>Matias Style One-handed Half-QWERTY</name>
__HoldingKeyToKey__, KeyCode::SPACE, KeyCode::SPACE, KeyCode::VK_NONE, KeyCode::VK_CONFIG_SYNC_KEYDOWNUP_notsave_flip_hands
commands=(cow{say,think}); while [ "rainbows are delightful" ]; do (fortune | ${commands[$RANDOM % ${#commands[@]}]} -f $(cowsay -l | tail -n+2 | xargs -n 1 | sort -R | head -n 1) | lolcat -a ) && sleep 2; done
devvyn /
Created Feb 22, 2015
code sketch: grab a CSV file with a column called "OTV SKU#" and split the characters in all the values into a character tree
from CsvFileModel import CsvFileModel # available from
import json
import yaml
import collections
class StringTree(object):
def __init__(self):
c = CsvFileModel('csp.csv')
skus = list(x.strip() for x in c['OTV SKU#'])
devvyn /
Last active Sep 9, 2017
Super easy CSV file reader class with column accessors (magic __getattr__ for named columns)
# coding=utf-8
Convenience wrapper for csv.DictReader showing use of __getattr__ to do magic lookups on the loaded file.
To procedurally implement CsvFileModel, without a new class, pass the target package_name and/or filename to the constructor.
For example:
my_spending_report = CsvFileModel(filename='spendnov1995.tsv', package_name='')
my_spending_report = CsvFileModel(filename='spendnov1995.tsv')