Skip to content

Instantly share code, notes, and snippets.

View chrisvasqm's full-sized avatar

Christian Vasquez chrisvasqm

View GitHub Profile
@chrisvasqm
chrisvasqm / eslint.config.js
Created June 8, 2024 20:06
Flat ESLint Config file for JavaScript
import globals from "globals";
export default [
{
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: globals.node
}
}
@chrisvasqm
chrisvasqm / .dockerignore
Created June 6, 2024 22:30
Sample .dockerignore for a Node project
dist
node_modules
.git
.env
*.log
Dockerfile
docker-compose.yaml
.vscode
.idea
test
@chrisvasqm
chrisvasqm / deploy.sh
Created June 1, 2024 04:35
Sample deployment script to use with a Virtual Machine setup (Linode, Digital Ocean Droplets, etc)
echo "Switching to master branch"
git checkout master
echo "Building app..."
pnpm build
echo "Deploying files to server..."
scp -r dist/* app@<DOMAIN_OR_IP>:/var/www/<DOMAIN_OR_IP>/
echo "Deployment done!"
@chrisvasqm
chrisvasqm / s3-delete-script.js
Created May 31, 2024 20:40
Delete objects from S3 while excluding some
const aws = require('aws-sdk');
// Configure the AWS SDK with your credentials
aws.config.update({
accessKeyId: 'ACCESS_KEY',
secretAccessKey: 'SECRET_ACCESS_KEY',
region: 'REGION'
});
// Create an S3 service object
@chrisvasqm
chrisvasqm / frontend-backend-database-compose.yml
Created May 27, 2024 11:56
Demostration docker-compose.yml file for a project with a Frontend + Backend+ Database setup to make local development easier
services:
db:
image: mongo:4.0-xenial
ports:
- 27017:27017
volumes:
- vidly:/data/db
api:
build: ./backend
@chrisvasqm
chrisvasqm / tsconfig.json
Last active May 25, 2024 16:28
Sample tsconfig.json file to convert a JavaScript project to TypeScript (Tip: Remove the "module" property from your package.json if you have it)
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2020",
"sourceMap": true,
"outDir": "dist"
},
"include": [
"*"
services:
postgres:
image: postgres:16.3-alpine3.20
container_name: appname
ports:
- '5432:5432'
environment:
POSTGRES_DB: appname
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
@chrisvasqm
chrisvasqm / Dockerfile
Last active June 6, 2024 20:11
Sample Dockerfile for a Node backend using Prisma and pnpm
FROM node:20.14.0-alpine3.20
WORKDIR /app
COPY . .
RUN npm install -g pnpm
RUN pnpm install
RUN pnpm generate
RUN pnpm migrate
RUN pnpm build
EXPOSE 3000
USER node
@chrisvasqm
chrisvasqm / Shapes.java
Last active April 23, 2024 00:14
Shapes exercise
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
var shapes = Arrays.asList(
new Circle(3),
new Rectangle(5, 10),
new Square(5)
);
@chrisvasqm
chrisvasqm / APIClient.java
Created March 26, 2024 03:29
API Testing with Java + RestAssured + TestNG + Truth
package org.example.services;
import io.restassured.RestAssured;
import java.util.List;
public class APIClient<T> {
private final Class<T> type;
private final String baseUrl;
private final String endpoint;