Skip to content

Instantly share code, notes, and snippets.

"""
Although the code in appears broken with inspection, it is not. Sly uses some hacky syntax.
https://sly.readthedocs.io/en/latest/sly.html#writing-a-parser
"""
from pypika import (
Bracket,
Case,
Not,
Order,
@twheys
twheys / useFlexLayout.js
Created November 12, 2019 16:01
react-table 7.0.0-beta
import PropTypes from 'prop-types';
const propTypes = {};
export const useFlexLayout = hooks => {
hooks.useMain.push(useMain);
};
useFlexLayout.pluginName = 'useFlexLayout';
@twheys
twheys / scan_for_modules.py
Created June 7, 2017 11:57
Small generator function that recursively scans a directory for all python modules.
def scan_for_modules(path):
"""
Generator function which scans a directory for all python modules and returns them successively.
"""
modules = []
for finder, pkgname, is_module in pkgutil.iter_modules([path]):
if pkgname in ['setup']:
continue
mod = importlib.import_module(pkgname)
@twheys
twheys / tea.py
Last active August 24, 2023 11:57
Python implementation of the Tiny Encryption Algorithm (TEA)
# coding: utf-8
"""
Implementation of the Tiny Encryption Algorithm (TEA) for Python
https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
Example Usage:
import tea
# The key must be 16 characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@twheys
twheys / n_armed_bandit.py
Last active August 29, 2015 14:24
Implementation of the methods described by Richard Sutton in Chapter 2 of his book on reinforcement learning. Includes both greedy and softmax selection as well as reinforcement comparison. Requires python 3, scipy for calculations and plotting.
"""
Implementation of the methods described by Richard Sutton in Chapter 2 of his book on reinforcement learning.
http://webdocs.cs.ualberta.ca/~sutton/book/ebook/the-book.html
"""
__author__ = 'Timothy Heys, twheys@gmail.com'
import itertools
from bisect import bisect