Skip to content

Instantly share code, notes, and snippets.

前端开发常用命令和配置

Sass

$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l

确保只有 gems.ruby-china.org,遇到ssl证书问题,改用http

安装node-sass失败时,打开~/.npmrc,添加

@knownothingsnow
knownothingsnow / browser-detector.js
Created June 8, 2016 03:31
通过user-agent检测浏览器环境
/*判断浏览器类型*/
let browser = {
versions: function() {
let u = navigator.userAgent, app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > - 1, //IE内核
presto : u.indexOf('Presto') > - 1, //opera内核
webKit : u.indexOf('AppleWebKit') > - 1, //苹果 谷歌内核
gecko : u.indexOf('Gecko') > - 1 && u.indexOf('KHTML') == - 1,//火狐内核
mobile : ! ! u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
@knownothingsnow
knownothingsnow / Array_unique.js
Created May 28, 2016 19:54
数组去重的ES5解法
function unique(arr) {
let n = []
arr.forEach((item, index) => {
if (n.indexOf(item) === -1) n.push(item)
})
return n
}