How can I define alias for Mongo Shell - alias

In MongoDB Shell, there is a command edit <variable> to inspect/modify the value by your favourite editor specified by EDITOR.
But how can I create an alias for edit, such as e <variable>?

The edit command is part of the C++ implementation of the mongo shell (src/mongo/shell/dbshell.cpp#L470 in the MongoDB GitHub repo). Native functions like edit are exposed in the interactive shell interpreter but are not readily available to invoke or override via JavaScript (see: Differences Between Interactive and Scripted mongo).
As at MongoDB 3.4 I'm not aware of any obvious way to alias a native code function unless you're keen to modify the source code and build a custom mongo shell.
However, if you are writing any significant scripts for the mongo shell a much more recommendable approach would be to use the load(...) command instead of edit.
Advantages of load() over edit include:
Ability to edit multiple variables and functions in a single file.
edit only edits a single variable or function.
Detect JavaScript syntax errors before you close your draft
edit detects changes when your editor closes a temporary file; with load() you can test successive edits by saving in your editor without closing.
If edit encounters any JavaScript syntax errors when a file is closed, you'll lose your draft and the variable in the shell will remain at the original value.
Your working files are saved in a non-temporary path so you can commit them to version control.

Related

Is it possible to have .net console application that embed another executable file?

I have a single command line windows executable that has many options built into this exe file.
Eg:
(It can take screenshot)
ToolGo.exe printscreen c:\temp\filename.jpg yyyymmdd
(It can show up)
ToolGo.exe showIP machineA
I want to write another command line application, possibly in .net , where it can embed/build a wrapper around this ToolGo.exe file into my application without the user be able to use the ToolGo.exe, and also users can only access one function of this main exe file.
In the example I want this other tool to access only the print screen function in this new exe file.
The new application will have this:
Tool2go.exe printscreen c:\temp\filename.jpg yyyymmdd
But if someone types the following, it will not work:
Tool2go.exe showIP machineA
Or
ToolGo.exe showIP machineA
Any ideas how I can write this code to do this in a .net command line application?
This is a multi-part question, so I'll just give the main part of the issue as the answer with suggestions on handling the rest.
You can embed a .exe into your program by clicking on Properties and navigating the the Resources section, and adding that .exe to it.
After that, it's just a matter of extracting it locally so you can pass your commands to it, and handle it's responses. (I'm not really aware of any way to do so w/out first extracting the. exe; the .exe itself needs to run somehow after all).
To extract the embedded .exe, you do this:
' Extract the MyProgram resource (i.e. your .exe)
Dim b() As Byte = My.Resources.MyProgram
' Write it to the user's Temp folder
File.WriteAllBytes(Environment.ExpandEnvironmentVariables("%TEMP%\MyProgram.exe"), b)
By extracting it to the user's Temp folder, you can pass it your commands, and since it's 'out of sight' the user probably won't even know it's there to directly use it themselves, unless they're a bit more advanced and visit their Temp folder often. You can slightly help to avoid this, but extracting the .exe when your program starts, and then deleting it when it exits, so it only exists on the user's system while your program is running.
As far as what the user can and cannot type in order to pass to the program, you can simply handle the filtering with your program; since your program is the one passing the commands to the .exe, just don't pass any commands that you don't allowed, and pass the ones you do want allowed.

How to debug using Karate UI when calling a feature file from another feature file

I am trying to debug with Karate UI, when calling a feature file from my feature file Eg: App.run("src/test/java/demo/cats/cats.feature", "dev");
When calling dogs.feature in the cats.feature file, how should I debug cats.feature.
When I start UI with the feture file path example above, it fails as I am calling another feature file.
Error:javascript evaluation failed
Instead of the UI, I recommend you use the JUnit HTML report to troubleshoot tests. Step-through debugging is quite hard - especially if you are a non-programmer.
Note that you can use the print statement within a test to log the values of variables to make it easier to troubleshoot. Take a look at this video: https://twitter.com/KarateDSL/status/935029435140489216

SoapUI - Increase property value for each test case

I want to use a property ('currentId') which has a certain start value. For each test case the value should be increased by 1. I can do that by adding an extra test step in each test case which increases the value but that would be much copy paste. The code for that would be (see reference):
def uniqueUserPortion = testRunner.testCase.testSuite.project.getPropertyValue("currentId")
// convert it to an Integer, and increment
def uniqueUserPortionInc = uniqueUserPortion.toInteger() + 1
// set the property back as string
testRunner.testCase.testSuite.project.setPropertyValue("currentId", uniqueUserPortionInc.toString())
To avoid that copy&paste I've added the code above to the Load Script of the project but it doesn't work:
testSuite.testCases.each {
*code above*
}
What can I do to use the code in one script/call for all test cases?
I could define the property as the start value plus the test case ID but that would be a definition in each test case again since I can not reference the #TestCase#ID in project level/property.
Issue with what your are trying
Load Script of the project is executed once when you import the project into soapui workspace. So, this approach does not work.
As you rightly mentioned, either you need to have it in a separate step of the each test case or you can add the same code as setup script. Yes, it is copy paste only
It is possible to achieve easily using SoapUI NG which pro edition using Event feature.
Then your next question may be : how to do it in Open Source edition of SoapUI.
Here is an soapuiExtensions which I did sometime ago which allows you do the same without having to copy paste for each test case in open source edition.
All you need do is have your groovy script into a specific file called 'TestCaseBeforeRun.groovy'. That means, the script is executed before running each test case.
For more details refer README
This soapuiExtensions library allows users to have some additional functionality in soapUI(free edition) tool, like soapui pro allows to do something before, after doing something.
For eg: User may want to do something before running a test case or after running a test case etc by implementing appropriate groovy script as required. Allow me to add an example here. Usually user may want to add credentials for the request step automatically, see the script samples/scripts/TestSuiteTestStepAdded.groovy
How to use this library:
set SOAPUI_HOME environment variable.
copy lib/SoapUIExtListeners.jar file under $SOAPUI_HOME/bin/ext directory
copy samples/listeners/custom-listeners.xml file under $SOAPUI_HOME/bin/listeners directory
copy samples/scripts directory under $SOAPUI_HOME
And implement appropriate groovy script available under $SOAPUI_HOME/scripts. Refer Mappings file in order to implement respective groovy script.
Note: for windows users, you may need to check %SOAPUI_HOME%\bin\soapui.bat which actually overwrites SOAPUI_HOME, need to fix soapui.bat script if requires.
Uses jdk 7, soapUI 4.5.1, and groovy 1.8.9
Dependency
log4j
UPDATE: this is realted to the note in the above.
As it was mentioned in the note, soapui.bat overrides SOAPUI_HOME environment variable on windows, needs to be tweaked a bit. May be you want to copy that groovy file under %SOAPUI_HOME%\bin\scripts (this is without tweaking soapui.bat)and retry. If your machine is linux then it should work if you copy the groovy file under $SOAPUI_HOME/scripts directory

EXRM - Can I set vm.args values from the config.exs file?

Somewhat related to this question - Parametrizing node name in Elixir Exrm - is there a way to dynamically set the content of the rel/vm.args file?
In the title, I suggest the use of config.exs, but I'm interested in any scheme that will allow me to add, remove and edit vm arguments at build time.
A bash script might be an idea, but a solution that would also work on Windows, and is preferably based on Elixir code would be the idea.
You can commit to your project repo a rel/vm.args file that you would like to be used instead of the Exrm generated one. Exrm will automatically use this file instead.

Rename a vbscript process

When we run a *.vbs file, in processes, we used to get "wscript.exe". We can change this "wscript.exe" to our custom name by creating a shortcut and executing the shortcut.
Is it possible to display the current *.vbs file name in process, without using shortcuts?
No. Your script is running in an interpreter, and it's the interpreter executable name that is being displayed in the process list.
While it's not impossible to change the process name, you'd need admin privileges to be able to do this, and you'd need to rewrite the interpreter (wscript.exe) to actually do it. See this answer to a similar question.