Skip to content

Instantly share code, notes, and snippets.

@okomarov
okomarov / Matlab_factoryDefaults
Last active August 29, 2015 14:12
MATLAB factory defaults to script
%% R2014b
% Retrieve all factory defaults
s = get(0,'factory');
fnames = fieldnames(s);
% groupnames = unique(regexp(fnames, 'factory[A-Z][a-z]+','match','once'));
% Select those of interest
groupnames = {
'factoryAnimatedline'
'factoryAnnotationpane'
@okomarov
okomarov / R2014b
Created April 9, 2015 11:49
R2014b - 6da0553 - ACID(36)
% This file was created by matlab2tikz.
%
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}
@okomarov
okomarov / R2014a
Created April 9, 2015 11:53
R2014a - 6da0553 - ACID(16)
% This file was created by matlab2tikz.
%
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}
% This file was created by matlab2tikz.
%
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}
@okomarov
okomarov / check_gpu_ram_colab.py
Created July 18, 2018 15:15
Check allocated GPU by Colab
# memory footprint support libraries/code
!ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi
!pip install gputil
!pip install psutil
!pip install humanize
import psutil
import humanize
import os
import GPUtil as GPU
%matplotlib notebook
import pandas_datareader as pdr
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
# Download gold data (ETF)
gld = pdr.get_data_yahoo('GLD',start='1984-01-01')
@okomarov
okomarov / webapp.py
Created January 2, 2019 17:23
Excerpt from dash_on_flask/app/webapp.py
# Imports here
# ....
server_bp = Blueprint('main', __name__)
@server_bp.route('/')
def index():
return render_template("index.html", title='Home Page')
@server_bp.route('/login', methods=['GET', 'POST'])
@okomarov
okomarov / __init__.py
Created January 2, 2019 17:26
Full app factory for dash_on_flask/app
from flask import Flask
from config import BaseConfig
def create_app():
server = Flask(__name__)
server.config.from_object(BaseConfig)
register_extensions(server)
register_blueprints(server)
@okomarov
okomarov / dashapp.py
Last active December 14, 2021 04:03
Excerpt from dash_on_flask/dashapp.py
# Other dash and not related imports
# ...
# Import factory method
from app import create_app
# Method to protect dash views/routes
def protect_dashviews(dashapp):
for view_func in dashapp.server.view_functions:
if view_func.startswith(dashapp.url_base_pathname):
@okomarov
okomarov / callbacks.py
Last active February 21, 2019 20:00
layout.py
from datetime import datetime as dt
import pandas_datareader as pdr
from dash.dependencies import Input
from dash.dependencies import Output
def register_callbacks(dashapp):
@dashapp.callback(Output('my-graph', 'figure'), [Input('my-dropdown', 'value')])
def update_graph(selected_dropdown_value):