Skip to content

Instantly share code, notes, and snippets.

View slachiewicz's full-sized avatar

Sylwester Lachiewicz slachiewicz

View GitHub Profile
pkill -9 gpg-agent
source <(gpg-agent --daemon)
2020-04-01 21:14:54,418 [ 64084] ERROR - #org.jetbrains.idea.maven - IntelliJ IDEA 2019.3.4 Build #IU-193.6911.18
2020-04-01 21:14:54,419 [ 64085] ERROR - #org.jetbrains.idea.maven - JDK: 11.0.6; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o
2020-04-01 21:14:54,419 [ 64085] ERROR - #org.jetbrains.idea.maven - OS: Windows 10
2020-04-01 21:14:54,422 [ 64088] ERROR - #org.jetbrains.idea.maven - Last Action: Maven.ReimportProject
2020-04-01 21:14:56,501 [ 66167] INFO - j.ide.actions.RevealFileAction -
Exit code 1
2020-04-01 21:14:57,703 [ 67369] INFO - rationStore.ComponentStoreImpl - Saving appFileTypeManager took 16 ms, ProjectJdkTable took 15 ms
2020-04-01 21:14:57,788 [ 67454] INFO - rationStore.ComponentStoreImpl - Saving Project (name=maven, containerState=ACTIVE, componentStore=C:\projects\maven-sources\core\maven) ProjectPlainTextFileTypeManager took 15 ms, libraryTable took 16 ms
2020-04-01 21:15:52,073 [ 121739] INFO - j.ide.actions.RevealFileActio
@slachiewicz
slachiewicz / MyBenchmark.java
Created February 2, 2020 10:47 — forked from AdamStelmaszczyk/MyBenchmark.java
Should I use Java's String.format() if performance is important?
package org.sample;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.concurrent.TimeUnit;
@slachiewicz
slachiewicz / haversine.scala
Created January 14, 2020 21:34 — forked from pavlov99/haversine.scala
Spherical distance calcualtion based on latitude and longitude with Apache Spark
// Based on following links:
// http://andrew.hedges.name/experiments/haversine/
// http://www.movable-type.co.uk/scripts/latlong.html
df
.withColumn("a", pow(sin(toRadians($"destination_latitude" - $"origin_latitude") / 2), 2) + cos(toRadians($"origin_latitude")) * cos(toRadians($"destination_latitude")) * pow(sin(toRadians($"destination_longitude" - $"origin_longitude") / 2), 2))
.withColumn("distance", atan2(sqrt($"a"), sqrt(-$"a" + 1)) * 2 * 6371)
>>>
+--------------+-------------------+-------------+----------------+---------------+----------------+--------------------+---------------------+--------------------+------------------+
|origin_airport|destination_airport| origin_city|destination_city|origin_latitude|origin_longitude|destination_latitude|destination_longitude| a| distance|
@slachiewicz
slachiewicz / forex-scrape.md
Created September 5, 2019 09:49 — forked from bretton/forex-scrape.md
Scraping Forex Data

Scraping Forex Data

I was looking for ways to scrape forex data after fixer.io switched to a subscription model with rate-limiting, making their API useless for lots of queries.

1. Use an alternative API

One alternative API which is still free is https://exchangeratesapi.io/

It's basically a drop-in replacement for fixer.io and can be used to get all forex rates in json format at

@slachiewicz
slachiewicz / README.md
Created April 5, 2019 22:14 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Configuration Properties

Configuring your Service Provider through configuration properties is pretty straight forward and most configurations could be accomplished this way. The two limitations that exists are: You can only configure what is exposed as properties, obviously, and you cannot provide specific implementations or instances of the different Spring Security SAML classes/interfaces. If you need to provide custom implementations of certain types or a more dynamic configuration you'll need to use the Java DSL approach for that configuration, but as expressed before, you can configure as much as you can through properties, while using the DSL configuration for any dynamic or custom implementations configuration. You can mix the two flavors.
The following table shows all the available properties (Parsed from Spring Configuration Metadata file).

Key Default Value Description
saml.sso.default-failure-url /
@slachiewicz
slachiewicz / LocalTSA.java
Created June 28, 2018 23:22 — forked from Glamdring/LocalTSA.java
A local TSA
@Service
public class TimestampService {
private static final Logger logger = LoggerFactory.getLogger(TimestampService.class);
public static final AlgorithmIdentifier sha512oid = getSha512Oid();
private SecureRandom random = new SecureRandom();
@Value("${timestamp.keystore.path}")
private Resource keystorePath;
public class TimestampValidationService {
public boolean validate(String hash, String encodedTimestampToken) {
try {
byte[] tokenBytes = Base64.getDecoder().decode(encodedTimestampToken);
CMSSignedData signedData = new CMSSignedData(tokenBytes);
TimeStampToken token = new TimeStampToken(signedData);
Optional<X509CertificateHolder> certHolder = getCertificateHolder(signedData);
BcRSASignerInfoVerifierBuilder verifierBuilder = new BcRSASignerInfoVerifierBuilder(
new DefaultCMSSignatureAlgorithmNameGenerator(),
@slachiewicz
slachiewicz / alior-bank-kantor.user.js
Created May 13, 2018 18:01 — forked from glorpen/alior-bank-kantor.user.js
Adds password input field for LastPass on AliorBank Kantor page
// ==UserScript==
// @name AliorBank Kantor
// @namespace glorpen
// @include https://kantor.aliorbank.pl/login/password
// @version 1
// @grant none
// ==/UserScript==
var oldInput = document.getElementById("masked-password");
var input = document.createElement("input");