Skip to content

Instantly share code, notes, and snippets.

View dimaspante's full-sized avatar
🚀

Dimas Pante dimaspante

🚀
View GitHub Profile
@dimaspante
dimaspante / tips.sql
Created January 3, 2023 16:20
MySQL tips
/*! Convert field content to utf8 */
UPDATE table SET field = convert(cast(convert(field using latin1) as binary) using utf8
@dimaspante
dimaspante / clip-path.css
Created November 10, 2022 12:39
A CSS file which uses the clip-path property, allowing you to make complex shapes in CSS basically using polygons. Summarized from https://bennettfeely.com/clippy/
/**
* CSS file created using Bennett Feely's clip-path generator <https://bennettfeely.com/clippy/>
*/
.clipped-parallelogram {
-webkit-clip-path: polygon(25% 0%, 100% 0%, 75% 100%, 0% 100%);
clip-path: polygon(25% 0%, 100% 0%, 75% 100%, 0% 100%);
}
.clipped-trapezoid {
@dimaspante
dimaspante / post_notification.php
Last active May 9, 2022 19:13
Exemplo de post de notificação e-commerce Cielo + antifraude Braspag
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json");
require_once '../vendor/autoload.php';
use Cielo\API30\Ecommerce\Browser;
Index:
<?php
define("RECAPTCHA_V3_SITE_KEY", "XXX");
?>
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo RECAPTCHA_V3_SITE_KEY; ?>"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo RECAPTCHA_V3_SITE_KEY; ?>', {action: 'contato'}).then(function(token) {
document.getElementById('recaptchaResponse').value = token;
@dimaspante
dimaspante / resumable-download.php
Created February 2, 2021 14:07 — forked from kosinix/resumable-download.php
PHP - resumable download
<?php
class ResumeDownload {
private $file;
private $name;
private $boundary;
private $delay = 0;
private $size = 0;
function __construct($file, $delay = 0) {
if (! is_file($file)) {
@dimaspante
dimaspante / functions.php
Created December 17, 2020 18:46
Cria menus padrão com itens (WP)
<?php
if ( ! function_exists( 'my_theme_setup' ) ) {
function my_theme_setup() {
//Ref. https://developer.wordpress.org/reference/functions/wp_create_nav_menu/
$menu_name = 'Menu 1';
$menu_exists = wp_get_nav_menu_object( $menu_name );
if( !$menu_exists ) {
$menu_id = wp_create_nav_menu($menu_name);
@dimaspante
dimaspante / .htaccess
Created November 24, 2020 21:49
Default htaccess with security headers
Options -Indexes
RewriteEngine On
# Force https
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Disable folder navigation
RewriteCond %{REQUEST_FILENAME} !-f
@dimaspante
dimaspante / ws_tnt.php
Last active November 14, 2022 20:00
Webservice TNT Logística
<?php
$xmlr = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.calculoFrete.mercurio.com" xmlns:mod="http://model.vendas.lms.mercurio.com">
<soapenv:Header/>
<soapenv:Body>
<ser:calculaFrete>
<ser:in0>
<mod:login>' . $user_login . '</mod:login>
<mod:senha></mod:senha>
<mod:nrIdentifClienteRem>' . $cnpj . '</mod:nrIdentifClienteRem>
@dimaspante
dimaspante / dias.js
Last active April 13, 2022 03:15
Exibe a hora e data por extenso no campo id dt_inscricao
function mostrarDataHora(){
var hoje = new Date();
//https://stackoverflow.com/questions/24998624/day-name-from-date-in-js
var days = ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'];
var mons = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var nome = days[hoje.getDay()];
var data = nome + ', ' + ("0" + hoje.getDate()).slice(-2) + ' de ' + mons[hoje.getMonth()] + ' de ' + hoje.getFullYear();
var hora = ("0" + hoje.getHours()).slice(-2) + ":" + ("0" + hoje.getMinutes()).slice(-2) + ":" + ("0" + hoje.getSeconds()).slice(-2);
@dimaspante
dimaspante / woo_functions.php
Last active May 2, 2023 04:46
Edições gerais para o Woocommerce no arquivo de funções do Wordpress
<?php
/**
* Altera detalhes nos forms de checkout
*
* Lista de campos disponível em:
* https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
*/
function my_shipping_fields($fields){
$fields['shipping']['shipping_address_2']['label_class'] = "visible"; //form de entrega