Skip to content

Instantly share code, notes, and snippets.

@Ogaday
Ogaday / date_range.py
Created March 9, 2020 13:05
Date Range
from datetime import datetime, timedelta
from typing import Iterator
def date_range(
start: datetime,
stop: datetime,
step: timedelta
) -> Iterator[datetime]:
"""
@Ogaday
Ogaday / README.md
Last active March 9, 2020 12:36
Tranpose Dict

Dictionary puzzle of the week:

The objective is to write an expression or function that, given a dictionary in which each value is a list, transpose it so the result is list of dictionaries, where:

  • The keys of each new dictionary are the same as the keys of the original dictionary
  • The values of the ith dictionary correspond to the ith elements of the values of the original dictionary

If that doesn't make sense, here's an example:

# Input:
@Ogaday
Ogaday / README.md
Created October 21, 2019 17:31
Rebracer

Python Kata by @nhumrich of the Pythondev Slack communtiy.

Write a function that takes in a string, and returns a string with everything inside curly brackets {} removed. Example: hello {world} returns hello {}. Example 2: {hello} {world} returns {} {}

Only submissions that DO NOT use regex will be accepted for taco's

tacos for: 1st, cleanest, shortest, fastest, my choice

nested doesn't count. So { hello {something} there} should return: {}

@Ogaday
Ogaday / puzzle.py
Last active July 17, 2019 09:11
Expected updates when finding the max
#!/usr/bin/python3
"""
Simulation of the solution to a problem from a blog post by Nadbordrozd:
http://nadbordrozd.github.io/interviews/index.html
"""
from random import Random
def count_updates(x):
"""
@Ogaday
Ogaday / env.yml
Created July 11, 2019 16:25
Conda environment for PyDataLDn19 Workshop: Advanced Software Testing for Data Scientists
name: test4ds
dependencies:
- python>=3.7
- scikit-learn=0.21.2
- pandas=0.24.2
- numpy=1.16.4
- pip
- pip:
- pytest
- pytest-cov
@Ogaday
Ogaday / fib.py
Created July 1, 2019 16:50
Fibonacci Function
"""
Implementation of a function that returns elements from the Fibonacci sequence using DP
https://en.wikipedia.org/wiki/Fibonacci_number
https://en.wikipedia.org/wiki/Dynamic_programming
"""
import logging
logger = logging.getLogger(__name__)
import numpy as np
def mae(y_true, y_pred):
'''
Caluclate mean absolute error between two vectors
'''
return np.mean(np.abs(y_pred - y_true))
@Ogaday
Ogaday / Dockerfile
Created April 5, 2018 12:12
Minimal bokeh-stitch example
FROM continuumio/miniconda3:latest
RUN conda update conda -y
WORKDIR /opt/example/
COPY environment.yml /opt/example/
COPY ex_bokeh.ipymd /opt/example/
@Ogaday
Ogaday / genesis_public_key
Created March 1, 2018 12:18
genesis_public_key
04c7074a2a2c094a81c8fb23c3766d17b162de6d09baaf1916544e35f8af30159c8d4da5ebcb14dc18b2c1e1ac30749a05a2a58169b9c933714376a6efa08ce53b;tinybot-ca
@Ogaday
Ogaday / connection_tools.py
Last active September 6, 2017 14:34
kbcstorage snippets
'''
Utilities for manipulating sqlalchemy connection to keboola workspace.
Example usage::
from getpass import getpass
from kbcstorage.client import Client
import sqlalchemy as sqa