Pygame is a multimedia library for Python for making games and multimedia applications. In this article we will see how to use the pygame module to get customized font and text on the screen taking into consideration, its height, width, and position in the pygame window.In the below program we initialize the pygame module and then define the mode and the caption for the image. Next we add the font text and define the coordinates for the font. The screen.blit function paints the screen while the while loop keeps listening the end of the game is clicked.Exampleimport pygame import sys ... Read More
Pygame is a multimedia library for Python for making games and multimedia applications. In this article we will see how to use the pygame module to paint a picture on the screen taking into consideration, its height, width and position in the pygame window.In the below program we initialize the pygame module and then define the mode and the caption for the image. Next we load the image and define the coordinates. The screen.blit function paints the screen while the while loop keeps listening the end of the game is clicked.Exampleimport pygame pygame.init() w = 300; h = 300 screen ... Read More
Pandas is one of the most popular python library for data analysis and data wrangling. In this article we will see how we can create a pandas dataframe and then delete some selective rows ort columns from this data frame.Deleting roewsIn the below example we have the iris.csv file which is read into a data frame. We first have a look at the existing data frame and then apply the drop function to the index column by supplying the value we want to drop. As we can see at the bottom of the result set the number of rows has ... Read More
Transport Layer Security known as TLS is a very important part while using URI commands such as Invoke−WebRequest or Invoke−Restmethod commands and package commands such as Find−Package or Install−Package because they interact on the internet and PowerShell needs TLS1.2 version for that.We may get the below errors when we use the lower TLS version.WARNING: Unable to download the list of available providers. Check your internet connection. WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. Find-Package : No match was found for the specified search criteria and package nameTo resolve the above error, we need to change the TLS version. To check ... Read More
Tree command graphically shows the folder structure of the given drive or a path. It is similar to Get−ChildItem or dir recursive command except this shows the graphical structure. For example, the below command will retrieve the folder structure of C:\VMs includingtree c:\VMsOutputThere are also two other switches supported for this command. They will appear in the help section of this command.c:\>tree /? Graphically displays the folder structure of a drive or path. TREE [drive:][path] [/F] [/A] /F Display the names of the files in each folder. /A Use ASCII instead of extended characters.This command is a cmd utility ... Read More
PowerShell 7 supports the -AsHashtable parameter in the ConvertFrom−JSON command to convert the JSON to hashtable directly and that is a great feature. Consider we have the below JSON file, We can use the pipeline command ConvertFrom−JSON to convert the JSON file to the custom table format and with the −AsHashtable parameter to convert the custom object to the hashtable.PS C:\Temp> Get-Content .\testsevent.json | ConvertFrom-Json -AsHashtable Name Value ---- ----- Events {602d9444−d2cd−49c7−8624−8643e7171297} DocumentIncarnation 0To retrieve the data, PS C:\Temp> $out = Get−Content .\testsevent.json | ConvertFrom−Json −AsHashtable PS C:\Temp> $out.EventsOutputPS C:\Temp> $out.Events Name Value ---- ----- Description Host server is undergoing ... Read More
To mount the ISO file in Windows using PowerShell, we can use the Mount−DiskImage command. The below command will mount the image file stored at the C:\ISO location.Mount−DiskImage −ImagePath "C:\ISOs\Windows_Server_2016_Datacenter_EVAL_en−us_14393_refresh (1).ISO"OutputAttached : True BlockSize : 0 DevicePath : \.\CDROM0 FileSize : 6972221440 ImagePath : C:\ISOs\Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh (1).ISO LogicalSectorSize : 2048 Number : 0 Size : 6972221440 StorageType : 1 PSComputerName :You can also check from Windows Explorer that the disk is mounted.To mount on the remote computer, we can use CIMSession as a remote session and mount the disk.$sess = New−CimSession −ComputerName Labmachine2k12 Mount−DiskImage −CimSession $sess −ImagePath F:\Windows_Server_2016_Datacenter.isoIn the above example, ... Read More
To dismount the ISO file on the Windows Server using PowerShell, we need to use the Dismount−DiskImage command. When you use this command, you need to use the same path used for mounting the disk image.In this example, we have a disk mounted on E: on the local server, that we can check using the windows explorer or cmdlets.We have the source ISO image stored at F: drive, so we can dismount the image using the below command.ISO Disk will be mounted from the E:To dismount the disk on the remote server, we can use the CIMSession command.$sess = New−CimSession ... Read More
Bokeh is an python data visualization library for web browsers. It czncreate elegant, concise construction of versatile graphics. It is used to quickly and easily make interactive plots, dashboards, and data applications. In this article we will see how we can create various types of basic graphs using Bokeh.Plotting LinesWe can create a line plot by using the x and y coordinates of the points in it as two lists. We directly display the output in the browser by specifying the height and width of the figure. We can also supply additional parameters like width of the line and colour ... Read More
To format the disk using PowerShell, we can use the Format−Volume command. For example, we have to format the E: on the local server then we can use the simple format command as shown below.Format−Volume −DriveLetter E −Force −VerboseTo format the disk with the specific filesystem use the below command.Format−Volume −DriveLetter E −FileSystem NTFS −Full −Force −VerboseThe above command with Format the E drive with the NTFS file system (there are other file systems like FAT, FAT32, exFAT) forcefully.You can even change the label for the drive while formatting using −NewFileSystemLabel command.Format−Volume −DriveLetter E −FileSystem NTFS −NewFileSystemLabel "Temporary Stroage" −Full ... Read More