This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIPAddress(){ | |
var interfaces = require('os').networkInterfaces(); | |
for(var devName in interfaces){ | |
var iface = interfaces[devName]; | |
for(var i=0;i<iface.length;i++){ | |
var alias = iface[i]; | |
if(alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal){ | |
return alias.address; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const DAY_TIMESTAMP = 60 * 60 * 24 * 1000 | |
export const HOUR_TIMESTAMP = 60 * 60 * 1000 | |
export const MINUTE_TIMESTAMP = 60 * 1000 | |
export function formatDate(date, fmt) { | |
const o = { | |
'M+': date.getMonth() + 1, | |
'd+': date.getDate(), | |
'h+': date.getHours(), | |
'm+': date.getMinutes(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function hasClass(el, className) { | |
const reg = new RegExp('(^|\\s)' + className + '(\\s|$)') | |
return reg.test(el.className) | |
} | |
export function addClass(el, className) { | |
if (hasClass(el, className)) { | |
return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
原帖地址: http://topic.csdn.net/u/20110113/19/b0d5d506-4307-428b-a61d-7974aa66a2da.html | |
首先要说明的是:这里介绍的方法都是大部分是本人“悟”出来的,所以网上难有流传! | |
好方法不能自己私藏,否则就白忙乎这几天了,分享给有需要的朋友们。如果有转载,敬请注明来自*CSDN老邓*作品。 | |
呵呵,给自己打广告,实在是无耻之极,权当无聊之时打字之用。 | |
欢迎流传,为最优秀的分布式版本管理系统Git做宣传!! | |
步骤: | |
1. 下载:http://loaden.googlecode.com/files/gitconfig.7z | |
2. 解压到:<MsysGit安装目录>/cmd/,例如:D:\Program Files\Git\cmd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"vars": { | |
"@gray-base": "#000", | |
"@gray-darker": "lighten(@gray-base, 13.5%)", | |
"@gray-dark": "lighten(@gray-base, 20%)", | |
"@gray": "lighten(@gray-base, 33.5%)", | |
"@gray-light": "lighten(@gray-base, 46.7%)", | |
"@gray-lighter": "lighten(@gray-base, 93.5%)", | |
"@brand-primary": "darken(#428bca, 6.5%)", | |
"@brand-success": "#5cb85c", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"vars": { | |
"@gray-base": "#000", | |
"@gray-darker": "lighten(@gray-base, 13.5%)", | |
"@gray-dark": "lighten(@gray-base, 20%)", | |
"@gray": "lighten(@gray-base, 33.5%)", | |
"@gray-light": "lighten(@gray-base, 46.7%)", | |
"@gray-lighter": "lighten(@gray-base, 93.5%)", | |
"@brand-primary": "darken(#428bca, 6.5%)", | |
"@brand-success": "#5cb85c", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://github.com/benfrain/rwd/blob/master/ch3/example_03-02/main.js | |
// This debounce function (via: https://remysharp.com/2010/07/21/throttling-function-calls) merely stops functioned firing too often on repetitive events (such as resize/scroll) | |
function debounce(fn, delay) { | |
var timer = null; | |
return function () { | |
var context = this, args = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(function () { | |
fn.apply(context, args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongo = require('mongodb').MongoClient; | |
var url = 'mongodb://localhost:27017/learnyoumongo'; | |
var size = process.argv[2]; | |
mongo.connect(url, function(err,db){ | |
if(err) throw err; | |
var prices = db.collection('prices'); | |
prices.aggregate([{ | |
$match: { | |
size: size | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongo = require('mongodb').MongoClient; | |
var age = process.argv[2]; | |
var url = 'mongodb://localhost:27017/learnyoumongo'; | |
mongo.connect(url, function(err, db){ | |
if(err) throw err; | |
var parrots = db.collection('parrots'); | |
parrots.count({ | |
age: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongo = require('mongodb').MongoClient; | |
var dbName = process.argv[2]; | |
var url = 'mongodb://localhost:27017/'+dbName; | |
mongo.connect(url, function(err, db){ | |
if(err) throw err; | |
var col = db.collection('users'); | |
col.update({ | |
username: 'tinatime' | |
},{ | |
$set: { |