Skip to content

Instantly share code, notes, and snippets.

View HenriqueSilverio's full-sized avatar
🎯
Focusing

Henrique Silvério HenriqueSilverio

🎯
Focusing
View GitHub Profile
const BrokerManager = function BrokerManager () {
let connection = null
let channel = null
return Object.create({
async getConnection () {
if (!connection) {}
return connection
},
async getChannel () {
if (!channel) {}
(() => {
const tracksSelector = '.tracklist-row'
const $tracks = Array.from(document.querySelectorAll(tracksSelector))
const tracks = $tracks.reduce((result, track) => {
const { name, artist } = {
name: track.querySelector('.tracklist-name').innerText.trim(),
artist: track.querySelector('.tracklist-row__artist-name-link').innerText.trim()
}
return `${result}\n${name} - ${artist}`
}, '')
<?php
function getChildrenProducts()
{
$productId = get_the_ID();
$product = wc_get_product($productId);
$childrenIds = $product->get_children();
if (empty($childrenIds)) {
return [];
<?php
function str_random($length = 16)
{
$string = '';
$len = strlen($string);
while ($len < $length) {
$size = $length - $len;
@HenriqueSilverio
HenriqueSilverio / 01--src-Contracts-Shortcode.php
Last active October 19, 2018 13:08
Object-Oriented approach to create shortcodes in WordPress plugins.
<?php
namespace MyPlugin\Contracts;
interface Shortcode
{
public function getTag(): string;
public function start(): void;
@HenriqueSilverio
HenriqueSilverio / permissions-seeder.php
Last active September 23, 2018 16:14
Laravel Roles and Capabilities seeder sample.
<?php
use App\Models\Role;
use App\Models\Capability;
use Illuminate\Database\Seeder;
class PermissionsSeeder extends Seeder
{
private $roles = [[
'slug' => 'administrator',
@HenriqueSilverio
HenriqueSilverio / fresh-wp-install-with-wp-cli.md
Last active October 3, 2018 16:46
Commands to build a fresh WordPress install using WP-CLI.

1. wp core download

2. wp core install

3. wp config create --dbname=wpdev --dbuser=homestead --dbpass=secret --dbcharset=utf8mb4 --dbcollate=utf8mb4_general_ci

4. wp config set WP_DEBUG true --raw --type=constant

5. wp core install --url={{ url }} --title={{ title }} --admin_user={{ user }} --admin_password={{ pass }} --admin_email={{ email }} --skip-email

class Field {
constructor(options = {}, validator = {}) {
this.props = {
id: options.id,
type: options.type,
label: options.label,
feedback: options.feedback,
placeholder: options.placeholder,
}
@HenriqueSilverio
HenriqueSilverio / redis-setup.md
Last active July 24, 2018 17:25
Passo a passo sobre como instalar e configurar o Redis em servidor Ubuntu.

Redis: Instalação e configuração

Pré-requisitos

Para instalar o Redis vamos precisar dos pacotes build-essential e tcl.

Instale os pacotes com o seguinte comando:

sudo apt-get update

@HenriqueSilverio
HenriqueSilverio / ssl-tls-nginx.md
Last active February 26, 2022 15:03
Instalação/Configuração de SSL/TLS no Nginx com Let’s Encrypt

SSL/TLS no Nginx com Let’s Encrypt

Instalar o cliente do Let’s Encrypt

Primeiro adicione o repositório do certbot com o seguinte comando:

add-apt-repository ppa:certbot/certbot

Em seguida instale o certbot e o plugin para o Nginx: