Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create a dummy file of any size with PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 18-Mar-2021 5K+ Views

To create any dummy file of having any size with PowerShell, we can use the below command.Example$f = new-object System.IO.FileStream c:\temp\test.dat, Create, ReadWrite $f.SetLength(50MB) $f.Close()The above command will create 50MB of Test.dat dummy file in the C:\temp. Such files are used for testing purposes.

Read More

How to get the default Documents from the IIS site using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 18-Mar-2021 611 Views

To get the default documents stored on the IIS default website page, you can use the below command.ExampleGet-WebConfigurationProperty -Filter //defaultDocument/files/add    -PSPath 'IIS:\Sites\Default Web Site' -Name value `    | select valueOutputValue ----- Default.htm Default.asp index.htm index.html iisstart.htmTo check if the Default document contains a specific file, (Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\Sites\Default Web Site' -Name value).value -contains 'iisstart.htm'The above command checks if the IIS default website contains any iisstart.htm on the default document page.You can also use another website instead of using 'Default Web site'. To get the default documents file at the IIS level, (Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:' ...

Read More

How to copy only updated or newer files with PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 18-Mar-2021 10K+ Views

To copy only updated or newer files with PowerShell, we can use Copy-Item with some logic in the script that to check if the files exist on the destination folder if not then copy that file and if yes then compare the timestamp and copy the latest file. This would be tricky because we need to write several lines of code for it.But Windows support xCopy utility which can directly copy the newer or updated files and this utility we can accommodate in PowerShell as well.xCopy uses a switch called /d. its actual syntax is, Syntax/d [:MM-DD-YYYY]This means if the date ...

Read More

Golang Program to find the position of the rightmost set bit

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 376 Views

ExamplesConsider n = 20(00010100)Now return log2(20 & -20) => 2+1 => 3Approach to solve this problemStep 1 − Define a method, where n and is an argument, return type is int.Step 2 − Return log2(n & -n)+1.Examplepackage main import (    "fmt"    "math"    "strconv" ) func FindRightMostSetBit(n int) int {    if (n & 1) != 0{       return 1    }    return int(math.Log2(float64(n & -n))) + 1 } func main(){    var n = 20    fmt.Printf("Binary of %d is: %s.", n, strconv.FormatInt(int64(n), 2))    fmt.Printf("Position of the rightmost set bit of the given number %d is %d.", n, FindRightMostSetBit(n)) }OutputBinary of 20 is: 10100. Position of the rightmost set bit of the given number 20 is 3.

Read More

Golang Program to toggle the Kth of the given number n.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 199 Views

ExamplesConsider n = 20(00010100), k = 3.After toggling the kth bit of the given number: 00010000 => 16.Approach to solve this problemStep 1 − Define a method, where n and k would be the arguments, returns type is int.Step 2 − Perform AND operation with n ^ (1

Read More

Golang program to check if k'th bit is set for a given number or not.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 2K+ Views

ExamplesConsider n = 20(00010100), k = 3So, the result after turning off the 3rd bit => 00010000 & (1

Read More

Golang Program to turn on the k'th bit in a number.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 238 Views

Example For example consider n = 20(00010100), k = 4. So result after turning on 4th bit => 00010000 | (1

Read More

Golang program to turn off the k'th bit in a number.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 227 Views

ExampleConsider n = 20(00010100), k = 3 The result after turning off the 3rd bit => 00010000 & ^(1 16sApproach to solve this problemStep 1 − Define a method, where n and k would be the arguments, return type is int.Step 2 − Perform AND operation with n & ^(1

Read More

Text box with line wrapping in Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 2K+ Views

Matplotlib can wrap text automatically, but if it's too long, the text will be displayed slightly outside of the boundaries of the axis anyways.StepsCreate a new figure, or activate an existing figure, using figure().Set the axis properties using plt.axis() method.Make a variable input_text to store the string.Add text to figure, using plt.text() method where style='oblique', ha='center', va='top', ...etc.To show the figure use plt.show() method.Exampleimport matplotlib.pyplot as plt fig = plt.figure() plt.axis([0, 10, 0, 10]) input_text = 'Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy.' plt.text(5, 5, input_text, fontsize=10, style='oblique', ha='center', va='top', ...

Read More

Plot mean and standard deviation in Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 17-Mar-2021 10K+ Views

First, we can calculate the mean and standard deviation of the input data using Pandas dataframe.Then, we could plot the data using Matplotlib.StepsCreate a list and store it in data.Using Pandas, create a data frame with data (step 1), mean, std.Plot using a dataframe.To show the figure, use plt.show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt data = [-5, 1, 8, 7, 2] df = pd.DataFrame({       'data': data,       'mean': [2.6 for i in range(len(data))],       'std': [4.673328578 for i in range(len(data))]}) df.plot() plt.show()Output

Read More
Showing 50131–50140 of 61,297 articles
Advertisements