This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void deleteDirRecursively(File dir) { | |
File[] children = dir.listFiles(); | |
for (File child : children) { | |
if (child.isDirectory()) { | |
deleteDirRecursively(child); | |
} else { | |
child.delete(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public static void main(String[] args) { | |
for (int x = 2; x <= 6; x += 4) { | |
for (int y = 1; y <= 9; y++) { | |
for (int z = x; z <= x + 3; z++) { | |
System.out.print(String.format("%d * %d = %-2d ", z, y, y * z)); | |
} | |
System.out.println(); | |
} | |
System.out.println(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="score"> | |
score: <span class="score_val">0</span> | |
</div> | |
<div class="canvas-wrapper"> | |
<canvas width="400" height="400"></canvas> | |
</div> | |
<div class="controls"> | |
<button class="btn-start">Start</button> | |
<button class="btn-pause">Pause</button> |