Skip to content

Instantly share code, notes, and snippets.

View jfhbrook's full-sized avatar
💭
KNEE DEEP IN THE HOOPLA

Josh Holbrook jfhbrook

💭
KNEE DEEP IN THE HOOPLA
View GitHub Profile
@jfhbrook
jfhbrook / kinja-api-response-example.json
Last active April 25, 2019 21:31
An example of what a Kinja API response might look like
{
"meta": {
"error": null,
"warnings": [],
},
"data": {
"firstName": "Josh",
"lastName": "Holbrook",
"bio": "Born in Alaska, lives in New York, has a pet budgie! Fun stuff!"
}
@jfhbrook
jfhbrook / xmonad.hs
Created April 4, 2019 20:49
Current xmonad.hs
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Util.EZConfig
myConfig = docks $ ewmh def
{ terminal = "spawn-alacritty-cwd"
, modMask = mod4Mask
, focusedBorderColor = "#fabd2f"
small coffee mug: 1 cup
large coffee mug: 1.5 cups
my huge-ass fist: 2 3/8 cups displacement in water
everything in https://lifehacker.com/use-your-hand-to-estimate-your-portions-5880630 - about 2x what they say
working guesstimate of a sunac salad bar tongload: 1 cup for bulking ingredients, 1/3 cup for flavoring ingredients, 4 oz for chicken

So an environment.yml might look like this:

name: my-environment
dependencies:
  # conda deps use globs
 - python=3.7.*
 - pip:
   # pip deps use requirements.txt format
 - some_pip_dependency==1.2.3
||connect.facebook.net/*fbevents.js$script
||*.facebook.com/*tr
||*.facebook.com/*impression.php
@jfhbrook
jfhbrook / cool_api.py
Created October 1, 2018 16:38
cool api
@app.route('/whatever')
@handler
def route():
warn(Warning('some warning'))
return 'some result'
# json response: {"meta":{"warnings":[{"type":"Warning","message":"some warning"}]},"data":"some result"}
@jfhbrook
jfhbrook / yield_warnings.py
Last active September 30, 2018 03:09
good or bad idea?
@app.route('/whatever')
@kinja_handler
def route():
# do stuff
# exceptions get captured
# can optionally use yield keyword to collect
# warnings during execution - would "manually"
# exhaust the generator to collect warnings
# and a return value distinctly
@app.route('/whatever')
def route():
builder = ResponseBuilder()
# exceptions get stored in the builder if raised
# Alternately call builder.error(exc) I guess
with builder.capture():
# We can push warnings onto the builder
# These can be subclassed
builder.warning(GenericWarning('some warning'))
class Perhaps:
pass
class Probably(Perhaps):
def __init__(self, value):
self.value = value
class NahTho(Perhaps):
pass
@jfhbrook
jfhbrook / mixin_inits.py
Created May 30, 2018 03:00
Use mixins to pull in initialize-y methods as capabilities then call them explicitly in your class
class FooMixin(object):
def foo(self):
print('do foo')
class BarMixin(object):
def bar(self):
print('do bar')
class StuffDoer(FooMixin, BarMixin):
def __init__(self):