Skip to content

Instantly share code, notes, and snippets.

View camaleaun's full-sized avatar

Gilberto Tavares camaleaun

  • Yogh
  • Joinville SC, Brazil
  • 11:01 (UTC -03:00)
View GitHub Profile
@camaleaun
camaleaun / .editorconfig
Last active May 22, 2018 02:02
Recaptcha v2 php
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
charset = iso-8859
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@camaleaun
camaleaun / cpfcnpj.js
Last active January 7, 2020 20:22
CPF and CNPJ validators
String.prototype.pad = function (length) {
'use strict';
var s = this;
while (s.length < length) {
s = '0' + s;
}
return s;
};
String.prototype.numbers = function () {
'use strict';
@camaleaun
camaleaun / genpwd
Last active November 10, 2018 19:59
Generate password like in wp
#!/bin/bash
rand() {
RANGE=$2
rand=$RANDOM
let "rand %= $RANGE"
}
generate_password() {
chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
@camaleaun
camaleaun / testpost.php
Created December 11, 2017 12:51
Test post
<?php
print_r($_POST);
?>
<form method="POST" action="testpost.php">
<input type="hidden" name="prod" value="teste" />
<button class="btn-orcamento center-block" type="submit">adicionar ao orçamento</button>
</form>
<div class="budget">
<p>Solicite um orçamento</p>
<form class="form-pedido" id="form-pedido-add" method="post" action="<?php echo esc_attr( site_url() ); ?>/orcamento">
<?php wp_nonce_field( 'ac_nonce_produtos', 'nonce_produtos', true, true ); ?>
<input type="hidden" name="type_page_verify" value="produtos" />
<input type="hidden" name="prod" value="<?php the_ID(); ?>"/>
<?php
$cores = get_field( 'cores' );
if ( $cores ) {
@camaleaun
camaleaun / single-product.php
Created November 30, 2017 02:33
Logic to make carousel for gallery thumbs with four children in each item
<?php
/**
* The Template for displaying all single products
*
* @package gallery-thumbs
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@camaleaun
camaleaun / Requirements.php
Last active November 17, 2017 00:16
Interface HTML by PHP to show info from endpoint JSON API
<?php
declare(strict_types=1);
/**
* Interface to JSON endpoint.
*/
namespace GilbertoTavares;
/**
* Class to GET JSON and print.
@camaleaun
camaleaun / devopsopening.md
Last active April 26, 2020 01:52
Setup Nginx web server with PHP and WordPres environment
  1. Connect to server

Only first connection to create username and SSH configure:

$ ssh root@domain

Recomended (most secure):

@camaleaun
camaleaun / bulkrename.sh
Created November 7, 2017 15:12
Rename images without spaces and special characteres for import
#!/bin/bash
slug() {
slug="$1"
slug=${slug,,}
slug=${slug// /_}
slug=${slug//ó/o}
slug=${slug//ô/o}
slug=${slug//é/e}
slug=${slug//ú/u}
@camaleaun
camaleaun / weathersbs.sh
Last active November 7, 2017 15:38
Get temperatures from company of water service in São Bento do Sul SC - Brazil
#!/bin/bash
echo 'Temperatures in São Bento do Sul SC - Brazil'
CURL=$(curl -s http://www.samaesbs.sc.gov.br/)
NOW=$(echo $CURL | grep -oP 'temperatura\">\K([\d.]+)')
HIGH=$(echo $CURL | grep -oP '_max\">\K([\d.]+)')
LOW=$(echo $CURL | grep -oP '_min\">\K([\d.]+)')
echo " Now $NOWºC"