• 23 November

    Get File Size in KB, MB, GB in PowerShell

    💡 TL;DR To Get File Size in KB, MB, GB in PowerShell, use Get-Item cmdlet to get the file at specified location and use length property on the file to get the file size. Divide file size by 1 KB, 1 MB and 1 GB to get the file size in KB, MB, GB respectively. […]

  • 20 November

    Exit if Statement in Python

    Using break Statement Use the break statement to exit if statement in Python. [crayon-678d879850e28139540916/] [crayon-678d879850e2c579321426/] The break statement is used to terminate the loop prematurely. This statement is commonly utilized in loops to exit from them if a particular condition was met. In the above example, we used a for loop to iterate over a […]

  • 18 November

    Replace String in Multiple Files in PowerShell

    💡 TL;DR To replace String in multiple files, use Get-ChildItem to get all the required files and iterate over the files using ForEach-Object. In each iteration, read the file content using Get-Content cmdlet, use replace() method to replace text and Set-Content to save the content in the files. Here is simple example: Let’s say, you […]

  • 18 November

    Replace Space with Comma in PowerShell

    💡 TL;DR To replace space with comma in PowerShell, you can use String’s replace() method or PowerShell’s replace operator. Here is simple example: [crayon-678d87985105d825229218/] There are multiple ways to replace Space with Underscore in PowerShell. Let’s go through them. Using String’s replace() method Use string’s replace() method to replace space with comma in PowerShell. Replace […]

  • 18 November

    Replace Space with Underscore in PowerShell

    💡 TL;DR To replace space with underscore in PowerShell, use String’s replace() method or PowerShell’s replace operator. Here is simple example: [crayon-678d8798510f7183917336/] There are multiple ways to replace Space with Underscore in PowerShell. Let’s go through them. Using String’s replace() method You can use string’s replace() method to replace space with underscore in PowerShell. Replace […]

  • 18 November

    How to Remove Decimals in Python

    Quick Solution To Remove decimals in Python, use int() function. [crayon-678d87985119c848385576/] Or use math.trunc() [crayon-678d87985119e598948772/] Output 3 Please note that when we remove decimal places, number before decimal point(.) will remain the same. If you want to round it up or down, then you should use round() instead. Two of the most common types to […]

  • 16 November

    Print None as Empty String in Python

    The term None in python is not the same as an empty string or 0. None is a whole data type in itself that is provided by python and it is utilized to define a null value. An object of the None data type can be, however, represented as an empty string in python by […]

  • 06 November

    Get Filename without Extension in PowerShell

    💡 Quick Answer You can get filename without extension in PowerShell using BaseName property with Get-Item cmdlet. [crayon-678d879851342603585857/] Output: [crayon-678d879851344760703950/] While working on a Windows operating system, you may often encounter the requirement of getting filename without extension. For example: FileName : C:\temp\sample.txt FileName without extension: sample In this post, we will see various ways […]

  • 04 November

    Pass 2D Array to Function in C++

    Two-dimensional arrays have rows and columns, storing data inside this matrix. These 2D matrices cannot be passed directly to functions like single-dimension arrays. The program needs to follow some required rules. Ways to Pass a 2D Array to function in C++ This article explains the various method to pass a 2D matrix to a method […]