Set a keyboard shortcut in Options -> Environment -> Keyboard
Search for the command: SolutionExplorer.SyncWithActiveDocument.
Se images below:
Category: Tips & Tricks
How to delete all node_modules files fast and simple for a repo
Run the following in the repo root folder: (deletes all node_modules folders and its content recursively):
npx rimraf ./**/node_modules
(Npx command is available from NPM version 5.2)
This might take som time since node_module usually contains a lot of files.
How to set memory limit for ElasticSearch in Windows
Running elasticsearch on my local development machine takes up half of system memory by default. Here is instructions on how to change max memory size.
Prerequisites:
* Windows 10
* This instruction is for Elasticsearch version 7.16.2 but probably works on other versions as well
* Running elasticsearch.bat (in development mode not as a service)
Goto folder:
“C:\elasticsearch\elasticsearch-7.16.2\config\jvm.options.d\”
Create file:
“jvm.options” (normal text file, utf-8)
Setting for maximum of 4GB memory allocation:
-Xms4g -Xmx4g
Change both “4” values into other value if desired.
Restart elasticservice.bat
Instructions if running elasticsearch as a service on Windows:
You can set the memory limit for Elastic Search on Windows Server by following command:
[Elasticsearch Path]\bin>elasticsearch-service.bat manager
Note: Run command prompt as administrator
It will open manager as shown here: Image: ElasticSearch service properties
Now go to the ‘Java’ tab and change settings based on your requirement.
Note: Make sure, you changed it under ‘JavaOptions’ textbox and also for separate parameters. For example, to set 1GB initial memory pool and maximum memory pool, you can set ‘1024’ MB for both.
From: https://stackoverflow.com/questions/28798845/how-to-set-memory-limit-to-elasticsearch-in-windows
3 Ways to Clone Objects in JavaScript | SamanthaMing.com
Great blog post explaining different ways for cloning objects in JavaScript. Also explains the difference between shallow and deep copy.
As you can see, the deep copy is a true copy for nested objects. Often time shallow copy is good enough, you don’t really need a deep copy. It’s like a nail gun vs a hammer. Most of the time the hammer is perfectly fine. Using a nail gun for some small arts and craft is often case an overkill, a hammer is just fine. It’s all about using the right tool for the right job
Source: 3 Ways to Clone Objects in JavaScript | SamanthaMing.com
Top 9 GitHub Copilot alternatives (code completion tools) to try in 2022 (free and paid)
GitHub Copilot is a code completion tool from GitHub and OpenAI. It employs OpenAI’s Codex, a transformer trained on billions of code lines on GitHub, to auto-generate code based on the current file’s contents and your cursor location. Copilot is compatible with popular code editors like Visual Studio Code, Visual Studio, Neovim, and JetBrains IDEs and offers support for languages like Python, JavaScript, TypeScript, Ruby, and Go.
According to GitHub and user reviews, Copilot can generate whole code lines, functions, tests, and documentation. All it needs is context and the behind-the-scenes work of developers who committed their code to GitHub, regardless of their software license.
When the Copilot beta ended, GitHub released the pricing for individual users. The subscription included a 60-day free trial, which would turn to $10/month or $100/year per user.
Source: Top 9 GitHub Copilot alternatives to try in 2022 (free and paid)
Fine Code Coverage – Visual Studio Marketplace
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
Source: Fine Code Coverage – Visual Studio Marketplace
Usage:
- Install
- Open the Fine Code Coverage window
- Run all unit tests
- See stats in Fine Code Coverage window
- Exclude the test project itself from coverage calculation:
(Below excludes project that ends with .Test and all its types (*
Pattern: [assemblyname]type
Filter Expressions:
Wildcards
* => matches zero or more characters
Examples
[*]* => All types in all assemblies (nothing is instrumented)
[coverlet.*]Coverlet.Core.Coverage => The Coverage class in the Coverlet.Core namespace belonging to any assembly that matches coverlet.* (e.g coverlet.core)
[*]Coverlet.Core.Instrumentation.* => All types belonging to Coverlet.Core.Instrumentation namespace in any assembly
[coverlet.*.tests]* => All types in any assembly starting with coverlet. and ending with .tests
Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.
How to Deserialize JSON to C# cherry-picking a small portion of JSON data
JSON deserialization in C# refers to the process of forming up .NET objects from a JSON string. Most of the time, this means creating strongly-typed POCOs. However, there are certain situations when we may prefer flexibility over type-inference. For example, cherry-picking a small portion of JSON data, dealing with external JSON data whose structure is largely unknown or changes very often, etc. Dynamic deserialization comes into play for such cases. This does not necessarily mean the use of language’s inbuilt dynamic keyword. There are other ways as well.We are going to see how we can do this using the native System.Text.Json library and the popular Newtonsoft.Json library.
Source: How to Deserialize JSON Into Dynamic Object in C# – Code Maze
Using telnet as a tool for troubleshooting network port connections
Note that you may need to enable telnet on your workstation (see this Article: How to enable telnet for troubleshooting when CMD reports: “‘telnet’ is not recognized as an internal or external command”)
Once you have telnet enabled, follow these steps:
- Open a command prompt
- Type in “telnet <IP ADDRESS OF SERVER PC> <PORT>” and press enter.
- For example, you would type “telnet 123.45.67.89 1521”
- If a blank screen appears then the port is open, and the test is successful.
- If you receive a connecting… message or an error message then something is blocking that port. It could be the Windows firewall, a third party firewall like your anti-virus software, or an institutional hardware firewall between the workstation and the server.
Rxjs debugging subscribers
I wanted to see how many listeners there was for a certain subject, and where they reside in the source code.
Here is how in chrome devtools, put a breakpoint before the subjects .next() call. And inspect the subject:
observers array count = number of “listeners”
FunctionLocation = source code reference
(Context: Angular v11, rxjs)
8 Apps to Enable Tabs in File Explorer on Windows 10
8 Apps to Enable Tabs in File Explorer on Windows 10
Source: 8 Apps to Enable Tabs in File Explorer on Windows 10