Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Busy being amazing

Chris Neve ChrisLeNeve

💭
Busy being amazing
View GitHub Profile
View gist:c486760f4c292e532ef517fb7add8d3e
//@RunWith(SpringJUnit4ClassRunner.class) // for JUnit 4
//@ExtendWith(MockitoExtension.class) // for running with a Mockito runner. No Spring features
@ExtendWith(SpringExtension.class) // for running with a Spring runner. Loads Spring features (bean loading, etc)
@DisplayName("My test class name (JUnit 5)")
//@SpringBootTest // will load application context
public class MyTest {
// Strategy for loading one specific bean
// If not in a static inner class: needs to be imported on class with @Import
@ChrisLeNeve
ChrisLeNeve / Sudoku
Created Mar 25, 2020
Very basic sudoku solver (will not succeed beyond basic sudokus)
View Sudoku
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
class Solution {
static final int BOARD_LENGTH = 9;
public static void main(String[] args) {
@ChrisLeNeve
ChrisLeNeve / pre-commit
Last active Mar 17, 2020
git pre commit hook - blocking added accents and bad characters
View pre-commit
#!/bin/bash
echo "Checking your changes..."
#Whatever characters you want here, in the grep
if git diff --cached origin/stage *.html | grep -c 'é\|è\|ô'
then
echo "Impending doom shall be thy fate, o vilainous junior dev! Banish from thy work these monstrosities, or live to see thy kin demolished"
exit 1
@ChrisLeNeve
ChrisLeNeve / scratch_13.java
Created Nov 13, 2019
Project Euler, problem 11 finalised
View scratch_13.java
class Scratch {
static long CURRENT_MAX = Long.MIN_VALUE;
public static void main(String[] args) {
int[][] grid = setupGrid();
computeMaxProduct(grid);
System.out.println(CURRENT_MAX);
}
private static void computeMaxProduct(int[][] grid) {
@ChrisLeNeve
ChrisLeNeve / scratch_9.java
Created Oct 25, 2019
Project Euler problem 10
View scratch_9.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
class Scratch {
static final boolean COMPOSITE = false;
static final boolean PRIME = true;
public static void main(String[] args) {
@ChrisLeNeve
ChrisLeNeve / scratch_8.java
Created Oct 23, 2019
Project Euler - problem 9
View scratch_8.java
class Scratch {
public static void main(String[] args) {
Scratch s = new Scratch();
Triplet t = s.solution();
System.out.println("The triplet is: " + t.a + "," + t.b + "," + t.c);
int product = t.a * t.b * t.c;
}
private Triplet solution() {
@ChrisLeNeve
ChrisLeNeve / scratch_7.java
Created Oct 22, 2019
Project Euler, problem 8
View scratch_7.java
import java.math.BigInteger;
class Scratch {
private static String NUMBER = "73167176531330624919225119674426574742355349194934" +
"96983520312774506326239578318016984801869478851843" +
"85861560789112949495459501737958331952853208805511" +
"12540698747158523863050715693290963295227443043557" +
"66896648950445244523161731856403098711121722383113" +
"62229893423380308135336276614282806444486645238749" +
"30358907296290491560440772390713810515859307960866" +
@ChrisLeNeve
ChrisLeNeve / scratch_7.java
Created Oct 14, 2019
Project euler problem 7 - take 1
View scratch_7.java
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
class Scratch {
public static void main(String[] args) {
System.out.println(solution());
}
private static int solution() {
@ChrisLeNeve
ChrisLeNeve / scratch_6.java
Created Oct 14, 2019
Project Euler: problem 6
View scratch_6.java
class Scratch {
public static void main(String[] args) {
System.out.println(solution(10));
}
private static int solution(int max) {
int sumOfSquares = 0, sum = 0;
for (int i = 1; i <= max; i++) {
sumOfSquares += (i * i);
sum += i;
@ChrisLeNeve
ChrisLeNeve / largest_palindrome.java
Last active Oct 2, 2019
Project Euler 4: largest palindrome
View largest_palindrome.java
import java.util.TreeSet;
class Scratch {
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) {
int solution = findLargestPalindrome();
System.out.println(solution);
}
You can’t perform that action at this time.