Skip to content

Instantly share code, notes, and snippets.

View trepichio's full-sized avatar
🧠
Talk is cheap. Show me the code!

João Trepichio trepichio

🧠
Talk is cheap. Show me the code!
View GitHub Profile
@trepichio
trepichio / node-version-prompt-zsh-theme.md
Last active July 5, 2021 22:01
prompt node version Oh-my-ZSH-theme

Any oh-my-zsh Theme with node version info.

Installation

Place this piece of code in .oh-my-zsh/custom/themes/<your_theme>.zsh_theme

# NODE
function node_prompt_version {
    if which node &> /dev/null; then
        echo "%{$fg_bold[blue]%}node(%{$fg[red]%}$(node -v)%{$fg[blue]%}) %{$reset_color%}"
 fi
@trepichio
trepichio / restore_all_software_ubuntu.md
Last active July 5, 2021 01:41
Restore all software on Ubuntu

Backup list of software

Backup your home directory. To save the list of installed software use following command:

sudo dpkg --get-selections > package_list

This will create a file with a list of all pakcages/softwares that are installed on this system. You will need to backup this file to somewhere safe.

Restore list of all installed software

Then when you reinstall ubuntu on your machine you can use the following command to install all these software

@trepichio
trepichio / scripts-bitnami.md
Last active June 22, 2021 01:20
Scripts Bitnami

Acessando o servidor

ssh -i [your-private-key].pem bitnami@[public-ip]

Conhecendo os scripts disponibilizados pela Bitnami

@trepichio
trepichio / regexBrazilianPhones.js
Last active May 14, 2021 23:37
Regex para telefone e celular BR
/**
* Validates both phone and mobile numbers with[out] DDD and DDI
* valid examples: +55(11) 98888 - 8888 / 9999 - 9999 / 21 98888 - 8888 / 5511988888888
*/
export const regexBrazilianPhones = /^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:9\d|[2-9])\d{3})\-?(\d{4}))$/
export const regexBRMobilePhone = /^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:9\d)\d{3})\-?(\d{4}))$/
export const regexBRPhone = /^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:[2-9])\d{3})\-?(\d{4}))$/
@trepichio
trepichio / isValidCPF.js
Created May 14, 2021 07:42
CPF Validation
export const isValidCPF = (cpf) => {
if (typeof cpf !== "string") return false
cpf = cpf.replace(/[\s.-]*/igm, '')
if (cpf.length !== 11 || !Array.from(cpf).filter(e => e !== cpf[0]).length) {
return false
}
var soma = 0
var resto
@trepichio
trepichio / drop_all_tables.sql
Created May 14, 2021 00:01
DROP ALL TABLES [POSTGRESQL]
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN
(
SELECT table_name
FROM information_schema.tables
WHERE table_schema=current_schema()
)
@trepichio
trepichio / css-reset.css
Created April 8, 2021 13:30
css-reset-defaults
/* Box sizing rules */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Remove default padding */
ul[class],
ol[class] {
@trepichio
trepichio / add_proj_folders.sh
Last active November 13, 2021 01:18
Addtional Vue Project folders
#copy and paste or edit and run
cd src
mkdir common
mkdir common/components common/mixins common/directives
mkdir layouts
mkdir middlewares
mkdir plugins
mkdir services
@trepichio
trepichio / .gitignore
Last active August 24, 2020 14:13
GitIgnore for Django Projects
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
@trepichio
trepichio / transfer_partial_git.md
Last active October 14, 2023 08:07
Transfer a partial history from a git branch to a new repository

Transfer a partial history from a Git Branch to a new Repository

Steps to reproduce:

  1. In your current repository, create a new orphan branch, containing the contents of the first commit you want to copy:

      $ git checkout --orphan -b tmpbranch <hash_of_first_commit>
      $ git commit -a -m 'first commit'
  2. Cherry-pick the rest of the commits you want: