Skip to content

Instantly share code, notes, and snippets.

View bzin's full-sized avatar
🔲 ⬛ 🔳 ⬛ 🔲

Ruben Nascimento bzin

🔲 ⬛ 🔳 ⬛ 🔲
View GitHub Profile
@bzin
bzin / createMarkup.js
Created November 5, 2020 13:34
Create markup util for React dangerouslysetinnerhtml
/**
* Create markup for React dangerouslySetInnerHTML
* Read: https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
*
* @param text
* @returns {{__html: *}}
*/
const createMarkup = (html) => {
return {
__html: html || ''
@bzin
bzin / Seo.js
Last active November 5, 2020 13:34
SEO React component to use with Seomatic plugin in combination with Next.js
import Head from 'next/head'
import { parse } from 'node-html-parser'
// Utilitation function to deal with https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
// See: https://gist.github.com/bzin/a348421f733ee177a943669956dcd6b9#file-createmarkup-js
import createMarkup from '../../utils/createMarkup'
const Seo = (props) => {
const metaTitleContainer = JSON.parse(props.metaTitleContainer).title || { title: '' }
const metaScriptContainer = JSON.parse(props.metaScriptContainer)
@bzin
bzin / cli-commands-dev-ops.md
Last active August 23, 2022 07:57
CLI commands and other snippets that I use all the time

Server backups (utils commands)

Use the below CLI commands to backup important files in a server.

PS: have in mind that this assumes a specific folder structure

cd / && tar -zcf /data/backup/server_etc_[project-name]_prod_backup_[date].tar.gz etc
cd /data && tar -zcf /data/backup/projects_[project-name]_prod_backup_[date].tar.gz projects
cd backup/ && mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-[project-name]-backup-$(date +%F).sql -u root -p