Skip to content

Instantly share code, notes, and snippets.

View elrrrrrrr's full-sized avatar
🐼
Hope it was happy

elrrrrrrr elrrrrrrr

🐼
Hope it was happy
  • alipay.com
  • Shanghai
View GitHub Profile

Step 1: Clone the bundles into your Sublime Text packages directory

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScript
git clone https://github.com/miksago/jade-tmbundle.git Jade
git clone https://github.com/LearnBoost/stylus.git Stylus

Step 2: Restart Sublime Text 2

@elrrrrrrr
elrrrrrrr / HTML-tags.md
Last active August 29, 2015 14:06 — forked from yisibl/HTML-tags.md

常用的 HTML 头部标签

详细介绍参见原文:yisibl/blog#1

<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
    <meta charset='utf-8'> <!-- 声明文档使用的字符编码 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用 IE 最新版本和 Chrome -->
@elrrrrrrr
elrrrrrrr / cleanCache
Created September 16, 2014 14:40
清空require缓存
Object.keys(require.cache)
.forEach( function(key) {
delete require.cache[key];
})
@elrrrrrrr
elrrrrrrr / flexbox
Created September 14, 2014 15:53
flex实现平铺布局
display inline-block
display -webkit-flex
display flex
justify-content space-around
-webkit-justify-content space-around
@elrrrrrrr
elrrrrrrr / heredoc
Created September 12, 2014 15:28
heredoc实现模版渲染
function heredoc(fn) {
return fn.toString().split('\n').slice(1,-1).join('\n') + '\n'
}
var a = heredoc(function(){/*
<%data.forEach(function(e){%>
<a class="item" href="pizzahut-detail.html?version=*&id=<%=e.pic%>">
<div class="cnt">
<img src="img/0<%=e.pic%>.jpg">
<div class="wrap">
@elrrrrrrr
elrrrrrrr / ellipsis
Last active August 29, 2015 14:06
多行css末尾省略号
display -webkit-box
-webkit-line-clamp 2
-webkit-box-orient vertical
overflow hidden
@elrrrrrrr
elrrrrrrr / slide
Created September 4, 2014 14:57
原生slide组件
function listenGesture(el) {
// el.on('touchstart', function(e) {
// startX = endX = 0;
// var touch = e.touches[0];
// startX = touch.pageX;
// })
// el.on('touchmove', function(e) {
// e.preventDefault();
// })
@elrrrrrrr
elrrrrrrr / toast
Created September 3, 2014 06:56
Toast
var $ = require('zepto'),
Toast = function(text) {
var toast = $('<div class="toast"><div class="bg"></div>' + text + '</div>');
toast.appendTo($('body'));
setTimeout(function() {
toast.animate({opacity: 0}, 300, function() {
$(this).remove();
})
}, 2000);
@elrrrrrrr
elrrrrrrr / Array.js
Last active August 29, 2015 14:05
在低版本浏览器中兼容数组的一些方法
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@elrrrrrrr
elrrrrrrr / module.exports&exports
Created August 23, 2014 11:51
module.exports和exports的区别。
/**
Initially,module.exports=exports , and the require function returns the object module.exports refers to.
if we add property to the object, say exports.a=1, then module.exports and exports still refer to the same object. So if we call require and assign the module to a variable, then the variable has a property a and it's value is 1;
But if we override one of them, for example, exports=function(){}, then they are different now: exports refers to a new object and module.exports refer to the original object. And if we require the file, it will not return the new object, since module.exports is not refer to the new object.
For me, i will keep adding new property, or override both of them to a new object. Just override one is not right. And keep in mind that module.exports is the real boss.
**/