Visual Studio Code - launch parameter for node app being surrounded by double quotes - node.js

I'm having some problems putting a parameter for launching (debugging) a node app from Visual Studio Code. I'm using this config at launch.json:
// Command line arguments passed to the program.
"args": [
"-cache-dig cache"
]
and when launching VS Code surrounds the parameter with double quotes:
node foo.js "-cache-dig cache"
...which is not accepted by this app. Any suggestions?

Change the args key in your launch configuration to put each command line argument in a separate element.
For example:
"args": [
"-cache-dig",
"cache"
]
The reason being that while -cache-dig cache is a single option at the application level, it is actually composed of two separate command line arguments (a name -cache-dig and a value cache).

Related

How to check if the environment variable "PROJ_LIB" is defined and how to unset it ? (PyQGIS Standalone Script Executer)

I just tried the standalone PyQGIS application by running the custom script "Proximity.py"* in a VS Code project without the need of a GUI (such as QGIS).
But, when I run the python-program I get the following message:
proj_create_from_database: C:\Program Files\PostgreSQL\14\share\contrib\postgis-3.2\proj\proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected. It comes from another PROJ installation. (see also: Error Message after launching the configuration (launch.json) from VS Code (when pressing F5))
I'm trying this online example with the following installations:
PostgreSQL 14
Python39
.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\launcher
osgeo4w-setup.exe (including QGIS LTR)
I read that there is a solution by undefining [PROJ_LIB] before importing pyproj or osgeo: del os.environ ['PROJ_LIB'] as described under this link. If this is also supposed to be the correct solution in this case, can someone help me with step-by-step instructions (for dummies)?
. * The "Proximity.py" script is a pyqgis standalone example from "https://github.com/MarByteBeep/pyqgis-standalone"
Finally, I got a solution to be able to run the "standalone PyQGIS"* example "Proximity" (provided by MarByteBeep).
This solution was possible without needing to launch the configuration file "launch.json" as above described. And so, avoiding the need to make any configuration to the environment variable "PROJ_LIB" by trying to circumvent the above issue.
I just first added the following two code-lines (see here line 2 and 3) in the python file "main.py" so as to be able to use the plugin "PROCESSING" (initially line 8 of the "main.py" file), then I store it and finally I ran it.
Line 1: from qgis.core import
Line 2: import sys
Line 3: sys.path.append('C:\Program Files\QGIS 3.24.1\apps\qgis\python\plugins')
Line 4: qgs = QgsApplication([], False)
Line 5: ...
The Proximity example is based on the answer of "Mar Tjin" to the following Question: "Looking for manual on how to properly setup standalone PyQGIS without GUI"
. * By "Standalone PyQGIS" I refer to code/scripts that can be run outside the QGIS-GUI (=> QGIS-Desktop/Server Application). In my case under the external Editor VS Code

Prevent exec command running on module unload ibm load sharing facilty

I have a tcl script which is a modulefile within the IBM Load Sharing Facitily (lsf) used to configure some environment variables and launch a python script by using the exec command.
When the module is unloaded normally the opposite of all the commands are run, but also the exec command is run as normal. I would like it so that the exec part is only run on module load and not on module unload.
Here is what I tried so far
if { !(is-loaded mymodule)} {
exec .venv/bin/python mypython.py
}
I also tried this
if { module-info command load } {
exec .venv/bin/python mypython.py
}
For each one I get a similar error
Module ERROR: invalid bareword "module"
in expression " module-info command [load] ";
should be "$module" or "{module}" or "module(...)" or ...
both exceptions complain either about an invalid bareword (either "is" or "module") depending on which snippet I try. Is my snytax invalid?
My syntax was incorrect, in the end I was able to solve the problem with the following:
set is_load_command [module-info command load]
if { $is_load_command == 1 } {
exec .venv/bin/python mypython.py
}
I had two problems, correctly understanding comparisons in tcl and using return values from a called function. Neither really behaved how I am used to.

Scala.js - pass command line arguments from SBT run

When running the app using the sbt run while developing normal JVM app, I can pass command line arguments using run <args>. When I try the same with Scala.js, I get an error "No valid parser available". When trying runMain variant like runMain Main.main arg, the error is "Expected non-whitespace character", with arrow pointing just behind Main.main.
Is there some way how to pass arguments to the Scala.js / Node.js application when running it from SBT?
(I am using Scala.js 0.6.15).
No, there isn't, because JavaScript does not have a notion of command-line arguments. Node.js does, but only if started from the command-line, and that use case is not supported by the sbt plugin, I'm afraid.
Feel free to file a feature request. I'm not sure it can be accommodated, but we can look into it eventually.
One can define a custom task calling node.js, and parse arguments using SBT parsers. Add this into build.sbt:
import complete.DefaultParsers._
lazy val runa = inputKey[Unit]("Run app with arguments")
runa := {
(fastOptJS in Compile).value // build it first
val args: Seq[String] = spaceDelimited("<arg>").parsed
val npmRun = "node index.js" + args.map("\"" + _ + "\"").mkString(" "," ","")
npmRun.!
}
You also need to create a file index.js in your project root, containing something like this:
require("./target/scala-2.12/xxxx-jsdeps.js");
require("./target/scala-2.12/xxxx-fastopt.js");
In the intervening years, a library has emerged to address this:
https://ben.kirw.in/decline/

Pass "content of file" instead of "location of file"

I am creating an electron app for windows and using some windows app dependencies.
The other dependencies require a file path as variable. Example
dependency.exe --config /path/to/config/file.conf
i wish to replace /path/to/config/file.conf directly with the content
for example
dependency.exe --config $("configuration content")
Reason? I do not wish to create a config file for user to see and keep it as closed source
I'm assuming dependency.exe is your app. You can have it read from standard input, then use the type command to get the configuration file contents:
type file.conf | dependency.exe

How to create a JSCS config file on windows

When I try to create a JSCS config file:
C:\Blog\BlogWeb>jscs --auto-configure "C:\Blog\BlogWeb\temp.jscs"
I get the following error:
safeContextKeyword option requires string or array value
What parameter am I supposed to pass? What is a safecontextkeyword?
New to NPM and JSCS, please excuse ignorance.
JSCS was complaining that I didn't have a config file, so I was trying to figure out how to create one.
JSCS looks for a config file in these places, unless you manually specify it with the --config option:
jscs it will consequentially search for jscsConfig option in package.json file then for .jscsrc (which is a just JSON with comments) and .jscs.json files in the current working directory then in nearest ancestor until it hits the system root.
I fixed this by:
Create a new file named .jscsrc. Windows Explorer may not let you do this, so may need to use the command line.
Copy the following into it. It doesn't matter if this is the preset you want to use or not. The command will overwrite it.
{
"preset": "jquery",
"requireCurlyBraces": null // or false
}
Verify that it works by running a command such as:
run the command
jscs --auto-configure .jscsrc

Resources