- 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
// 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; |
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() { | |
var cache = {}; | |
this.tmpl2 = 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] || | |
tmpl(document.getElementById(str).innerHTML) : |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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, Server-Side String Interpolation | |
* Base on John Resig's Microtemplating: http://ejohn.org/blog/javascript-micro-templating/ | |
* | |
* @param str {String} A string with key or object path in handlebar-like syntax: e.g. {{user.name}} | |
* @param data {Object} The data source with with to grab the key matching values | |
* @return {String} The final string with key-value replacements | |
*/ | |
var safeInterpolate = function safeInterpolate (str, data){ | |
// Create a new function with the template converted into executable code. | |
var fn = new Function("obj", |
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 - https://johnresig.com/ - MIT Licensed | |
// Forked by @yuzulabo | |
(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) ? |
NewerOlder