Flattens any array dimension to one dimensional array using ES2015 reduce function and recursion
A Pen by Vlad Bezden on CodePen.
| import json | |
| from datetime import date, datetime | |
| def to_json(obj): | |
| '''JSON serializer for objects not serializable by default''' | |
| if isinstance(obj, (datetime, date)): | |
| return obj.isoformat() | |
| raise TypeError (f'Type {type(obj)} not serializable') |
| import datetime as dt | |
| import matplotlib.pyplot as plt | |
| from matplotlib import style | |
| import pandas as pd | |
| import pandas_datareader.data as web | |
| style.use('ggplot') | |
| start = dt.datetime(2000, 1, 1) | |
| end = dt.date.today() |
| import asyncio | |
| MAX_TASKS = 5 | |
| async def hello(): | |
| print('Hello') | |
| await asyncio.sleep(3) | |
| print('World!') | |
| def main(): |
| from time import perf_counter | |
| from contextlib import contextmanager | |
| @contextmanager | |
| def timer(label: str): | |
| '''Context Manager for calculating time. | |
| Note: | |
| code example is based on Python 3.6 |
Flattens any array dimension to one dimensional array using ES2015 reduce function and recursion
A Pen by Vlad Bezden on CodePen.
An example of pure way getting last element of the array.
A Pen by Vlad Bezden on CodePen.
| <div id="app" /> |
Determines if number is power of 2 using Math.log2
A Pen by Vlad Bezden on CodePen.