Skip to content

Instantly share code, notes, and snippets.

View carlohcs's full-sized avatar
🎯
Focusing on my Postgraduate degree!

Carlos Santana carlohcs

🎯
Focusing on my Postgraduate degree!
View GitHub Profile
@carlohcs
carlohcs / Learn-About-OWASP.md
Created May 4, 2023 13:29
Learn About OWASP

Learn About OWASP

The Open Web Application Security Project (OWASP) "is an open community dedicated to enabling organizations to conceive, develop, acquire, operate, and maintain applications that can be trusted."

Learn More about OWASP

Top Ten Project

The community publishes books, articles, holds events and provides guidance in the furtherance of application security. In relation to this training, it also publishes the OWASP Top Ten project.

@carlohcs
carlohcs / update-repositories.sh
Created May 16, 2022 12:43
Update git repositories inside the current folder
#!/bin/bash
currentFolder=$(pwd)
for folder in */; do
if [ "$folder" != "node_modules/" ]; then
echo "Updating folder ${folder}"
cd $folder
git fetch --all -p
@carlohcs
carlohcs / compress-files-to-separate-folder-excluding-folders.sh
Created April 15, 2022 03:56
Compress files to separate folders and exclude folders
#!/bin/bash
currentFolder=$(pwd)
echo "#################################"
echo "# Compressing folders from ${currentFolder}"
echo "#################################"
for i in */; do tar -czvf "${i%/}.tar.gz" --exclude "node_modules" --exclude ".next" "$i"; done
@carlohcs
carlohcs / _middleware.ts
Created March 20, 2022 15:31
Next.js middleware to check if user could access a private route
// This file should be placed at pages/_middleware.ts
import { NextRequest, NextResponse } from 'next/server'
import { verifyIsLogged } from 'services/session'
const BASE_URL = 'https://my-site.com'
const PRIVATE_ROUTES = ['my-profile']
const LOGIN_URL = `${BASE_URL}/api/auth?redir=`
export async function middleware(req: NextRequest) {
@carlohcs
carlohcs / Dockerfile-react
Created February 1, 2022 20:45
Build an image docker with static react application
# build environment
FROM node:13.12.0-alpine as builder
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build
@carlohcs
carlohcs / git-helpers.md
Last active August 15, 2021 20:01
Git Helpers

Git Helpers

Remove master/main branch from git and replace for one locally

git push origin otherbranch:master -f

Change author name/email from oldest commits

@carlohcs
carlohcs / how-to-use-ssl-on-github.md
Created August 13, 2021 21:26
How to use SSL on GitHub

How to use SSL on GitHub

Create a SSH file:

$ ssh-keygen -t ed25519 -C "your-email@server.com"

Move private and public key in the folder ~/.ssh

@carlohcs
carlohcs / GetVariables.js
Created August 6, 2021 03:08
Get variables with defined name in JSON file created by style-dictionary
import variables from "path/variables.json";
/**
* Return variables as "$prefix-color-brand-..."
*
* @param {String} name
* @returns {String}
*/
function formatVariableName(name) {
const prefix = "$prefix";
@carlohcs
carlohcs / get-heroku-env-values.js
Created January 31, 2021 23:52
Get heroku env values
const keys = {};
const keyInputs = document.querySelectorAll(".config-var-key");
const keyInputsValue = document.querySelectorAll(".config-var-value");
[...keyInputs].map((item, key) => {
keys[item.value] = keyInputsValue[key].value;
});
@carlohcs
carlohcs / domain.css
Created March 4, 2020 19:12
domain css
@import url(http://jsuol.com.br/g/uolfw/fonts/uol-text.css?type=bold,light&cache=11);
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/