Skip to content

Instantly share code, notes, and snippets.

View melekes's full-sized avatar

Anton Kaliaev melekes

View GitHub Profile
@melekes
melekes / bst.rs
Created December 27, 2021 09:44
BST || k_largest element
use anyhow::anyhow;
use anyhow::Result;
use std::mem::swap;
type Child = Option<Box<Node>>;
#[derive(Debug, Eq, PartialOrd, PartialEq, Clone)]
pub struct Node {
pub value: i32,
package log
import (
"fmt"
"io"
stdlog "log"
"strings"
)
type stdlibLogger struct {
@melekes
melekes / notes.md
Created February 15, 2020 08:43 — forked from calebamiles/notes.md
Notes on Open Source Governance Models

Node.js Foundation

  • Healthy Open Source
    • explicit goal to be a lightweight process
    • concrete ability to scale to hundreds of contributors
    • good fundamental goals
      • transparency
      • participation
      • efficacy
    • ecosystem projects encouraged but not required to adopt foundation governance templates
  • creation of projects under TSC explicity delegates authority from TSC to project TC
@melekes
melekes / README.md
Last active June 1, 2019 03:30
Requirements for a Tendermint client

Requirements for a Tendermint client

Broadcasting transactions

  1. An evil proposer can drop valid transactions (tendermint/tendermint#3322). To ensure tx A will be committed, the client needs to a) send it to multiple nodes b) subscribe for its result https://tendermint.com/docs/app-dev/subscribing-to-events-via-websocket.html or query the result later using /tx API endpoint (requires the tx indexer enabled) https://tendermint.com/rpc/#tx.

  2. Multiple nodes above requirement comes from a simple fact that an evil node can drop your tx.

Quering

@melekes
melekes / client.go
Created March 5, 2019 12:31
Example of using Tendermint HTTP client to subscribe for new block headers
package main
import (
"context"
"os"
"os/signal"
"syscall"
"github.com/tendermint/tendermint/libs/log"
@melekes
melekes / badger_db.go
Last active January 30, 2019 11:55
Alternative databases, which were used to benchmark Tendermint indexing
package db
import (
"bufio"
"io"
"os"
"sync"
"github.com/dgraph-io/badger"
)
@melekes
melekes / twopy.py
Last active July 21, 2017 06:04 — forked from hellosteadman/twopy.py
Add your Twitter friends' RSS feeds to a single OPML file
# -*- coding: utf-8 -*-
"""
This script requires the following Packages
1: Twitter: https://pypi.python.org/pypi/twitter
2: PyQuery: https://pypi.python.org/pypi/pyquery
3: Jinja2: https://pypi.python.org/pypi/Jinja2
It's fairly primitive but works. It uses a Jinja2 template to create an OPML
file from the RSS feeds of the websites run by the people you follow on
@melekes
melekes / upgrade_tendermint.yml
Last active April 24, 2017 20:53
Ansible playbook for upgrading Tendermint
---
- hosts: all
tasks:
- name: get version
shell: tendermint version
register: version
- name: copy and unpack binary if newer version is being installed
[Unit]
Description=Counter
Requires=network-online.target
After=network-online.target
[Service]
Environment=""
Restart=on-failure
User={{ user }}
Group={{ group }}
// addOrMax performs safe addition: if result overflows, it returns MaxUint64
func addOrMax(accum, value uint64) uint64 {
if (accum + value) < accum {
return math.MaxUint64
} else {
return accum + value
}
}
// subOrZero performs safe subtraction: if result underflows, it returns 0