Skip to content

Instantly share code, notes, and snippets.

View ysdede's full-sized avatar
🏠
Working from home

ysdede

🏠
Working from home
View GitHub Profile
@ysdede
ysdede / sha256.py
Created September 1, 2024 13:15
sha256.py Numba njit implementation
"""This Python module is an implementation of the SHA-256 algorithm.
From https://github.com/keanemind/Python-SHA-256"""
'''
MIT License
Copyright (c) 2018 Keane Nguyen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ysdede
ysdede / gist:403ac8eab6f082739bc8c08b093b3135
Created March 29, 2023 15:53
Postgresql create/setup databases using the command line
Linux shell:
```bash
sudo -u postgres psql -c "CREATE DATABASE optuna_db;"
sudo -u postgres psql -c "CREATE USER optuna_user WITH PASSWORD 'password';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE optuna_db to optuna_user;"
```
Window:
```cmd
psql -U postgres -W -c "CREATE DATABASE optuna_db;"
@ysdede
ysdede / Optimize_tk3.py
Last active November 4, 2022 18:54
Multi-objective NSGAII hyperparameters optimization with Optuna v3
import contextlib
import json
import signal
import sys
from subprocess import PIPE, Popen, call
import click
import jessetk2.utils as utils
from optuna import samplers
import optuna
@ysdede
ysdede / install_odoo.cmd
Created July 20, 2022 16:03
Prepare enviroment for installing Odoo from source on Windows
git clone https://github.com/odoo/odoo.git
psql -U postgres -W -c "CREATE DATABASE odoo_db1;"
psql -U postgres -W -c "CREATE USER odoo_user1;"
psql -U postgres -W -c "GRANT ALL PRIVILEGES ON DATABASE odoo_db1 to odoo_user1;"
pip install setuptools wheel
pip install -r https://raw.githubusercontent.com/odoo/odoo/15.0/requirements.txt
@ysdede
ysdede / influxdb
Created May 10, 2022 12:43
/etc/init.d/influxdb
#!/bin/bash
### BEGIN INIT INFO
# Provides: influxd
# Required-Start: $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the InfluxDB process
### END INIT INFO
@ysdede
ysdede / influxdb2.sh
Last active November 25, 2023 19:32
InfluxDB 2.x Open Source Time Series Database on wsl2
wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null
sudo apt-get update && sudo apt-get install influxdb2
sudo chmod +x /etc/init.d/influxdb
sudo chown root:root /etc/init.d/influxdb
sudo update-rc.d influxdb defaults
sudo update-rc.d influxdb enable
@ysdede
ysdede / install_clickhouse.sh
Created December 22, 2021 20:24
Install Clickhouse
sudo apt-get install apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4
echo "deb https://repo.clickhouse.com/deb/stable/ main/" | sudo tee \
/etc/apt/sources.list.d/clickhouse.list
sudo apt-get update
sudo apt-get install -y clickhouse-server clickhouse-client
sudo service clickhouse-server start
@ysdede
ysdede / install_grafana.sh
Created December 22, 2021 19:13
Install Grafana OSS
sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
# Add this repository for stable releases:
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
# Add this repository if you want beta releases:
echo "deb https://packages.grafana.com/oss/deb beta main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
# After you add the repository:
@ysdede
ysdede / Optimize-NSGAII.py
Last active January 16, 2022 21:35
Multi-objective NSGAII hyperparameters optimization with Optuna
import json
import signal
import sys
from subprocess import PIPE, Popen, call
import jessetk.utils as utils
import optuna
# Multi-objective NSGAII hyperparameters optimization with Optuna
# Wraps Jesse ai's backtest function as an objective function
@ysdede
ysdede / Pick-Parameters.py
Last active January 15, 2022 23:33
Pick best parameters from Optuna database
import optuna
import statistics
import json
# This code snippet filters Optuna trials based on performance metrics and standard deviation
# and generates a results.csv file containing all results
# and a SEQ.py file containing all hyperparameters
study = optuna.create_study(study_name="Band5min-LongOnly", directions=["maximize", "maximize"],
storage="postgresql://optuna_user:optuna_password@localhost/optuna_db_3", load_if_exists=True)