function getDateLastDayOfMonth(date) {
if (!date) return;
const [year, month] = date.split('-');
const lastDay = new Date(year, month, 0).getDate();
// JavaScript months are 0-indexed
return new Date(Date.UTC(year, month - 1, lastDay, 12));
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { prisma } from "@/db.server"; | |
import { getUser } from "@/session.server"; | |
import type { PutObjectCommandInput } from "@aws-sdk/client-s3"; | |
import { S3Client } from "@aws-sdk/client-s3"; | |
import { PutObjectCommand } from "@aws-sdk/client-s3"; | |
import { delCachedData, presetValues } from "./utils/utils"; | |
import { v4 as uuid } from "uuid"; | |
const { STORAGE_ACCESS_KEY, STORAGE_SECRET, STORAGE_REGION, STORAGE_BUCKET } = | |
process.env; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop local db with force | |
docker exec -it $(docker ps | grep postgres | awk '{print $1}') psql -U postgres -d postgres -c "DROP DATABASE pedegas WITH (FORCE);" | |
# Create DB | |
docker exec -it $(docker ps | grep postgres | awk '{print $1}') psql -U postgres -d postgres -c "CREATE DATABASE pedegas;" | |
# Restore DB | |
bash -c 'gunzip -c ~/Documents/*.tar.gz | pg_restore --dbname="postgresql://postgres:postgres@localhost:5432/pedegas"' | |
# Clean Redis data | |
docker exec -it $(docker ps | grep redis | awk '{print $1}') redis-cli -a ads FLUSHALL |
docker run -e MYSQL_ROOT_PASSWORD=password -d -p 3306:3306 mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: [main] | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
TF_STATE_BUCKET_NAME: ${{ secrets.AWS_TF_STATE_BUCKET_NAME }} | |
PRIVATE_SSH_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "tst", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"prebuild": "rimraf dist", | |
"build": "tsc", | |
"start": "node ./dist/index.js", | |
"dev": "npm run prebuild && tsc-watch --onSuccess \"npm run start\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -o errexit | |
set -o nounset | |
IFS=$(printf '\n\t') | |
# Docker | |
sudo apt remove --yes docker docker-engine docker.io containerd runc || true | |
sudo apt update |
ref. https://gist.github.com/silverark/2fd88d03fddbe373fce87da80afdc3ce
Line 22:
This connection string should be global, and reusable for all the operations, and not recreated for every method
Line 22:
It’s a really bad code practice to put the connection string inside the code, the common usage is to declare the variables inside a .env file for different environments, but never inside the code itself,
The variables, user, password and dbname should not be public.