Skip to content

Instantly share code, notes, and snippets.

@SamWSoftware
SamWSoftware / Amplify-Songs-UnAuth-S3-Access
Last active June 25, 2021 07:28
Amplify Guest User Iam Templates
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::{YOUR_S3_BUCKET}/public/*"
],
@SamWSoftware
SamWSoftware / handler.py
Created May 20, 2021 10:35
Python version of the Lambda Code
import json
def lambda_handler(event, context):
if event['httpMethod'] == "GET":
return getItem(event)
if event['httpMethod'] == "POST":
return createCart(event)
def getItem(event):
functions: {
UserLogin: {
handler: `src/handler.main`,
environment: {
USERS_TABLE: { Ref: 'UsersTable' },
},
iamRoleStatements: [
{
Effect: 'Allow',
@SamWSoftware
SamWSoftware / testUtils.ts
Created January 22, 2021 09:40
How spread works and limitations with nested objects
const defaultRequest = {
body: null,
headers: {},
multiValueHeaders: {},
httpMethod: "",
isBase64Encoded: false,
path: '',
pathParameters: null,
queryStringParameters: null,
multiValueQueryStringParameters: null,
@SamWSoftware
SamWSoftware / launch.json
Created November 28, 2020 20:43
VS Code Debugging Launch JSON
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Serverless Offline",
@SamWSoftware
SamWSoftware / ReferenceOwnAPIUrl.yml
Created October 30, 2020 08:06
A way to reference your own API Gateway url from within a serverless file
apiURLBase: { 'Fn::Join': [ '', [ 'https://', { 'Ref': 'ApiGatewayRestApi' }, '.execute-api.${self:provider.region}.amazonaws.com/${self:provider.stage}' ] ] }
if [ "$#" -ne 1 ]; then
echo "Usage : ./build.sh lambdaName";
exit 1;
fi
lambda=${1%/}; // # Removes trailing slashes
echo "Deploying $lambda";
cd $lambda;
if [ $? -eq 0 ]; then
echo "...."
activeGender(gender) {
let men = document.querySelector(".menTab").classList;
let women = document.querySelector(".womenTab").classList;
gender = this.state.gender === gender ? "" : gender;
this.setState({ gender });
if (gender === "mens") {
men.add("active");
women.remove("active");
} else if (gender === "womens") {
women.add("active");
const Landing = () => {
return (
<div className="center background-img">
<div className="center-box">
<div className="white-box hpTitle">
<h1>Where will your shoes take you?</h1>
</div>
<div className="row">
<div className="col l3 offset-l2 m5 offset-m1 s10 offset-s1">
<Link to="./products/womens">
addClickTracking() {
const trackingSettings = new helper.TrackingSettings();
const clickTracking = new helper.ClickTracking(true, true);
trackingSettings.setClickTracking(clickTracking);
this.addTrackingSettings(trackingSettings);
}