Skip to content

Instantly share code, notes, and snippets.

View wvanderdeijl's full-sized avatar

Wilfred van der Deijl wvanderdeijl

View GitHub Profile
@wvanderdeijl
wvanderdeijl / JacocoReporter.java
Last active September 23, 2015 11:13
JacocoReporter to write a HTML report from a Jacoco execution data file
package org.adfemg.datacontrol.view.uitest;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@wvanderdeijl
wvanderdeijl / JacocoRule.java
Last active December 7, 2023 15:35
JUnit Rule to write Jacoco execution data file after each test for application under test running on a (remote) container
package org.adfemg.datacontrol.view.uitest;
import java.io.IOException;
import java.net.ConnectException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Logger;
@wvanderdeijl
wvanderdeijl / PerceptualDiffMatcher.java
Last active October 8, 2015 13:07
Hamcrest matcher to take a screenshot from a running selenium WebDriver and compare it to a known good * "reference image". One of the advancement we still need is to inject custom css (or js) before taking a screenshot to cover dynamic elements that should not fail the test (like a stock ticker or weather report)
package com.redheap.test.perceptual;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
@wvanderdeijl
wvanderdeijl / ConstructOnce.ts
Created April 11, 2017 09:38
Decorators to allow angular controller subclasses without knowing anything about dependencies of base class
/**
* decorator especially for BaseController to block second call to its constructor. The constructor is invoked twice due to the
* trickery in the Controller decorator on any subclass of BaseController. The writer of that subclass will invoke
* `super()` in its constructor but we have to ignore this call to BaseController as the Controller decorator has already invoked
* BaseController with the required dependencies.
*/
function ConstructOnce(): ClassDecorator {
return (c: ControllerConstructor) => {
const wrapped = function (this: BaseController, ...args: any[]) {
// only invoke constructor the first time, and ignore second (no-arg) call
@wvanderdeijl
wvanderdeijl / string-date-adapter.ts
Created September 16, 2017 07:57
Rough version of an string based ISO DateAdapter for Angular Material 2
import { DateAdapter } from '@angular/material';
// import { Optional, Inject } from '@angular/core';
const MONTH_NAMES = {
'long': [
'Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'
],
'short': ['Jan', 'Feb', 'Mrt', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'],
'narrow': ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D']
};
@wvanderdeijl
wvanderdeijl / GIT-MERGED.md
Last active April 7, 2021 05:51
Clean up merged git branches

To get list of merged branches:

git branch --merged develop
git branch --merged master

To delete all merged branches while asking approval for each branch: (be careful not to delete important branches like develop, staging or master)

git branch --merged develop | xargs -n 1 -p git branch -d
@wvanderdeijl
wvanderdeijl / get-credentials.sh
Created March 30, 2021 14:42
Temporary AWS credentials from AWS Cognito Identity Pool (using Cognito User Pool)
export USR=xxxxxxxx
export PWD=xxxxxxxx
export COGNITO_CLIENT_ID=40qxxxxxxxxxxxxxxxxxxxxn40
# 12 digit numeric AWS account id
export AWS_ACCOUNT_ID=765000000630
export AWS_REGION=eu-central-1
export IDENTITY_POOL_GUID=e14xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxd89
export USER_POOL_ID=eu-central-1_oYTxxxxov
# sign in with username/password
@wvanderdeijl
wvanderdeijl / aws-client.ts
Created May 31, 2021 20:05
Showcasing Google Cloud Workload Identity Federation from AWS using google-auth-library and nodejs client libraries
import { AssumeRoleCommand, STSClient } from '@aws-sdk/client-sts';
import { Resource } from '@google-cloud/resource-manager';
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
const AWS_REGION = 'eu-west-1';
const AWS_ROLE_ARN = 'arn:aws:iam::999999999999:role/my-federated-role';
const GCP_PROJECT_ID = 'my-google-project';
const GCP_IDENTITY_PROVIDER = '//iam.googleapis.com/projects/PROJECTNUMBER/locations/global/workloadIdentityPools/POOL-ID/providers/PROVIDER-ID';
const GCP_SERVICE_ACCOUNT = 'ID@PROJECT.iam.gserviceaccount.com';
@wvanderdeijl
wvanderdeijl / aws-raw.ts
Created May 31, 2021 20:08
Showcasing Google Cloud Workload Identity Federation from AWS using raw http requests
import { Sha256 } from '@aws-crypto/sha256-universal'; // or @aws-crypto/sha256-js
import { AssumeRoleCommand, STSClient } from '@aws-sdk/client-sts';
import { SignatureV4 } from '@aws-sdk/signature-v4';
import axios from 'axios';
const AWS_REGION = 'eu-west-1';
const AWS_ROLE_ARN = 'arn:aws:iam::999999999999:role/my-federated-role';
const GCP_IDENTITY_PROVIDER = '//iam.googleapis.com/projects/PROJECTNR/locations/global/workloadIdentityPools/POOL-ID/providers/PROVIDER-ID';
const GCP_SERVICE_ACCOUNT = 'ID@PROJECT.iam.gserviceaccount.com';
@wvanderdeijl
wvanderdeijl / gcp-key-wrapping.md
Last active June 10, 2021 08:49
Google key wrapping

Task 1. Creating the encryption key

Important: When using customer-supplied encryption keys, it is up to you to generate and manage your encryption keys. You must provide Compute Engine a key that is a 256-bit string encoded in RFC 4648 standard base64. For this lab, you will just generate a key with a random number.

  1. On the Google Cloud Platform menu, click Activate Cloud Shell to open Cloud Shell. If prompted, click Continue.
  2. Enter the following single command in Cloud Shell to create a 256 bit (32 byte) random number to use as a key:
openssl rand 32 > mykey.txt
  1. View the mykey.txt to verify the key was created: