Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Alexey-N-Chernyshov's full-sized avatar

Alexey Alexey-N-Chernyshov

  • Soramitsu
  • Innopolis
View GitHub Profile
@Alexey-N-Chernyshov
Alexey-N-Chernyshov / test.kt
Created August 16, 2018 12:26
Quorum example in Iroha
@Test
fun testQuorum() {
var keypair1 = ModelCrypto().generateKeypair()
var keypair2 = ModelCrypto().generateKeypair()
var txBuilder = ModelUtil.getModelTransactionBuilder()
var tx = txBuilder
.createdTime(ModelUtil.getCurrentTime())
.creatorAccountId("test@notary")
.createAccount("multisig", "notary", keypair1.publicKey())
.appendRole("multisig@notary", "tester")
@Alexey-N-Chernyshov
Alexey-N-Chernyshov / gist:6d5199ca89e77a09da51720094157d46
Created January 15, 2018 12:22
Inplace visitor for boost::variant
/**
* Inplace visitor for boost::variant.
* Usage:
* boost::variant<int, std::string> value = "1234";
* ...
* visit_in_place(value,
* [](int v) { std::cout << "(int)" << v; },
* [](std::string v) { std::cout << "(string)" << v;}
* );
*/
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadLocalRandom;
public class DiningPhilosophers {
static int philosophersNumber = 5;
static Philosopher philosophers[] = new Philosopher[philosophersNumber];
static Fork forks[] = new Fork[philosophersNumber];
static class Fork {
@Alexey-N-Chernyshov
Alexey-N-Chernyshov / main.c
Last active July 4, 2016 10:32
IPC via lseek
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
int main() {
@Alexey-N-Chernyshov
Alexey-N-Chernyshov / main.c
Created June 12, 2016 18:23
C struct allignment.
#include <stdio.h>
#include <stddef.h>
struct foo {
short a;
int b;
char c;
};
int main(void) {
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package adjacencylistgraph;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
//the third line for search
inStr = in.nextLine().trim().split(" ");
for (String str : inStr) {
if (!str.isEmpty()) {
AVLTree.Node node = tree.find(Integer.parseInt(str)).right;
out.print((node == null ? "null" : node.value) + " ");
System.out.print((node == null ? "null" : node.value) + " ");
}
}
//the second line for search
inStr = in.nextLine().trim().split(" ");
for (String str : inStr) {
if (!str.isEmpty()) {
RBTree.Node node = tree.find(Integer.parseInt(str));
node = node == null ? null : node.right;
out.print((node == null ? "null" : node.value) + " ");
System.out.print((node == null ? "null" : node.value) + " ");
}
}
@Alexey-N-Chernyshov
Alexey-N-Chernyshov / client.c
Last active April 22, 2024 09:41
Example of client/server with select().
// Simple example of client.
// Client prints received messages to stdout and sends from stdin.
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/select.h>
#include <netinet/in.h>
@Alexey-N-Chernyshov
Alexey-N-Chernyshov / sieve_of_eratosthenes.py
Created November 15, 2012 14:56
Решето Эратосфена на Python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
n = input("Вывод простых чисел до числа (включительно): ") + 1
# Выписать подряд все целые числа от 2 до n (2, 3, 4, …, n).
a = [True] * n