Skip to content

Instantly share code, notes, and snippets.

View 6174's full-sized avatar

Marc Chen 6174

View GitHub Profile
@6174
6174 / collapsiblelists.js
Created March 8, 2014 09:27
collapsiblelists.js
/*
CollapsibleLists.js
An object allowing lists to dynamically expand and collapse
Created by Stephen Morley - http://code.stephenmorley.org/ - and released under
the terms of the CC0 1.0 Universal legal code:
http://creativecommons.org/publicdomain/zero/1.0/legalcode
@6174
6174 / canvas-blur-image.js
Last active June 28, 2022 17:50
canvas image blur
/**
* Light layer on top of a canvas element to represent an image displayed
* within. Pass in a canvas element and an Image object and you'll see the
* image within the canvas element. Use the provided methods (e.g. blur) to
* manipulate it.
*
* @constructor
* @param {HTMLElement} element HTML canvas element.
* @param {Image} image Image object.
*/
@6174
6174 / ast_traversal.js
Created February 21, 2014 08:38
ast traversal
/*
Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
@6174
6174 / fuzzy_search.js
Created February 20, 2014 09:12
sublime text like fuzzy search
/**
* Fuse - Lightweight fuzzy-search
*
* Copyright (c) 2012 Kirollos Risk <kirollos@gmail.com>.
* All Rights Reserved. Apache Software License 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
if (!window.__p) {
window.originalSetTimeout = setTimeout;
window.originalSetInterval = setInterval;
eval("var setTimeout, setInterval;");
setTimeout = function() {
return Function.prototype.apply.call(window.newSetTimeout, null, arguments);
};
setInterval = function() {
return Function.prototype.apply.call(window.newSetInterval, null, arguments);
};
var args = Array.prototype.slice.call(arguments, 0);
var condExpr = args[0], timeout = args[1],
poll = args[2], cb = args[3];
var waitForConditionImpl = function(conditionExpr, limit, poll, cb) {
if ((new Date().getTime()) < limit) {
var res = eval(conditionExpr);
if (res === true ) {
cb(res);
} else {
setTimeout(function() {
function defineProperty(me, children, data, p){
Object.defineProperty(me, p,{
get:function(){
if(typeof data[p] == "object")
return children[p];
else return data[p];
},
set:function(v){
data[p] = v ;
me.dispatchEvent({
<!DOCTYPE html>
<html>
<head>
<title>DEMO</title>
<script type="text/javascript" src="simple_javascript_templating.js"></script>
</head>
<body>
<table id="table_1">
</table>
<script type="text/html" id="tmpl_1">