JavaScript

JavaScript number only lock

function(event) {
// Allow: backspace, delete, tab, escape, and enter
if ( event.keyCode == 46 ||
event.keyCode == 8 ||
event.keyCode == 9 ||
event.keyCode == 27 ||
event.keyCode == 13 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
else {
// Ensure that it is a number and stop the keypress
if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) &&
(event.keyCode < 96 || event.keyCode > 105 )) {
event.preventDefault();
}
}
}

Display remote Node.JS service logs on Chrome Console

In recent years, we got plenty of PaaS services which provide very simple and easy way to deploy our Node.JS services.

Usually after deploying my service, I have to use the command line tools or visit some very slow web pages to access the server logs. It’s really waste my time.

But today, I want to introduce a tool, Chrome Logger, it provides a way to display server logs into Chrome Developer Tool’s Console.

Install it, then visit my sample project on Heroku to see what’s going on.

  • Sample Test Project on Github

Update 06/25 00:40:

  • If you’re using ExpressJS, you can simple log your error like following error handling middleware

Update 06/25 01:50:

Pull requests sent : chromelogger & express-chrome-logger.

Good luck to myself.