Skip to content

Instantly share code, notes, and snippets.

  • -A: Show all files except the implied . and ...
  • -t: Sort entries by time modified.
  • -r: Reverse the sort order. That is, the last modified file will appear last. This way, even if there are many files, the last modified files will always be in terminal's view, since they will be printed the last.
  • -l: Print output in long format, which prints one entry per line, instead of column format, which is the default when the ls output goes to a terminal.

Summary

Indexing a string with an out-of-bounds index throws an exception, whereas slicing it with out-of-bounds indices simply return an empty string.

Details

In a repository, I came across a code like:

if some_list[some_number:some_number+1] == some_variable:
@ugultopu
ugultopu / How can the Command Line Tools package not be installed, yet the Command Line Tools still be present on macOS?.md
Created February 18, 2021 12:56
Explanation of how can Command Line Tools on a macOS system can be present, even though the software package of it is missing

Summary

Sometimes, some software updates cause some package "receipts" to disappear (to be removed). This means, even though the package is actually still installed, the receipt for it will be missing. Since the receipt will be missing, one will think that the package is missing too, even though it is actually there.

In other words, this incident of removal of a package receipt without the actual removal of the package essentially disturbs the "integrity" of the native "package system" of macOS.

Details

I had neither Xcode, nor the com.apple.pkg.CLTools_Executables package:

$ pkgutil --pkg-info com.apple.pkg.CLTools_Executables
@ugultopu
ugultopu / How to create a LinkedIn profile without a phone number?.md
Last active March 3, 2021 20:34
Approaches for creating an account without providing a phone number on web applications that require a phone number only when they think that you are "suspicious"

Summary

If you are reading this article, chances are LinkedIn always asks for a phone number when you attempt to create an account. This means LinkedIn has put your IP address (your "public IP address", which almost surely means the IP address of your Internet router) to a "blacklist". Hence, in order to be able to create a LinkedIn profile without LinkedIn requiring a phone number, you first need to get out of this "blacklist".

To do so, you need to change your IP address. Here, "your IP address" means "your public IP address", which almost surely means the IP address of your Internet router. Hence, you need to access your router and change its IP address. Hence, this is a bit technical and the details depend on your router's make and model.

After getting out of LinkedIn's "blacklist", you need to use a web browser that does not block trackers, scripts, etc. when attempting to create an account. That is, you need to make yourself look as "docile" as possible to LinkedIn.

The safest bet for this is to

Use the touch command like:

touch -t '1509260825' <path to the file>

This will set both the creation and modification date of the file to "2015-09-26 08.25".

To preserve the creation and modification dates when coping a file, use the -p option of the cp command like:

cp -p <path to the file> <destination path>

UPDATE

Although below are methods to extract the contents of a macOS package without actually installing it, the best way might be to create a blank disk image and install the package to this disk image in order to inspect the package contents. To do so:

  • Open the Disk Utility app.
  • Choose "File > New Image > Blank Image". Alternatively, simply press CMD-N.
  • Set the parameters and click on "Save" to create the blank disk image.
  • After creation, it should be already mounted. If not, you can mount it by navigating to the directory that it is placed at and double clicking on the disk image file.
  • Run the package installer by double clicking on the package file.
  • Select this newly created blank disk image as the destination and install it.
  • If the script is preventing you from installing by saying, for example, "macOS isn't installed", you can:
git filter-repo --email-callback ' return b"new_email_address" if email == b"old_email_address" else email '

Documentation

If git-filter-repo is not installed, you have to install it. git-filter-repo is a program:

  1. Developed by Elijah Newren, who is a veteran contributor to Git.
  2. Endorsed by Git as the replacement for the git-filter-branch program, which had numerous issues.

For reasons that I don't know, it has to be installed separately, instead of being included in a Git distribution. At least this is the case in the version of Git that I'm using.

Because GitHub handles them using JavaScript. Their ID's are prefixed with user-content-. Hence, an ID is like user-content-some-fragment, whereas the fragments are expressed only as some-fragment.

Summary

Specify the path to your plugin script with a leading ./ or ../. A Babel plugin is a regular CommonJS module, and Babel "processes" what you provide as the "plugin identifier" before converting it to a "module identifier" and loading that CommonJS module using the require function of Node.js.

Per [Node.js module loading rules][Node.js modules API document], a module identifier the does not start with ./ or ../ is searched in node_modules/. Since a plugin that we are currently developing is (most likely) not in a node_modules/ folder, we must specify the path to it with a leading ./ or ../ so that the plugin will not try to be located in a node_modules/ folder, but it will be tried to be located in the relative path that we provide.

Details

As mentioned in ["What is a Babel Plugin?"], a Babel plugin is nothing but regular a CommonJS module, whose value of module.exports is expected to be a function by Babel. Hence, after creating a Babel plugin (i.e after creating a Comm

Disclaimer: This article applies to Babel that runs on Node.js, which is the most common way of running Babel. I didn't check how Babel on a web browser works. The reason I wrote this article is because I didn't notice anywhere on Babel docs that explains what exactly is a Babel plugin. Babel docs mention how a Babel plugin works, what's its purpose, etc. but as far as I can tell, they don't mention what a Babel plugin is.

A Babel plugin is a CommonJS module, whose export is expected by Babel to be a function. That's it. Note that I didn't say "default export", because there is no concept of "default export" in CommonJS. In CommonJS, there is only the module.exports property. This property's value can be any valid JavaScript value. However, Babel expects the value of the module.exports property of a CommonJS module that is designated as a Babel plugin to be a JavaScript function.

How do we know that a Babel plugin is a "CommonJS module"? Can't it be an "ES6 module" as well? No. A Babel plugin is a Com