Skip to content

Instantly share code, notes, and snippets.

@dciccale
dciccale / demo.html
Created June 4, 2014 11:10
Client-side template engine
<!doctype html>
<script>function t(s,d){for(var k in d)s=s.replace(new RegExp('{{\\s*'+k+'\\s*}}','g'),d[k]);return s;}</script>
<script type="template" id="tmpl">
<h1>Hello {{ name }}!</h1>
</script>
<script>
var tmpl = document.getElementById('tmpl').innerHTML;
@dciccale
dciccale / insertAfter
Created April 27, 2011 18:47
JavaScript insertAfter function
// JavaScript function to insert a node after another node
function insertAfter(node, nodeToInsert) {
node.parentNode.insertBefore(nodeToInsert, node.nextSibling);
}
@dciccale
dciccale / LICENSE.txt
Created August 2, 2011 00:00 — forked from 140bytes/LICENSE.txt
FormValidator.js - Form validation in 114 bytes of JavaScript
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Denis Ciccale <http://webdecs.wordpress.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@dciccale
dciccale / NOTE.txt
Created August 6, 2011 19:42
Extend jQuery form selectors expressions with HTML5 input types
** IMPORTANT **
This will only work on modern browsers that supports these new input types, if not they will be treated as "text" types.
@dciccale
dciccale / anotated.js
Created August 31, 2011 09:37
Detect if Flash Player is installed in your browser and get its version (180bytes)
function(a, b) {
try {
b = new ActiveXObject(a+b+'.'+a+b).GetVariable('$version')
} catch (e) {
b = navigator.plugins[a+' '+b];
b = b ? b.description : "";
}
return b.match(/\d+/)[0];
@dciccale
dciccale / html5ie.js
Created December 23, 2011 14:50
HTML5 tag support for IE<9 in 222 bytes
for(var a="abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),b=a.length;b--;)document.createElement(a[b])
@dciccale
dciccale / README.md
Last active September 29, 2015 19:27
jQuery xxspubsub in 111 bytes gzipped inspired by @cowboy's Tiny Pub/Sub

jQuery XXSPubSub

jQuery pub/sub in 111 bytes gzipped inspired by @cowboy's Tiny Pub/Sub

@dciccale
dciccale / README.md
Last active December 9, 2015 17:49
requestAnimationFrame shim in 155 bytes (127 gzipped)

requestAnimationFrame shim

Cross-browser requestAnimationFrame in 155 bytes of JavaScript.

.vimrc.json

A demo to see how it would be to have a .vimrc with json syntax.

@dciccale
dciccale / README.md
Last active December 11, 2015 08:18
hasOwnProperty shim in 115 bytes (counting only the actual function)

hasOwnProperty shim

Cross-browser hasOwnProperty shim in 115 bytes of JavaScript.