Skip to content

Instantly share code, notes, and snippets.

View garryyao's full-sized avatar

Garry garryyao

View GitHub Profile
@garryyao
garryyao / gist:26061ffab5a7217c011639786d4a1b0e
Created November 20, 2023 12:22
tny300_checkout_flow.json
{
"status": "Success",
"data": {
"data": {
"checkoutFlows": [
{
"brand": {
"name": "The New Yorker",
"slug": "the-new-yorker"
},
@garryyao
garryyao / pause-all-clusters.js
Created February 10, 2023 18:10
Atlas Cluster Automation Scripts
exports = async function() {
// Supply projectID and clusterNames...
const projectID = '<your Atlas project id>';
const clusterNames = ['<your cluster names>'];
// Get stored credentials...
console.log(context.values.get("AtlasPrivateKey"))
const username = context.values.get("AtlasPublicKey");
const password = context.values.get("AtlasPrivateKey");
@garryyao
garryyao / aws_sso_creds.sh
Last active January 11, 2023 11:41
export SSO temporary credentials as ENV variables
# AWS SSO Get temprory AWS credentials
# Add to your bash profile
# usage: AWS_PROFILE=<aws_profile> aws_sso_creds
aws_sso_creds() {
local account_id role_name access_token sso_region profile_region temp_creds
echo "Logging in to profile: ${AWS_PROFILE}"
aws sso login --profile ${AWS_PROFILE}
@garryyao
garryyao / apple-receipt.txt
Created October 20, 2022 12:29
Example over-sized Apple purchase receipt
MIMB8SQGCSqGSIb3DQEHAqCDAfEUMIMB8Q8CAQExCzAJBgUrDgMCGgUAMIMB4MIGCSqGSIb3DQEHAaCDAeCyBIMB4K0xgwHgqDAKAgEIAgEBBAIWADAKAgEUAgEBBAIMADALAgEBAgEBBAMCAQAwCwIBAwIBAQQDDAE3MAsCAQsCAQEEAwIBADALAgEPAgEBBAMCAQAwCwIBEAIBAQQDAgEAMAsCARkCAQEEAwIBAzAMAgEKAgEBBAQWAjQrMAwCAQ4CAQEEBAICAQAwDQIBDQIBAQQFAgMCcQAwDQIBEwIBAQQFDAMxLjAwDgIBCQIBAQQGAgRQMjU2MBgCAQQCAQIEENM+ZgDVmu05o5qDDGqzAX8wGwIBAAIBAQQTDBFQcm9kdWN0aW9uU2FuZGJveDAcAgEFAgEBBBQxwUf3oXRidId3oaVznGpx8q0MzTAeAgEMAgEBBBYWFDIwMjItMTAtMTlUMTM6MzM6MjJaMB4CARICAQEEFhYUMjAxMy0wOC0wMVQwNzowMDowMFowIQIBAgIBAQQZDBdjb20uY29uZGVuZXQuRXBpY3VyaW91czBVAgEHAgEBBE0HOx9ezVHEfTaOiszoQphSl5zjvZc40aWR5YrPCKuPH3lzTi8d2wvADMcnNYHVvCVTqLswlIYI+5K1sqHGP0falTF1tIxWQaVZcz3GEDBXAgEGAgEBBE\/5zBlNi2bAF21mHUquhDZFBgvZV4RoeAm54aB4T5fmAAhvpA7b3DPUj8lt\/Ra8FnPAaA+XbikRGZLLmXyhJEqvfukG6FoHcH+h2RrxojvhMIIBoQIBEQIBAQSCAZcxggGTMAsCAgatAgEBBAIMADALAgIGsAIBAQQCFgAwCwICBrICAQEEAgwAMAsCAgazAgEBBAIMADALAgIGtAIBAQQCDAAwCwICBrUCAQEEAgwAMAsCAga2AgEBBAIMADAMAgIGpQIBAQQDAgEBMAwCAgarAgEBBAMCAQMwDAICBq4CAQEEAwIBADAMAgIGsQ
@garryyao
garryyao / outbox.js
Created September 12, 2022 12:53
outbox db schema
const subscriptionEvent = new mongoose.Schema({
martechId: {
type: String,
required: true,
},
subscriptionId: {
type: String,
required: true,
},
clientId: {
@garryyao
garryyao / index.html
Created December 6, 2019 08:48
Coding Challenge full-stack engineer challenge // source https://jsbin.com/hovusux
<html>
<head>
<meta name="description" content="full-stack engineer challenge" />
<title>Coding Challenge</title>
<style id="jsbin-css">
body {
font-family: Arial;
font-size: 80%;
}
@garryyao
garryyao / index.js
Last active October 4, 2019 14:01
really simple SNS in javascript
const SNS = require('./sns');
const sns = new SNS();
function smsSubscriber(data) {
console.log(`send sms for transaction: ${data.transactionId}`);
return 'sms';
}
async function emailSubscriber(data) {
//await fetch('/email');
@garryyao
garryyao / findCommonNames.js
Last active September 3, 2019 10:54
find common names - design for performance
const names = ['Huey', 'Dewey', 'Louie', 'Donald', 'Launchpad'];
const moreNames = ['Donald', 'Mickey', 'Minnie', 'Goofy', 'Chip', 'Dale'];
/**
* Find common names in two arrays of names
* @param names1
* @param names2
* @returns {[]} names contained in both arrays
*/
const findCommonNames = (names1, names2) => {
This file has been truncated, but you can view the full file.
{"type":2300,"data":{"_id":"people/57698912526852117","_key":"57698912526852117","_rev":"_XxFNZIy--_","created":"2018-11-20T15:47:51.382Z","externalIds":[{"id":"55c64f6ec4e6a2d8dcde5f62","source":"fashionshow"}],"name":"Ken Downing","roles":["CELEBRITY"],"status":"active","updated":"2018-11-20T15:47:51.382Z"}}
{"type":2300,"data":{"_id":"people/57698912526855622","_key":"57698912526855622","_rev":"_XxFNZ7W--_","created":"2018-11-20T15:47:51.382Z","externalIds":[{"id":"55c64f5ac4e6a2d8dcde5aae","source":"fashionshow"}],"name":"Jesper Lund","roles":["MODEL"],"status":"active","updated":"2018-11-20T15:47:51.382Z"}}
{"type":2300,"data":{"_id":"people/57698912526844744","_key":"57698912526844744","_rev":"_XxFNQ0e--_","created":"2018-11-20T15:47:51.382Z","externalIds":[{"id":"5a934edf1a71770bab842f09","source":"fashionshow"}],"name":"Alena Podloznaya","roles":["MODEL"],"status":"active","updated":"2018-11-20T15:47:51.382Z"}}
{"type":2300,"data":{"_id":"people/57698912526854790","_key":"57698912526854790","_rev":"_X
{"indexes":[{"fields":["name"],"id":"3215362","minLength":2,"sparse":true,"type":"fulltext","unique":false},{"deduplicate":true,"fields":["name"],"id":"3215365","selectivityEstimate":1,"sparse":false,"type":"hash","unique":true},{"deduplicate":true,"fields":["status"],"id":"3215368","selectivityEstimate":1,"sparse":false,"type":"hash","unique":false},{"deduplicate":true,"fields":["roles"],"id":"3215371","selectivityEstimate":1,"sparse":false,"type":"hash","unique":false},{"deduplicate":true,"fields":["alternativeNames"],"id":"4305927","selectivityEstimate":1,"sparse":false,"type":"hash","unique":false}],"parameters":{"allowUserKeys":true,"cid":"5598711","count":0,"deleted":false,"doCompact":true,"globallyUniqueId":"h7763A8B08E5E/1300145","id":"5598711","indexBuckets":8,"indexes":[{"fields":["_key"],"id":"0","selectivityEstimate":1,"sparse":false,"type":"primary","unique":true},{"fields":["name"],"id":"3215362","minLength":2,"sparse":true,"type":"fulltext","unique":false},{"deduplicate":true,"fields":["name"],