Skip to content

Instantly share code, notes, and snippets.

View zguillez's full-sized avatar
🚀
Dev Rocket

Guillermo de la Iglesia zguillez

🚀
Dev Rocket
View GitHub Profile
@zguillez
zguillez / Event_Controller
Last active June 20, 2023 21:37
GTM - Event_Controller
<script>
window.dataLayer = window.dataLayer || [];
var botones = document.querySelectorAll('.btn');
var botones_ = [
['LIKE', 'boton_like'],
['CONTACT', 'boton_contact']
];
botones.forEach(function (boton) {
var href = boton.getAttribute('href');
var target = boton.getAttribute('target');
@zguillez
zguillez / Click_Logger
Created June 20, 2023 14:34
GTM Click_Logger
<script>
console.log('[@][click:element]', {{Click Element}});
console.log('[@][click:id]', {{Click ID}});
console.log('[@][click:classes]', {{Click Classes}});
console.log('[@][click:text]', {{Click Text}});
console.log('[@][click:url]', {{Click URL}});
console.log('[@][click:target]', {{Click Target}});
</script>
<?php
$plaintext = "test@test.com";
$key = "secret";
$method = "AES-256-CBC";
$iv_length = openssl_cipher_iv_length($method);
$iv = openssl_random_pseudo_bytes($iv_length);
$ciphertext = openssl_encrypt($plaintext, $method, $key, OPENSSL_RAW_DATA, $iv);
$ciphertext = base64_encode($iv . $ciphertext);
@zguillez
zguillez / Debug.php
Created March 1, 2023 11:33
Display errors and warnings in PHP
/**
* require_once __DIR__ . '/inc/debug.php';
* $debugger = new Debug(true);
*/
class Debug
{
public function __construct($debug)
{
if ($debug) {
ini_set('display_startup_errors', 1);
@zguillez
zguillez / cors.php
Created March 1, 2023 11:28
Allow cors in PHP
header("Content-Type: application/json;charset=utf-8");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
header("Access-Control-Allow-Methods: POST, OPTIONS");
header("Allow: POST, OPTIONS");
$method = $_SERVER['REQUEST_METHOD'];
if ($method == "OPTIONS") {
die();
}
@zguillez
zguillez / wp-code-snippet-gtm
Created February 22, 2023 12:24
Add GTM in code snipped wordpress plugin
add_action( 'wp_head', function () { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
<?php } );
@zguillez
zguillez / dataLayer-event-variable
Created February 22, 2023 11:13
Get variable from dataLayer event
function() {
for (var i=0; i<dataLayer.length; i++) {
if (dataLayer[i][0]==='event' && dataLayer[i][1]==='view_item') {
return dataLayer[i][2].items[0].id;
}
}
}
@zguillez
zguillez / .zshrc
Created February 12, 2023 15:39
bash alias
alias c="clear"
alias zls="clear; ls -lash"
alias zgit="clear; git log --oneline --all --graph; git branch -vva; git status"
alias zpull="git pull origin"
alias zcommit="git add --all; git commit -am"
alias zpush="git push origin"
alias zupdate="git add --all; git commit -am update; git push origin --tags"
alias zdocs="clear; cd $HOME/Documentos"
alias zdown="clear; cd $HOME/Downloads"
alias zrepos="clear; cd $HOME/Documentos/Repositorios"