Skip to content

Instantly share code, notes, and snippets.

For example, you wanted to block an image using Adblock Plus filter syntax:

expressjs.com/images/bg.jpg

After adding this rule, if you go to Express.js website and refresh the page (that is, assuming that you already loaded a page from Express.js website before adding the Adblock Plus rule), you will observe that the rule did not work. The reason is, the image was cached and it is simply being served from the cache. Hence, it seems like the rule is not working.

To observe that the rule is indeed working, you can open a private browser window (for example by pressing CMDSHIFTN) and loading the page there. Then, you should observe that the filter indeed works.

To get the filter working on non-private windows as well, simply clear the cache for the domain by:

Source

Though had it been possible, it would have been very convenient for zero-downtime deployment in case of column name changes, etc.

Data accuracy is very important for having a well-functioning application. The most risky place where bad data can be introduced is user input. Entering an address is a worldwide example where getting it right (valid and complete) is not very straightforward.

I can think of two approaches for making sure that a user entered address is accurate (valid and complete):

Conventional Method

This is the conventional mailing (aka postal) address method. This one is not very straightforward to get right, since:

  • There are lots of fields to enter.
  • Formats change between countries and in some instances, even within countries.

Let's say that on a previous version of a library, everything was working fine but after you have upgraded, a bug started to occur. Obviously, this change of behavior was introduced later to the library (via a commit). If we were able to detect which change has introduced this, we could:

  • Fork our own version of the library.
  • In our own fork, revert the change that introduced the changed behavior.
  • Use our own fork of the library.

To discover which commit has introduced this change, we can use the "bisect" command in Git. "git bisect" is basically a binary search, where Git helps us. That is, it is nothing but a binary search (of commits), where the "bisect" command does the "boring" stuff like taking a note of which commit was a good commit, and which commit was a bad commit, etc. Let's discover "git bisect" with a concrete example:

We'll give an example over a Node.js project which depends on a library named TypeORM. That is, let's say that our Node.js project dep

If an issue is fixed on GitHub (that is, if a PR is created for it and that PR is merged), to find the versions that this fix is effective at, you need to:

  • Go the the page of the issue.
  • From the page of the issue, discover the PR that fixes the issue and go to the PRs page.
  • From the PRs page, find the commit hash that merges the PR (most likely a merge commit hash) and click on it to go to the commit's page.
  • On the top of the commit's page, there is a summary box with the commit title and description. This box also contains which branch this commit is in and which tags contain this commit. The tags part tells us which versions of the software contains the fix.

NOTE: I'm not sure but this feature might be available only with "GitHub releases", instead of regular Git tags. That is, if you release versions just by using regular Git tags, this might not be available, but if you are using "GitHub releases", then it might be available.

Example:

Hello,

We are migrating from BitBucket to GitHub, but we have realized that there is already an account with the name "ToolBX" on GitHub. Since account names are case-insensitive on GitHub, it is not possible to create an account with the name "TOOLBX" either. Hence, I would like to ask you to please hand over this account to either me (utku.gultopu@toolbx.com) or Kerry Zhu (kerry@toolbx.com) instead.

Thank you

If the Allen key is turning but not grabbing and you think that your socket is rounded or stripped, maybe it is not. Maybe you are using a metric Allen key, instead of an imperial one (or vice versa).

As you know, Allen keys (like many other tools) come in sets. I grabbed the set that came with my tool set, found the largest key that can fit in the socket and tried turning. It was turning but not grabbing. I thought that the socket was rounded. Later on, I realized that there is another set of Allen keys in my tool set. Again, I found the largest key that can fit in the socket and tried turning. This time it worked like a charm.

Turns out, the first key that I tried was from a metric set, where the key was 3 millimetres. The second key that I tried was from an imperial set, which was 1/8 inches (which is 3.175 millimetres). As you can observe, these are "almost" the same size, but being "almost" the same size is not enough. That additional 0.175 mm that is brought by the 1/8 inch Allen key was what was nece

// Open the Developer Tools, switch to the "Console" tab, copy and paste the following code:
(function () {
for (const element of document.querySelectorAll('div[data-allocation-index]')) {
// Remove all video panes, except the main one.
if (element.attributes.getNamedItem('data-allocation-index').value !== '0') element.remove();
}
})();
// Now, only the main presentation pane must be appearing. To make this pane cover the whole screen

Question

I would like a way for Visual Studio Code to always show me which TypeScript files in my project has an error. I would like these shown to me on the problems gadget on the bottom status bar, as well as represented with a red font and a red dot in the file explorer view on the left side. How can I achieve this?

Answer

  • Make sure you have a tsconfig.json file at the root of your project. The contents of it does not matter, it can be just an empty file. All that matters is that it is present, so that, as far as I can tell, Visual Studio Code will be able to tell that this is a TypeScript project and hence, it will enable the built-in TypeScript extension for the project.
  • Press CMDSHIFTp, type "task" and select "Tasks: Run Task".
  • Type "watch" and select "tsc: watch - tsconfig.json". That is, we're running a task named tsc: watch, which comes from the tsconfig.json file (where, in reality, it simply comes from the built-in TypeScript extension in Vi