Skip to content

Instantly share code, notes, and snippets.


Brian Demers bdemers

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

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:

#!/usr/bin/env bash
# requires `yq` and `jq` cli tools
OKTA_API_TOKEN=$(yq --raw-output .okta.client.token ~/.okta/okta.yaml)
CERT=$(cat "${RENEWED_LINEAGE}/cert.pem")
KEY=$(cat "${RENEWED_LINEAGE}/privkey.pem")
CHAIN=$(cat "${RENEWED_LINEAGE}/chain.pem")
bdemers /
Created April 20, 2020 13:52
IntelliJ Live Templates

Preferences -> Editor -> Live Templates

bdemers /
Last active April 10, 2020 19:45
TestNG + Mockito + PowerMock
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
public class SomeTest {
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;
bdemers /
Created October 11, 2019 17:37
Create and Parse JWTs in Java with JJWT
package com.okta.developer;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Base64;
bdemers /
Created October 4, 2019 21:52
Wrap Beans
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 / 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}"
if [ $exit_code -ne 0 ]; then
return 1