Skip to content

Instantly share code, notes, and snippets.

View jgcmarins's full-sized avatar

João Marins jgcmarins

View GitHub Profile
@jgcmarins
jgcmarins / xlsxToPdfChatGPT.js
Created November 8, 2023 19:15
Chat GPT code to generate pdf from xlsx
const fs = require('fs');
const { PDFDocument, rgb } = require('pdf-lib');
const ExcelJS = require('exceljs');
// Function to convert XLSX to PDF
async function convertXlsxToPdf(inputXlsxPath, outputPdfPath) {
// Create a new PDF document
const pdfDoc = await PDFDocument.create();
// Load the XLSX file
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(inputXlsxPath);
@jgcmarins
jgcmarins / decision-matrix.md
Created September 25, 2023 14:49
Looking for a new career opportunity? Use this table to create a ranking of all job offers

Table of concepts and definitions

Concept Definition
Autonomy How well will this company give me autonomy to do my job?
Freedom How much freedom will I have to balance work and personal life?
Responsibilities What level of responsibilities will I have, and how extensive will they be?
Culture How well does this company's culture align with my values, and how open is the company to allowing me to contribute to the culture I believe in?
Tech Stack How closely does the tech stack used by this company align with my preferences, and to what extent is the company willing to allow me to use the stack I prefer?
Personal Growth How big is the potential of this company to help me keep growing?
@jgcmarins
jgcmarins / index.js
Created August 18, 2023 13:09
New Encryption Key
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
@jgcmarins
jgcmarins / Dockerfile
Created August 10, 2022 17:39
Python Dockerfile with FatAPI
FROM python:3.10
WORKDIR /code
#COPY ./requirements.txt /code/requirements.txt
COPY ./ /code/
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
#COPY ./app /code/app
@jgcmarins
jgcmarins / MyPrivatePage.ts
Created July 11, 2022 22:37
Next.js SSR authentication and routing between public and private pages with getServerSideProps and cookies
import type { NextPage } from 'next';
import { getServerSidePropsPrivate } from '../../../middlewares/getServerSidePropsPrivate';
const MyPrivatePage: NextPage = ({ me }) => {
// use me data
/* code goes here */
};
export const getServerSideProps = getServerSidePropsPrivate;
@jgcmarins
jgcmarins / MEMOIZE.md
Created March 26, 2021 13:57 — forked from mrousavy/MEMOIZE.md
Memoize!!! 💾 - a react (native) performance guide
In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and  
returning the cached result when the same
inputs occur again.                                         
                                                     — wikipedia
@jgcmarins
jgcmarins / ReactNativeFormikExample.tsx
Last active April 5, 2021 00:49
React Native + Formik hooks example
import React from 'react'
import { FormikProvider, useFormik } from 'formik'
import * as yup from 'yup'
import TextInputFormik from './TextInputFormik'
const ReactNativeFormikExample: React.FC<unknown> = (props) => {
const formik = useFormik({
initialValues: {
name: '',
@jgcmarins
jgcmarins / index.js
Created March 20, 2021 00:16
Curebase Technical Interview - Coding Problem (https://www.curebase.com/)
const readlineSync = require('readline-sync');
function isValid1(answer) {
return answer === 'y'
}
function isValid2(answer) {
return Number(answer) >= 18 && Number(answer) <= 75
}
@jgcmarins
jgcmarins / babel.config.js
Created March 3, 2021 19:57
Angora JavaScript build setup with Webpack and Babel (https://www.npmjs.com/package/@angoralabs/angora-js)
module.exports = {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},