How to get the file-path of the currently executing javascript code

Within the script: var scripts = document.getElementsByTagName(“script”), src = scripts[scripts.length-1].src; This works because the browser loads and executes scripts in order, so while your script is executing, the document it was included in is sure to have your script element as the last one on the page. This code of course must be ‘global’ to … Read more

PHP absolute path to root

Create a constant with absolute path to the root by using define in ShowInfo.php: define(‘ROOTPATH’, __DIR__); Or PHP <= 5.3 define(‘ROOTPATH’, dirname(__FILE__)); Now use it: if (file_exists(ROOTPATH.’/Texts/MyInfo.txt’)) { // … } Or use the DOCUMENT_ROOT defined in $_SERVER: if (file_exists($_SERVER[‘DOCUMENT_ROOT’].’/Texts/MyInfo.txt’)) { // … }

How can I generate a list of files with their absolute path in Linux?

If you give find an absolute path to start with, it will print absolute paths. For instance, to find all .htaccess files in the current directory: find “$(pwd)” -name .htaccess or if your shell expands $PWD to the current directory: find “$PWD” -name .htaccess find simply prepends the path it was given to a relative … Read more

Jest + Typescript + Absolute paths (baseUrl) gives error: Cannot find module

I was struggling with the same problem and actually it turns out that a simple change seems to do the trick. I just updated the moduleDirectories field in jest.config.js. Before moduleDirectories: [‘node_modules’] After moduleDirectories: [‘node_modules’, ‘src’] Hope it helps.

tech