- BigPipe and React
- React components
- Share state
- Server Side rendering
- Modularization of components
- Re-initialization
- checksum
- event adding
- html bloat
- JSX
Discover gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 || []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
repository(owner: "ethereum", name: "solidity") { | |
description | |
id | |
sshUrl | |
url | |
releases(last: 100) { | |
totalCount | |
nodes { | |
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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) : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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] || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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; |
NewerOlder