UBUNTU disk size increase

To increase disk size, first we need to see disk status;

df -h

If it’s a VM, make sure VM has allocated enough space before performing next actions.

Here’s the list of steps for a simple scenario where you have two partitions, /dev/sda1 is an ext4 partition the OS is booted from and /dev/sdb2 is swap. For this exercise we want to remove the swap partition an extend /dev/sda1 to the whole disk.

  1. As always, make sure you have a backup of your data – since we’re going to modify the partition table there’s a chance to lose all your data if you make a typo, for example.
  2. Run sudo fdisk /dev/sda
    • use p to list the partitions. Make note of the start cylinder of /dev/sda1
    • use d to delete first the swap partition (2) and then the /dev/sda1 partition. This is very scary but is actually harmless as the data is not written to the disk until you write the changes to the disk.
    • use n to create a new primary partition. Make sure its start cylinder is exactly the same as the old /dev/sda1 used to have. For the end cylinder agree with the default choice, which is to make the partition to span the whole disk.
    • use a to toggle the bootable flag on the new /dev/sda1
    • review your changes, make a deep breath and use w to write the new partition table to disk. You’ll get a message telling that the kernel couldn’t re-read the partition table because the device is busy, but that’s ok.
  3. Reboot with sudo reboot. When the system boots, you’ll have a smaller filesystem living inside a larger partition.
  4. The next magic command is resize2fs. Run sudo resize2fs /dev/sda1 – this form will default to making the filesystem to take all available space on the partition.

That’s it, we’ve just resized a partition on which Ubuntu is installed, without booting from an external drive.

https://askubuntu.com/questions/116351/increase-partition-size-on-which-ubuntu-is-installed

nameof expression (C# reference)

nameof expression produces the name of a variable, type, or member as the string constant. A nameof expression is evaluated at compile time and has no effect at run time. When the operand is a type or a namespace, the produced name isn’t fully qualified. The following example shows the use of a nameof expression:

Console.WriteLine(nameof(System.Collections.Generic));  // output: Generic
Console.WriteLine(nameof(List<int>));  // output: List
Console.WriteLine(nameof(List<int>.Count));  // output: Count
Console.WriteLine(nameof(List<int>.Add));  // output: Add

List<int> numbers = [1, 2, 3];
Console.WriteLine(nameof(numbers));  // output: numbers
Console.WriteLine(nameof(numbers.Count));  // output: Count
Console.WriteLine(nameof(numbers.Add));  // output: Add

Read more here

Default value for a boolean parameter in JavaScript function

See following example;

You could skip the ternary, and evaluate the “not not x”, e.g. !!x.

If x is undefine, !x is true, so !!x becomes false again. If x is true !x is false so !!x is true.

function logBool(x) {
    x = !!x;
    console.log(x);
}

var a, b = false, c = true;
logBool(a); // false
logBool(b); // false
logBool(c); // true

https://stackoverflow.com/questions/24332839/set-a-default-value-for-a-boolean-parameter-in-a-javascript-function

How Much to Spend on an SSL Certificate

To choose the best one, consider what information your visitors will share.

For example, if you manage a website that requires customers to give personal details or processes financial transactions, we recommend opting for an EV certificate that offers a higher security level. If you run a blog without a transaction page, a DV certificate ($8/year) might be enough.

For more info, read here.

Empty Functions in JavaScript

An “empty” function in JavaScript is one that has no statements or executable code inside of its function body. Empty functions can be helpful as placeholders for future-implemented functions or as default functions to avoid errors if a function call is made when no action is needed.

What are Empty Functions in JavaScript?

A function that has no statements or instructions inside of its body is said to be an “empty function” in JavaScript. For defining an “empty function”, the “function” keyword, empty pair of parentheses, and an empty pair of curly braces are used.

How to Define Empty Functions in JavaScript?

The following syntax is utilized for creating an empty function:

function emptyFunction() {

// no statement or instructions

}

Or

const emptyFunction = () => {

// no statement or instructions

};

Use Case Scenarios of Empty Functions in JavaScript

Empty functions can be useful in various situations, such as:

  • Developers may want to define a function but do not yet have an actual implementation. So, they have to use the empty function as a placeholder and then add the implementation details later.
  • Sometimes, developers need a function that does nothing while defining event handlers for elements. So, they utilize the empty function as a placeholder for the element’s event attribute until the actual functionality is not added.
  • While defining an object, developers may want to include a default function as one of the properties of the object. For this, an empty function can be utilized as a temporary replacement for the default function until it is replaced with a new implementation.

Example: Add Empty function to Handle Event

Here, we will handle the click event of the button using the empty function as a placeholder that will be implemented later for any specific task.

First, define an empty function “buttonClick()” to handle the button’s click event:

function buttonClick() {}

Now, access the button by getting its reference using the assigned id:

const button = document.getElementById("btn");

Then, assign the empty function “buttonClick()” to the click event of the button:

button.onclick = buttonClick;

The above code helps to handle the click event to avoid errors.