Code snippets are available for a multitude of languages, including C#, C, Visual Basic, XML, and T-SQL, to name a few. To view all the available installed snippets for a language, open the Code Snippets Manager from the Tools menu (or, press Ctrl+K, Ctrl+B), and choose the language from the drop-down menu at the top. Code snippets can be accessed in the following general ways.
After I moved to a static site hosted on GitHub Pages, I was looking at different options to share the code snippets in a better way. With the Hugo generated static pages, there are a few options for code sharing in an article.
- Woody ad snippet helps to create and store code snippets or repeated text in a special library available from the admin bar of your website. All snippets can be added through shortcodes or automatically anywhere on your website. You can show or hide snippets using conditional logic.
- It'd be great if you could have your snippets available in the chrome menu as shortcuts OR find a way to let me call the snippet from the console rather than having to go the Snippets area and manually execute them. Adding this would add value beyond the default snipping functionality in Chrome Dev Tools.
You can use the simple pre-formatted text in markdown. This is usually done by enclosing code snippet in ```. This appears (in Hugo Coder theme I am using) as a big black block and has no way to choose the right syntax highlighting based on what programming language the snippet is written in. There are no line numbers or no highlighting of lines in a code snippet and so on.
C# Code Snippets
The second method involves Hugo's default Highlight shortcode. This is a good method that supports line numbers, language type, and line highlights. But, the only shortcoming is that I have to now store the code snippet locally in the same static page. So, if I need to update the code snippet, I end up updating the static page itself.
So, wanted to explore something better and then I found the Gist shortcode in Hugo. Using this shortcode, you can embed a GitHub Gist on a static page. This seemed like a good fit for me since I get the line numbers, language based syntax highlighting, and nothing saved locally in the static page. However, for adding the code snippets as Gists, I first need to upload the Gist and then use it in my article. For this, I need to navigate to the GitHub site and then return once I am done uploading Gists. This is where I found GistPad VS Code extension quite helpful. With this extension in place, I can now create/update/delete Gists right inside VS Code where I am writing all the markdown content for the articles. So, I never have to leave VS Code. Here is how it appears in VS Code.
As you see in the screenshot, I can group all Gists that belong a specific article or category and then simply use them here in an article. With this integration, I simply write all code as a Gist and then use the following syntax to make it appear here.
Simple. Bill 282. I will be using this method of sharing code snippets within an upcoming article series. Stay tuned.
Share on:So, wanted to explore something better and then I found the Gist shortcode in Hugo. Using this shortcode, you can embed a GitHub Gist on a static page. This seemed like a good fit for me since I get the line numbers, language based syntax highlighting, and nothing saved locally in the static page. However, for adding the code snippets as Gists, I first need to upload the Gist and then use it in my article. For this, I need to navigate to the GitHub site and then return once I am done uploading Gists. This is where I found GistPad VS Code extension quite helpful. With this extension in place, I can now create/update/delete Gists right inside VS Code where I am writing all the markdown content for the articles. So, I never have to leave VS Code. Here is how it appears in VS Code.
As you see in the screenshot, I can group all Gists that belong a specific article or category and then simply use them here in an article. With this integration, I simply write all code as a Gist and then use the following syntax to make it appear here.
Simple. Bill 282. I will be using this method of sharing code snippets within an upcoming article series. Stay tuned.
Share on:This is a quick blog post to show a nifty place to store code snippets in HANA Studio. I'm thinking of snippets that you execute often and lose somewhere in your HANA Studio tabs, the ones where you haven't been super diligent about saving as sql files. (Confession time, this is me, I have useful code snippets stored in lots of random places that seemed like a good place at the time. 😉 )
Note: I know HANA Studio is 'dead' with HANA 2.0, however many people are still using it and are still using HANA XS Classic, so perhaps this tip will help someone have a nicer experience in the client tool.
This is also the same spot where you can upload the helpful sql zip file that SAP provides as per 'SAP Note 1969700 – SQL statement collection for SAP HANA'. I'm not going to go through those steps now as they are already nicely covered in the following blog:
Using the same concept we're also able to store our own SQL snippets, here are the steps:
Step 1: Double-click on any system in HANA Studio and then navigate to the 'System Information' tab
Step 2. Right-click in the open area and select 'New SQL Statement'
Step 3: Give your script a name and description and paste your code in. It must start with SELECT or WITH.
Step 4: You can save using top menu, it will then be available on all systems you've configured in HANA Studio and you do not have to repeat the steps per system
Step 5: Your script will now be available on the 'System Information' tab.
Step 6: Right-click and select 'Execute' to run it Filepane 1 9 12 download free.
Step 7: The results will be displayed in a data preview screen
Step 8: You can also open the script in the SQL Console by right-clicking and selecting 'Open in SQL Console', perhaps if you want to edit it before executing
Store Code Snippets Online
Tip: If you perhaps want to store script that doesn't start with SELECT or WITH :
Then you can just fool it with a dummy select statement followed by your script. It won't execute if you call the 'Execute' function as this is expecting a single result, however you can still open it with SQL Console and execute from there
Save Code Snippets
Good luck getting organized. 🙂