Skip to content

Instantly share code, notes, and snippets.

View emkamal's full-sized avatar
:octocat:
Stay hungry. Stay foolish.

Kamal emkamal

:octocat:
Stay hungry. Stay foolish.
View GitHub Profile
@emkamal
emkamal / logAllFunctionCalls.js
Created July 13, 2021 13:19
Js snippet to log all function calls
(function() {
var call = Function.prototype.call;
Function.prototype.call = function() {
console.log(this, arguments); // Here you can do whatever actions you want
return call.apply(this, arguments);
};
}());
@emkamal
emkamal / kill_winnat.bat
Created April 27, 2021 14:45
Sometimes I got a problem when I want to run a program that listen to port but I got this error saying port is unaccessible. Even though when being checked from netstat or tcpview.exe, the port is available. the solution that works for me:
net stop winnat
@emkamal
emkamal / createDom.js
Last active June 7, 2017 12:02
function to create dom in a more concise way
var createDom = function (tag, config)
{
var elem = document.createElement(tag);
if (config) {
for (var key in config) {
if (key !== "attrs" && key !== "events" && key !== "styles" && key !== "options" && key !== "parent") {
elem[key] = config[key];
}
}
@emkamal
emkamal / kamal_javascript_debugger.js
Last active July 13, 2017 14:39
A little extension to the good ol' console.log
var kamal_javascript_debugger = function(text, obj, showtrace=true){
var initChar = "\uD83E\uDC36 ";
if(showtrace){
var stack = (new Error).stack;
stack = stack.split('\n').map(function (line) { return line.trim(); });
stack = stack.splice(stack[0] === 'Error' ? 2 : 1);
}
if(typeof text === "object" && obj === undefined){
obj = text;