Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergey Levitin selevit

View GitHub Profile
@selevit
selevit / backup-edgeos-config.sh
Created Feb 19, 2022
Backup EdgeOS config to S3
View backup-edgeos-config.sh
#!/bin/vbash
set -e
source /opt/vyatta/etc/functions/script-template
# Save configuration to backups
NOW=`date -I'seconds'`
BACKUP_ROOT="/backup"
CONFIG_FILE="edgerouter_config_${NOW}.boot"
save "${BACKUP_ROOT}/${CONFIG_FILE}"
View threadsafe_vcrpy.py
@fixture(autouse=True, scope='session')
def threadsafe_vcrpy() -> None:
"""This fixture fixes an known VCR.py bug with threading and force_reset():
https://github.com/kevin1024/vcrpy/issues/212
There was a PR for this: https://github.com/kevin1024/vcrpy/pull/300
But the author was not sure if this fix covers all corner cases, and that's why hadn't merge it.
For our needs it's fully enough, that's why we will monkeypatch it until it's not fixed in the lib."""
from vcr.patch import force_reset as original_force_reset
@selevit
selevit / MultiTransfer.sol
Created Feb 19, 2020
An Ethereum smart contract which transfers many different ERC20 tokens and ETH in one transaction.
View MultiTransfer.sol
pragma solidity >=0.4.21 <0.7.0;
pragma experimental ABIEncoderV2;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
contract MultiTransfer {
struct Destination {
address token;
uint256 amount;
@selevit
selevit / MultiTransfer.sol
Created Feb 19, 2020
An Ethereum smart contract which transfers many different ERC20 tokens and ETH in one transaction
View MultiTransfer.sol
pragma solidity >=0.4.21 <0.7.0;
pragma experimental ABIEncoderV2;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
contract MultiTransfer {
struct Destination {
address token;
uint256 amount;
View check_bots.py
import os
from collections import namedtuple
import yaml
class BotConfigNotFound(Exception):
pass
@selevit
selevit / rt_bot_api_checker.go
Last active Nov 15, 2016
Набросок CI скрипта, который будет проверять корректность ботов radio-t (https://github.com/umputun/rt-bot)
View rt_bot_api_checker.go
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
@selevit
selevit / pumps.sql
Created Jan 27, 2016
Ебаный насос
View pumps.sql
-- phpMyAdmin SQL Dump
-- version 3.5.8.1
-- http://www.phpmyadmin.net
--
-- Хост: localhost
-- Время создания: Янв 27 2016 г., 15:17
-- Версия сервера: 5.5.37-0ubuntu0.13.10.1
-- Версия PHP: 5.5.3-1ubuntu2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
View osnovi_prog_var.py
#!/usr/bin/env python3
def main():
"""Вычисляет коллизии вариантов у студентов
Вариант определяется по сумме двух последних цифр
номера зачетки
"""
filename = 'list_auz_studbook.txt'
View feedback.php
<?php
// Разрешенные для загрузки mime-типы файлов
$upload_allow_mimetypes = array(
"image/png",
"image/jpeg",
);
// Разрешенные для загрузки расширения
$upload_allow_ext = array("jpg", "png", "jpeg", "jpe");
// максимальный размер картинки (в байтах)
View logic.py
#!/usr/bin/env python3
import sys
LOGIC_OPERATIONS = ["and", "or", "not"]
class ImaginaryVar(object):
"""Мнимая математическая переменная"""