Skip to content

Instantly share code, notes, and snippets.

View SahanAmarsha's full-sized avatar
🏠
Working from home

Sahan Amarsha SahanAmarsha

🏠
Working from home
View GitHub Profile
@SahanAmarsha
SahanAmarsha / index.js
Last active November 7, 2023 20:53
SahanAmarsha/lambda-image-resizer/index.js
const aws = require("aws-sdk");
const sharp = require("sharp");
const s3 = new aws.S3();
exports.handler = async function (event, context) {
console.log("Received S3 event:", JSON.stringify(event, null, 2));
if (event.Records[0].eventName === "ObjectRemoved:Delete") {
return;
}
const bucket = event.Records[0].s3.bucket.name;
@SahanAmarsha
SahanAmarsha / App.tsx
Created March 15, 2022 18:12
App.tsx After Adding Navbar and Footer
// src/App.tsx
import React from "react";
import { Box, CssBaseline, ThemeProvider } from "@mui/material";
import { createTheme } from "@mui/material/styles";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import { routes as appRoutes } from "./routes";
import Navbar from "./components/Navbar";
import Footer from "./components/Footer";
@SahanAmarsha
SahanAmarsha / Footer.tsx
Created March 15, 2022 18:00
Example Footer component.
@SahanAmarsha
SahanAmarsha / Navbar.tsx
Last active March 15, 2022 18:10
Example Navbar Component
// src/components/Navbar.tsx
import React, { FC, ReactElement } from "react";
import {
Box,
Link,
Container,
IconButton,
Menu,
MenuItem,
@SahanAmarsha
SahanAmarsha / App.tsx
Last active March 17, 2022 09:59
App.tsx Iterating Through Routes
// src/App.tsx
import React from "react";
import { Box, CssBaseline, ThemeProvider } from "@mui/material";
import { createTheme } from "@mui/material/styles";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import { routes as appRoutes } from "./routes";
function App() {
@SahanAmarsha
SahanAmarsha / routes.ts
Created March 15, 2022 17:02
Define routes in our React App
// src/routes.ts
// pages
import Home from "./pages/Home";
import About from "./pages/About";
import Products from "./pages/Products";
// other
import {FC} from "react";
@SahanAmarsha
SahanAmarsha / Home.tsx
Last active March 13, 2022 09:17
Home Page Component
// src/pages/Home.tsx
import React, {ReactElement, FC} from "react";
import {Box, Typography} from "@mui/material";
const Home: FC<any> = (): ReactElement => {
return (
<Box sx={{
flexGrow: 1,
backgroundColor: 'whitesmoke',
@SahanAmarsha
SahanAmarsha / App.tsx
Last active March 17, 2022 09:18
App.tsx after adding custom theme
import React from "react";
import {
Box,
CssBaseline,
Paper,
ThemeProvider,
Typography,
} from "@mui/material";
import { createTheme } from "@mui/material/styles";
@SahanAmarsha
SahanAmarsha / Custom_Theme.txt
Created March 4, 2022 17:35
Define custom theme
// define theme
const theme = createTheme({
palette: {
primary: {
light: '#63b8ff',
main: '#0989e3',
dark: '#005db0',
contrastText: '#000',
},
secondary: {
@SahanAmarsha
SahanAmarsha / App.tsx
Last active March 17, 2022 09:14
App.tsx renders MUI components
import React from "react";
import { Box, CssBaseline, Paper, Typography } from "@mui/material";
function App() {
return (
<div>
<CssBaseline />
<Box
height="100vh"
display="flex"