Skip to content

Instantly share code, notes, and snippets.

View fabianvf's full-sized avatar

Fabian von Feilitzsch fabianvf

View GitHub Profile
@fabianvf
fabianvf / composable.py
Last active May 20, 2020 15:21
Python function composition with a dot operator
class Composable(object):
''' A function decorator that allows you to use Haskell style dot notation for function composition '''
fns = {}
def __init__(self, fn):
self.fn = fn
Composable.fns[fn.__name__] = fn
def __call__(self, *args, **kwargs):
''' simply calls the function '''
@fabianvf
fabianvf / typed_compose.py
Created November 18, 2015 23:41
Typed compose
from typing import Callable, TypeVar
T = TypeVar('T')
T2 = TypeVar('T2')
T3 = TypeVar('T3')
def compose(func1: Callable[[T], T2],
func2: Callable[[T3], T]) -> Callable[[T3], T2]:
def inner(arg: T3) -> T2:
@fabianvf
fabianvf / test.erb
Created April 25, 2016 17:33
How to test erb templates with ruby
<%= conditon ? 'True case' : 'False case' %>)
@fabianvf
fabianvf / RFE_template.md
Last active July 21, 2016 18:11
FIrst stab at a template for useful feature requests

Motivation:

  • Why do you want this feature?
  • Is it a priority? Why?
  • Who needs it (internal, customer, etc)?

Current Behavior:

  • If you are proposing a change to an existing feature, where does the existing feature fall short?
  • If it is too difficult to use in its current state, where does the difficulty lie?

Desired Behavior:

@fabianvf
fabianvf / oreilly_downloader.py
Last active February 26, 2020 13:42
Downloads Oreilly free ebooks by category. Requires requests library and python 2. Categories I've see so far are business, data, iot, security, web-platform, webops-perf, programming, so usage would look like: python oreilly_downloader.py business data iot security web-platform webops-perf programming
import os
import re
import sys
import requests
filename_matcher = re.compile(r'http://www.oreilly.com/(.*)/free/(.*).csp')
def main():
categories = sys.argv[1:]
urls = map(lambda x: 'http://www.oreilly.com/{}/free/'.format(x), categories)
@fabianvf
fabianvf / tmp
Created February 19, 2018 20:14
{"dockerImageMetadataVersion": "1.0", "dockerImageLayers": [{"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "name": "sha256:af4b0a2388c69010cf675c050e51cb1fabbdf2303f955c31805b280324fd4523", "size": 73673211}, {"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "name": "sha256:cd2a3f5b40aec8ab0f334bc11f3198f0a4148d2ee736c1e6d113d663a245785d", "size": 7840118}, {"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "name": "sha256:8bc68d31852a947c8baf3d1966c7abbd743ac68df5ac20e31a12951c6d5e7335", "size": 4419}, {"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "name": "sha256:32c96411826bc7ff61d7b7600f5f93d68a7a95363cd35409e728fab84844c0cd", "size": 172026}, {"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "name": "sha256:b7ff7f3aa64f4be8857bfeb9aaeb6dde2b8eca7a75ad513c359e0272946421df", "size": 90636991}, {"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "name": "sha256:5171f2e47af85e7aeb96e4990e376e61f65042ce5fe
---
- hosts: localhost
connection: local
become: true
gather_facts: false
vars:
proxy_passthrough: false
env:
name: ALBUM_TITLE
---
- hosts: localhost
connection: local
become: true
gather_facts: false
vars:
proxy_passthrough: false
env:
name: ALBUM_TITLE
---
- hosts: oo_first_master
roles:
- lib_openshift
post_tasks:
- when: osm_default_node_selector is not defined
block:
- name: Retrieve non-infra, non-master nodes
oc_obj:
---
- hosts: oo_first_master
roles:
- lib_openshift
post_tasks:
- when: osm_default_node_selector is not defined
block:
- name: Retrieve non-infra, non-master nodes
oc_obj: