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 / govwords.py
Created April 15, 2017 07:01
GOVT WORDS
import os
import sys
from random import choice
def get_dict_words():
"""Get some words from local dict."""
# Choices: web2, words, web2a, connectives, propernames
folder = 'words'
@christabor
christabor / omes.py
Created February 25, 2017 09:17
*omes
from pprint import pprint as ppr
import nltk
def get_dict_words():
# Choices: web2, words, web2a, connectives, propernames
folder = 'words'
osx_words = '/usr/share/dict/{}'.format(folder)
with open(osx_words, 'r') as wordfile:
@christabor
christabor / tuples.py
Created January 27, 2017 23:16
More collections - tuples
"""Specialized tuples."""
def n_tuple(argcount):
"""Return a new function to generate a tuple.
But only if the specified arity is met.
"""
def _tuple(*someargs):
if len(someargs) != argcount:
@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 / __init__.py
Last active December 2, 2016 00:16
PostgreSQL introspection to API - some automation experiments
# Make this folder import-able.
@christabor
christabor / superlist.py
Last active November 24, 2016 06:47
kinda sorta numpy style array and also dict.
class SuperDict():
def __init__(self, **kwargs):
self.items = dict(**kwargs)
def __getitem__(self, key):
if isinstance(key, tuple):
_curr = self.items
for num in key:
_curr = _curr[num]
return _curr
@christabor
christabor / app.py
Created November 17, 2016 05:11
graph_api
from flask import Flask
from flask.ext.restless import APIManager
import models
app = Flask(__name__)
app.config['DEBUG'] = True
manager = APIManager(app, session=models.session)
manager.create_api(models.Edge, methods=['GET', 'POST', 'PUT', 'DELETE'])
@christabor
christabor / jasmine_runner.py
Last active November 9, 2016 08:38
Javascript test runner in Python...
"""A python runner for nodejs test files."""
import os
import subprocess
import sys
def check_tests():
"""Run all tests."""
js_files = [f for f in os.listdir('.') if f.endswith('Spec.js')]
@christabor
christabor / app.py
Created October 26, 2016 19:50
Flask app module toggling
from flask import Flask
import settings
from service_a import svc_a as svc_a_bp
app = Flask('myapp')
if settings.SERVICES['serviceA'].enabled:
app.register_blueprint(svc_a_bp)
@christabor
christabor / jsondash.json
Last active November 3, 2016 06:35
testing loading data for jsondash https://github.com/christabor/flask_jsondash
{
"data": {
"xs": {
"setosa": "setosa_x",
"versicolor": "versicolor_x"
},
"columns": [
["setosa_x", 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.4, 3.0, 3.0, 4.0, 4.4, 3.9, 3.5, 3.8, 3.8, 3.4, 3.7, 3.6, 3.3, 3.4, 3.0, 3.4, 3.5, 3.4, 3.2, 3.1, 3.4, 4.1, 4.2, 3.1, 3.2, 3.5, 3.6, 3.0, 3.4, 3.5, 2.3, 3.2, 3.5, 3.8, 3.0, 3.8, 3.2, 3.7, 3.3],
["versicolor_x", 3.2, 3.2, 3.1, 2.3, 2.8, 2.8, 3.3, 2.4, 2.9, 2.7, 2.0, 3.0, 2.2, 2.9, 2.9, 3.1, 3.0, 2.7, 2.2, 2.5, 3.2, 2.8, 2.5, 2.8, 2.9, 3.0, 2.8, 3.0, 2.9, 2.6, 2.4, 2.4, 2.7, 2.7, 3.0, 3.4, 3.1, 2.3, 3.0, 2.5, 2.6, 3.0, 2.6, 2.3, 2.7, 3.0, 2.9, 2.9, 2.5, 2.8],
["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],