Skip to content

Instantly share code, notes, and snippets.

lifesinger lifesinger

Block or report user

Report or block lifesinger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mock-rules
[
'{{repeat(5, 7)}}',
{
id: '{{index}}',
guid: '{{guid}}',
isActive: '{{bool}}',
balance: '{{numeric(1000,4000,%=$0,0.00)}}',
picture: 'http://placehold.it/32x32',
age: '{{numeric(20,40)}}',
name: '{{firstName}} {{surname}}',
View gist:6665622
for (var i = 0; a < 3; i++) {
setTimeout(function() {
console.log(a);
}, 0);
};
// 控制台中的输出结果是什么?
View gist:3360992
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==

function xx() {
function hello(name) {
  alert('Hello, ' + name);
}
eval('(hello("New user"))')
View gist:3176815
// oldj:设 A = $("#id a"),B = $("#id .c a"),求 A - B。要求:
// 1、不能用 jQuery 等框架;
// 2、兼容 IE6 在内的各大浏览器;
// 3、尽可能高效;
// 4、尽可能简短。
function getWanted() {
var root = document.getElementById('id')
var all = root.getElementsByTagName('*')
@lifesinger
lifesinger / gist:2584518
Created May 3, 2012
eventproxy questions
View gist:2584518

朴灵的 EventProxy, README 里有个例子:

var proxy = new EventProxy();
var render = function (template, data, l10n){
    _.template(template, data);
};
proxy.assign("template", "data", "l10n", render);
$.get("template", function (template) {
    // something
View script-for-3pc.js
<script>
;(function(d, s, c, n, h) {
c = d.getElementsByTagName(s);
c = c[c.length - 1]; c.id = "t-a-{pid}";
n = d.createElement(s);
n.async = 1;
n.src = 'http://{host}/{path}?i={pid}';
h = d.getElementsByTagName('head')[0];
if(h) h.insertBefore(n, h.firstChild);
})(document, 'script');
View detect-ie.js
/**
* modified from http://gist.github.com/527683
* only improve slightly to get small
*/
var ie = function(v, p, needle, undef) {
needle = p.getElementsByTagName('br');
while(
p.innerHTML = '<!--[if gt IE ' + (++v) + ']><br><![endif]-->',
You can’t perform that action at this time.