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 / gist:a2be64e76920b7b3ac0ed0b7b560587f
Last active June 10, 2024 08:16
Web changes for Kensetsu configurable stables
async subscribeOnAverageCollateralPrices(context): Promise<void> {
const { commit, state } = vaultActionContext(context);
const { collaterals, averageCollateralPriceSubscriptions } = state;
const newIds: string[] = [];
const idsToRemove: string[] = [];
// Check if there are new collateral assets or some of them were removed
// TODO Please, check - stablecoins may be different as well as collaterals
for (const collateralId in collaterals) {
if (!(collateralId in averageCollateralPriceSubscriptions)) {
newIds.push(collateralId);
@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 July 19, 2024 17:08
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>