Skip to content

Instantly share code, notes, and snippets.

View mtliendo's full-sized avatar
🦦
Living that sweet otter life!

Michael Liendo mtliendo

🦦
Living that sweet otter life!
View GitHub Profile
@mtliendo
mtliendo / multi-env-backend-deploy-then-amplify.yml
Created March 27, 2023 20:33
GitHub action flow to deploy multi-env cdk app that then deploy an Amplify frontend
name: Deploy CDK Project
on:
push:
branches:
- develop
pull_request:
branches:
- main
types:
- closed
@mtliendo
mtliendo / multi-env-deploy.yml
Created March 27, 2023 20:32
GitHub action flow to deploy a multi-env CDK app
name: Deploy CDK Project
on:
push:
branches:
- develop
pull_request:
branches:
- main
types:
- closed
@mtliendo
mtliendo / xferFromUserToOrg.js
Last active January 22, 2022 05:09
xfer a repo from a personal account to an org
const axios = require('axios')
axios({
url: `https://api.github.com/repos/${username}/${repoName}/transfer`,
method: 'POST',
data: {
new_owner: `${orgName}`,
},
headers: {
Accept: 'application/vnd.github.v3+json',
@mtliendo
mtliendo / post-push.js
Last active December 1, 2021 21:47
Using Amplify command hooks, showcase how to upload the aws-exports file to Vercel after the `amplify push` command is ran. This allows customers to use the Amplify CLI, and JavaScript modules while hosting their app on Vercel.
/**
* @param data { { amplify: { environment: string, command: string, subCommand: string, argv: string[] } } }
* @param error { { message: string, stack: string } }
*/
import { execSync } from 'child_process'
import { writeFileSync, readFileSync, copyFileSync, rmSync } from 'fs'
const hookHandler = async (data, error) => {
const VERCEL_ENVVAR_NAME = 'NEXT_PUBLIC_AMPLIFY_CONFIG'
@mtliendo
mtliendo / amplify-authentication.js
Created January 4, 2021 20:44
AmplifyAuthenticator example
import React from 'react'
import Amplify from 'aws-amplify'
import {
AmplifyAuthenticator,
AmplifySignOut,
AmplifySignUp,
} from '@aws-amplify/ui-react'
import { AuthState, onAuthUIStateChange } from '@aws-amplify/ui-components'
import config from '../aws-exports'
@mtliendo
mtliendo / fetchFollowerCounts.js
Created October 14, 2020 21:05
retreive a list of followers from twitter
const cheerio = require('cheerio')
const axios = require('axios').default
async function fetchFollowerCounts(usernames) {
const followerData = usernames.map((username) => {
return axios.get(`https://mobile.twitter.com/${username}`).then((res) => {
const $ = cheerio.load(res.data)
const searchContext = `a[href='/${username}/followers']`
const followerCountString = $(searchContext)
.text()
@mtliendo
mtliendo / app.jsx
Created May 8, 2020 08:30
Amplify configuration with pre-made apiGateway (api) and Cognito (auth)
import React from "react";
import logo from "./logo.svg";
import "./App.css";
import Amplify, { API } from "aws-amplify";
import { withAuthenticator } from "aws-amplify-react";
Amplify.configure({
Auth: {
identityPoolId: "us-east-1:af865d51-my-identity-pool930304c62ee1",
region: "us-east-1",
@mtliendo
mtliendo / async-callback-example.js
Created April 29, 2019 18:09
An quick intro to understanding callback functions via forms
// First let's grab a form
console.log('first')
const someForm = document.getElementById('some-form')
// Next, we'll add an event listener with the event and a callback function
// Note that the anonymous function is
someForm.addEventListener('submit', (evt) => {
console.log('second')
//this is an asynchronous function.
@mtliendo
mtliendo / dynamoExportAndConvert.js
Created April 17, 2019 13:37
Export and Convert Dynamo Table to JavaScript JSON
//! How to get all records from a Dynamo DB Table and store as regular JSON
// 1. Run the following command in the terminal
// * Note that the output will be in Dynamo JSON format
// aws dynamodb scan --region REGION --profile PROFILE_NAME --table-name TABLE_NAME > exports.json
// 2. Convert from Dynamo JSON to regular JSON.
const AWS = require('aws-sdk')
const fs = require('fs')
@mtliendo
mtliendo / dynamo.json
Created April 17, 2019 13:24
Dynamo JSON format
{
"Count": 1,
"Items": [
{
"name": {
"S": "Michael Liendo"
},
"kids": {
"N": "3"