Skip to content

Instantly share code, notes, and snippets.

View prianichnikov's full-sized avatar

Maksim Prianichnikov prianichnikov

View GitHub Profile
@prianichnikov
prianichnikov / Solution.java
Created November 14, 2023 12:24
Find correct brackets
import java.util.EmptyStackException;
import java.util.Map;
import java.util.Stack;
public class Solution {
public static void main(String[] args) {
System.out.println(isCorrectBrackets("[{}]"));
System.out.println(isCorrectBrackets("[{]}"));
System.out.println(isCorrectBrackets("[{}{}{}{}]"));
@prianichnikov
prianichnikov / Solution.java
Created November 8, 2023 15:03
Thrilling Teleporters game
/*
We are developing a new board game, Thrilling Teleporters.
The board consists of consecutive squares from 0 to last_square, some of the spaces also contain Teleporters, which are given as comma delimited strings "from,to".
The game is played as follows:
1. Each turn, the player rolls a die numbered from 1 to die_sides.
2. The player moves forward the rolled number of squares.
3. The player stops at last_square if they reach it.
4. If the player finishes on a square with a teleporter, they are moved to where the teleporter points.
@prianichnikov
prianichnikov / Solution.java
Created November 7, 2023 14:41
Technical interview task
/*
We have a two-dimensional board game involving snakes. The board has two types of squares on it: +'s represent
impassable squares where snakes cannot go, and 0's represent squares through which snakes can move.
Snakes can only enter on the edges of the board, and each snake can move in only one direction.
We'd like to find the places where a snake can pass through the entire board, moving in a straight line.
Here is an example board:
col--> 0 1 2 3 4 5 6
+----------------------
/*
Longest Common Prefix
Example 1:
Input: strs = ["flower","flow","flight"]
Output: "fl"
Example 2:
Input: strs = ["dog","racecar","car"]
Output: ""
@prianichnikov
prianichnikov / Algo_MovingAverage.java
Last active June 27, 2023 15:21
Moving average implementation
public class MovingAverage {
private final int[] array;
private int index;
private long sum;
public MovingAverage(int size) {
this.array = new int[size];
this.index = 0;
}
@prianichnikov
prianichnikov / check-internet-speed.txt
Last active November 16, 2023 06:57
Check internet speed
# iperf3 server start
iperf3 -s
# standard client check from client to server
iperf3 -t 30 -c <IP>
# reverse client check from server to client
iperf3 -t 30 -R -c <IP>
# public iperf servers
[Unit]
Description=SoftEther VPN Server
After=network.target auditd.service
ConditionPathExists=!/opt/vpnserver/do_not_run
[Service]
Type=forking
EnvironmentFile=-/opt/vpnserver
ExecStart=/opt/vpnserver/vpnserver start
ExecStartPost=/bin/sleep 3s
cd /opt/vpnserver
# Создаем новый tap-интерфейс, где:
# VPN - название созданного хаба,
# /DEVICE - часть названия tap-интерфейса, которое будет добсавлено к "tap_"
./vpncmd localhost:5555 /SERVER /CMD BridgeCreate VPN /DEVICE:vpn /TAP:yes
# Проверяем ново-созданный интерфейс
# Status должен быть "Operating"
./vpncmd localhost:5555 /SERVER /CMD BridgeList
cd /opt/vpnserver/
# Включение SecureNat
./vpncmd localhost:5555 /SERVER /HUB:VPN /CMD SecureNatEnable
# Установка mac адреса, ip адреса и маски хаба, где:
# /IP - ip-адрес вируального роутера хаба
# /MASK - его маска
# /MAC - MAC-адрес
./vpncmd localhost:5555 /SERVER /HUB:VPN /CMD SecureNatHostSet /MAC:00-11-22-33-44-55 /IP:192.168.234.1 /MASK:255.255.255.0
cd /opt/vpnserver/
# Проверка сервера
./vpncmd /TOOLS /CMD Check
# Отключение Keep Alive Internet Connection
./vpncmd localhost:5555 /SERVER /CMD KeepDisable
# Выбор более устойчивого алгоримта шифрования чем установлен по умолчанию
./vpncmd localhost:5555 /SERVER /CMD ServerCipherSet AES256-SHA