code-snippets

Setting up a snippet in Visual Studio Code with regex

北城余情 提交于 2019-12-01 13:30:56
{ "Comment": { "prefix": "#", "body": "<!-- ${TM_FILEPATH/([^/]*\/[^/]*)$/$1/} -->" } } I have set up the about code snippet, the purpose is to add a comment that adds the file's base directory and file name <!-- templates/base.html --> like this but discards the rest of the path. I believe this is originally based on TextMate snippets. I have tried everything but I can't get it to work, it's probably something silly but I don't see what I'm doing wrong. Using just TM_FILEPATH without the regex results in <!-- /Users/johndoe/Sites/blog/blog/templates/base.html --> I used this https://code

Setting up a snippet in Visual Studio Code with regex

一世执手 提交于 2019-12-01 09:48:49
问题 { "Comment": { "prefix": "#", "body": "<!-- ${TM_FILEPATH/([^/]*\/[^/]*)$/$1/} -->" } } I have set up the about code snippet, the purpose is to add a comment that adds the file's base directory and file name <!-- templates/base.html --> like this but discards the rest of the path. I believe this is originally based on TextMate snippets. I have tried everything but I can't get it to work, it's probably something silly but I don't see what I'm doing wrong. Using just TM_FILEPATH without the

Is this possible with Visual Studio snippets?

不打扰是莪最后的温柔 提交于 2019-12-01 09:02:34
问题 I use a modified form of TODO comment (SteveC_TODO) that allows me to group my own todos together in the task list. Yesterday I thought it would be nice to modify the refactoring snippets to add a todo comment to the usual NotImplemented exception. I modified the Method Stub - Body snippet to this $signature$ { //SteveC_TODO: implement $end$$signature$ throw new $Exception$(); } but this results in the todo comment having the full method signature. It serves the purpose but I would prefer the

How to convert imperial units of length into metric?

回眸只為那壹抹淺笑 提交于 2019-12-01 08:15:45
Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object in imperial units. It can go like this: $length = "3' 2 1/2\""; or like this: $length = "1/2\""; or in fact in any other way we normally would write it. In effort to reduce global wheel invention, I wonder if there is some function, class, or regexp-ish thing that will allow me to convert Imperial length into Metric length? Here is my solution. It uses eval() to evaluate the expression, but don't worry, the regex check at

How to convert imperial units of length into metric?

﹥>﹥吖頭↗ 提交于 2019-12-01 06:58:54
问题 Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object in imperial units. It can go like this: $length = "3' 2 1/2\""; or like this: $length = "1/2\""; or in fact in any other way we normally would write it. In effort to reduce global wheel invention, I wonder if there is some function, class, or regexp-ish thing that will allow me to convert Imperial length into Metric length

Snippet code to create constructor in VS2010 Express

允我心安 提交于 2019-12-01 04:23:44
Is there any ready for use code snippet in VS 2010 Express edition (for C#), to create constructor with parameters from selected properties? When I create a new class and I've written following code: public class FileDetails { public int ID { get; set; } public string FileName { get; set; } public string FilePath { get; set; } public DateTime LastWriteTime { get; set; } public FileStatus LastFileStatus { get; set; } public NotifyIfFileNotExists NotifyIfFileNotExists { get; set; } public string RecepientsEmailList { get; set; } public string AdminEmailList { get; set; } public FileDetails() { }

Shopify liquid: How can I conditionally include snippets in Shopify liquid?

浪尽此生 提交于 2019-12-01 03:38:46
I would like to include a snippet in a template but only if the snippet file exist. Is there any way I can do it? Now I'm just using: {% include 'snippetName' %} But this throws the error: Liquid error: Could not find asset snippets/snippetName.liquid The reason I need such a functionality is because I have a background process that adds the snippet later on. Had this problem myself. This was my solution: {% capture the_snippet_content %}{% include the_snippet %}{% endcapture %} {% unless the_snippet_content contains "Liquid error" %} {% include reviews_snippet %} {% endunless %} Basically

Snippet code to create constructor in VS2010 Express

爱⌒轻易说出口 提交于 2019-12-01 02:17:50
问题 Is there any ready for use code snippet in VS 2010 Express edition (for C#), to create constructor with parameters from selected properties? When I create a new class and I've written following code: public class FileDetails { public int ID { get; set; } public string FileName { get; set; } public string FilePath { get; set; } public DateTime LastWriteTime { get; set; } public FileStatus LastFileStatus { get; set; } public NotifyIfFileNotExists NotifyIfFileNotExists { get; set; } public

How to increase character lengh in blogger snippet instead of using limited length, 'data:post.snippet'?

不打扰是莪最后的温柔 提交于 2019-12-01 00:22:58
I'm currently using 'data:post.snippet' for blogger mobile snippet. <div class='post-body' style='color:black;'> <b:if cond='data:post.snippet'><data:post.snippet/></b:if> </div> But its character length(140) is too low, and it doesn't give a line break between the headings and paragraphs. When there's a heading at the very start line break is necessary. Can someone please suggest me a javascript code to replace above code to overcome those two issues. You can utilize the data:post.longSnippet data tag which has the limit of upto 300-400 character <div class='post-body' style='color:black;'>

Shopify liquid: How can I conditionally include snippets in Shopify liquid?

戏子无情 提交于 2019-11-30 23:56:07
问题 I would like to include a snippet in a template but only if the snippet file exist. Is there any way I can do it? Now I'm just using: {% include 'snippetName' %} But this throws the error: Liquid error: Could not find asset snippets/snippetName.liquid The reason I need such a functionality is because I have a background process that adds the snippet later on. 回答1: Had this problem myself. This was my solution: {% capture the_snippet_content %}{% include the_snippet %}{% endcapture %} {%