Skip to content

Instantly share code, notes, and snippets.

View christabor's full-sized avatar
😅
I may be slow to respond.

Chris Tabor christabor

😅
I may be slow to respond.
View GitHub Profile
@christabor
christabor / flask_fsm.py
Created July 12, 2017 05:38
Flask Finite State Machine PoC
"""FSM abstraction in python for flask.
==========================
Requirements:
1. Transition from/to steps
2. Only allow certain transitions
3. Reset FSM once in a certain position (stopping state)
E.g. a form that may then save to a DB and then
@christabor
christabor / gitignore-filter.py
Last active January 17, 2023 12:26
Generator stream gitignore filter python
def gitignore2list(directory):
"""Get a list of gitignore entries from a file."""
try:
with open('{}/.gitignore'.format(directory), 'r+') as ignorefile:
yield (x.rstrip() for x in ignorefile.read().split('\n')
if x and not x.startswith('#'))
except OSError:
yield None
@christabor
christabor / alien-names.txt
Created January 3, 2017 09:49
alien name generator
Joovfif Laav Puuhge
Diuse'Uoclu Bulvi
Veemza'Coogku Wiizzaq
Pecgad'Niqbej Livqic
Xad'Fecye Kodva
Ham-Wefqon Xuqqek
Zaance Vooqfe Ueehmuv
Raadzuc-Yiikheu Voow
Siijuu'Boomnaq Peen
Lervo Fuusi Sen
@christabor
christabor / bookmarks_inverted_index.py
Last active April 8, 2021 17:38
Make your chrome bookmarks into a searchable, tokenized inverted index
"""Tokenize bookmark titles and create an inverted index."""
import re
import os
import sys
from pprint import pprint as ppr
from collections import Counter, defaultdict
from pyquery import PyQuery as pq
@christabor
christabor / pkgutil_analysis.py
Last active January 7, 2021 23:45
A quick script to analyze python package code structure
"""Generate a report about the meta information of a pckage.
This includes its children modules,
functions, classes, arg/kwarg count, etc.
"""
import ast
import inspect
import os
import pkgutil
import sys
@christabor
christabor / fields_science_combinatorics.py
Last active June 19, 2019 03:28
generated-scientifc-fields-results
# -*- coding: UTF-8 -*-
"""Scientific branches."""
from itertools import permutations
from random import choice
branches = {
"Acarology": "study of mites",
"Aceology": "science of remedies, or of therapeutics; iamatology.",
"Acology": "study of medical remedies",
@christabor
christabor / Principles.md
Last active March 9, 2019 06:34
Bret Victor principles

Articles and their respective points

GLOBAL

  • Interactivity
  • Direct manipulation
  • Intuition
  • See the data, see the changes

===============================================================================

@christabor
christabor / plant_reproduction_exp.py
Created February 26, 2018 05:01
plant type reproduction automata experiment
from random import choice
types = ['sporophyte', 'gametophyte']
class Plant(object):
def __init__(self, type=None):
self.type = type or choice(types)
@christabor
christabor / fizzbuzz
Last active February 11, 2018 15:48
Fizzbuzz SASS (SCSS)
// To generate the html, I use an expansion tool like Emmett and run:
// ul#fuzzbuzz>li$num*100
@mixin fizzbuzz-content($num) {
@if $num % 15 == 0 {
content: 'FizzBuzz';
}
@elseif $num % 5 == 0 {
content: 'Buzz';
}
@christabor
christabor / wrapped_ctxmgr.py
Created January 25, 2018 21:33
decorators/ctxmgrs
from contextlib import contextmanager
def to_mgr(fn):
fn.__converted__ = True
@contextmanager
def fn2(*args, **kwargs):
try:
fn(*args, **kwargs)