Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Henrique Silvério HenriqueSilverio

Block or report user

Report or block HenriqueSilverio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View get-children-products.php
<?php
function getChildrenProducts()
{
$productId = get_the_ID();
$product = wc_get_product($productId);
$childrenIds = $product->get_children();
if (empty($childrenIds)) {
return [];
View str_random.php
<?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 Oct 19, 2018
Object-Oriented approach to create shortcodes in WordPress plugins.
View 01--src-Contracts-Shortcode.php
<?php
namespace MyPlugin\Contracts;
interface Shortcode
{
public function getTag(): string;
public function start(): void;
@HenriqueSilverio
HenriqueSilverio / permissions-seeder.php
Last active Sep 23, 2018
Laravel Roles and Capabilities seeder sample.
View permissions-seeder.php
<?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 Oct 3, 2018
Commands to build a fresh WordPress install using WP-CLI.
View fresh-wp-install-with-wp-cli.md

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

View 01-text-field.js
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 Jul 24, 2018
Passo a passo sobre como instalar e configurar o Redis em servidor Ubuntu.
View redis-setup.md

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 Oct 23, 2018
Instalação/Configuração de SSL/TLS no Nginx com Let’s Encrypt
View ssl-tls-nginx.md

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:

View api-worker.conf
[program:api-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/api.com.br/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/api.com.br/worker.log
@HenriqueSilverio
HenriqueSilverio / eloquent-relationships.php
Created Mar 30, 2018
Ajuda em tópico sobre relacionamento de tabelas usando Eloquent, no grupo Laravel Brasil do Facebook: https://www.facebook.com/groups/laravelbrasil/permalink/1755843834437664/
View eloquent-relationships.php
<?php
// Arquivo `/app/Estado.php`:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Estado extends Model
{
You can’t perform that action at this time.