Global scope for user snippet in Atom.io editor - sublimetext

I would like to transform some snippets that I wrote for the Sublime Text 3 editor to the atom.io editor.
Since I have a "license" snippet that is valid for any type of file (any file extension) then in the licence.sublime-snippet file I did'n specify a scope:
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
Now, i see the above example in atom/snippets.
'.source.js':
'console.log':
'prefix': 'log'
'body': 'console.log(${1:"crash"});$2'
The outermost keys are the selectors where this snippets should be
active.
but I can't figure out how can I specify a global scope or better yet do not specify it at all as well as I did in .sublime-snippet. Any help is appreciated; in particular still have not found the comprehensive documentation of detailed operation snippet atom therefore also some links to this kind of docs are welcome.

Is this what you're looking for?
'*':
'console.log':
'prefix': 'log'
'body': 'console.log(${1:"crash"});$2'

#Basil Musa: For a snippet to be available in (js and html) files you specify it like this:
'.html.js':
'snippet-name':
'snippet-shortcut': 'log'
'snippet-body': 'console.log(${1:"placeholder"});$2'

Related

using <#include> resoults in error: Can't find resource

I am implementing a freemarker code in an environment that stores the templates in an database.
for example
${bundle.key}
will display the value of the row with row_id = 'key'
However when I use include directive something doesn't work.
I have a template with a key GenF as follows
<#function PriceFormat Number>
<#return Number?string['0.0000']>
</#function>
if i run
${GenF.PriceFormat(1.568)}
I get the output
1.5680
as expected.
but when i run
<#include bundle.GenF>
${PriceFormat(1.568)}
I receive an error message:
Can't find resource for bundle ...structures.shared.localization.bl.MultiResourceBundle, key
do I use the include directive wrong, or is something was not defined correctly in the Data model by our programmers?
#include expects the name
(path, "file" name) of a template, not the template content itself. See: https://freemarker.apache.org/docs/ref_directive_include.html
What you seem to want is <#bundle.GenF?interpret />. Though note that the parsed template won't be cached that way, unlike when you invoke a template with #include. For #include to be able to resolve "bundle.GenF" as template name (or rather something like "bundle:/GenF", but it's up to you), you have to use a custom TemplateLoader (see Configuration.setTemplateLoader).
As far as you only need this for defining custom number formats, you may also want to consider using custom number formats (https://freemarker.apache.org/docs/pgui_config_custom_formats.html), like ${1.538?string.#bundle_GenF}.

Serilog console conditional output template based on log level, (and low profile color in console)

Please first excuse me, I am not so familiar with the Serilog, I started with it quite recently.
I would like use a certain log level in my console app to be used as normal console output by default (output just the rendered message) and then optionally, when specified by optional commandline argument like -verb also have output in such default format "{Timestamp:HH:mm:ss} [{Level:u3}] {Message}{NewLine}{Exception}"(and additionally perhaps with more low profile color)
My questions are:
which (the cleanest) way can it be accomplished?
a) in case of filtering: can you please help me, how the filtering would look like in the fluent configuration API?
b) in case of using a custom ITextFormater, can it somehow inherit the part
providing rendering such format templates as mentioned above?
c) any better way, or ??
is it possible to somehow make (using the output format template) for the console sink such a "lower profile" color?
You can just switch the outputTemplate based on the presence of the command-line flag:
bool verbose = false;
var template = verbose ?
"{Timestamp:HH:mm:ss} [{Level:u3}] {Message}{NewLine}{Exception}" :
"{Message}{NewLine}";
Log.Logger = new LoggerConfiguration()
.WriteTo.Console(outputTemplate: template,
theme: SystemConsoleTheme.Grayscale)
.CreateLogger();
See the theme argument supplied in the example for how to change coloring.

How to reference an *.rst file from the docstring of a module using sphinx

I wrote a little tutorial in rst format. Now for the documentation generated by apidoc, I would like to reference that tutorial in the docstring using:
:any:`<my_tut>`
Where my_tut.rst is in the top level directory of my Sphinx-documentation source-folder. However, I get the error
WARNING: 'any' reference target not found: my_tut
Added info:
The output of apidoc is not in the toplevel source folder, but in a subfolder called code.
The :doc: role can be used to create a cross-reference to my_tut.rst:
:doc:`my_tut`
If the link source and the link target are in different folders, that needs to be taken into account. With a target one level above the source, it would look like this:
:doc:`../my_tut`
An alternative is to add a label immediately before the relevant heading in my_tut.rst and use that as the cross-reference target. If the label definition is .. _my_label:, you would reference it like this:
:any:`my_label`
You could also use :ref:`my_label`.

RuboCop Error - Define a global variable in Cucumber RUBY files

I need to define a global variable in my Cucumber env.rb file which can be accessed throughout the framework in all step methods. Currently i am defining as this in my env.rb file:
$global_var ||= false
And i need to access this var into the Before hook as well After hook and few step methods where i am re-initializing this. It is working perfectly as i want. But the problem is, rubocop doesn't like this and throwing error as "do not use global variable". How can i resolve this ???
FYI, I tried using singleton to define this var as accessor and not quite sure where i am missing.
Change the config file for rubocop. use the link:
Example to Change
Look for the passage starting with When we look in the .rubocop_todo.yml file we see something like this: and also Configure Rubocop to be your style guide
Link to List of Configuration Changes possible:
Link to List of Styles
change .rubocop.yml file:
Style To Change:
GlobalVars: Enabled: false
Example File : Example file - how it looks like
How to Configure Style: Style/Inheritance Guide

Is there any way to have Visual Studio ignore the <devdoc> tag when compiling?

Basically, I was attempting to keep all of my documentation in a separate file and use the <include> tag. This would let me keep my source code free of documentation clutter. I still wanted a way to have some developer notes about classes and members, so I used the <devdoc> tag. The problem is now Visual Studio adds my developer notes to the xml documentation file. Is there any way to not have it compile into the xml documentation?
/// <devdoc>This is an interesting Foo class</devdoc>
/// <include file="docs.xml" path='Doc/Member[#for="MyNamespace.Foo"]/*' />
public class Foo { ... }
Which resulted in:
<member name="T:MyNamespace.Foo">
<devdoc>This is an interesting Foo class</devdoc>
<Summary>Some summary for testing.</Summary>
</member>
I realize that Sandcastle is not going to use the <devdoc> class when it generates its documentation, but if I want to give intellisense information about my library I need to include the generated xml file. If it's impossible, it's not the end of the world, but I'm hoping that there is a way to exclude it to begin with.
I would create a simple console application that would be called from a post-build event. The application will remove all <devdoc> tags. It can be really simple. Just read the generated XML file and use regex like this:
using System.Text.RegularExpressions;
Regex regex = new Regex("<devdoc>(.|\n)*</devdoc>", RegexOptions.Compiled | RegexOptions.Multiline);
s = regex.Replace(s, string.Empty);
You can also use XmlDocument and its GetElementsByTagName method and then XmlNode.RemoveChild to remove the tags. But I believe regex would be more efficient.

Resources