Skip to content

Instantly share code, notes, and snippets.

View jarrodmedrano's full-sized avatar
🌜

Jarrod Medrano - Senior Software Engineer jarrodmedrano

🌜
View GitHub Profile
@jarrodmedrano
jarrodmedrano / resize.tsx
Created January 26, 2025 14:51
Cloudinary resize
const cld = new Cloudinary({
cloud: {
cloudName: "slashclick",
},
});
const myImage = cld.image(popout);
const srcSetOptions = [
{ width: 200, transformation: scale().width(200) },
{ width: 400, transformation: scale().width(400) },
{ width: 600, transformation: scale().width(600) },
@jarrodmedrano
jarrodmedrano / auth.ts
Created February 11, 2024 17:22
Email & provider auth for next 13
import { User as DefaultUser } from '@auth/core/types'
import { AdapterUser as DefaultAdapterUser } from '@auth/core/adapters'
import Google from 'next-auth/providers/google'
import Facebook from 'next-auth/providers/facebook'
import Apple from 'next-auth/providers/apple'
import EmailProvider, { EmailConfig } from 'next-auth/providers/email'
import NextAuth from 'next-auth'
import type { NextAuthConfig } from 'next-auth'
// import GitHub from 'next-auth/providers/github'
@jarrodmedrano
jarrodmedrano / Dockerfile
Created October 9, 2023 02:02
PNPM docker
Had same problem on COPY --from=builder /app/out/full/ . line as everyone else using pnpm.
Added **/node_modules to root .dockerignore to resolve.
Then ran into issues with the last 3 COPY lines. Needed to also copy the next.config.js from the with-docker example. tldr- I was missing output: standalone
Ended up with this. I like it because pnpm and turbo are pulled to "base", allowing me to just use bare alpine in the end result.
copied from the with-docker example and updated to use pnpm.
@jarrodmedrano
jarrodmedrano / jest.timers.ts
Created June 1, 2023 13:27
Jest set date time
jest.useFakeTimers().setSystemTime(new Date('2023-01-01'));
@jarrodmedrano
jarrodmedrano / ecs.yml
Created April 20, 2023 22:03 — forked from tkgregory/ecs.yml
An example CloudFormation template for deployment of a container to ECS.
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
SubnetID:
Type: String
Resources:
Cluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: deployment-example-cluster
LogGroup:
@jarrodmedrano
jarrodmedrano / testhooks.js
Last active August 31, 2023 21:00
Test custom hooks
//@testing-library/react-hooks package will help to test hooks functionalities.
const { result, waitForNextUpdate } = renderHook(() => useCustomHooks());
act(() => {
result.current[0]('123');
});
await waitForNextUpdate();
expect(result.current[1].isSuccess).toBe(true);
@jarrodmedrano
jarrodmedrano / Dockerfile
Created April 16, 2023 00:22
docker turbo
##########
## DEPS ##
##########
FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
Description: Animals4Life base VPC Template + Boostrapped Wordpress (requires VPC_EFS_AURORA in CREATE_COMPLETE)
Parameters:
LatestAmiId:
Description: AMI for Wordpess Instance (default is latest AmaLinux2)
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
DBName:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
@jarrodmedrano
jarrodmedrano / vpc-efs-aurora.yaml
Created April 12, 2023 19:15
VPC EFS Aurora example
Description: Animals4Life base VPC Template + EFS + Aurora DB Cluster
Parameters:
LatestAmiId:
Description: AMI for Wordpess Instance (default is latest AmaLinux2)
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
DBName:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
@jarrodmedrano
jarrodmedrano / cloudwatch.txt
Created February 16, 2023 20:14
installing cloudwatch agent
wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
sudo rpm -U ./amazon-cloudwatch-agent.rpm
# IAM ROLE
EC2 Role
EC2
CloudWatchAgentServerPolicy