Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Demers bdemers

View GitHub Profile
@bdemers
bdemers / TokenViewerApplication.java
Created November 18, 2020 21:33
Simple Spring Access Token Tool
View TokenViewerApplication.java
@SpringBootApplication
public class TokenViewerApplication {
public static void main(String[] args) {
SpringApplication.run(TokenViewerApplication.class, args);
}
@RestController
static class TokenController {
@bdemers
bdemers / content.md
Last active August 26, 2020 16:59
Amazon Drive Update
View content.md

Dear Customer,

We’re writing to let you know about an upcoming change that may affect how you access your content on Amazon Drive, and to help you take steps to keep your content safe.

We understand that you have used Synology Cloud Sync or Hyper Backup on Synology NAS to store information on Amazon Drive.

Amazon will discontinue access to Amazon Drive by Synology Cloud Sync and Hyper Backup starting on November 1st, 2020. Neither application will have access to Amazon Drive after November 1st, 2020, and the only way you will be able to access your stored content will be via Amazon Drive or Amazon Photos web, desktop, and mobile apps.

To ensure a smooth transition, we urge all Synology Cloud Sync and Hyper Backup users to follow these steps:

View okta.sh
#!/usr/bin/env bash
echo "RENEWED_LINEAGE: ${RENEWED_LINEAGE}"
# requires `yq` and `jq` cli tools
OKTA_API_TOKEN=$(yq --raw-output .okta.client.token ~/.okta/okta.yaml)
API_URL="${1}/api/internal/v1/custom-url-domain/certificate"
CERT=$(cat "${RENEWED_LINEAGE}/cert.pem")
KEY=$(cat "${RENEWED_LINEAGE}/privkey.pem")
CHAIN=$(cat "${RENEWED_LINEAGE}/chain.pem")
@bdemers
bdemers / README.md
Created April 20, 2020 13:52
IntelliJ Live Templates
View README.md

Preferences -> Editor -> Live Templates

@bdemers
bdemers / SomeTest.java
Last active April 10, 2020 19:45
TestNG + Mockito + PowerMock
View SomeTest.java
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.testng.PowerMockObjectFactory
import org.testng.IObjectFactory
import org.testng.annotations.ObjectFactory
import org.testng.annotations.Test
import static org.mockito.Mockito.*
import static org.powermock.api.mockito.PowerMockito.mockStatic
@PrepareForTest(AStaticClass.class)
public class SomeTest {
View KotlinConfigureMojo.java
package org.jetbrains.kotlin.maven;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import java.io.File;
@bdemers
bdemers / AppExample.java
Created October 11, 2019 17:37
Create and Parse JWTs in Java with JJWT
View AppExample.java
package com.okta.developer;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Base64;
@bdemers
bdemers / Wrapper.java
Created October 4, 2019 21:52
Wrap Beans
View Wrapper.java
@Bean
BeanPostProcessor delegateForFoo() {
return new WrappingBeanPostProcessor<>(Foo.class, original -> new MyCustomFoo(original));
}
public class WrappingBeanPostProcessor<T> implements BeanPostProcessor {
private final Class<T> type;
private final UnaryOperator<T> beanCreator;
@bdemers
bdemers / mvnwarn.zsh
Created September 30, 2019 19:56
Maven Fail On Warning
View mvnwarn.zsh
# Tested on OS X (with a bunch of gnu utils installed)
function mvnwarn {
tmp_file=$(mktemp $TMPDIR/$(uuidgen).txt)
MAVEN_OPTS="-Djansi.force=true" mvn -Dstyle.color=always $@ | tee "${tmp_file}"
exit_code=${pipestatus[1]}
if [ $exit_code -ne 0 ]; then
return 1
fi