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
//@@ I don’t want to listen to your music when I switch tabs | |
var track = new Audio('./darkhast.mp3'); | |
function isVisible (e){ | |
document.title = document.hidden ? 'please come back and enjoy your music' : 'Enjoying!'; | |
return document.hidden ? track.pause() : track.play(); | |
} | |
document.addEventListener('visibilitychange',isVisible); |
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 array_list = [1,2,3,4,5,3]; | |
Array.prototype.raoEach = function(cb){ | |
for (i = 0; i < this.length; i++) { | |
cb(this[i]); | |
} | |
} | |
array_list.raoEach(function(a){ | |
console.log(a+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
app.use(function(req, res, next) { | |
var allowedOrigins = ['http://127.0.0.1:8020', 'http://localhost:8020', 'http://127.0.0.1:9000', 'http://localhost:9000']; | |
var origin = req.headers.origin; | |
if(allowedOrigins.indexOf(origin) > -1){ | |
res.setHeader('Access-Control-Allow-Origin', origin); | |
} | |
//res.header('Access-Control-Allow-Origin', 'http://127.0.0.1:8020'); | |
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS'); | |
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization'); | |
res.header('Access-Control-Allow-Credentials', 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
<button onClick="start()">start</button> | |
<button onClick="stop()">stop</button> | |
<button onClick="pause()">pause</button> | |
<button onClick="play()">play</button> | |
<span id="status"></span> | |
let audioChunks = []; | |
let mediaRecorder; | |
//Start the recording |
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
//The compositionstart, compositionupdate and compositionend events might be helpful. They help you detect when IME input is being used. | |
EVENTS FIRE | |
When IME is visible :- | |
--> compositionstart, compositionupdate, compositionend, input | |
When IME closed :- | |
--> keydown, input | |
$('#id').on('compositionupdate', function(e) { | |
console.log(e.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 typeChecker(_input){ | |
if([undefined, null, NaN].includes(_input)){ | |
return _input; | |
}else if(_input === 'true' || _input === 'false'){ | |
return "Boolean"; | |
}else if(new RegExp(".*[a-zA-Z]+.*").test(_input) || _input === ''){ | |
return typeof _input; | |
}else{ | |
return Number.isInteger(+_input) ? 'integer' : 'flaot'; | |
} |
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 userProfiler(howMuch){ | |
return new Array(howMuch).fill().map((data,i)=>{ | |
return { | |
'id' : i, | |
'name' : 'dummyUser'+i, | |
'Mobile' : Math.floor(Math.random() * 9000000000) + 1000000000, | |
'age' : Math.floor(Math.random() * (100-10 + 10) + 1) | |
} | |
}); | |
} |
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 array = [ | |
{"name":"dheeraj"}, | |
{"name":"download"}, | |
{ "name":"code"}, | |
{"name":"bookbookbookbook"}, | |
{"name":"book"} | |
]; | |
function getMax() { | |
return array.reduce((max, p) => p.name.length > max ? p.name.length : max, array[0].name.length); |
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
['mousemove', 'touchmove'].forEach(function(e) { | |
window.addEventListener(e, mouseMoveHandler); | |
}); |
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
//Util.js | |
export function reactBind(data,that){ | |
return data.forEach((fn) => that[fn] = that[fn].bind(that)); | |
} | |
//myNewComponet.jsx | |
import reactBind from './Util.js'; | |
class myNewComponet extends React.Component{ | |
constructor(props) { |
OlderNewer