Passing spaces in arguments for Visual Studio Pro 2019 - visual-studio

I am trying to debug a command line program inside Visual Studio. I am sharing my configuration with another machine using Box. The paths I am passing have spaces in them and I haven't been successful in escaping the spaces so that instead of 3 arguments I get 9. This is the relevant section from the original launch.vs.json.
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
"name": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
"args": [
"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json",
"C:\\Users\\212434537\\Box Sync\\Edge Agent\\static.json",
"C:\\Users\\212434537\\Box Sync\\Edge Agent\\dynamic.json"
]
}
None of these work.
"\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\""
"\\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\\""
"\\\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\\\""
"\\\\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\\\\""
How can I escape my spaces so that each argument is passed as a single argument instead of three. Note: I saw this question but it didn't solve my problem.

It turns out you need to surround the spaces with singly-escaped double-quotes:
Here is the resultant section:
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
"name": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
"currentDir": "C:\\Users\\212434537\\source\\Edge-Agent",
"args": [
"C:\\Users\\212434537\\Box\" \"Sync\\Edge\" \"Agent\\srasku-windows.json",
"C:\\Users\\212434537\\Box\" \"Sync\\Edge\" \"Agent\\static.json",
"C:\\Users\\212434537\\Box\" \"Sync\\Edge\" \"Agent\\dynamic.json"
]
}

A simple workaround for this, is just to include the entire path in quotes, such as:
"C:\Users\212434537\Box Sync\Edge Agent\dynamic.json"
So, the escaped json becomes:
"\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\dynamic.json\""

Related

How to replace Artifactory file "pattern" path dynamically in rtUpload in Jenkins Declarative Pipeline

I'am trying to dynamically replace my zip file pattern in rtDownload in my declarative jenkinsfile but the value is not taken up by the function.
A zip file with a newer version is created and uploaded on JFrog with every build and I want to download a particular version in my local system.
I have defined "VERSION" in def VERSION and used it as -
rtDownload (
serverId: 'Jfrog',
spec: '''{
"files": [
{
"pattern": "<path>-<filname>${VERSION}.zip",
"target": "<path>-<filename>${VERSION}.zip",
"flat": "true"
}
]
}'''
)
But it does not replace my VERSION with the version I am providing through String parameter configured in the jenkins job.
Any suggestions would be greatly appreciated. Thanks.
In groovy single quote strings ('') and single quote multi line strings (''' ''') do not support string interpolation, only double quote strings support this.
You can read more info on string interpolation in groovy in the Official Documentation.
So to fix it just use double quoted multi line string, that will enable the evaluation of your parameters:
rtDownload (
serverId: 'Jfrog',
spec: """{
"files": [
{
"pattern": "<path>-<filname>${VERSION}.zip",
"target": "<path>-<filename>${VERSION}.zip",
"flat": "true"
}
]
}"""
)

Error reading project.json, Unterminated string error when performing dotnet restore

Using Visual Studio for Mac to perform a "dotnet restore" but the terminal shows this message:
error : Error reading
'/Users/abc/corefx/src/Microsoft.TargetingPack.Private.CoreCLR/ref/project.json' at line 8 column 1 : Unterminated string. Expected delimiter: ". Path 'frameworks', line 8, position 1.
error:Unterminated string. Expected delimiter: ". Path 'frameworks', line 8, position 1.
project.json:
{
"dependencies": {
"Microsoft.TargetingPack.Private.CoreCLR": "1.2.0-beta-24904-03"
},
"frameworks": {
"netcoreapp1.1.0”: {}
}
}
I have found the file but I cannot identify the cause of the problem. What could cause this error message?
It looks to me like the netcoreapp1.1.0 property name is terminated with a typographic right quote mark ” which is not valid JSON. It should be a standard straight quote " instead.
{
"dependencies": {
"Microsoft.TargetingPack.Private.CoreCLR": "1.2.0-beta-24904-03"
},
"frameworks": {
"netcoreapp1.1.0": {}
}
}

Is there a way I can get historic performance data of various alerts in Nagios as json/xml?

