Skip to content

Instantly share code, notes, and snippets.

View billjohnston's full-sized avatar
🥳

Bill Johnston billjohnston

🥳
View GitHub Profile
@billjohnston
billjohnston / resource-directives.js
Created January 12, 2015 17:14
Old version of Resource Directives
var resourceDirectives = angular.module('resourceDirectives', ['ui.bootstrap']);
var head = angular.element(document.querySelector('head'));
head.prepend('<style> .rd_loading .rd_text{visibility: hidden;} .rd_loading .rd_spinner{display: block;} .rd_loading .rd_spinner{display: block;} .rd_spinner{display: none;} .rd_spinner .fa{vertical-align: top;} .rd_position-relative{position: relative;} .rd_absolute-center{position: absolute; margin: auto; text-align: center; top:0; left:0; right:0; bottom:0; width: 1em; height: 1em;}</style>');
resourceDirectives.factory('interpolate_url', [
'resourceDirectivesConfig', '$location',
function(resourceDirectivesConfig, $location){
return function(url, params, data){
var match = url.match(/(\:[a-zA-Z_-]*)/g);
@billjohnston
billjohnston / mockFileUpload.js
Last active May 3, 2017 17:17
Mock a file input onChange event for testing
export default const mockFileUpload = (fileInput, fileUrl) => new Promise((resolve, reject) => {
try {
const xhr = new XMLHttpRequest()
xhr.open('GET', fileUrl, true)
xhr.responseType = 'blob'
xhr.onload = (e) => {
if (xhr.status == 200) {
fileInput.files[0] = xhr.response
const mockEvent = document.createEvent('HTMLEvents')
mockEvent.initEvent('change', true, true)

Keybase proof

I hereby claim:

  • I am billjohnston on github.
  • I am billjohnston (https://keybase.io/billjohnston) on keybase.
  • I have a public key ASDrLwq-EnNNKKrHznxvjUR_jGFbW3Tb7TQEyQPNDJJzXQo

To claim this, I am signing this object:

@billjohnston
billjohnston / curl.sh
Created March 2, 2021 19:16
webhookrelay debug
curl https://1zfeu833kgom8kvdororgg.hooks.webhookrelay.com -X POST
curl https://my.webhookrelay.com/v1/webhooks/0d970bf0-9c84-440a-8013-6835287e6c7b -X POST
import * as jsonwebtoken from 'jsonwebtoken'
import jwkToPem from 'jwk-to-pem'
import nodeAjax from 'lambdas/util/nodeAjax'
import { HttpMethod } from 'types'
import { Middleware } from 'lambda-api'
import {
cognitoUserPoolId,
cognitoUserPoolClientId,
region,
} from 'lambdas/functions/restApi/envVars'
@billjohnston
billjohnston / import_csv.sh
Last active June 28, 2021 20:27
Cognito CSV user import
IMPORT_NAME="cognito_import_test"
CSV_PATH="/full/path/to/importTest.csv"
USER_POOL_ID="asdfasdfasdf"
CLOUDWATCH_ROLE_ARN="arn:aws:iam::469973828956:role/CognitoStack-CognitoImportRole95D37A15-20RNO02KSGD5"
REGION="us-east-1"
JOB_DETAILS=$(aws cognito-idp create-user-import-job --job-name "${IMPORT_NAME}" --user-pool-id "${USER_POOL_ID}" --cloud-watch-logs-role-arn "${CLOUDWATCH_ROLE_ARN}" --region "${REGION}" --profile CognitoService) && \
PRE_SIGNED_URL=$(jq -r '.UserImportJob.PreSignedUrl' <<< "${JOB_DETAILS}") && \
JOB_ID=$(jq -r '.UserImportJob.JobId' <<< "${JOB_DETAILS}") && \
curl -v -T "${CSV_PATH}" -H "x-amz-server-side-encryption:aws:kms" "${PRE_SIGNED_URL}" && \