Skip to content

Instantly share code, notes, and snippets.

View FelipeGangrel's full-sized avatar

Felipe Pires de Oliveira FelipeGangrel

View GitHub Profile
@FelipeGangrel
FelipeGangrel / getExcerpt
Last active February 10, 2021 18:25
getHtmlExcerpt.js
export function getExcerpt(htmlString, length) {
const span = document.createElement("span");
span.innerHTML = htmlString;
const outputString = span.textContent || span.innerText;
if (outputString.length > length) {
// obtendo os *length* primeiros caracteres sem quebrar palavras
// usando flag s para tratar a string como single line
const exp = new RegExp(`^(.{${length}}[^\\s]*).*`, "s");
@FelipeGangrel
FelipeGangrel / react-native-android-studio-no-wsl2.md
Last active July 4, 2021 18:29 — forked from georgealan/react-native-android-studio-no-wsl2.md
React Native no Emulador Android Studio com WSL2

PROJETOS REACT-NATIVE RODANDO NO WSL2 UBUNTU 20.04 COM API BACKEND

📆 Artigo escrito dia: 03/09/2020 📆 Artigo atualizado dia: 10/10/2020

Minhas especificações: Microsoft Windows 10 Enterprise Versão 2004 (Compilação 19041.450). WSL2 - Ubuntu 20.04.

INDÍCE

@FelipeGangrel
FelipeGangrel / docker-compose.yml
Created July 12, 2021 20:10
Useful Docker Compose Config
# For mysql use root/root as user/password
# For ftp use admin/123 as user/password
version: "3.3"
services:
db:
image: mysql
container_name: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
@FelipeGangrel
FelipeGangrel / PortProxyWithNetshOnPowerShell.md
Last active September 30, 2021 17:04
Port proxy with netsh on PowerShell
netsh interface portproxy add v4tov4 listenport=3333 listenaddress=0.0.0.0 connectport=3333 connectaddress=<YOUR_IP>
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
export PS1='\[\e[\033[01;34m\]\u@\h \[\e[38;5;211m\]\W\[\e[\033[38;5;48m\] $(parse_git_branch)\[\e[\033[00m\]\$ '
@FelipeGangrel
FelipeGangrel / rn-with-wsl-wsa.md
Created August 28, 2022 12:38 — forked from xquangdang/rn-with-wsl-wsa.md
Develop React Native app with WSL and WSA

Develop React Native app with WSL and WSA

Requirement

  • Windows Subsystem for Linux 2 (WSL2)
  • Windows Subsystem for Android (WSA)
  • NodeJS install inside WSL2

Steps

WSA

@FelipeGangrel
FelipeGangrel / MysqlRestoreFromDump
Created October 26, 2024 21:51
Restore Mysql database from dump file on docker
docker exec -i [container_name] sh -c 'exec mysql -u root -p"$MYSQL_ROOT_PASSWORD" [database_name]' < /path/to/dump.sql