VSCode snippets display length - vscode-snippets

I have this problem that showed up today. I have a bunch of snippets I use for javascript, and till yesterday I would use them by typing snippet name, and then tabbing to use it.
Now, it would only show if I type first 2 characters of its name. If I type a third one, I will not show as a suggestion.
This are a couple of my snippets:
"event-listener": {
"prefix": "event-listener",
"body": [
"${1:elem}.addEventListener('${2:click}', e => { ",
" $3 ",
"});"
]
},
"try-catch": {
"prefix": "try-catch",
"body": [
"try {",
" $1",
"}",
"catch (error) {",
" console.log(error); ",
"}"
]
},
If I typed ev for the first one, it would display as suggetion. If I typed eve, then it would show default VSCode suggestions. Same for if I typed tr (it would show my snippet), and try (it wouldn't).

Well, I was reading some similar questions, and tried restarting VSCode, and it worked. Hope someone finds this helpful.

Related

How to respect Solr conditions in order

I need to send a query to Solr with two conditions in OR, instead of sending the query twice:
{!complexphrase inOrder=true}title:"some tests*" || title:(some tests*)
.. where, in the first condition, I want the precise result. If not found, then it goes to OR and retrieves any result that has at least one word in the search phrase. But when I launch the query, I still get the right condition results first.
Here is my data:
{
"title": "some values"
},
{
"title": "data tests"
},
{
"title": "some tests"
}
The response I need is:
{
"title": "some tests"
},
{
"title": "data tests"
},
{
"title": "some values"
}
I already tried using boosting, like so: {!complexphrase inOrder=true}title:"some tests*"^2 || title:(some tests*)^1 but didn't work. I am NOT able to change the Solr configuration since it's a software that's already in production and not managed by me. I even cannot sort by rating, infact I don't receive best occurences first. Solr version is 7.3.1. Any help is appreciated, thanks in advance!
I solved it with a work-around. Instead of putting two OR conditions, I managed to apply a working boost on the title field, using edismax.
What I had to change in my Java application was:
From
SolrQuery q = new SolrQuery("*");
To
SolrQuery q = new SolrQuery("(" + query + "*)");
and added:
q.set("defType", "edismax");
q.set("qf", "title^100");
Now, I'm not making a precise query but I'm retrieving documents with a higher match first without changing any configuration! The Solr Frontend equivalent is similar, but the query should look like this:
http://localhost:8983/solr/mycollection/select?defType=edismax&q=(some%20test*)&qf=title^100
Hope it helps someone

How can I make snippet that place a variable in the script in VSCODE?

I want my prefix "ffz15" turns into "font-size: var(--fz15)".
So, when I have typed "ffz", everything that goes after this prefix should come as variable and inserts in snippets body.
It should be something like this (pseudocode):
"font-size variable": {
"scope": "css, scss",
"prefix": "fzz{value-of-font-size}",
"body": [
"font-size: var(--fz{value-of-font-size}px)",
],
},
I think it can be made quite simple, but I cannot find any information about that.
Thank you in advance for your help.
I don't think you can use part of the prefix as a variable in the snippet. Can you just do this instead? Use fzz as prefix, then it inserts the snippet, and puts you at the place where you just type the font size:
"font-size variable": {
"scope": "css, scss",
"prefix": "fzz",
"body": [
"var(--fz$0)",
],
},

Hyperlink Markdown dynamically in discord

I'm trying to make an embed message where the title of the video is the link. To achieve that I'm using square brackets and parentheses around the objects, but they are being shown as strings in the message. Any ideas on how this could be done?
for (let i in listaResultados){
embed.addField(
`${parseInt(i)+1}: [${listaResultados[i].tituloVideo}](${listaResultados[i].link})`,
listaResultados[i].descricao)
}
Embed field names do not support markdown, including masked links.
I think there are couple solutions you can do.
Utilize the Embed's title and url properties. However, this would limit you to producing only one embed per video, which means only 10 total (at one time) since 10 is the limit per message.
{
"embed": {
"title": "Music Video Title",
"description": "Description goes here",
"url": "https://video-url.com"
}
}
The other way is to do what the other user mentioned - use the description field.
{
"embed": {
"title": "Music Videos List",
"description": "1. [Video 1](https://google.com) \n 2. [Video 2](https://google.com/) \n 3. [Video 3](https://google.com/)"
}
}
You can use this website for quick reference and experimentation of the embed code.

MS Flow (Azure) and Double quote

I hope you can help me as I'm a little stuck on this problem and cannot find a nice solution.
I would like to create an HTTP POST and the body of my request need to be something like this
.... (code)
{
"table":"DimDate"
}
.... (code)
The "table" : "Dimdate" is built , part by a string variable ( myVar='{"table":"' ) and a dynamic field (all stored on another string variable called myString).
Meaning I've got on my MS Flow a variable myString = "table": "DimDate"
Till there no issue. My problem appear when I want to embed my variable in the body of the HTTP Post.
It seems all is converted as
.... (code)
{
\"table\":\"DimDate\"
}
.... (code)
Question is why do I have those "\" ? and how to remove them ?
I've check and it seems they appear by default from the start , in my different variables. How to remove them when I use the variable myString in the HTTP POST body ?
I've already try to convert to plain-text, look for use char (no idea how), etc...
Any idea ?
Thanks
Addendum
a) Idea is to be able to add in the body of my HTTP POST the following body
{
"CommitMode": "transactional",
"MaxParallelism": 2,
"Objects": [
{ "Table": "table1" },
{ "Table": "table2"},
{ "Table": "table3"}
],
"RetryCount": 2,
"Type": "Full"
}
b) For that I set an initial variable _mystring as '{"table":"'
c) with a loop I put in a variable _myVar a concatenation of _mystring with a array of table ( table1,2 and 3) . the variable _myVar at the end is ok. No issue there
d) the HTTP POST body appear on the screen "as this" :
{
"CommitMode": "transactional",
"MaxParallelism": 4,
"Objects": [
{
"Table": "#{variables('_Table')}"
}
],
"RetryCount": 2,
"Type": "Full"
}
e) Like that all appear perfect. The problem is that when I run the flow, the body of the HTTP is not OK as even the variable _mystring which is used. It seems the " is replaced by \" and this generate a wrong output of the HTTP POST.
Is there a way to avoid Microsoft Flow replace the " by \" ?
Miguel
Finally an easy solution was found.
Microsoft fix that during their next Logic App release.
Topic close

