周五node分享会,大家有空提前准备一些东西
(1) 先到下面的链接 找对应文件的node安装文件安装。
http://nodejs.org/dist/v0.10.22/
在命令行
$ node -v
"use strict"; | |
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances. | |
// If one of those happens, we want to retry until it doesn't. | |
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a | |
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects; | |
// it has no synchronous behavior (e.g. throwing). | |
function dontGiveUp(f) { | |
return f().then( | |
undefined, // pass through success |
周五node分享会,大家有空提前准备一些东西
(1) 先到下面的链接 找对应文件的node安装文件安装。
http://nodejs.org/dist/v0.10.22/
在命令行
$ node -v
/** | |
* steal from: https://raw.githubusercontent.com/lindenb/jsandbox/master/src/sandbox/MakeGraphDependencies.java | |
* thanks a lot | |
*/ | |
package sandbox; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; |
iPhone 通过微信内置浏览器访问网页时得到 User Agent 是:
Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B329 MicroMessenger/5.0.1
Android 通过微信内置浏览器访问网页时得到 User Agent 是:
Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255
in your .bashrc
add below alias
alias cf="curl -Ls http://www.commandlinefu.com/commands/random |hxprune -c sample-output | hxprune -c meta|hxprune -c votes |hxprune -c options |hxprune -c window-bar | hxnormalize -x | hxselect -s '\n' '.terminal-display' | w3m -dump -T text/html"
'use strict'; | |
var toCompelition = function(signature) { | |
/* app.get(name) */ | |
var apiReg = /([a-zA-Z.]+)\(([\w\s\[\]\.\|,]*)\)/g; | |
var varReg = /([a-zA-Z.]+)/g; | |
var com = null; | |
var matchs = apiReg.exec(signature); | |
if (matchs) { |
someCMD | awk 'BEGIN{cmd="date +%H:%M:%S.%N"} {cmd|getline D; close(cmd); print D,$0}' | |
"this way slow down the cmd execute try below | |
someCMD | awk '{print strftime("%H:%M:%S"),$0}' |
'use strict'; | |
var zlib = require('zlib'); | |
var fs = require('fs'); | |
var fileName = process.argv[2]; | |
var buffer = fs.readFileSync(fileName); | |
zlib.unzip(buffer, function(_, buf) { | |
// console.log(buf.toString('hex')); | |
console.log(buf.toString()); | |
}); |
var day = 24*3600*1000; | |
var expiredTime = Date.now() - day *90; | |
var expiredDate = new Date(expiredTime); | |
var objectIdFromDate = function (date) { | |
var idStr = Math.floor(date.getTime() / 1000).toString(16) + "0000000000000000"; | |
return new ObjectId(idStr); | |
}; | |
db.tokens.remove({_id:{$lt:objectIdFromDate(expiredDate)}}) |
# you should download the files in m3u8 file first | |
ffmpeg -i the.file.m3u8 -acodec copy -vcodec copy -y -loglevel info -bsf:a aac_adtstoasc -f mp4 your-mp4-file.mp4 | |
# First 10 Minutes | |
ffmpeg -i VIDEO_SOURCE.mp4 -vcodec copy -acodec copy -ss 0 -t 00:10:00 VIDEO_PART_1.mpg | |
# Second 10 Minutes | |
ffmpeg -i VIDEO_SOURCE.mp4 -vcodec copy -acodec copy -ss 00:10:00 -t 00:20:00 VIDEO_PART_2.mpg | |
# Rest after the first 20 Minutes | |
ffmpeg -i VIDEO_SOURCE.mp4 -vcodec copy -acodec copy -ss 00:20:00 VIDEO_PART_3.mpg |