Skip to content

Instantly share code, notes, and snippets.

/*!
* @license
* TradingView Lightweight Charts™ v4.1.2
* Copyright (c) 2023 TradingView, Inc.
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/
(function () {
'use strict';
/**
@sefgit
sefgit / _cmd.bat
Created June 2, 2024 05:13
PYTHON virtualenv
@echo off
rem mkdir workspace
rem copy _cmd.bat .
rem cd workspace
rem virtualenv .venv
Set workdir=%cd%\.venv
rem echo VIRTUALENV: %workdir%
For /F "delims=\" %%A in ("%workdir%") do (
Set Name=%%~nxA
@sefgit
sefgit / unblock.ps1
Last active May 27, 2024 17:26
Scripts to unblock dlls
Get-ChildItem -Path . -Recurse -Filter *.dll -File -Name | Unblock-File
@sefgit
sefgit / chart.py
Created May 26, 2024 02:22
Freezing python lightweight_charts using pyinstaller
from os import chdir
from os.path import dirname
import multiprocessing
import numpy as np
import pandas as pd
import asyncio
from lightweight_charts import Chart
async def main():
#print(sys._MEIPASS)
@sefgit
sefgit / tornado_bg_task.py
Created May 19, 2024 21:03
tornado background task
# https://mike.depalatis.net/blog/tornado-background-tasks.html
@tornado.concurrent.run_on_executor
def refresh():
do_something_that_takes_a_while()
tornado.ioloop.IOLoop.instance().add_callback(self.refresh)
@sefgit
sefgit / app.py
Created May 19, 2024 12:11
Streamlit with Socket.IO enabled : inspired by st_route.py
from st_socketio import sio, st_socketio
import streamlit as st
@sio.on('chat')
async def chat_event(sid, data, auth):
print('chat ', sid, data, auth)
await sio.emit('chat', data[::-1], sid);
return "OK", sid
@sio.event
@sefgit
sefgit / chat.html
Created May 19, 2024 07:12
socketio on tornado
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Socket.IO chat</title>
<style>
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages > li { padding: 0.5rem 1rem; }
#messages > li:nth-child(odd) { background: #efefef; }
</style>
@sefgit
sefgit / readme.txt
Created May 19, 2024 01:22 — forked from nathanqthai/readme.txt
simple tornado server with ssl
to generate example certs
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout host.key -out host.crt
run server:
chmod +x server.py
./server.py
test server:
openssl s_client -connect localhost:8888
@sefgit
sefgit / _idle.bat
Created May 16, 2024 02:07
Python IDLE virtual environment
REM
REM Copy this file to the ROOT FOLDER of python virtual environment
REM === by sefgit
REM
@set "VIRTUAL_ENV=%cd%"
@if defined _OLD_VIRTUAL_PROMPT (
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
@if not defined PROMPT (
@sefgit
sefgit / Python3.9 on ubuntu22.04 Jammy
Created May 5, 2024 00:51 — forked from basaks/Python3.9 on ubuntu22.04 Jammy
Python3.9 on ubuntu22.04 Jammy
## Install Python3.9 interpreter on ubuntu 22.04
On a terminal just do the following steps:
Install dependencies:
sudo apt install tar build-essential checkinstall libreadline-dev \
libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev \
libbz2-dev openssl libffi-dev