Skip to content

Instantly share code, notes, and snippets.

View sostenesapollo's full-sized avatar
👻

Sóstenes Apollo sostenesapollo

👻
View GitHub Profile
@sostenesapollo
sostenesapollo / GetLastDayOfMonth.md
Last active November 9, 2023 13:19
Get last day of month
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));
}
@sostenesapollo
sostenesapollo / mysql-run.md
Created October 17, 2023 19:09
Run using docker

docker run -e MYSQL_ROOT_PASSWORD=password -d -p 3306:3306 mysql

Criar um crud com remix

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 }}
{
"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\""

A simple Docker and Docker Compose install script for Ubuntu

Usage

  1. sh install-docker.sh
  2. log out
  3. log back in

Links

A simple Docker and Docker Compose install script for Ubuntu

Usage

  1. sh install-docker.sh
  2. log out
  3. log back in

Links

ref. https://gist.github.com/silverark/2fd88d03fddbe373fce87da80afdc3ce

Bad code

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.

const name = 'Sóstenes Apollo';
const filterText = removeAccents(`%${name}%`).toLowerCase();
console.log('Filter text', filterText);
this.prisma.$queryRaw`select
id, name
from users
where LOWER(unaccent(name)) LIKE ${filterText};`.then((users) =>
console.log(users),
);

🌱🌎 Configure Dokku Environment

  • Followed these steps: CONHEÇA O DOKKU & APRENDA A CONFIGURÁ-LO PASSO-A-PASSO

  • Crie um droplet na digital ocean usando vps com imagem do dokku

  • Crie um app no dokku via ssh do seu server

  • Lembrando que pra configurar o ssl o seu domínio tem que estar apontado para os servers da digital ocean