This file contains 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
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Launch App", | |
"type": "node", | |
"request": "launch", |
This file contains 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
{ | |
"files.exclude": { | |
"**/.git": true, | |
"**/.svn": true, | |
"**/.hg": true, | |
"**/CVS": true, | |
"**/.DS_Store": true, | |
"**/node_modules": true | |
} | |
} |
This file contains 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
# Set the HEAD to the old commit that we want to tag | |
git checkout 9fceb02 | |
# temporarily set the date to the date of the HEAD commit, and add the tag | |
GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" \ | |
git tag -a v1.2 -m"v1.2" | |
# set HEAD back to whatever you want it to be | |
git checkout master |
This file contains 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
/** | |
* Credits to: | |
* https://aaronaddleman.com/articles/how-to-pipe-a-output-from-child-process-into-a-webpage/ | |
*/ | |
// how to pipe a output from child process into a webpage | |
// start with importing an http server | |
var http = require('http'); | |
// import the spawn function | |
var spawn = require('child_process').spawn; |
This file contains 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 request = require('request'); | |
var express = require('express'); | |
var app = express(); | |
app.get('/goofy', function(req, res) { | |
request('http://images1.wikia.nocookie.net/__cb20120715102950/disney/images/a/a5/Disneygoofy2012.jpeg').pipe(res); | |
}); | |
app.get('/loop', function(req, res) { | |
res.render('mypage'); |
This file contains 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
const fs = require('fs'); | |
const file = fs.createWriteStream('./big.file'); | |
for(let i=0; i<= 500000; i++) { | |
file.write('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n'); | |
} | |
file.end(); |
This file contains 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
/* | |
* @param {String} filepath | |
* @param {function} callback function(err, data){} | |
*/ | |
function readJsonFileAsync(filepath, callback) { | |
var fs = require('fs'); | |
fs.readFile(filepath, 'utf-8', function(err, data) { | |
if (err) { callback(err, null); } | |
else { | |
result = JSON.parse(data); |
This file contains 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 minTohhmmss(totalSeconds){ | |
var hours = Math.floor(totalSeconds / 3600); | |
totalSeconds %= 3600; | |
var minutes = Math.floor(totalSeconds / 60); | |
var seconds = Math.floor(totalSeconds % 60); | |
var ret = ""; | |
hours ? ret = hours + "h" : ""; | |
minutes ? ret += minutes + "m": ""; |
This file contains 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
const responseGoogleStatus = (responseType) => { | |
return (response) => { | |
console.log(responseType, response); | |
if (responseType == "Success") { | |
loggedIn = true; | |
token = response.accessToken; | |
} | |
if (responseType == "Failed") { | |
throw new Exception("Some error from Google API response", response); |
OlderNewer