How to use Dialog.ElicitSlot for Python as Runtime environment

I want to fill a slot not at the beginning of the invocation of the intent, but at a later part in the intent request. I want to provide user some options, and I want them to select one out of those. For that I'm trying to use Dialog.ElicitSlot, but somehow I'm getting an error :
"Request to skill endpoint resulted in an error."
I'm returning this when I need the user to select an option from my list.
return {
"version": "1.0",
"sessionAttributes": {},
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "These are the multiplex" + ("es" if len(multi_list) > 1 else "") + " " + outputSpeech + ". Please select one out of these."
# outputSpeech contains the list of options I want the user to select from
},
"shouldEndSession": False,
"directives": [
{
"type": "Dialog.ElicitSlot",
"slotToElicit": "MULTIPLEX",
"updatedIntent": {
"name": "GetMovieDetails",
"confirmationStatus": "NONE",
"slots": {
"CITY" : {
"name" : "CITY",
"confirmationStatus" : "NONE",
"value" : city # this is already filled, it is just anti-capitalised
},
"NAME" : {
"name" : "NAME",
"confirmationStatus" : "NONE",
"value" : movie_name # this is already filled, it is just anti-capitalised
},
"MULTIPLEX" : {
"name" : "MULTIPLEX",
"confirmationStatus" : "NONE",
}
}
}
}
]
}
I'm testing my skill using python-lambda-local, it is working fine on my local machine (I just had to change the dialogState to "COMPLETED" manually, like the one here). It returns everything written above. But It gives an error while testing it on Skill Tester. Here is the output which is returned in the Skill Tester.
PS : I did not check the Slot Filling check box in the Build Section. (As I need the slot to be filled later), and here is the complete code just in case.
Try with omitting the entire "updatedIntent" part, as this information is not required for ElicitSlot.
But more important: You have to make sure that your script returns actual text in JSON-format!
Have a look at http://flask.pocoo.org/docs/1.0/api/#flask.json.jsonify
or https://docs.python.org/2/library/json.html
God, I hate to admit this.
The Dialog.ElicitSlot works fine, and the way I expect it to do so.
The error with my code is, there is no error. I figured my skill was taking some time to fetch data from remote site and doing some calculations on it. So I increased the time out and bam, it worked.
It is always a better to test your skill locally, but it is great to test it once on the aws lambda console. I don't know why I didn't do that earlier.
So to conclude, I just had to increase the timeout in my skill.

Resources