Skip to content

Instantly share code, notes, and snippets.

View SevanBadal's full-sized avatar
🐙

Sevan SevanBadal

🐙
View GitHub Profile
@SevanBadal
SevanBadal / backend-data.ts
Last active July 2, 2025 03:59
AWS Amplify Gen 2 Create User Custom Mutation
// amplify/data/backend.ts
import { type ClientSchema, a, defineData } from "@aws-amplify/backend";
import { createUserResolver } from "../functions/create-user-resolver/resource";
const schema = a.schema({
// Custom mutation for creating users
createUser: a
.mutation()
.arguments({
@SevanBadal
SevanBadal / backend.ts
Created June 27, 2025 02:51
AWS Amplify Gen 2: REST API Lambda Function for Creating Cognito Users
// amplify/backend.ts
import { defineBackend } from "@aws-amplify/backend";
import { auth } from "./auth/resource";
import { data } from "./data/resource";
import { PolicyStatement, Effect } from "aws-cdk-lib/aws-iam";
import {
RestApi,
LambdaIntegration,
AuthorizationType,
CognitoUserPoolsAuthorizer,
@SevanBadal
SevanBadal / aws-profile-selector.sh
Last active May 5, 2025 05:40
AWS Profile Switcher: An interactive Bash tool that simplifies switching between AWS CLI profiles. Provides a numbered menu of available profiles from your AWS config, sets the selected profile as the current AWS_PROFILE environment variable, and displays identity information—eliminating the need to repeatedly type '--profile' flags.
# Configure AWS CLI
select_aws_profile() {
echo "Available AWS Profiles:"
PS3="Select AWS profile (enter number): "
# Get profiles directly using grep and sed
profiles=($(grep '^\[profile' ~/.aws/config | sed 's/\[profile \(.*\)\]/\1/') "Skip")
select profile in "${profiles[@]}"; do
[[ "$profile" == "Skip" ]] && break
@SevanBadal
SevanBadal / demo.js
Created March 21, 2024 21:05
NextJs 14 Image component fills parent w/out overflow
import Image from 'next/image'
import HeroImage from '/public/hero.jpg'
export default function Hero() {
return (
<div style={{ position: 'relative', width: '100%', height: '100vh' }}>
<Image
src={HeroImage}
alt="Picture of the author"
{
"name": "bubble",
"version": "1.0.0",
"description": "",
"main": "bubbleSort.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
@SevanBadal
SevanBadal / binary-search.js
Last active December 13, 2023 02:53
Two binary search implements, one using recursion and another using loops. Quest from https://daily-quest-tau.vercel.app
const binarySearch = (array, target) => {
// min and max are indexes
let min = 0
let max = array.length - 1
// while loop will run until min and max cross each other
while(min <= max) {
// find middle index
const middle = Math.floor((min + max) / 2)
const current = array[middle]
// determine if we need to search left or right or end if we found it
@SevanBadal
SevanBadal / package.json
Last active December 13, 2023 02:45
Daily Quest reverseWords. Quest from https://daily-quest-tau.vercel.app
{
"name": "daily-quest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
@SevanBadal
SevanBadal / .vimrc
Created June 28, 2023 16:04
My default .vimrc file
" Enable syntax highlighting
syntax on
" Enable line numbers
set number
" Show matching brackets
set showmatch
" Indenting Configs
set autoindent
set smartindent
set tabstop=4
@SevanBadal
SevanBadal / week-11b-worksheet.hs
Last active April 19, 2023 19:39
Haskelliday: A Functor-Applicative-Monad Break from Class. I suggest loading this file into GHCI and exploring the main function and MyTree data type before proceeding to the questions.
import System.Random (StdGen, randomR, split, newStdGen)
-- main to help debug your Functor, Applicative and Monad instances
-- feel free to edit main!
main :: IO ()
main = do
treeOne <- generateRandomTree 10 -- tree of ten random nodes
-- you will end of needing to construct a tree of expressions of some type (a -> a) for the applicative
-- you can construct that tree manually via value constructors or by creating a new generateTree function
print treeOne
import System.Random
main :: IO ()
main = do
g1 <- newStdGen
g2 <- newStdGen
let tenRandomLetters = take 10 (randomRs ('a', 'z') g1)
let randomInts = take 10 (randomRs (1, 10) g2)
let mixLettersAndNumbers = [(letter, number) | letter <- randomLetters, number randomInts]
print mix