Skip to content

Instantly share code, notes, and snippets.

View dfop02's full-sized avatar

Diogo Fernandes dfop02

View GitHub Profile
@dfop02
dfop02 / cleanner.txt
Created June 9, 2024 00:09
Cleaning Infected Win 10
# What they do?
# They make Windows compare itself to a known good image from Microsoft and replace anything that doesn't look the same.
# It fixes any parts of windows that have been broken or replaced for some reason.
Dism.exe /online /cleanup-image /restorehealth
Sfc /scannow
@dfop02
dfop02 / docker.rake
Created April 19, 2024 12:15
Manage docker from Rails using rake
# Change "container_name" for the name of your app container created in docker-compose.yml
desc "Manage docker from rails"
namespace :docker do
desc "Docker build container"
task build: :environment do
system "docker-compose -f #{Rails.root.join('docker-compose.yml')} build"
end
desc "Docker up container"
task up: :environment do
@dfop02
dfop02 / sheets_to_docs.js
Created July 12, 2023 13:29
Automatically create a google docs based on template when google sheets new lines
// ENV START
const docTemplateId = '';
const docFolderId = '';
const sheetName = '';
// ENV END
function onOpen(){
initializeMenu();
}
@dfop02
dfop02 / pre-commit-forbidden-words.sh
Created June 14, 2023 13:25
pre-commit to avoid commit forbidden words in any branch
#!/bin/bash
# You can change for any forbbiden words and file extensions you want
FILES='(rb|haml|js)'
FORBIDDEN='(binding.pry|debugger)'
# Change for y or n if you prefer verbose or not
VERBOSE=y
# Colors
GREP_COLOR='4;5;37;41'
@dfop02
dfop02 / Github Workflow to Rails
Created May 23, 2023 23:18
CI/CD for Github Workflow using Rails and Mysql 5.7 - Runs Rubocop and then RSpec.
name: CI
on:
# Only run this workflow on these actions and branches
push:
branches: [ "master" ]
pull_request:
branches: [ "master", "release/*" ]
permissions:
contents: read
@dfop02
dfop02 / bin pre-commit
Created March 8, 2023 13:45
A pre-commit bin file to execute on your Rails application at any moment with few hooks that I frequently use.
#!/usr/bin/env sh
# Where go this file? Rails.root/bin/pre-commit
# How use? Just run "bin/pre-commit install" or "bin/pre-commit uninstall"
# This will execute the file "lib/pre-commits/pre-commit", who will install
# ALL files added on "HOOKS" variable.
current_pre_commit=$(cat .git/hooks/pre-commit 2>/dev/null | sed -n 's/PRE_COMMIT_INSTALLED=//p')
if [[ $1 = 'install' ]]; then
@dfop02
dfop02 / rubocop.yml
Last active November 28, 2022 19:16
My personal rubocop config
AllCops:
TargetRubyVersion: 2.7
require:
- rubocop-performance
- rubocop-rails
- rubocop-rspec
#################### Lint ################################
@dfop02
dfop02 / react_bot.py
Last active November 2, 2022 00:30
Discord Bot that copy a message reacted n times by specific emoji then paste into other channel
import os
import discord
from discord.utils import get
from dotenv import load_dotenv
load_dotenv()
# Bot Token
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
# Channel to listen (full name)
CHANNEL_LISTEN = os.getenv('CHANNEL_LISTEN')
@dfop02
dfop02 / git_tips.txt
Last active July 12, 2024 13:59
All my git codes and tips
######################### Git tips #########################
===== Git Checkout =====
git checkout . => Delete all changes on current branch
git checkout branch_name => Switch Branch
git checkout -b branch_name => If Branch not exist, create and Switch
git checkout origin/master Gemfile => Reset specific file from master
===== Git Branch =====