Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Thinking

ram0973 ram0973

:octocat:
Thinking
  • Russia
  • Naberezhnye Chelny
  • Twitter @ram0973
View GitHub Profile
@ram0973
ram0973 / tokens.md
Created Apr 26, 2021 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication
View tokens.md

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
View Sum.java
package com.javarush.task.task04.task0442;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
int number = 0;
@ram0973
ram0973 / Main.java
Last active Mar 14, 2021
Java Mockito example
View Main.java
// Let's consider an example. UsdConverter class is responsible for converting local currency to USD (United States dollar).
// The test should check the behavior of the tested unit in isolation from its dependencies.
// As the exchange rate varies with time, UsdConverter uses ExchangeRateService to get the latest updates.
// Moreover, getUsd method of a live ExchangeRateService can send a request over HTTP to get the actual exchange rate,
// which is difficult to reproduce in the test environment.
// Mockito allows us to avoid those difficulties and provides an API for creating empty objects and managing behavior.
// Note: here we use BigDecimal since financial transactions need high accuracy:
public class UsdConverter {
@ram0973
ram0973 / Words.java
Created Feb 25, 2021
Java count most 10 frequent words in text
View Words.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.function.Function.identity;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
@ram0973
ram0973 / hell.java
Created Feb 21, 2021
Фабрика фабрик
View hell.java
class TestDrive {
public static void main(String[] args) throws InterruptedException {
BurgerStore mcDonalds = new McDonStore();
BurgerStore burgerKing = new BurgerKingStore();
Burger burger;
System.out.println("-Hello, one McDonalds style cheeseburger");
System.out.println("-Okay! Please wait for a sec, -Calling to the McDonaldsStore. -Cheeseburger");
burger = mcDonalds.orderBurger(Burger.CHEESE);
@ram0973
ram0973 / deleteDirRecursively.java
Created Jan 31, 2021
deleteDirRecursively in Java
View deleteDirRecursively.java
public void deleteDirRecursively(File dir) {
File[] children = dir.listFiles();
for (File child : children) {
if (child.isDirectory()) {
deleteDirRecursively(child);
} else {
child.delete();
}
}
@ram0973
ram0973 / Main.java
Created Jan 31, 2021
Deepest file or directory
View Main.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
class Main {
public static void main(String[] args) throws IOException {
Path longestPath = Files.walk(Paths.get("D:\\Downloads\\basedir"))
.max(Comparator.comparingInt(Path::getNameCount)).orElseThrow(NullPointerException::new);
@ram0973
ram0973 / Main.java
Last active Mar 8, 2021
Как получить список живых нитей из группы ThreadGroup? Как получить список мертвых нитей из группы ThreadGroup?
View Main.java
package com.examples;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Main {
public static List<Thread> threads = new ArrayList<>();
public static void main(String[] args) throws InterruptedException {
Random random = new Random();
@ram0973
ram0973 / a-infinality-w10-config.sh
Created May 18, 2020 — forked from sorenvonsarvort/a-infinality-w10-config.sh
Windows 10-like font rendering config for Linux
View a-infinality-w10-config.sh
# make sure You have installed the infinality patches
export INFINALITY_FT_FILTER_PARAMS="8 17 50 17 8"
export INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH="0"
export INFINALITY_FT_FRINGE_FILTER_STRENGTH="55"
export INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH="0"
export INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH="0"
export INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="20"
export INFINALITY_FT_CHROMEOS_STYLE_SHARPENING_STRENGTH="0"
export INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"
View fix-wsl2-dns-resolution
1. Create a file: /etc/wsl.conf.
2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away
[network]
generateResolvConf = false
3. In a cmd window, run wsl --shutdown
4. Restart WSL2
5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
6. Put the following line in the file