Skip to content

Instantly share code, notes, and snippets.

View volyx's full-sized avatar

Dmitrii Volykhin volyx

View GitHub Profile
@volyx
volyx / main.rs
Created March 17, 2022 16:21
RorateRighr
fn main() {
let mut matrix: Vec<Vec<i32>> = Vec::new();
let s : String = " 1 2 3\n 4 5 6\n 7 8 9".to_string();
for line in s.lines() {
let mut row : Vec<i32> = Vec::new();
for val in line.split_whitespace() {
//import 'dart:html';
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:provider/provider.dart';
import 'package:wndlust_flutter/notifier/story_change_notifier.dart';
import 'package:wndlust_flutter/notifier/user_change_notifier.dart';
import 'package:wndlust_flutter/api.dart';
@volyx
volyx / ParseRSAKeys.java
Created April 14, 2020 17:39 — forked from destan/ParseRSAKeys.java
Parse RSA public and private key pair from string in Java
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import static org.bson.assertions.Assertions.notNull;
final class Either<L, R> {
public static <L, R> Either<L, R> left(final L value) {
return new Either<>(notNull("value", value), null);
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class Test {
private static final AtomicInteger poolNumber = new AtomicInteger(1);
private static final AtomicInteger threadNumber = new AtomicInteger(1);
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpMethod;
import com.linecorp.armeria.common.grpc.GrpcSerializationFormats;
import com.linecorp.armeria.common.grpc.protocol.GrpcHeaderNames;
import com.linecorp.armeria.server.HttpServiceWithRoutes;
import com.linecorp.armeria.server.Server;
import com.linecorp.armeria.server.cors.CorsServiceBuilder;
import com.linecorp.armeria.server.docs.DocServiceBuilder;
import com.linecorp.armeria.server.docs.DocServiceFilter;
@volyx
volyx / ParallelSuite.java
Created November 10, 2019 09:06 — forked from mustafau/ParallelSuite.java
Parallelize JUnit test suites.
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
import org.junit.runners.model.RunnerScheduler;
public class ParallelSuite extends Suite {
@volyx
volyx / ParallelParameterized.java
Created November 10, 2019 09:05 — forked from mustafau/ParallelParameterized.java
Parallelize JUnit parameterized tests.
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.runners.Parameterized;
import org.junit.runners.model.RunnerScheduler;
public class ParallelParameterized extends Parameterized {
public ParallelParameterized(Class<?> arg0) throws Throwable {
@volyx
volyx / templateReplace.java
Last active January 16, 2018 11:16
Fully extendable java html template engine
// regex for uri template pattern
public static Pattern TEMPLATE_PATTERN = Pattern.compile("\\{(.*?)\\}");
public static String templateReplace(String template,
Map<String, Object> properties) {
String result = template;
try {
if (template != null && template.contains("{")
&& template.contains("}")) {
Matcher m = TEMPLATE_PATTERN.matcher(template);
@Grapes([
@Grab('io.ratpack:ratpack-groovy:1.5.0-rc-2'),
@Grab('org.slf4j:slf4j-simple:1.7.25')
])
import static ratpack.groovy.Groovy.ratpack
import ratpack.jackson.*;
class User {
String name;
String surname;