Skip to content

Instantly share code, notes, and snippets.

@jwicks
jwicks / cognito-login.js
Last active February 2, 2018 22:00
Node.js CLI script to login a Cognito user and print JWT tokens
/**
* Logs the user into the specified Cognito User Pool and prints out JWT tokens
* @example
* $ node cognito-login.js username="john.doe" password="j0hn.d0e" user-pool-id="us-east-1_Xxxxxxxx" app-client-id="2axxyyxxyxxxyyxxxyy"
* {
* "accessToken": "eyJra...aQ",
* "identityToken": "eyJra...iA",
* "refreshToken": "eyJj...Wg"
* }
*/
@jwicks
jwicks / sidekiq-worker-cloudwatch-queue-size.rb
Last active November 21, 2019 07:14
Sidekiq worker for publishing queue size metric to AWS CloudWatch
class QueueSizeMetricWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { minutely }
sidekiq_options retry: false
# Publish a custom metric on CloudWatch with the Sidekiq queue size
def perform
cloudwatch = Aws::CloudWatch::Client.new(