Skip to content

Instantly share code, notes, and snippets.

View shai-almog's full-sized avatar

Shai Almog shai-almog

View GitHub Profile
@shai-almog
shai-almog / Error.txt
Created February 25, 2023 11:11
Maven vs. Gradle in Spring Boot
A problem occurred configuring root project 'wordle'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.3.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.3
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.3 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.3 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11
- Other compatible att
Feature VS Code Comments Links
Breakpoint Video, Post
Conditional Breakpoint Video, Post
Logpoint/Tracepoint Video, Post
Step Over Video, Post
Step Into Video, Post
Step Out Video, Post
Continue Video, Post
Run to Cursor Video, Post
Return Immediately Restart Frame is available Video, Post
@shai-almog
shai-almog / valid-words.txt
Created January 30, 2023 03:30
List of all the valid words for WORDLE
aahed
aalii
aargh
aarti
abaca
abaci
aback
abacs
abaft
abaka
@shai-almog
shai-almog / Main.java
Created January 16, 2023 11:03
A trivial command line wordle game with no real dictionary
import java.util.Scanner;
public class Main {
private static final String WORD = "LYMPH";
private static final String[] DICTIONARY = {"CRATE", "USING", "LYMPH", "LUMPS", "LOOMS"};
public static void main(String[] args) {
System.out.println("Write a guess:");
Scanner scanner = new Scanner(System.in);
int attempts = 0;
for(String line = scanner.nextLine() ; line != null ; line = scanner.nextLine()) {
public static void main(String[] argv) throws InterruptedException {
Executors.newVirtualThreadPerTaskExecutor().
execute(() -> {
System.out.print("StringList: " + stringList);
});
stringList = List.of("ZZ", "XX", "LL", "DDD");
}
@shai-almog
shai-almog / Main.java
Created December 11, 2022 16:15
One loop outperforms two
public class Main {
private static final int SIZE = 5_000_000;
private static final int[] arr1 = initArray(SIZE);
private static final int[] arr2 = initArray(SIZE);
public static void main(String[] args) throws InterruptedException {
// warmup
long[] results = new long[6];
results[0] = twoLoops();
results[1] = oneLoop();
@shai-almog
shai-almog / prime-app.js
Created October 19, 2021 11:58
Prime number calculator used as part of a debugging tutorial on talktotheduck.dev
const MAX_NUMBER = 10 ** 9;
let cnt = 0
function isPrime(num) {
if (num === 2) {
return true;
}
if (num < 2 || num % 2 === 0) {
return false;
}
@shai-almog
shai-almog / prime_main.py
Created October 19, 2021 09:00
Prime number calculator used as part of a debugging tutorial on talktotheduck.dev
import math
import time
import six
if six.PY2:
# In python2, range returns a list instead of an iterator. When running on a large range,
# this can take up all of the available memory and crash the process.
range = xrange
@shai-almog
shai-almog / PrimeMainComplex.kt
Created October 19, 2021 08:58
Prime number calculator used as part of a debugging tutorial on talktotheduck.dev
import kotlin.math.pow
object PrimeMainComplex {
class PrimeChecker(i: Int) {
companion object { var zero = 0 }
var num = 0
var self: PrimeChecker
init {
@shai-almog
shai-almog / PrimeMainMR.java
Created October 19, 2021 08:56
Prime number calculator used as part of a debugging tutorial on talktotheduck.dev
import java.math.BigInteger;
public class PrimeMainMR {
public static int cnt = 0;
// this is the RabinMiller test, deterministically correct for n < 341,550,071,728,321
// http://rosettacode.org/wiki/Miller-Rabin_primality_test#Python:_Proved_correct_up_to_large_N
public static boolean isPrime(BigInteger n, int precision) {
if (n.compareTo(new BigInteger("341550071728321")) >= 0) {