Skip to content

Instantly share code, notes, and snippets.

View gxcsoccer's full-sized avatar
🎯
Focusing

zōng yǔ gxcsoccer

🎯
Focusing
  • Alibaba
  • Hangzhou
View GitHub Profile
(function() {
var cache = {};
this.tmpl = function(str, data) {
cache[str] = cache[str] ||
new Function('data', [
'var _p="";\nwith(arguments[0]||{}){\n_p+="',
str.replace(/"/g, '\\$&')
.replace(/[\r\n]/g, '')
.replace(/<%([^\w\s\}\)]*)\s*(.*?)\s*%>/g, function(match, mark, code) {
if (mark === '=') return '"+(' + code + ')+"';
@wintercn
wintercn / HTMLLexicalParser.js
Last active August 5, 2019 11:16
HTML语法分析器模型
function StartTagToken(){
}
function EndTagToken(){
}
function Attribute(){
}
@wintercn
wintercn / showboxes.js
Created May 21, 2013 06:34
显示页面的盒结构
function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);
@kejun
kejun / dabblet.css
Created May 3, 2013 14:03
Untitled
p:nth-child(1) {
font-size: 12px;
margin: 20px;
width: 200px;
height: 150px;
-webkit-hyphens: auto;
-webkit-shape-inside: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
overflow: hidden;
}
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
var config = require('./config.js'),
xml2js = require('xml2js'),
http = require('http');
var baiduZm = function() {
this.root = "box.zhangmen.baidu.com";
};
baiduZm.prototype = {
constructor: baiduZm,
@wondger
wondger / foreRequire.js
Created October 12, 2012 08:56
reload nodejs module without cache
function foreRequire(module) {
delete require.cache[path.resolve(module)];
return require(module);
}
@wondger
wondger / LevenshTeinDistance.js
Created April 26, 2012 17:43
LevenshTeinDistance
/*
* @name:LevenshteinDistance.js
* @description:
* @author:wondger@gmail.com
* @date:2012-04-17
* @param:
* @todo:
* @changelog:
*/
var LevenshteinDistance = {
@hagino3000
hagino3000 / method_missing.js
Last active January 16, 2020 13:11
__noSuchMethod__ for Chrome
/**
* Enable route to __noSuchMethod__ when unknown method calling.
*
* @param {Object} obj Target object.
* @return {Object}
*/
function enableMethodMissing(obj) {
var functionHandler = createBaseHandler({});
functionHandler.get = function(receiver, name) {