This file contains hidden or 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.sql.Connection; | |
import java.sql.SQLException; | |
import mockit.Expectations; | |
import mockit.Mocked; | |
import mockit.NonStrictExpectations; | |
import org.junit.Ignore; | |
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.fail; |
This file contains hidden or 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 org.springframework.boot.CommandLineRunner; | |
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.context.annotation.FilterType; | |
@Configuration | |
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = CommandLineRunner.class)) | |
@EnableAutoConfiguration | |
public class TestApplicationConfiguration { |
This file contains hidden or 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
/** Rounds a double value to a specified number of decimal places. */ | |
public static double round(double value, int scale) { | |
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue(); | |
} |
This file contains hidden or 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.File; | |
import java.io.IOException; | |
import java.io.RandomAccessFile; | |
import java.nio.MappedByteBuffer; | |
import java.nio.channels.FileChannel; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.rules.TemporaryFolder; | |
import static org.junit.Assert.assertEquals; |
This file contains hidden or 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 util.graphics; | |
import java.awt.Color; | |
import java.awt.Dimension; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.SwingUtilities; | |
import javax.swing.WindowConstants; |
This file contains hidden or 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 org.junit.Test; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
public class StackOverflowSearchExample { | |
@Test |
This file contains hidden or 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 org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class DuplicateLogging { | |
private static final Logger logger = LoggerFactory.getLogger(DuplicateLogging.class); | |
public static void main(String[] args) throws IOException, InterruptedException { |
This file contains hidden or 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 static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | |
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; | |
import static com.github.tomakehurst.wiremock.client.WireMock.get; | |
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; | |
import static org.junit.Assert.assertEquals; | |
import wiremock.org.apache.http.client.utils.URIBuilder; | |
import java.net.URI; | |
import java.net.URISyntaxException; |
This file contains hidden or 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.time.Instant; | |
import org.threeten.extra.Interval; | |
import com.fasterxml.jackson.annotation.JsonAutoDetect; | |
import com.fasterxml.jackson.annotation.JsonCreator; | |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
// Exclude JavaBean properties that are not part of the state |
This file contains hidden or 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
-- a^0 mod b is 1. Once we find the next power with a remainder of 1, the remainders will repeat. | |
-- Take from a list until the first element repeats | |
takeUntilFirstRepeats (x:xs) = x : takeWhile (/= x) xs | |
remaindersOfPowers a b = takeUntilFirstRepeats [a^i `mod` b | i <- [0..]] | |
-- Example | |
remaindersOfPowers 9 7 |