Skip to content

Instantly share code, notes, and snippets.

View mitkrieg's full-sized avatar

Mitchell Krieger mitkrieg

View GitHub Profile
@mitkrieg
mitkrieg / .deps...npm...@chainlink...contracts...src...v0.6...interfaces...AggregatorV3Interface.sol
Created November 13, 2021 20:20
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.7+commit.b8d736ae.js&optimize=false&runs=200&gist=
# Edited run_test() in ExampleTest class in bitcoin/test/functional/example_test.py
# Test mines a new block on node1, sends block to node2 and checks to see if node2 recieved.
def run_test(self):
"""Main test logic"""
# Create P2P connections will wait for a verack to make sure the connection is fully up
peer_messaging = self.nodes[0].add_p2p_connection(BaseNode())
# Generating a block on one of the nodes will get us out of IBD
blocks = [int(self.nodes[0].generate(nblocks=1)[0], 16)]
@mitkrieg
mitkrieg / callbacks.py
Created February 27, 2021 08:23
callbacks in dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from layouts import example_graph1, example_graph2
from app import app
@app.callback(
Output("tab-content", "children"),
Input("tabs", "active_tab"),
)
@mitkrieg
mitkrieg / layouts.py
Created February 27, 2021 07:37
Dash Layouts
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from app import app
import plotly.express as px
#####################################
# Add your data
#####################################
@mitkrieg
mitkrieg / index.py
Created February 27, 2021 07:17
Dash index.py
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from app import app, server
#import your navigation, styles and layouts from layouts.py here
from layouts import nav_bar, layout1, layout2, CONTENT_STYLE
import callbacks
# Define basic structure of app:
@mitkrieg
mitkrieg / app.py
Last active February 26, 2021 21:18
Dash app.py
import dash
import dash_bootstrap_components as dbc
#Instantiates the Dash app and identify the server
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
server = app.server
# instantiate the model and fit the timeseries
prophet = Prophet(weekly_seasonality=False, changepoint_range=1,changepoint_prior_scale=0.75)
prophet.fit(ts)
# create a future data frame
future = prophet.make_future_dataframe(periods=25)
forecast = prophet.predict(future)
# display the most critical output columns from the forecast
forecast[['ds','yhat','yhat_lower','yhat_upper']].head()
from fbprophet.plot import add_changepoints_to_plot
a = add_changepoints_to_plot(fig.gca(),m,forcast)
fig
@mitkrieg
mitkrieg / basic_fbprophet.py
Created February 19, 2021 23:32
Basic FB Prophet Model
from fbprophet import Prophet
# instantiate the model and fit the timeseries
prophet = Prophet()
prophet.fit(ts)
# create a future data frame
future = prophet.make_future_dataframe(periods=25)
forecast = prophet.predict(future)
@mitkrieg
mitkrieg / read_covid_data.py
Last active July 26, 2022 21:07
read_covid_data
import pandas as pd
# read data from NY times
df = pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us.csv")
# engineer new cases
df['new_cases'] = df.cases - df.cases.shift().fillna(0)
# create pandas time series
df.date = pd.to_datetime(df.date)