Skip to content

Instantly share code, notes, and snippets.

@blanklob
blanklob / ga4-shopify-custom-pixel.js
Created July 1, 2023 23:40
Google Analytics 4 Shopify Custom Pixel
// Step 1. Add and initialize your third-party JavaScript pixel (make sure to exclude HTML)
// Replace with you GA4 Tag
const TAG_ID = 'G-XXXXXXXXXX';
const script = document.createElement('script');
script.setAttribute('src', `https://www.googletagmanager.com/gtag/js?id=${TAG_ID}`);
script.setAttribute('async', '');
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
@sambacha
sambacha / search.graphql
Last active April 26, 2024 08:24
Every Solidity Release and its description
{
repository(owner: "ethereum", name: "solidity") {
description
id
sshUrl
url
releases(last: 100) {
totalCount
nodes {
id
/* jshint ignore:start */
// Blows up jshint errors based on the new Function constructor
//Templating methods
//Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
cache = {},
template = helpers.template = function(templateString, valuesObject){
// If templateString is function rather than string-template - call the function for valuesObject
if(templateString instanceof Function){
return templateString(valuesObject);
@dmikey
dmikey / gist:6800380
Created October 2, 2013 20:53
Simple jquery template usage $(element for display).($template as jquery selector, data);
$.fn.tmpl = function(template, data){
var _ = {
cache: {},
// John Resig - simple html template
render: function render(template, data) {
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(template) ?
_.cache[template] = _.cache[template] ||
render(document.getElementById(template).innerHTML) :
@mcmlxxxiii
mcmlxxxiii / tmpl.js
Created July 19, 2011 13:21
Microtemplating function of John Resig
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
@pazguille
pazguille / index.html
Last active April 26, 2024 08:23
Simple JavaScript Templating by John Resig
<script type="text/html" id="item_tmpl">
<div id="<%=id%>" class="<%=(i % 2 == 1 ? " even" : "")%>">
<div class="grid_1 alpha right">
<img class="righted" src="<%=profile_image_url%>"/>
</div>
<div class="grid_6 omega contents">
<p><b><a href="/<%=from_user%>"><%=from_user%></a>:</b> <%=text%></p>
</div>
</div>
</script>
@taufiqpsumarna
taufiqpsumarna / clear-docker-cache.sh
Last active April 26, 2024 08:23
Used to cleanup unused docker containers and volumes in Gitlab Runner
#!/usr/bin/env bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
#########################################################################################
# SCRIPT: clear-docker-cache.sh
# Description: Used to cleanup unused docker containers and volumes
# Source: https://gitlab.com/gitlab-org/gitlab-runner/blob/main/packaging/root/usr/share/gitlab-runner/clear-docker-cache
######################################################################################
IFS=$'\n\t'
set -euo pipefail
<?php
/**
* Read ACF fields from JSON
*/
function PREFIX_acf_register_json_fields() {
if (function_exists("acf_add_local_field_group")) {
$acf_json_data = locate_template("path/to/advanced-custom-fields.json");
$custom_fields = $acf_json_data ? json_decode(file_get_contents($acf_json_data), true) : array();
foreach ($custom_fields as $custom_field) {
@guzmonne
guzmonne / utils.js
Created June 24, 2017 21:56
cognito-auth.utils.js
(function(win){
// Simple JavaScript Templating
// John Resig - https://johnresig.com/ - MIT Licensed
// https://johnresig.com/blog/javascript-micro-templating/
//
// There are some minor modification done by me.
var cache = {};
function tmpl(str, data){
var fn;
@3rd-Eden
3rd-Eden / README.md
Created March 16, 2015 13:04
BigPipe & React sitting a tree.
  • BigPipe and React
  • React components
  • Share state
  • Server Side rendering
  • Modularization of components
  • Re-initialization
    • checksum
    • event adding
    • html bloat
  • JSX