Skip to content

Instantly share code, notes, and snippets.

View petrusnog's full-sized avatar
🏠
Coding from home

Petrus Nogueira petrusnog

🏠
Coding from home
  • Fortaleza - CE
View GitHub Profile
@petrusnog
petrusnog / snippet.js
Last active November 11, 2020 05:16
How to automate this code snippet?
var $i = 1;
idea.keywords.forEach(function ( keyword ) {
if ( $i < idea.keywords.length ) {
this.keywords += keyword.text + ", ";
} else {
this.keywords += keyword.text + ".";
}
$i++;
});
@petrusnog
petrusnog / horario_bool.php
Last active October 27, 2020 15:06
Horário Bool - Função que retorna true ou false mediante o horário.
<?php
//
// Horário Bool - Função que retorna true ou false mediante o horário da requisição.
//
function horario_bool () {
$dias_da_semana = [
'Monday',
@petrusnog
petrusnog / carrinho.js
Last active October 8, 2020 02:59
Exemplo de módulo que chama Vue Components.
var carrinho = (function () {
Vue.component('carrinho-item', {
props: ['thumbnail', 'preco'],
template: `
<li class="carrinho-item">
<figure class="carrinho-thumb">
<img :src="thumbnail">
</figure>
<a class="carrinho-title" href="#"><slot></slot></a>
@petrusnog
petrusnog / rpg.html
Last active September 30, 2020 22:35
RPG Monster | Exercício em Vue.js
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>RPG</title>
<meta charset="utf-8">
<style media="screen">
@petrusnog
petrusnog / listas.html
Created September 29, 2020 03:49
Lista de contatos - My First Vue.js Application!
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Lista de contatos</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
<style media="screen">
#vueroot{
@petrusnog
petrusnog / product_visibility_hidden.php
Created July 20, 2020 22:36
Script that set all Woocommerce's "Product Visibility" to "Hidden"
<?php
$args = array(
"post_type" => "product",
"posts_per_page" => -1,
);
$post_query = new WP_Query($args);
if ( $post_query->have_posts() ) {
@petrusnog
petrusnog / get_filtered_terms.php
Last active July 17, 2020 14:27
Filtrar termos de produtos filtrados por tax e meta query. (Ex: Exibir as categorias de todos os produtos fora de estoque)
<?php
function get_filtered_terms ( $post_type, $taxonomy, $tax_query = 0, $meta_query = 0 ) {
//Filtra os posts de acordo com a filtragem passada
$args = [
"post_type" => $post_type,
"posts_per_page" => -1,
];
if ( $tax_query ) {
@petrusnog
petrusnog / lightbox-template.php
Last active June 2, 2020 00:09
Sistema de Lightbox para vídeos
<?php
//wp_is_ipad vai em functions.php
function wp_is_ipad ( ) {
if( strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') ) {
return true;
} else{
return false;
}
}
//SISTEMA DE DROPDOWNS
//Configurações dos dropdowns
//Argumentos
// [0] => (String) (Obrigatório) Título,
// [1] => (Boolean) (Default: false) Apenas Mobile,
// Para manter os valores padrões, adicione apenas o título no array $dropdowns
// Para modificar os valores padrões, adicione um array no array $dropdowns com as modificações
@petrusnog
petrusnog / brazilian_real_notation.php
Created May 14, 2020 19:34
Brazilian Real Notation - A simple PHP snipppet to convert numbers to brazilian real currency.
function brazilian_real_notation ( $price = 0 ) {
return "R$" . number_format($price, 2, ',', '.');
}