Skip to content

Instantly share code, notes, and snippets.

Nicola Pernice yumyo

Block or report user

Report or block yumyo

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
@yumyo
yumyo / datalayer.php
Created Nov 6, 2019
WordPress Google Tag Manager Data Layer
View datalayer.php
<!-- K Google Tag Manager Data Layer -->
<script type="text/javascript">
// URL toolbox - helps grabbing elements in the URL
var _d = document;
var _dl = _d.location;
var _dlp = _dl.pathname;
var _dls = _dl.search;
var _dr = _d.referrer;
// Initialize your data layer and start pushing variables from custom WordPress PHP data layer
@yumyo
yumyo / wp-google-tag-manager
Created Nov 6, 2019 — forked from tankbar/wp-google-tag-manager
Add Google Tag Manager in WordPress with hooks and actions
View wp-google-tag-manager
<?php
/* ADD GTM TO HEAD AND BELOW OPENING BODY */
add_action('wp_head', 'google_tag_manager_head', 20);
function google_tag_manager_head() { ?>
<!-- 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);
View google-doc-cms-test.php
<?php
// This was a quick proof of concept from 2009, use the script freely - https://www.realisingdesigns.com/web-design-articles/using-google-docs-quick-easy-cms/
// Specify document
$gd_doc = "dd9zpc9r_4jh8qv76j";
$gd_doc_type = "doc";
$gd_array = array();
$gd_array["doc"]["url"] = "http://docs.google.com/View?id=".$gd_doc;
$gd_array["doc"]["start"] = '&lt;div id="doc-contents"&gt;';
@yumyo
yumyo / index.html
Created May 15, 2019
simple-landing
View index.html
<div class="img"></div>
<div class="hatch"></div>
@yumyo
yumyo / post-receive
Last active May 17, 2019
WP Dev/Test/Live ENV post-receive hook #devops
View post-receive
# The PROD directory
PROD="/var/www/main.domain/"
# The TEST directory
TEST="/var/www/test.domain/"
# The DEV directory
DEV="/var/www/dev.domain/"
# A temporary directory for deployment
TEMP="/home/[server_user]/temp-deploy/"
# The Git repo
REPO="/home/[server_user]/git-domain-bare/"
View WP-Autoload.php
<?php
/*
The MIT License (MIT)
Copyright (c) 2015 Twitter Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@yumyo
yumyo / WP Objects
Created Jul 4, 2018
List of WP Objects structure (WP_Post, WP_Post_Type, WP_Term)
View WP Objects
WP_Post Object
(
[ID] => 50491
[post_author] => 520
[post_date] => 2016-10-18 19:00:46
[post_date_gmt] => 2016-10-18 18:00:46
[post_content] =>
[post_title] => Home
[post_excerpt] =>
[post_status] => publish
View gist:89d34fffe3e862ba13ed98556e4ad1f9
(
[ID] => 2849
[date] => 1505489663
[post_type] => post
[sticky] =>
[format] => image
[url] => http://mysite/mypost
[url_target] => _self
[title] => Lorem Ipsum is not simply random text.
[excerpt] => Contrary to popular belief, Lorem Ipsum is not simply random text.
@yumyo
yumyo / what-forces-layout.md
Created Oct 9, 2017 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@yumyo
yumyo / translate-service
Created Aug 14, 2017
WordReference as a Service AppleScript
View translate-service
on run {input, parameters}
set phrase to input as string
set phrase to quoted form of phrase
set from_lang to "en"
set to_lang to "it"
do shell script "open 'https://www.wordreference.com/'" & from_lang & to_lang & "'/'" & phrase
end run
You can’t perform that action at this time.