Skip to content

Instantly share code, notes, and snippets.

@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
(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) :
@eldrichgaiman
eldrichgaiman / tangela.svg
Created April 23, 2024 15:21
Tangela random tangle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cerebrl
cerebrl / safeInterpolate.js
Created March 11, 2015 23:07
Simple Server-Side String Interpolation. Demo: http://jsbin.com/pipudujixo/1/edit. Requires safeGet() here: https://gist.github.com/cerebrl/a52b69aafa9bf820bb1e
/* 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",
@nzws
nzws / tmpl.js
Last active April 26, 2024 08:21
// 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) ?