Skip to content

Instantly share code, notes, and snippets.

View billjohnston's full-sized avatar
🥳

Bill Johnston billjohnston

🥳
View GitHub Profile
@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}" && \
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 / 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

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 / 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)
@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);
var phantom = require('node-phantom-simple');
var user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36';
var page = 'http://google.com'
phantom.create(function (phantom_err, ph) {
ph.createPage(function (page_err, page) {
page.open(page, function (open_err, status) {
page.evaluate(function(){
return navigator.userAgent;
}, function(err, result){
@billjohnston
billjohnston / .gitignore
Created January 4, 2014 00:29
Make a scheduled node process w/ heroku scheduler
.DS_Store
node_modules/
.nodemonignore
@billjohnston
billjohnston / transmit_s3_public_instructions.txt
Created March 21, 2013 16:25
Place public-read permission on all files uploaded to amazon s3 with transmit
In Transmit go to:
Transmit > Preferences > Cloud
Select default extension.
Create a new header with the following values:
Name: x-amz-acl
Value: public-read
@billjohnston
billjohnston / install_phantomjs.txt
Created March 21, 2013 16:24
Install phantomjs on ubuntu
Download phantomjs binary from http://phantomjs.org/download.html
upload to home directory (or where-ever really)
Un-tar the file with:
********************
tar xvjf phantomjs-1.6.1-linux-i686-dynamic.tar.bz2
********************