Skip to content

Instantly share code, notes, and snippets.

View leeluolee's full-sized avatar
🎯
Focusing

ZhengHaibo leeluolee

🎯
Focusing
View GitHub Profile
@leeluolee
leeluolee / webkit-scrollbar.css
Created April 15, 2012 11:38
webkit自定义scrollbar
/*SCROLL BAR*/
body::-webkit-scrollbar-track-piece{
background-color:#fafafa;
-webkit-border-radius:0;
-moz-border-radius:0;
border-radius:0;
-webkit-border-bottom-right-radius:8px;
-webkit-border-bottom-left-radius:8px;
border-top-left-radius:0 0;
border-top-right-radius:0 0;
@leeluolee
leeluolee / node-cmd.js
Created April 22, 2012 06:47
node 命令行
// --- SETTINGS ---
var COMPILER_JAR = 'build/compiler.jar';
// --- SETUP ---
var _exec = require('child_process').exec;
function compile(srcPath, distPath) {
// exec is asynchronous
_exec(
'java -jar '+ COMPILER_JAR +' --js '+ srcPath +' --js_output_file '+ distPath,
@leeluolee
leeluolee / requestAnimationFrame.js
Created May 4, 2012 12:01
requestAnimationFrame
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
@leeluolee
leeluolee / escape-regexp.js
Created June 8, 2012 13:19
escape regexp
var escapeRegExp = function(string){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License
return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, function(match){
return '\\' + match;
});
};
@leeluolee
leeluolee / brunch-chai-mocha-test.js
Created June 21, 2012 02:10
brunch support chai
// Generated by CoffeeScript 1.3.3
(function() {
'use strict';
var BrunchTestRunner, Mocha, async, fs, fs_utils, helpers, loadJsdom, os, sysPath, test, watch, chai,//TODO
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__slice = [].slice;
os = require('os');
@leeluolee
leeluolee / overflow-texx.css
Created September 6, 2012 09:42
文本溢出显示胜率号
width:50px;float:left;text-overflow:ellipsis; white-space:nowrap; overflow:hidden;
@leeluolee
leeluolee / asyncjs.md
Created September 10, 2012 08:33
asyncjs

async javascript 笔记

按章节记录要点

The JavaScript Event Model

  1. console.log 在webkit浏览器中是异步的
  2. setTimeout、setInterval:js中唯二异步方式, 但是它们都存在最小间隔,如setTimeout(fn,0)效率远远不如process.nextTick(0),
  3. requestAnimationFrame 会尽量让浏览器保持60fps+ ,同时在后台保留CPU的计算能力,避免浪费
  4. 一旦你在函数中依赖了一个异步的方法,那所有外层的函数就全部是异步了。即所有的外层函数都需要那个callback参数来处理回调, 一般来讲不要超过两层的nested callback,如何实现?参考__asyncJs__或者@老赵的__windjs__(不推荐)
@leeluolee
leeluolee / folder.md
Created October 10, 2012 01:48
目录结构表示方法
├── node_modules/
│   └── ...
├── public/
│   ├── jam/
│   │   ├── ...
│   │   └── require.js
│   ├── client.js
│   ├── index.html
│ └── style.css
@leeluolee
leeluolee / module_write.js
Created October 16, 2012 04:51
兼容amd、commonjs、globalExports的模块书写方式
;(function(global){
// Exposure AMD COMMANDJS or GLOBAL ASSIGN
// ----------------------------------------------------------------------
if (typeof exports === 'object') { //commonjs 模式
module.exports = namespace;
} else if (typeof define === 'function' && define.amd) { //amd 模式 requirejs
define(function() {
return namespace
});
} else { // 全局模式
@leeluolee
leeluolee / test-responsive.css
Created November 1, 2012 03:34
debug responsive
@media only screen and (min-width: 768px) and (max-width: 980px){
body::before{
content: "Tablet media query (768px < 980px) fired";
font-weight: bold;
display: block;
text-align: center;
background: rgba(255,255,0, 0.9);
position: absolute;
top: 0;
left: 0;