Skip to content

Instantly share code, notes, and snippets.

View jonathangaldino's full-sized avatar
🏠
Working from home

Jonathan jonathangaldino

🏠
Working from home
View GitHub Profile
@jonathangaldino
jonathangaldino / file.txt
Created February 28, 2024 16:11
Install Puppetteer deps on Amazon Linux 2023
Source: https://www.youtube.com/watch?v=pdpzrv1H2RM
$ sudo yum install libXcomposite libXdamage libXrandr libgbm libxkbcommon pango alsa-lib atk at-spi2-atk cups-libs libdrm
@jonathangaldino
jonathangaldino / main.js
Created February 26, 2024 12:48
Chunk by chunk, from a web address to s3
const axios = require('axios');
const { MongoClient } = require('mongodb');
const { S3 } = require('aws-sdk');
const { PassThrough } = require('stream');
// Function to download image and upload to S3
async function downloadAndUploadImage(imageURL, s3, s3BucketName) {
try {
const response = await axios.get(imageURL, { responseType: 'stream' });
const s3Params = {
@jonathangaldino
jonathangaldino / private-pension-api-insomnia-requests.json
Created September 20, 2023 01:57
Private Pension API - Insomnia
{"_type":"export","__export_format":4,"__export_date":"2023-09-20T01:55:46.976Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_4157bf9d4f644c5788b108f5b93f9c79","parentId":"wrk_4ba7024e90064faaa8c8de293311e71b","modified":1695009408996,"created":1694867799799,"url":"http://localhost:3000/customers","name":"Create customer","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"cpf\": \"45645644600\",\n\t\"nome\": \"José da Silva\",\n\t\"email\": \"jose@cliente.com\",\n\t\"dataDeNascimento\": \"2010-08-24T12:00:00.000Z\",\n\t\"genero\": \"Masculino\",\n\t\"rendaMensal\": 2899.5\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1694867799799,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","
@jonathangaldino
jonathangaldino / schema_dumper.rb
Created May 3, 2023 17:56 — forked from drnic/schema_dumper.rb
Our rails db includes our own tables/schema and the Salesforce/Heroku Connect schema (under "salesforce.*"). We place this file in config/initializers/schema_dumper.rb and now our rails db:schema:dump includes both our own tables and the salesforce. tables.
# This solution was based on https://gist.github.com/GlenCrawford/16163abab7852c1bd550547f29971c18
Rails.configuration.to_prepare do
ActiveRecord::SchemaDumper.ignore_tables = %w[
salesforce._hcmeta
salesforce._sf_event_log
salesforce._trigger_log
salesforce._trigger_log_archive
]
end
@jonathangaldino
jonathangaldino / schema_dumper.rb
Created May 3, 2023 17:55 — forked from GlenCrawford/schema_dumper.rb
Patching Rails database schema dumps to support multiple PostgreSQL schemas.
# Overrides Rails file activerecord/lib/active_record/schema_dumper.rb to
# include all schema information in the db/schema.rb file, for example, in the
# create_table statements. This allows for a working development database
# to be built from a schema.rb file generated by rake db:schema:dump.
#
# This is essentially a rebuild of the "schema_plus_multischema" gem (which is
# unfortunately only compatible with Rails ~> 4.2).
#
# Tested with Rails 6.0.
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": [
"JZS429223Z.com.playlegis"
],
"appId": "JZS429223Z.com.playlegis",
"components": [
@jonathangaldino
jonathangaldino / nginx.conf
Last active May 28, 2020 14:04 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@jonathangaldino
jonathangaldino / rearct-native-app-in-wsl2.md
Last active May 25, 2020 16:00 — forked from bergmannjg/rearct-native-app-in-wsl2.md
Building a react native app in WSL2
@jonathangaldino
jonathangaldino / database.js
Created February 1, 2020 20:20
Usando o mongodb-memory-server
const mongoose = require("mongoose");
const { MongoMemoryServer } = require("mongodb-memory-server");
let mongoServer = null;
const connect = async () => {
mongoose.Promise = global.Promise;
mongoServer = new MongoMemoryServer();
const mongoUri = await mongoServer.getUri();
@jonathangaldino
jonathangaldino / create.test.js
Created January 21, 2020 03:27
Teste da função de criar usuários - exemplos
import supertest from "supertest";
import app from "../../../app";
import { connect, disconnect } from "../../../../test/database";
import {
generateUser,
removeUsers,
removePlates,
generatePlate
} from "../../../../test/helper";