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
showBrowserSize () { | |
const size = { | |
width: window.innerWidth || document.body.clientWidth, | |
height: window.innerHeight || document.body.clientHeight | |
}; | |
console.log('Width * Height', size); | |
} |
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 guid(len) { | |
var buf = [], | |
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', | |
charlen = chars.length, | |
length = len || 32; | |
for (var i = 0; i < length; i++) { | |
buf[i] = chars.charAt(Math.floor(Math.random() * charlen)); | |
} | |
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 checkedValues = $('input[name=checkedlist]:checked').map(function () { | |
return $(this).val(); | |
}).get(); |
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 fibonacci_series = (n) => | |
{ | |
if (n===1) | |
{ | |
return [0, 1]; | |
} | |
else | |
{ | |
var s = fibonacci_series(n - 1); | |
s.push(s[s.length - 1] + s[s.length - 2]); |
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 addSix = createBase(6); | |
console.log(addSix(10)); // returns 16 | |
console.log(addSix(21)); // returns 27 | |
function createBase(i){ | |
return (y) => { | |
return y + i; | |
}; | |
} |
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 array1 = [1, 2, 3, 4]; | |
const reducer = (accumulator, currentValue) => accumulator + currentValue; | |
// 1 + 2 + 3 + 4 | |
console.log(array1.reduce(reducer)); | |
// expected output: 10 | |
// 5 + 1 + 2 + 3 + 4 | |
console.log(array1.reduce(reducer, 5)); | |
// expected output: 15 |
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 sum = [1, 2, 3].reduce((a, b) => a + b, 0); | |
console.log(sum); // 6 |
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
/* | |
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
*/ | |
var http = require('http'), | |
fs = require('fs'), | |
util = require('util'); | |
http.createServer(function (req, res) { | |
var path = 'video.mp4'; |
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
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream, | |
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback | |
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance | |
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible). | |
var reqUrl = url.parse(req.url, true) | |
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined; | |
if (cameraName) { | |
try { | |
cameraName = decodeURIComponent(cameraName); |