Skip to content

Instantly share code, notes, and snippets.

@oharsta
oharsta / index.html
Created February 10, 2022 12:20
Noise example
<css-doodle click-to-update>
<style>
@grid: 80x1 / 80vmin;
@size: @rn(0, 100%, 5);
@offset: @plot(r: .5);
@random(.3) { filter: blur(2px) }
background-size: 35%;
background-image: @svg(
viewBox: 0 0 10 10;
circle {
@oharsta
oharsta / one-two-third-borders.scss
Created January 7, 2021 12:40
1/3 and 2/3 borders of a circle
$width: 70px;
.circle {
display: inline-block;
position: relative;
text-align: center;
width: $width;
height: $width;
margin-right: 20px;
@oharsta
oharsta / IntegrationTest.java
Created November 25, 2020 12:28
Create JWT for Spring Integration test for non-opaque tokens
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class IntegrationTest {
@LocalServerPort
protected int port;
@Autowired
protected ObjectMapper objectMapper;
@oharsta
oharsta / gist:7a88e3efb91f8749c6e777116a449db8
Created September 13, 2020 07:44
Ensure all annotated indexes on @document models are created in MongoDB after application startup
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.index.IndexOperations;
import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver;
import org.springframework.data.mongodb.core.mapping.Document;
@oharsta
oharsta / gist:9312a39f16cfa2ab9094afdc48210c86
Created September 12, 2020 14:20
Open unverified mac app
sudo xattr -r -d com.apple.quarantine /Applications/SomeApp/
@oharsta
oharsta / babel.config.js
Created March 28, 2020 15:56
IE11 Svelte Webpack configuration
module.exports = {
presets: [
[
'@babel/preset-env',
{
debug: true,
"corejs": 3,
"useBuiltIns": "entry",
targets: ['last 2 versions', 'ie >= 11']
}],
@oharsta
oharsta / KeyGenerator.java
Created November 26, 2019 07:53
PEM encoded RSA private key with certificate
package myconext.crypto;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.cert.CertIOException;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.OperatorCreationException;
@oharsta
oharsta / I18n.test.js
Created May 17, 2017 20:04
Verifying every I18n translation is present in all translations
import I18n from "i18n-js";
import en from "../locale/en";
import nl from "../locale/nl";
expect.extend({
toContainKey(translation, key) {
const pass = (translation[key] !== undefined);
return {
message: () => `Expected ${key} to be present in ${JSON.stringify(translation)}`,
pass: pass
@oharsta
oharsta / KeyStoreService.java
Created May 27, 2016 11:23
Add certificates and private keys to an existing or new KeyStore in Java or create a self-signed certificate and add this.
import org.apache.commons.io.IOUtils;
import sun.security.tools.keytool.CertAndKeyGen;
import sun.security.x509.X500Name;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.*;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
@oharsta
oharsta / EduGainFeedParser.java
Last active May 15, 2016 15:27
Parsing a large XML SAML feed of IdentityProviders and ServiceProviders to a Map with all Service Providers entityID's and the signing certificates
package eduproxy.saml;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.IOException;
import java.util.HashMap;