This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _create_react_component | |
if test (count $argv) -lt 1 | |
read -l -P "Name of component? " component | |
_create_react_component $component | |
else | |
set cmp $argv[1] | |
mkdir -p components/$cmp | |
echo " | |
import React from 'react' | |
import styles from './$cmp.module.css' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const xlsx = require('xlsx') | |
module.exports = function parseWorkbook(file) { | |
const result = {} | |
console.info(`Parsing workbook ${file}`) | |
const wb = xlsx.readFile(file) | |
if (!wb.SheetNames.length) throw new Error('Invalid workbook, no sheets available.') | |
const extractDataWithHeaders = (data = {}) => { | |
const result = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(N) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
return parseInt(N >>> 0).toString(2).split('1').reduce((acc, value, index, self) => value.length > acc ? (typeof self[index + 1] === 'string' ? value.length : acc) : acc, 0) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/pages/_app.js | |
import { Amplify, Auth } from 'aws-amplify' | |
import { | |
AmplifyAuthenticator, | |
AmplifySignUp, | |
AmplifySignIn, | |
AmplifySignOut, | |
} from '@aws-amplify/ui-react' | |
import config from '../aws-exports.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# .git/hooks/post-checkout | |
# Utility to change AWS Amplify environments on branch checkout | |
# helper to get path to aws-exports.js | |
function get_aws_exports_path { | |
local AMPLIFY_PROJECT_CONFIG_PATH="amplify/.config/project-config.json" | |
local AMPLIFY_EXPORTS_PATH=$(jq -r '.javascript.config.SourceDir' $AMPLIFY_PROJECT_CONFIG_PATH) | |
if [[ "$AMPLIFY_EXPORTS_PATH" == */ ]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LambdaClient, InvokeCommand } from '@aws-sdk/client-lambda' | |
/** | |
* Invoke our Lambda function with a payload | |
* @param {Object.<string, any>} payload | |
* @returns {Promise<import('@aws-sdk/client-lambda').InvokeCommandOutput>} | |
*/ | |
async function invoke(payload) { | |
/** @type {import('@aws-sdk/client-lambda').LambdaClient} */ | |
const client = new LambdaClient({ region: process.env.REGION }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
IFS='|' | |
AMPLIFY_ENVIRONMENT='dev' | |
AWS_REGION='us-east-1' | |
AWSCLOUDFORMATIONCONFIG="{\ | |
\"configLevel\":\"project\",\ | |
\"useProfile\":true,\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getDateFromEpoch = epoch => { | |
let date = new Date(0) | |
date.setUTCSeconds(epoch) | |
return date | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto from '@aws-crypto/sha256-js' | |
import { defaultProvider } from '@aws-sdk/credential-provider-node' | |
import { SignatureV4 } from '@aws-sdk/signature-v4' | |
import { HttpRequest } from '@aws-sdk/protocol-http' | |
import { default as fetch, Request } from 'node-fetch' | |
const { Sha256 } = crypto | |
const AWS_REGION = process.env.AWS_REGION || 'us-east-1' | |
const QUERY_LIST_USERS = /* GraphQL */ ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SNSClient, PublishCommand } from '@aws-sdk/client-sns' | |
const client = new SNSClient() | |
/** | |
* Publish a message to a phone number | |
* @param {string} number - phone number of recipient | |
* @param {string} [message] - message to send to phone number | |
* @returns {import('@aws-sdk/client-sns').PublishCommandOutput} | |
*/ | |
async function publish(number, message) { |