Skip to content

Instantly share code, notes, and snippets.

@ahmednooor
ahmednooor / abs_path.py
Created December 22, 2017 00:53
get_current_directory_absolute_path_python
# configure root directory path relative to this file
THIS_FOLDER_G = ""
if getattr(sys, "frozen", False):
# frozen
THIS_FOLDER_G = os.path.dirname(sys.executable)
else:
# unfrozen
THIS_FOLDER_G = os.path.dirname(os.path.realpath(__file__))
@ahmednooor
ahmednooor / addEventToEach.js
Last active December 22, 2017 00:55
Helper function to attach events to each element in an array without using for loop.
// -- Function --
function addEventToEach(arrayName, eventType, eventCallback) {
var i;
for (i = 0; i < arrayName.length; i += 1) {
arrayName[i].addEventListener(eventType, eventCallback, false);
}
return;
}