I am looking to get performance data of various alerts setup in my Nagios Core/XI. I think it is stored in RRDs. Are there ways I can get access to it?
If you're using Nagios XI you can get this data a few different ways.
If you're using XI 5 or later, then the easiest way that springs to mind is the API. Log in to your XI server as an administrator, navigate to 'Help' menu, then select 'Objects Reference' on the left hand side navigation and find 'GET objects/rrdexport' from the Objects Reference navigation box (or just scroll down to near the bottom).
An example curl might look like this:
curl -XGET "http://nagiosxi/nagiosxi/api/v1/objects/rrdexport?apikey=YOURAPIKEY&pretty=1&host_name=localhost"
Your response should look something like:
{
"meta": {
"start": "1453838100",
"step": "300",
"end": "1453838400",
"rows": "2",
"columns": "4",
"legend": {
"entry": [
"rta",
"pl",
"rtmax",
"rtmin"
]
}
},
"data": {
"row": [
{
"t": "1453838100",
"v": [
"6.0373333333e-03",
"0.0000000000e+00",
"1.7536000000e-02",
"3.0000000000e-03"
]
},
{
"t": "1453838400",
"v": [
"6.0000000000e-03",
"0.0000000000e+00",
"1.7037333333e-02",
"3.0000000000e-03"
]
}
]
}
}
BUT WAIT, THERE IS ANOTHER WAY
This way will work no matter what version you're on, and would actually work if you were processing performance data with NPCD on a Core system as well.
Log in to your server via ssh or console and get your butt over to the /usr/local/nagios/share/perfdata directory. From here we're going to use the localhost object as an example..
$ cd /usr/local/nagios/share/perfdata/
$ ls
localhost
$ cd localhost/
$ ls
Current_Load.rrd Current_Users.xml HTTP.rrd PING.xml SSH.rrd Swap_Usage.xml
Current_Load.xml _HOST_.rrd HTTP.xml Root_Partition.rrd SSH.xml Total_Processes.rrd
Current_Users.rrd _HOST_.xml PING.rrd Root_Partition.xml Swap_Usage.rrd Total_Processes.xml
$ rrdtool dump _HOST_.rrd
Once you run the rrdtool dump command, there is going to be an awful lot of output, so I keep that as an exercise for you, the reader ;)
If you're trying to automate something of some kind, then you should note that the xml files contain meta data for the rrd files and could potentially be useful to parse first.
Also, if you're anything like me, you love reading technical manuals. Here is a great one to read: RRDTool documentation
Hope this helped!

Path outside of project, Ruby Dir

I'm trying to return a list of files for a directory using the following code:
Dir[directory]
The issue I'm having is this appears to always take the url as relative to the project location. For example passing '*' into Dir returns an array containing my Gemfile etc.. I want to be able to get a list of files for directories such as /Users/jason/Pictures however when i pass in /Users/jason/Pictures/* I am returned an empty array.
Any pointers would be greatly appreciated.
Thanks.
Try:
Dir['/Users/jason/Pictures/*']
If there are files or directories embedded in that path you'll get an array back from Dir[]. If you don't, and you're sure there are files in the directory, then there's something wrong, but it's most likely in the glob string you gave it. Confirm it's the right path by moving to it and using pwd to see what the OS thinks it is. Dir[] doesn't return an error if the glob string isn't valid, it just returns an empty array.
You could try using File.exist?('glob string without *') and see whether that path exists before trying to iterate it.
On my machine, running this in IRB in my home directory:
Dir['./vim/bundle/*']
Returns:
[
[ 0] "./vim/bundle/closetag.vim",
[ 1] "./vim/bundle/ctrlp.vim",
...
[31] "./vim/bundle/vim-vividchalk",
[32] "./vim/bundle/Vundle.vim"
]
I can use an absolute path also:
Dir['/Users/ttm/vim/bundle/*']
And get:
[
[ 0] "/Users/ttm/vim/bundle/closetag.vim",
[ 1] "/Users/ttm/vim/bundle/ctrlp.vim",
...
[31] "/Users/ttm/vim/bundle/vim-vividchalk",
[32] "/Users/ttm/vim/bundle/Vundle.vim"
]
Notice that you get relative pathnames if you use a relative glob string, and absolute pathnames for an absolute glob string.
You need to use the entries method
Dir.entries('/')
=> [".", "..", ".apdisk", ".com.apple.backupd.mvlist.plist", ".dbfseventsd", ".DocumentRevisions-V100", ".DS_Store", ".file", ".fseventsd", ".hotfiles.btree", ".MobileBackups",".OSInstallMessages", ".PKInstallSandboxManager", ".Spotlight-V100", ".SymAVx86QSFile", ".Trashes", ".vol", "Applications", "bin", "cores", "dev", "etc", "home", "Library", "net", "Network", "opt", "private", "sbin", "System", "tmp", "Users", "usr", "var", "Volumes", "~"]
Here is the oficial documentation http://www.ruby-doc.org/core-2.1.2/Dir.html#method-c-entries

Sublime How to set new shortcut for a specific feature

In sublime I want to add a feature that if I enter a key combination. I want that combination to produce the following result:
SHIFT+Ctrl+ALT+ENTER : put a semicolon at the end of the line and create a new line and put the cursor there.
How to do it?
The process is quite straightforward. First, create a new file with these contents:
[
{
"command": "move_to",
"args":
{
"to": "eol"
}
},
{
"command": "insert",
"args":
{
"characters": ";\n"
}
}
]
and save it as Packages/User/semicolon-newline.sublime-macro where Packages is the directory opened when you select Preferences -> Browse Packages....
Next, go to Preferences -> Key Bindings-User and add the following:
{ "keys": ["ctrl+alt+shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/User/semicolon-newline.sublime-macro"} }
This file is JSON-formatted, so if it doesn't have any contents when you open it, surround the line above with square brackets [ ]. If there are already entries in it, place the line above at the top (after the opening [) and add a comma , at the end, after the final closing curly brace }.
Save the keybindings file, and you should be all set. This should work with both Sublime Text 2 and 3, on any platform.

Resources