Skip to content

Instantly share code, notes, and snippets.

@mbaersch
mbaersch / callback-example.js
Last active July 16, 2020 14:16
Upgrade Your Analytics Cookies to fight ITP2.1:
/* GTM : use the following code inside a customTask, hitCallback oder a cleanup tag
GA.JS : modify your existing tracking code with a customTask or hitCallback and execute the following code
GTAG.JS : modify your existing tracking code with a manual page_view event
including an event_callback (gtag.js) and execute the following code
customTask ga.js - see: https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks#adding_to_a_task
hitCallback ga.js - see: https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits#hitcallback
event_callback gtag.js - see: https://developers.google.com/analytics/devguides/collection/gtagjs/sending-data#implement_event_callback_functions
*/
{
"vars": {
"account": "account_name",
"profile": "profile_name",
"visitor_id": "CLIENT_ID(AMP_ECID_GOOGLE)",
"gclid": "${queryParam(gclid)}"
},
"extraUrlParams": {
"page_name": "home page for company x",
@prasetyop
prasetyop / admin.css
Last active March 13, 2023 13:33
Flexible Content Preview Pop Up
.acf-fc-popup .preview {
position: absolute;
right: 100%;
margin-right: 0px;
top: 0;
background: #383c44;
min-height: 100%;
border-radius: 5px;
align-content: center;
display: grid;
@ChrisFlannagan
ChrisFlannagan / geodistance.php
Created October 13, 2017 16:52
Calculate distance between to coordinates of latitude and longitude using the WP REST API and return posts ordered by distance from user's coordinates
<?php
/**
* Heavily borrowed from: http://xplus3.net/2010/08/08/filtering-on-a-non-standard-database-field-with-wordpress/
**/
class CoordinatesTable extends DB {
protected $db_option = "coordinates_db";
var l=['keydown','keypress','keyup','fullscreenerror','resize','scroll','submit','copy','paste','mouseover','mousemove','mousedown','mouseup','auxclick','click','dblclick','contextmenu','wheel','mouseleave','mouseout','select','pointerlockchange','pointerlockerror','drag','dragend','dragenter','dragover','dragleave','drop'],a=false;
dfwp_unregister = function(){
l.map(function(el){window.removeEventListener(el,dfwp_initGtm)});
};
dfwp_initGtm = function(){
if (!a){
a=true;
(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=
@nickdavis
nickdavis / acf-fields-repeater.php
Created November 10, 2016 10:59
Advanced Custom Fields > Repeater field example (set programatically)
<?php
add_action( 'acf/init', 'nd_acf_add_local_field_groups' );
/**
* Add Advanced Custom Fields programatically (Repeater field).
*
* @link https://www.advancedcustomfields.com/resources/register-fields-via-php/
* @link https://support.advancedcustomfields.com/forums/topic/register-two-locations-via-php-doesnt-work/
* @link https://support.advancedcustomfields.com/forums/topic/adding-additional-layout-to-flexible_content-field-in-child-theme/
*
@b4tman
b4tman / fan_ctrl.py
Last active March 28, 2023 09:57
Включение и регулировка скорости вращения вентилятора в зависимости от температуры для Raspberry Pi с помощью программной реализации ШИМ
#!/usr/bin/env python
# coding: utf8
# скрипт мониторит температуру, и с помощью ШИМ управляет
# GPIO пином (0-3В), который должен быть подключен на базу транзистора,
# который является ключем в цепи питания вентилятора (5В).
# пример подключения вентилятора через ключ:
# https://easyeda.com/b4tman.p2p/rpi-fan-01
# параметры:
@paulirish
paulirish / what-forces-layout.md
Last active November 15, 2024 16:45
What forces layout/reflow. The comprehensive list.

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.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@ericandrewlewis
ericandrewlewis / gist:95239573dc97c0e86714
Last active September 11, 2024 17:10
Setting up a WordPress site on AWS

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.