Skip to content

Instantly share code, notes, and snippets.

View vsmelov's full-sized avatar

Smelov Vladimir vsmelov

View GitHub Profile
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
@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
@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 / 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 {
rabbitmq:
image: rabbitmq:3-management
hostname: rabbitmq
environment:
RABBITMQ_DEFAULT_VHOST: vhost
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
@vsmelov
vsmelov / star.py
Created May 31, 2021 12:51
distances to space objects
from django.shortcuts import render
# def get_auctions
KM = 1000
earth = 12742*KM
sun = 1.4 * 10**6 * KM
sun_dist = 150 * 10**6 * KM
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.1;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Vesting {
IERC20 public immutable token;
struct Lock {
address receiver;
@vsmelov
vsmelov / test.json
Last active April 19, 2022 22:03
test json
{"name": "Vova"}
@vsmelov
vsmelov / DEXI.sol
Created August 9, 2022 07:32
DEXI 2022-08-09
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import '@openzeppelin/contracts/utils/EnumerableSet.sol';
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
library DateTime {
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;
interface IDexioLock {
function lock(
address owner,
address token,
uint256 amount,
uint256 unlockDate