Skip to content

Instantly share code, notes, and snippets.

View aquiseb's full-sized avatar

Sébastien aquiseb

View GitHub Profile
@aquiseb
aquiseb / animated-continuous-sections-using-sliding-divs.markdown
Created November 14, 2022 12:54
Animated Continuous Sections Using Sliding divs

Nextjs Authentication with AWS Amplify

Install AWS Amplify @preview

yarn add aws-amplify@preview

# Optional
yarn add hoist-non-react-statics

React + Ant modular prompt approach

This example shows how to trigger a simple prompt, but with a very modular approach.

/* eslint-disable react/prop-types */
import * as React from 'react';
import styled from 'styled-components';

import { Popconfirm as PopconfirmAnt, Button } from 'antd';
@aquiseb
aquiseb / AWS-Lambda-Node-Sass.md
Last active July 24, 2020 01:02
Get node-sass bindings for your AWS Lambda deployment

AWS Lambda - Node-Sass

If you deployed your app to AWS Lambda with scss, you most got an error saying the node-sass bindings are missing.

Missing binding /opt/nodejs/node_modules/node-sass/vendor/linux-x64-64/binding.node\nNode Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x\n\nFound bindings for the following environments:\n - OS X 64-bit with Node.js 12.x\n\nThis usually happens because your environment has changed since running npm install.\nRun npm rebuild node-sass to download the binding for your current environment.

Solution

AWS Lambda requires linux-x64-64_binding.node. If you're coding on macOs or Windows, you won't have it. So here's the command to include in your deployment script.

Three.js React Hooks

This example shows how to use animate a cube and highly reuse each part of Three.js.

import * as React from "react";
import * as THREE from "three";

// WORLD SIZE
// ---
@aquiseb
aquiseb / 06.png
Created May 1, 2020 17:38 — forked from mfd/06.png
Gilroy font
06.png
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Timeout: 60
Parameters:
Stage:
Type: String

AWS Cloudformation ApiGateway vs ApiGatewayV2 with Lambda

This shows how to convert a basic REST ApiGateway template to its equivalent HTTP ApiGatewayV2.

The original code before refactoring to ApiGatewayV2 comes from this article

Deployment

Replace MY_PROFILE, MY_REGION and MY_STACK_NAME

AWSTemplateFormatVersion: '2010-09-09'
Description: AWS API Gateway with a Lambda Integration
Parameters:
lambdaFunctionName:
Type: "String"
AllowedPattern: "^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$"
Description: Lambda function name. (Recommend to keep default)
Default: "lambda-api"
@aquiseb
aquiseb / troubleshooting.md
Created April 18, 2020 23:20 — forked from cmawhorter/troubleshooting.md
Solution to AWS Lambda node.js UnrecognizedClientException "The security token included in the request is invalid."

Troubleshooting AWS unauthorized errors in lambda requests

This is mainly for node.js but might apply to other environments. Unsure.

If you are running a AWS Lambda function that calls another AWS service and getting an error about invalid tokens or other access denied errors, do this:

Check IAM

The role assigned to your lambda function will need permission to perform the actions. Check IAM and make sure the role has all the permissions.