Skip to content

Instantly share code, notes, and snippets.

View stormslowly's full-sized avatar
🎯
Focusing

pshu stormslowly

🎯
Focusing
  • Hangzhou, Zhejiang, China
View GitHub Profile
@stormslowly
stormslowly / benchmark.js
Created July 19, 2017 16:51
generate array contains 1 to 1e7
console.time("Array.push");
const array = [];
for (var i = 0; i < 1e7; i++) array[i] = i;
console.timeEnd("Array.push");
console.time("new Array.push");
const array1 = new Array(1e7);
for (var i = 0; i < 1e7; i++) array1[i] = i;
console.timeEnd("new Array.push");
[alias]
st = status
ci = commit
co = checkout
dt = difftool
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen%cr %C(bold blue)<%an>%Creset'
lp = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen%cr %C(bold blue)<%an>%Creset'
ca = commit -a
[color]
ui = auto
@stormslowly
stormslowly / nginxproxy.md
Created January 6, 2017 03:43 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@stormslowly
stormslowly / download_egghead_videos.md
Last active December 13, 2016 14:19 — forked from ldong/download_egghead_videos.md
download *free* egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

var links = $('h4 a').get().map(function(a){ return a.href}).join('\n')
copy(links)
@stormslowly
stormslowly / aiff2mp3.sh
Created January 8, 2016 00:27
convert to aiff to mp3
ffmpeg -i "17 Audio Track.aiff" -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 17.mp3
vcl 4.0;
acl purgers {
"localhost";
"127.0.0.1";
"192.168.199.0"/24;
}
backend default {
.host = "localhost";
@stormslowly
stormslowly / ffmpeg usage memo.txt
Last active October 27, 2016 19:37
convert a m3u8 file to mp4 file
# 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
@stormslowly
stormslowly / remove.js
Created June 11, 2015 08:41
remove old date by ObjectId
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)}})
@stormslowly
stormslowly / inflate.js
Created May 12, 2015 01:08
git object inflate
'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());
});
@stormslowly
stormslowly / timestamp.sh
Last active August 29, 2015 14:20
add prefix time stamp for console output
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}'