code-snippets

Run my Javascript code on every page on my browser, similar to how a chrome extension would

匆匆过客 提交于 2020-06-16 06:47:47
问题 I know with Chrome I can use snippets to manually run some js code on a webpage. But This required manually executing the snippet. is there any way to have some JS code that my browser (chrome or firefox) would every time I visited a new page? 回答1: You may be looking for userscripts. These allow you to write Javascript code which will then be automatically executed whenever you visit a page matching a particular pattern. For example, the following userscript: // ==UserScript== // @name

How to add custom code snippets in VSCode?

烂漫一生 提交于 2020-06-09 07:30:26
问题 Is it possible to add custom code snippets in Visual Studio Code? And if so, how? VSCode is based on Atom, so it should be possible. 回答1: Hit > shift + command + p and type snippets Select Preferences: Open User Snippets Choose the language type for which you want to add the custom snippet vscode has comments to explain on how to add a snippet, as described on :> vsdoc Lets say, we want to open custom snippets for the language GO. Then we can do: Hit > command + p Type: go.json + enter And

How to get the base directory in visual studio code snippet?

北慕城南 提交于 2020-05-25 11:31:52
问题 I am trying to get the file current directory in a snippet for visual studio code. VSCode has a variable: TM_DIRECTORY , which is the fullpath . eg: {folder: "$TM_DIRECTORY"} would be replaced by {folder: "/Volumes/my-project-path/ParentFolder/MyFolder"} But I want only MyFolder . Normally, we can use a transform as indicated in the docs. Sublime Text works in the same way. But for as much as I try, the snippet simply outputs the whole regex. Could someone answer with the magical variable

How to get the base directory in visual studio code snippet?

和自甴很熟 提交于 2020-05-25 11:31:05
问题 I am trying to get the file current directory in a snippet for visual studio code. VSCode has a variable: TM_DIRECTORY , which is the fullpath . eg: {folder: "$TM_DIRECTORY"} would be replaced by {folder: "/Volumes/my-project-path/ParentFolder/MyFolder"} But I want only MyFolder . Normally, we can use a transform as indicated in the docs. Sublime Text works in the same way. But for as much as I try, the snippet simply outputs the whole regex. Could someone answer with the magical variable

Snippet to create Snippet in SSMS

☆樱花仙子☆ 提交于 2020-04-17 22:52:16
问题 Problem: Usually, if you want to save your code as a snippet, you have to open some xml template, investigate tags etc. Reference Is it possible to simplify this process as much as possible: i.e. create a SurroundsWith snippet that will wrap selected code by snippet code? 回答1: Please try following: Save this code as a create_new_snippet.snippet and add it to your SSMS through code snippet manager (Ctrl+K, Ctrk+B) <?xml version="1.0" encoding="utf-8" ?> <CodeSnippets xmlns="http://schemas

Woocommerce: Override login required for existing email. Add order to user account

℡╲_俬逩灬. 提交于 2020-03-21 07:23:28
问题 Woocommerce Settings: Guest checkout disabled. Create account during checkout enabled (user and passowrd auto generated) If user is REGISTERED. But NOT logged in. Checkout errors with "An account is already registered with your email address. Please log in." How do I override this to COMPLETE order, and tie order to existing account. Give a prompt to user to login next time for a faster checkout Can't find any snippet or module that can do it none yet. Happy to reward. 回答1: There is no hook

How do I use snippets for Jupyter Notebook with VSCode?

你离开我真会死。 提交于 2020-03-20 02:30:17
问题 I've been using VSCode for a while and at the moment I am trying to set up snippets to work. They seem to work well with simple Python (.py) files but not with Jupyter Notebook (.ipynb) files. Is there any way to make them work together? The snippet is right here: "Create a new figure":{ "scope": "python", "prefix": "nf", "body": [ "plt.figure(figsize=(9, 9))", "", "$1", "", "plt.show()" ] } 回答1: I'm a developer on this extension. From the comments above it seems like the answer is already

Grab x number of words before and after a given keyword?

北慕城南 提交于 2020-02-02 03:18:08
问题 How can I go about grabbing [x] number of words before and after a given keyword in a string in PHP? I am trying to tokenize results from a mysql query tailored to the keyword as a snippet. 回答1: $string = 'This is a test string to see how to grab words from an arbitrary sentence. It\'s a little hacky (as you can see from the results) - but generally speaking, it works.'; echo $string,'<br />'; function getWords($string,$word,$before=0,$after=0) { $stringWords = str_word_count($string,1);

Are there any alternatives to FastSharp?

爷,独闯天下 提交于 2020-01-14 03:08:29
问题 Are there any alternatives to Matt Manela's FastSharp tool? I have a vague recollection that there was at least one alternative. Here FastSharp is the download link. 回答1: Snippet Compiler LINQPad (by Joseph Albahari, author of C# 3.0 in a Nutshell) - definitely worth checking out, can connect to a DB and try out some LINQ to SQL etc. Snippy (by Jon Skeet, used for demos in his C# in Depth book) - apparently also has an add-in for Reflector. 回答2: Are you looking for SnippetCompiler? 来源: https:

Using code snippets in Visual Studio

人盡茶涼 提交于 2020-01-13 09:13:11
问题 Right now when I want to use the cw snippet (Code snippet for Console.WriteLn ). I am typing cw , Tab , Tab . Is this the correct (fastest!) way of doing it? If there wouldd be some way of only having to hit the tab key once or any other key I would be glad to know it. 回答1: That is the fastest way. Note that the first tab is just to get rid of the IntelliSense tooltip. The second tab is the one that actually does the work. In other words, you can do cw + esc/tab/enter + tab or even c + esc +