Skip to content

Instantly share code, notes, and snippets.

View okeyokoro's full-sized avatar

Daniel Okey-Okoro okeyokoro

View GitHub Profile
@okeyokoro
okeyokoro / tree.md
Created November 6, 2020 04:43 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

import requests
url = "https://api.github.com"
user = "<user-name>"
token = "<make-personal-access-token-@-https://github.com/settings/tokens>"
queries = [
{ "page": i , "per_page": 100 }
for i in [1, 2, 3,]
@okeyokoro
okeyokoro / install-docker.md
Created April 20, 2020 21:45 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command
@okeyokoro
okeyokoro / class.nim
Created April 16, 2020 20:33 — forked from bucho666/class.nim
nim class macro
import macros
proc typeName(head: NimNode): NimNode =
if head.len == 0: head else: head[1]
proc baseName(head: NimNode): NimNode =
if head.len == 0: newIdentNode("RootObj") else: head[2]
proc isObjectDef(head: NimNode): bool =
head.len == 0 or head[2].kind == nnkIdent
@okeyokoro
okeyokoro / install-psycopg2.sh
Created April 11, 2020 09:59 — forked from whyvez/install-psycopg2.sh
install psycopg2 on aws linux
sudo yum install gcc python27 python27-devel postgresql-devel
sudo curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python27
sudo /usr/bin/easy_install-2.7 pip
sudo pip2.7 install psycopg2
#!/usr/bin/env python
import re
from collections import defaultdict
from pprint import pprint
def findall(line, query="httpretty"):
rgx = re.compile(f"(?P<occurrence>[\w]*[import\s]?{query}[\w\.]*)\w*")
return re.findall(rgx, line)
class conduit(object):
def __init__(self, iterator):
self.iterator = iterator
def filter(self, predicate):
return conduit(itertools.ifilter(predicate, self.iterator))
def map(self, func):
return conduit(itertools.imap(func, self.iterator))
@okeyokoro
okeyokoro / mcmc
Created November 26, 2019 01:11 — forked from alexsavio/mcmc
Simple MCMC sampling with Python
"""
Some python code for
Markov Chain Monte Carlo and Gibs sampling
by Bruce Walsh
"""
import numpy as np
import numpy.linalg as npla