Skip to main content

Posts

Python create multiple choices for if statement

How to compare multiple choices in Python if statement? In an if else statement, if case sensitivity is a concern on the response or input from the user. Then the expected response should be defined on the if statement. Of course, there’s a good workaround on this kind of scenario like converting all input to lowercase or uppercase then start comparing or matching. Basically, the code below is for illustration purposes only. Converting the input to lowercase or uppercase is a good option, if the program is expecting a string input. However, code illustrated below will not be useful if the input is a number. In which case, converting the input to lowercase or uppercase will not help. Anyway, code below uses the string T, True or true as possible input that will display this message” You must have seen the sun! Or hoping to see the sun at the end of the tunnel!” if it matches “T, True or true”. If the input is TRUE, or other letter other than the characters mentioned above it...

Python if else pass or continue after evaluating input

Beginning in Python programming? If else statement is quite a basic statement in any programming language. If else is used in evaluating conditions or basically, it will tell the program what to do next if a specified match or input is encountered. In if else statement, depends on the conditional statement that is set then the next logic will determine on what action or execution will be performed. For example, after a match pattern occurs then the next statement will execute an action but sometimes after a match occurs you don't want to do anything instead the else statement will show what action or logic to be executed. In Python "continue" statement does not mean that it will continue to execute the code after the "continue" statement, instead it will break that execution and goes to the top of the code and continue the next course of action. However, "pass" statement in Python will mean literal "pass". So, if "pass" is...

Turn off Microphone settings in Windows 10

 How to turn off or disable Mic or Microphone settings in Windows 10? Steps below shows how to turn off Microphone settings in Windows 10. One method is to type: 'settings' on the search bar See image below: Another method, to bring up the settings option is to press "Windows Key + i key" together. See image below: Either method is used to bring up the settings, once the settings window is open. Type: micro or complete the word microphone Basically, the window settings has some sort of regex that matches the string that is being typed. See image below: The image above shows how to turn off the Microphone, if the login user has admin rights then the "change" option will be enabled. To turn it back on, just slide the switch on the microphone settings and it will be turned on. To test whether the microphone is working or not, Windows 10 provided a recorder called "voice recorder" app. On the search area just type: record and the voice recorder will be...

PowerShell read text file at a specific or certain lines

Reading log files or text file is quite basic and log files should be reviewed or else recording the logs if of no point. PowerShell code below read the 2 nd line of a specific text file specified on the path.   $logs = get-content c:\dev\log1.txt   "Line number 2 in log1.txt is: {0}" -f ( $logs [ 2 ] )     PowerShell code below uses a loop to read number of lines on a specific text file. $logs = get-content c:\dev\log1.txt   ForEach ( $line_number in 0 .. 10 ) {   "Line number $line_number is : {0}" -f ( $logs [ $line_number ] )}     Using above code, 0 is equal to line 1.   So, to read the first line code should be like this:     $logs = get-content c:\dev\log1.txt   "Line number 1 in log1.txt is: {0}" -f ( $logs [ 0 ] )     To read the last line: $logs = get-content c:\dev\xtest.txt -Tail 1 $logs     If above command will return an emp...

Use PowerShell in Excel VBA

VBA in Excel is very helpful since it can run things without any human intervention, or technically it can run task and automate things and just get the result. VBA coupled with PowerShell can even be more interesting. Of course, there is always some drawback or pros and cons. Bad actor can take advantage of VBA and PowerShell to run malicious software on user’s computer. For most users who are not aware or doesn’t believe that VBA and PowerShell can be used to steal data, one common reaction is; Is it possible? Or you are just trying to exaggerate and scare people? As the odds say, to see is to believe. Or to see it in action is one thing and trying to educate users is another thing. Cyber Security is a task that everyone should be a part of, a chain is useless if one its link is weak. Which is basically, true in digital world. The company may spend thousands of moneys on Firewall, Anti-Virus and other devices or software to thwart attack but just a simple click on a Phishin...

Check Windows Task Scheduler Status and Last Run Time

Task Scheduler is an awesome tool that every Sys Admin should be familiar with it. Task Scheduler in a way can help automate task, if the task is repetitive or a task that has to be done at a certain date and time, or a task has to be done once a week, once a month or even once a year. Task Scheduler is the best tool for this scenario. In this busy world of digital technology, who can keep remembering that a task must be done on a specific date and time. Yes, it might works once but as time goes on and task or jobs of a Sys Admin keep filing up chances are the task might be forgotten and the person-in-charge might just remember the things that needs to be done if there is an issue that happens already. So, Task Scheduler is a tool in which you test once, set if tested okay and forget about it. Test to make sure that the task to be set, works properly and just forgot about it; it will do the task repetitively albeit depends on the settings that was set. Of course, Task Scheduler...