Skip to content

Instantly share code, notes, and snippets.

View vsmelov's full-sized avatar

Smelov Vladimir vsmelov

View GitHub Profile
@vsmelov
vsmelov / SwapCheck.sol
Created March 1, 2021 15:52
compare if/else implementation of swap over case/switch
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract SwapCheck {
function implementation1_0(uint256 x, uint256 y) public returns(uint256 xx, uint256 yy) {
// transaction cost: 22236 gas
// execution: 580 gas
assembly {
@vsmelov
vsmelov / array.mpl
Last active March 28, 2021 17:00
a[3] = a[7] * 2
set _comment "define constants"
set maxASize 10
op mul maxASizeX2 maxASize 2
set m 7
set n 3
set _comment "def aGetIndex"
op add aGetIndexLine @counter 1
op add @counter @counter maxASizeX2
set aGetResult a0
set @counter aGetIndexCaller
@vsmelov
vsmelov / ubuntu20.04-post-install.sh
Last active November 11, 2020 12:51
Prepare working environment
sudo snap install chromium
sudo snap install sublime-text --classic
sudo snap install pycharm-professional --classic
sudo snap install skype --classic
sudo snap install zoom-client
sudo snap install slack --classic
sudo apt install -y htop iotop build-essential python3-pip git curl
echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee -a /etc/apt/sources.list
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
apm-server:
image: docker.elastic.co/apm/apm-server:6.7.1
# image: docker.elastic.co/apm/apm-server:6.5.3
command: -strict.perms=false
volumes:
- /etc/localtime:/etc/localtime:ro
- ./apm/apm-server.yml:/usr/share/apm-server/apm-server.yml
depends_on:
- es-tunnel
logging:
time.mktime(datetime.strptime('2019-01-07 09:43:20,158', '%Y-%m-%d %H:%M:%S,%f').timetuple())
import random
N_EXPERIMENTS = 10000
N_SWIPES = 250
A_REAL_RATE = 66 / 250
B_REAL_RATE = 70 / 250
def experiment():
""" observable rate for A and B """
This file has been truncated, but you can view the full file.
254'), 'token': None, 'aggregatedCap': Decimal('1'), 'timestamp': 1542383692233}
2018-11-16 16:54:55,699 - theo_calculator.py:263 - INFO - found_eff_vol=60000.00000000000000000000000
2018-11-16 16:54:55,699 - theo_calculator.py:266 - INFO - total_eff_vol_for_theo=53.54822760785947532988284620
2018-11-16 16:54:55,699 - theo_calculator.py:268 - INFO - total_vol_for_theo=0.009672938653992030036925841023
2018-11-16 16:54:55,699 - theo_calculator.py:276 - INFO - calculate_theo: processed 7 trades (found_eff_vol=60000.00000000000000000000000 >= eff_max_vol=60000)
2018-11-16 16:54:55,699 - theo_calculator.py:290 - INFO - Trade theo=5535.879997105127519920974511, total_eff_vol_for_theo=53.54822760785947532988284620, total_vol_for_theo=0.009672938653992030036925841023
update theo in 0.0041997432708740234sec
2018-11-16 16:54:55,997 - run.py:77 - INFO - get 1 trades for gemini {'since': 1542383681457, 'limit': 500}
2018-11-16 16:54:55,997 - run.py:79 - INFO - trades[0]: {'id': '4817350539', 'order': None, 'info': {'time
import socket
import logging
from contextlib import closing
import datetime
from sshtunnel import SSHTunnelForwarder
from cmreslogging.handlers import CMRESHandler
logger = logging.getLogger(__name__)
@vsmelov
vsmelov / asyncio_fail_on_task_exception.py
Created October 23, 2018 09:05
asyncio.Task fail doesn't cause to all program exit if it was set to some variable
import asyncio
import sys
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setLevel(logging.DEBUG)
logger.addHandler(sh)