How to add common language snippets in Visual Studio Code? - code-snippets

In official vscode documentation i have seen that is possible to create custom snippets for each language.
https://code.visualstudio.com/Docs/customization/userdefinedsnippets
Ex. (languageId).json
But if i want to define snippets common for all languages? It is possible?

Common users snippets are currently not supported, but there is a VSCode issue tracking this feature request. Please let us know if this is something you would find useful.
For completeness, VSCode extensions can register the same snippets for multiple languages but they must explicitly specify all languages they provide snippets for (there is no "language": "*" option).

For completeness, global snippets are now supported in VS Code out the box.
Probably redundant information as the UI already guides you to it via the auto-generated global.code-snippets file when you open User Snippets in the menu.
However something I didn't know and landed on this answer looking to find is that you can also use the scope field to narrow global snippets to a specific subset of languages.
For example if I want a certain snippet available in both javascript and typescript, but only in javascript and typescript (because it's annoying if it also appears in other languages)
"My Snippet": {
"prefix": "my-snippet",
"body": [ "my snippet code..." ],
"scope": "javascript,typescript" // define a strict subset of languages here
}

Related

Pine script intellisense ( autocomplete ) without Ctrl + Space

I have been using the pinescript editor in tradingview.com
I could not able to configure the editor much, Not even font size.
I am executing scripts in order to make changes in the editor like below.
$('#editor').css('font-size','21px');
I want the editor to suggest me without entering Ctrl + Space.
And also is there a generic advice as a newbie for using pine-script and editor. Some hack or tools which I can use ?
If you use VS Code, have a look at the first line here. It's an add-on by RicardoSantos.
Disclosure: the link in this answer points to a PineCoders FAQ entry. I am a member of the PineCoders community and I most probably wrote that FAQ entry. PineCoders is a TradingView-supported group of volunteer Pine coders and PineCoders' website is strictly educational. Neither TradingView nor PineCoders benefits financially from sending traffic to pinecoders.com, and the site contains no affiliate/referral links.

Translate JMeter menu items

About Translate JMeter projects,
I follow the translating steps and open I18NEdit,
I see the translation text options but I notice that I can't localize Menu items as File, Exit,..
It seems that there are texts (messages.properties) that can't be localized.
Is messages.properties localization is done manually by adding messages_[locale].properties?
Am I missing something ? Is it on purpose or should an enhancement be opened?
We don't really use i18nedit for translation. But you can still use it.
Anyway, Internationalization in JMeter is based on properties files:
src/core/org/apache/jmeter/resources/messages_[locale].properties
src/components/..../*.properties (except some like colors.properties)
src/protocol/..../*.properties
No need to translate deprecated components.
The 2 latter are related to components that rely on TestBean approach (no specific GUI)
Note that a PR (github mirror) is preferred over a patch:
https://github.com/apache/jmeter/blob/trunk/CONTRIBUTING.md

Dart lang: How do you browser feature test for file uploading & file reading APIs?

How do you feature test for browser support using Dart? Things that are common to test for in Javascript. It is unfortunately still a necessary evil.
For instance, how do you write a test if the browser supports 'XMLHttpRequestUpload' so that you can fallback to supported features?
Also, how do you test for 'FileReader', 'Worker', 'ArrayBuffer', 'DataView', 'Uint8Array', 'Float32Array', ... ?
In Javascript, you can test if the objects are available in the global namespace (Window, etc).
To check if you can access the file system use the FileSystem.supported field. Similarly for workers see Worker.supported.
Since Dart targets IE9+, I think the other API's you've listed are already supported cross browser.

F# interactive session persistance and other such user questions

Is there any way of persisting my F# session or serializing it into a file? i.e. so I can hand it to a friend and say "run this" and they will be at the same place I was? I know forth had this ability but I can't find any way of doing this.
An alternative would be a log file or something of similar ilk, but ideally it would strip the output and just give me the code I wrote.
On the topic of user questions, is there a config file for F# so I can add some "always includes" or alter the defaults?
There is no way to serialize the F# Interactive session or create some log of commands automatically.
The typical user interaction is that you write all your code in F# Script File (.fsx extension) and evaluate code by selecting lines and sending them to F# Interactive using Alt+Enter. If you work like this, then the F# Script File is a bit like log of your work - and you can easily send it to other people.
The good thing about this approach is that you can edit the file - if you write something wrong, you can correct it and the wrong version will not appear in the log. The bad thing is that you need some additional effort to keep the source file correct.
Regarding automatic inclusions - you can specify options for fsi.exe in Visual Studio Options (F# Tools). The --load command line parameter can be used to load some F# source at startup.

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use new ActiveXObject(). If you are using VBScript, you can just use CreateObject.
See this article for some background.

Resources