Skip to content

Instantly share code, notes, and snippets.

@espdev
espdev / qtabwidget.css
Last active May 1, 2024 06:52
A QTabWidget Custom Stylesheet Example
QTabWidget::pane {
border: 1px solid black;
background: white;
}
QTabWidget::tab-bar:top {
top: 1px;
}
QTabWidget::tab-bar:bottom {
@espdev
espdev / trading_day.py
Last active January 24, 2021 15:39
Trading days offset
from typing import Union
import pandas as pd
from trading_calendars import TradingCalendar, get_calendar
class TradingDay:
"""Offset for trading days
The class is useful to find previous and next trading days from given date.
@espdev
espdev / scanlines.ipynb
Created July 31, 2017 22:23
Vectorized scanlines calculation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@espdev
espdev / mirroring-point.ipynb
Created November 29, 2017 09:55
Отражение точки относительно заданного отрезка
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@espdev
espdev / use_matlab.py
Last active October 23, 2020 21:09
Using Matlab shared engine
# -*- coding: utf-8 -*-
import multiprocessing as mp
import matlab.engine as me
def start_matlab(ready_event, close_event):
print('Starting matlab...')
eng = me.start_matlab(option='-nodesktop')
@espdev
espdev / crspline_curve.m
Last active May 15, 2020 08:44
Catmull-Rom cubic spline interpolation [Matlab]
function varargout = crspline_curve(varargin)
%CRSPLINE_CURVE Конструирует двумерную кривую кубическим Catmull-Rom интерполяционным сплайном
%
% Описание:
% Функция конструирует двумерную кривую по узловым точкам, используя
% Catmull-Rom интерполяционные кубические сплайны.
% Данные сплайны могут локально контролироваться и проходят по
% узловым точкам, а не в выпуклой их оболочке.
%
% Литература:
@espdev
espdev / .inputrc
Last active April 8, 2020 13:38
The bash inputrc config for convenient autocompletion
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e\e": kill-whole-line
set colored-stats On
set completion-ignore-case On
set completion-prefix-display-length 3
set mark-symlinked-directories On
set show-all-if-ambiguous On
set show-all-if-unmodified On
@espdev
espdev / main.py
Created March 4, 2020 23:20
scipy/sprs random sparse matrices multiplication
import time
import numpy as np
from scipy.sparse import csr_matrix
def make_matrix(shape, nnz):
i = np.random.randint(0, shape[0] - 1, nnz)
j = np.random.randint(0, shape[1] - 1, nnz)
data = np.random.randn(nnz)
@espdev
espdev / main.py
Created March 4, 2020 10:59
Rust/Python sparse matrices multiplication
import time
import numpy as np
from scipy.sparse import diags
def make_matrix(pcount):
x = np.linspace(0., 10., pcount)
dx = np.diff(x)
odx = 1. / dx
@espdev
espdev / cls_is_none.py
Created January 17, 2020 12:43
cls is None
from typing import Optional
from pydantic import BaseModel, validator
class MyModel(BaseModel):
name: Optional[str]
class Config:
validate_assignment = True