This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
from torchinterp1d import Interp1d | |
class InterpModule(nn.Module): | |
def __init__(self, X, y): | |
super().__init__() | |
self.X = X | |
self.y = y | |
self.interp = Interp1d() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this in the zshrc generated by oh-my-zsh | |
alias gs="git status" | |
alias gd="git diff" | |
#other aliases | |
# alias build_proj_a="bazel build //src/proj/a/..." | |
# use: git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting to install zsh-syntax-highlighting plugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup_custom_logger(name): | |
formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(module)s - %(message)s') | |
handler = logging.StreamHandler() | |
handler.setFormatter(formatter) | |
logger = logging.getLogger(name) | |
logger.setLevel(logging.DEBUG) | |
logger.addHandler(handler) | |
return logger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install yfinance | |
from typing import Dict | |
def get_ticker_metadata(ticker: str) -> Dict[str, str]: | |
""" | |
:param ticker: stock ticker | |
:return: Dictionary containing some metadata | |
""" | |
result = {"company_name": "not_found", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_slack(something:str, channel:str) -> int: | |
""" | |
Sends message to slack channel | |
:param something: message | |
:param channel: channel to post | |
:return: response code | |
""" | |
data = { | |
'text': something, | |
'icon_emoji': ':robot_face:', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html | |
import numpy as np | |
from scipy import stats | |
import matplotlib.pyplot as plt | |
x = np.array([1,2,3]) | |
linregress(np.arange(len(x)), x) | |
slope, intercept, r_value, p_value, std_err = stats.linregress(np.arange(len(x)), x) | |
#plot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
def getUrl(symbol): | |
now = int(time.time()) | |
return "https://query1.finance.yahoo.com/v8/finance/chart/{}?symbol={}&period1={}&period2={}&interval=1m&includePrePost=true&lang=en-US®ion=US&corsDomain=finance.yahoo.com".format(symbol, symbol, now-20*60, now) | |
def main(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Library not loaded: /usr/local/lib/libmysqlclient.18.dylib | |
sudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.dylib /usr/local/lib/libmysqlclient.18.dylib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usepackage{listings} | |
\usepackage{color} | |
\definecolor{dkgreen}{rgb}{0,0.6,0} | |
\definecolor{gray}{rgb}{0.5,0.5,0.5} | |
\definecolor{mauve}{rgb}{0.58,0,0.82} | |
\lstset{frame=tb, | |
language=Java, | |
aboveskip=3mm, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{listings} | |
\usepackage[dvipsnames,table,xcdraw]{xcolor} | |
\definecolor{dkgreen}{rgb}{0,0.6,0} | |
\definecolor{gray}{rgb}{0.5,0.5,0.5} | |
\definecolor{mauve}{rgb}{0.58,0,0.82} | |
\lstset{language=Matlab,% |
NewerOlder