Binary Search Algorithm Implementation with Python

binary search algorithm in Python

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

Binary Search Algorithm Implementation with Python

Binary Search  is an algorithm that finds the position of a target in a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array. Even though the idea is simple, implementing binary search correctly requires attention to some subtleties about its exit conditions and midpoint calculation, particularly if the values in the array are not all of the whole numbers in the range.

Source: https://en.wikipedia.org/wiki/Binary_search_algorithm

Below the binary search algorithm implementation  with python:




Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6
Get 20% off Google Workspace (Google Meet)  Business Plan (AMERICAS) with  the following codes:  C37HCAQRVR7JTFK Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more codes)

Active Anti-Aging Eye Gel, Reduces Dark Circles, Puffy Eyes, Crow's Feet and Fine Lines & Wrinkles, Packed with Hyaluronic Acid & Age Defying Botanicals


#Test_Binary_Search.py
Array=[-2,1,0,4,7,8,10,13,16,17, 21,30,45,100,150,160,191,200]
Target=201
n=len(Array)
def binarySearch(A,T):
L=0
R=n-1
while (L <= R):
m=int((L + R)/2)
if ( A[m] < T ):
L = m +1
elif (A[m] > T):
R = m-1
else:
print("Target is at %s:" % m)
return m
print("Target not found")
return "unsuccessful"


binarySearch(Array, Target)


AI Unraveled: Demystifying Frequently Asked Questions on Artificial Intelligence (OpenAI, ChatGPT, Google Bard, Generative AI, Discriminative AI, xAI, LLMs, GPUs, Machine Learning, NLP, Promp Engineering)
Binary Search Algorithm implementation with python
binary search algorithm in Python
binary search algorithm in Python

In this example, the binary_search function takes a sorted list arr and an element x as input, and returns the index of the element if it is found, or -1 if it is not found. The function uses a binary search algorithm to search for the element in the list, by dividing the list into halves and comparing the element with the middle element of the list. If the element is greater than the middle element, it searches the right half of the list, and if it is less than the middle element, it searches the left half of the list. This process is repeated until the element is found or the list is exhausted.

Budget to start a web app built on the MEAN stack

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

I want to start a web app built on the MEAN stack (mongoDB, express.js, angular, and node.js). How much would it cost me to host this site? What resources are there for hosting websites built on the MEAN stack?

I went through the same questions and concerns and I actually tried a couple of different cloud providers for similar environments and machines.

Web Apps Feed

  1. At Digital Ocean, you can get a fully loaded machine to develop and host at $5 per month (512 MB RAM, 20 GB disk ). You can even get a $10 credit by using this link of mine.[1] It is very easy to sign up and start. Just don’t use their web console to connect to your host. It is slow. I recommend using ssh client to connect and it is very fast.
  2. GoDaddy will charge you around 8$ per month for a similar MEAN stack host (512 MB RAM, 1 core processor, 20 Gb disk ) for your MEAN Stack development.
  3. Azure use bitmani’s mean stack on minimum DS1_V2 machine (1core, 3.5 gB RAM) and your average cost will be $52 per month if you never shut down the machine. The set up is a little bit more complicated that Digital Ocean, but very doable. I also recommend ssh to connect to the server and develop.
  4. AWS also offers Bitmani’s MEAN stack on EC2 instances similar to Azure DS1V2 described above and it is around $55 per month.
  5. Other suggestions

All those solutions will work fine and it all depends on your budget. If you are cheap like me and don’t have a big budget, go with Digital Ocean and start with $10 off with this code.

Basic Gotcha Linux Questions for IT DevOps and SysAdmin Interviews

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

Some IT DevOps, SysAdmin, Developer positions require the knowledge of basic linux Operating System. Most of the time, we know the answer but forget them when we don’t practice very often. This refresher will help you prepare for the linux portion of your IT interview by answering some gotcha Linux Questions for IT DevOps and SysAdmin Interviews.

Get a $10 credit to have your own linux server for your MEAN STACK development and more. It is only $5 per month for a fully loaded Ubuntu machine.

Latest Linux Feeds

I- Networking:

  1. How many bytes are there in a MAC address?
    48.
    MAC, Media Access Control, address is a globally unique identifier assigned to network devices, and therefore it is often referred to as hardware or physical address. MAC addresses are 6-byte (48-bits) in length, and are written in MM:MM:MM:SS:SS:SS format.
  2. What are the different parts of a TCP packet?
    The term TCP packet appears in both informal and formal usage, whereas in more precise terminology segment refers to the TCP protocol data unit (PDU), datagram to the IP PDU, and frame to the data link layer PDU: … A TCP segment consists of a segment header and a data section.
  3. Networking: Which command is used to initialize an interface, assign IP address, etc.
    ifconfig (interface configuration). The equivalent command for Dos is ipconfig.
    Other useful networking commands are: Ping, traceroute, netstat, dig, nslookup, route, lsof
  4. What’s the difference between TCP and UDP; Between DNS TCP and UDP?
    There are two types of Internet Protocol (IP) traffic. They are TCP or Transmission Control Protocol and UDP or User Datagram Protocol. TCP is connection oriented – once a connection is established, data can be sent bidirectional. UDP is a simpler, connectionless Internet protocol.
    The reality is that DNS queries can also use TCP port 53 if UDP port 53 is not accepted.
    DNS uses TCP for Zone Transfer over port :53.
    DNS uses UDP for DNS Queries over port :53.

  5. What are defaults ports used by http, telnet, ftp, smtp, dns, , snmp, squid?
    All those services are part of the Application level of the TCP/IP protocol.
    http => 80
    telnet => 23
    ftp => 20 (data transfer), 21 (Connection established)
    smtp => 25
    dns => 53
    snmp => 161
    dhcp => 67 (server), 68 (Client)
    ssh => 22
    squid => 3128
  6. How many host available in a subnet (Class B and C Networks)
  7. How DNS works?
    When you enter a URL into your Web browser, your DNS server uses its resources to resolve the name into the IP address for the appropriate Web server.
  8. What is the difference between class A, class B and class C IP addresses?
    Class A Network (/ 8 Prefixes)
    This network is 8-bit network prefix. IP address range from 0.0.0.0 to 127.255.255.255
    Class B Networks (/16 Prefixes)
    This network is 16-bit network prefix. IP address range from 128.0.0.0 to 191.255.255.255Class C Networks (/24 Prefixes)
    This network is 24-bit network prefix.IP address range from 192.0.0.0 to 223.255.255.255
  9. Difference between ospf and bgp?
    The first reason is that BGP is more scalable than OSPF. , and this, normal igp like ospf cannot perform. Generally speaking OSPF and BGP are routing protocols for two different things. OSPF is an IGP (Interior Gateway Protocol) and is used internally within a companies network to provide routing.

II- Operating System
1&1 Web Hosting

Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6
Get 20% off Google Workspace (Google Meet)  Business Plan (AMERICAS) with  the following codes:  C37HCAQRVR7JTFK Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more codes)

Active Anti-Aging Eye Gel, Reduces Dark Circles, Puffy Eyes, Crow's Feet and Fine Lines & Wrinkles, Packed with Hyaluronic Acid & Age Defying Botanicals

  1. How to find the Operating System version?
    $uname -a
    To check the distribution for redhat for example: $cat /etc/redhat –release
  2. How to list all the process running?
    top
    To list java processes, ps -ef | grep java
    To list processes on a specific port:
    netstat -aon | findstr :port_number
    lsof -i:80
  3. How to check disk space?
    df shows the amount of disk space used and available.
    du displays the amount of disk used by the specified files and for each subdirectories.
    To drill down and find out which file is filling up a drive: du -ks /drive_name/* | sort -nr | head
  4. How to check memory usage?
    free or cat /proc/meminfo
  5. What is the load average?
    It is the average sum of the number of process waiting in the queue and the number of process currently executing over the period of 1, 5 and 15 minutes. Use top to find the load average.
  6. What is a load balancer?
    A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications.
  7. What is the Linux Kernel?
    The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also used to provide an interface for user-level interaction.
  8. What is the default kill signal?
    There are many different signals that can be sent (see signal for a full list), although the signals in which users are generally most interested are SIGTERM (“terminate”) and SIGKILL (“kill”). The default signal sent is SIGTERM.
    kill 1234
    kill -s TERM 1234
    kill -TERM 1234
    kill -15 1234
  9. Describe Linux boot process
    BIOS => MBR => GRUB => KERNEL => INIT => RUN LEVEL
    As power comes up, the BIOS (Basic Input/Output System) is given control and executes MBR (Master Boot Record). The MBR executes GRUB (Grand Unified Boot Loader). GRUB executes Kernel. Kernel executes /sbin/init. Init executes run level programs. Run level programs are executed from /etc/rc.d/rc*.d
    Mac OS X Boot Process:

    Boot ROMFirmware. Part of Hardware system
    BootROM firmware is activated
    POSTPower-On Self Test
    initializes some hardware interfaces and verifies that sufficient memory is available and in a good state.
    EFI Extensible Firmware Interface
    EFI does basic hardware initialization and selects which operating system to use.
    BOOTX boot.efi boot loader
    load the kernel environment
    Rooting/Kernel The init routine of the kernel is executed
    boot loader starts the kernel’s initialization procedure
    Various Mach/BSD data structures are initialized by the kernel.
    The I/O Kit is initialized.
    The kernel starts /sbin/mach_init
    Run Level mach_init starts /sbin/init
    init determines the runlevel, and runs /etc/rc.boot, which sets up the machine enough to run single-user.
    rc.boot figures out the type of boot (Multi-User, Safe, CD-ROM, Network etc.)
  10. List services enabled at a particular run level
    chkconfig –list | grep 5:0n
    Enable|Disable a service at a specific run level: chkconfig on|off –level 5
  11. How do you stop a bash fork bomb?
    Create a fork bomb by editing limits.conf:
    root hard nproc 512
    Drop a fork bomb as below:
    :(){ :|:& };:
    Assuming you have access to shell:
    kill -STOP
    killall -STOP -u user1
    killall -KILL -u user1
  12. What is a fork?
    fork is an operation whereby a process creates a copy of itself. It is usually a system call, implemented in the kernel. Fork is the primary (and historically, only) method of process creation on Unix-like operating systems.
  13. What is the D state?
    D state code means that process is in uninterruptible sleep, and that may mean different things but it is usually I/O.

III- File System

  1. What is umask?
    umask is “User File Creation Mask”, which determines the settings of a mask that controls which file permissions are set for files and directories when they are created.
  2. What is the role of the swap space?
    A swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing.
  • What is the role of the swap space?
    A swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing.
  • What is the null device in Linux?
    The null device is typically used for disposing of unwanted output streams of a process, or as a convenient empty file for input streams. This is usually done by redirection. The /dev/null device is a special file, not a directory, so one cannot move a whole file or directory into it with the Unix mv command.You might receive the “Bad file descriptor” error message if /dev/null has been deleted or overwritten. You can infer this cause when file system is reported as read-only at the time of booting through error messages, such as“/dev/null: Read-only filesystem” and “dup2: bad file descriptor”.
    In Unix and related computer operating systems, a file descriptor (FD, less frequently fildes) is an abstract indicator (handle) used to access a file or other input/output resource, such as a pipe or network socket.
  • What is a inode?
    The inode is a data structure in a Unix-style file system that describes a filesystem object such as a file or a directory. Each inode stores the attributes and disk block location(s) of the object’s data.

IV- Databases

  1. What is the difference between a document store and a relational database?
    In a relational database system you must define a schema before adding records to a database. The schema is the structure described in a formal language supported by the database and provides a blueprint for the tables in a database and the relationships between tables of data. Within a table, you need to define constraints in terms of rows and named columns as well as the type of data that can be stored in each column.In contrast, a document-oriented database contains documents, which are records that describe the data in the document, as well as the actual data. Documents can be as complex as you choose; you can use nested data to provide additional sub-categories of information about your object. You can also use one or more document to represent a real-world object.
  2. How to optimise a slow DB?
    • Rewrite the queries
    • Change indexing strategy
    • Change schema
    • Use an external cache
    • Server tuning and beyond
  3. How would you build a 1 Petabyte storage with commodity hardware?
    Using JBODs with large capacity disks with Linux in a distributed storage system stacking nodes until 1PB is reached.
    JBOD (which stands for “just a bunch of disks”) generally refers to a collection of hard disks that have not been configured to act as a redundant array of independent disks (RAID) array.
    JBOD

V- Scripting


AI Unraveled: Demystifying Frequently Asked Questions on Artificial Intelligence (OpenAI, ChatGPT, Google Bard, Generative AI, Discriminative AI, xAI, LLMs, GPUs, Machine Learning, NLP, Promp Engineering)
  1. What is @INC in Perl?
    The @INC Array. @INC is a special Perl variable that is the equivalent to the shell’s PATH variable. Whereas PATH contains a list of directories to search for executables, @INC contains a list of directories from which Perl modules and libraries can be loaded.
  2. Strings comparison – operator – for loop – if statement
  3. Sort access log file by http Response Codes
    Via Shell using linux commands
    cat sample_log.log | cut -d ‘”‘ -f3 | cut -d ‘ ‘ -f2 | sort | uniq -c | sort -rn
  4. Sort access log file by http Response Codes Using awk
    awk ‘{print $9}’ sample_log.log | sort | uniq -c | sort -rn
  5. Find broken links from access log file
    awk ‘($9 ~ /404/)’ sample_log.log | awk ‘{print $7}’ sample_log.log | sort | uniq -c | sort -rn
  6. Most requested page:
    awk -F\” ‘{print $2}’ sample_log.log | awk ‘{print $2}’ | sort | uniq -c | sort -r
  7. Count all occurrences of a word in a file
    grep -o “user” sample_log.log | wc -w

Learn more at http://career.guru99.com/top-50-linux-interview-questions/

Real Time Linux Jobs

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLF-C02 book

Script with hash tables on windows and Linux

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

How to declare and write a script with hash tables on windows and linux

A hash table, also known as a hash map, is a data structure that is used to store key-value pairs. It is an efficient way to store data that can be quickly retrieved using a unique key.

Here is an example of how to declare and write a script with a hash table in Python:

# Declare an empty hash table
hash_table = {}

# Add some key-value pairs to the hash table
hash_table[‘key1’] = ‘value1’
hash_table[‘key2’] = ‘value2’
hash_table[‘key3’] = ‘value3’

# Access a value using its key
print(hash_table[‘key2’]) # Output: “value2”

Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6
Get 20% off Google Workspace (Google Meet)  Business Plan (AMERICAS) with  the following codes:  C37HCAQRVR7JTFK Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more codes)

Active Anti-Aging Eye Gel, Reduces Dark Circles, Puffy Eyes, Crow's Feet and Fine Lines & Wrinkles, Packed with Hyaluronic Acid & Age Defying Botanicals

# Modify a value using its key
hash_table[‘key2’] = ‘new value’
print(hash_table[‘key2’]) # Output: “new value”

# Delete a key-value pair using the `del` statement
del hash_table[‘key1’]

# Check if a key is in the hash table using the `in` operator
print(‘key1’ in hash_table) # Output: False


AI Unraveled: Demystifying Frequently Asked Questions on Artificial Intelligence (OpenAI, ChatGPT, Google Bard, Generative AI, Discriminative AI, xAI, LLMs, GPUs, Machine Learning, NLP, Promp Engineering)

# Output: False

In this example, we declare an empty hash table using the {} syntax. We then add some key-value pairs to the hash table using the [] syntax. We access a value using its key, modify a value using its key, delete a key-value pair using the del statement, and check if a key is in the hash table using the in operator.

I hope this helps! Let me know if you have any questions.

    • Hash tables with powershell on windows

      Declaration:
      $states=@{“Alberta” = “Calgary”; “British Columbia” = “Vancouver”; “Ontario” = “Toronto” ; “Quebec” = “Montreal”}

      Name
      _____
      Value
      _______
      AlbertaCalgary
      British ColumbiaVancouver
      OntarioToronto
      QuebecMontreal

      Add new key-value in hashtable:
      $states.Add(“Manitoba”,”Winnipeg”)

      Remove key-value in hashtable:
      $states.Remove(“Manitoba”,”Winnipeg”)
      Change value in hashtable:
      $states.Set_Item(“Ontario”,”Ottawa”)
      Retrieve value in hashtable:
      $states.Get_Item(“Alberta”)
      Find key in hashtable:
      $states.ContainsKey(“Alberta”)
      Find Value in hashtable:
      $states.ContainsValue(“Calgary”)
      Count items in hashtable:
      $states.Count
      Sort items by Name in hashtable:
      $states.GetEnumerator() | Sort-Object Name -descending
      Sort items by Value in hashtable:
      $states.GetEnumerator() | Sort-Object Value -descending

    • Hash tables with perl on linux or windows

      Declaration:
      my %hash = (); #Initialize a hash
      my $hash_ref = {}; # Initialize a hash reference. ref will return HASH
      Clear (or empty) a hash
      for (keys %hash)
      {
      delete $hash{$_};
      }
      Clear (or empty) a hash reference
      for (keys %$href)
      {
      delete $href->{$_};
      }
      Add a key/value pair to a hash
      $hash{ ‘key’ } = ‘value’; # hash
      $hash{ $key } = $value; # hash, using variables
      Using Hash Reference
      $href->{ ‘key’ } = ‘value’; # hash ref
      $href->{ $key } = $value; # hash ref, using variables
      Add several key/value pairs to a hash
      %hash = ( ‘key1’, ‘value1’, ‘key2’, ‘value2’, ‘key3’, ‘value3’ );
      %hash = (
      key1 => ‘value1’,
      key2 => ‘value2’,
      key3 => ‘value3’,
      );

      Copy a hash
      my %hash_copy = %hash; # copy a hash
      my $href_copy = $href; # copy a hash ref
      Delete a single key/value pair
      delete $hash{$key};
      delete $hash_ref->{$key};

Hash tables with python on linux or windows

Hash tables are called dictionary in python.
Declaration:
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
Accessing Values
print “dict[‘Name’]: “, dict[‘Name’]
print “dict[‘Age’]: “, dict[‘Age’]
Output:
dict[‘Name’]: Zara
dict[‘Age’]: 7
Updating Dictionary
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLF-C02 book

dict[‘Age’] = 8; # update existing entry
dict[‘School’] = “DPS School”; # Add new entry
Delete Dictionary Elements
#!/usr/bin/python

dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}

del dict[‘Name’]; # remove entry with key ‘Name’
dict.clear(); # remove all entries in dict
del dict ; # delete entire dictionary

Source:

  1. https://technet.microsoft.com/en-us/library/ee692803.aspx
  2. http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/
  3. http://www.tutorialspoint.com/python/python_dictionary.htm

Things to do to build more diverse technical teams?

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

What are specific Things to do to build more diverse technical teams?

  • 1. Start at the junior high school level in poor neighborhood by helping schools to teach minority kids how to code.
  • 2. Help set up computer labs in junior high school in poor neighborhoods so that kids who cannot afford the equipment can use the lab.
  • 3. Start coding challenges with prizes in those high school neighborhood and make the kids feel confident about their abilities.
  • 4. Get successful minorities entrepreneurs to host the kids and give them tours of their companies and offices and projects to inspire them.
  • 5. Give internships to minorities kids starting in high school.
  • 6. For the kids in senior high school who missed early adoption to coding, speed them up with after hours coding classes to prepare them for college.
  • 7. In college, make the minority kids feel welcome. Try to make them part of all activities ( computer related or not).
  • 8. For the kids in senior high school who missed early adoption to coding, speed them up with after hours coding classes to prepare them for college.
  • 9. In college, make the minority kids feel welcome. Try to make them part of all activities ( computer related or not). Help find internships from top IT firms (Google, Apple, IBM, etc.) for minorities.
  • 10. When minorities start working after college, welcome them in the team and trust them. Don’t just invite certain kids to dinner and golf. It makes minorities feel unappreciated and unwanted.
  • 11. Give minorities the same opportunity of advancement at work with other employees.
  • 12. Inclusion, inclusion, inclusion in every aspect of the company is the key.
  • Assess the progress of your efforts and adjust. Make sure that team leads or managers are open minded people and make it a priority for them to build diverse teams, because in the long run, it will be a win win for the company

There are several specific things that organizations can do to build more diverse technical teams:

  1. Review and revise hiring practices: Organizations can review and revise their hiring practices to ensure that they are not biased against certain groups. This can include using standardized job applications, using objective criteria for evaluating candidates, and diversifying the pool of candidates by actively recruiting from underrepresented groups.
  2. Offer employee resources and support: Organizations can offer resources and support to employees from underrepresented groups to help them succeed and thrive in their roles. This can include providing access to mentorship, networking opportunities, and professional development resources.
  3. Promote diversity and inclusion: Organizations can make a concerted effort to promote diversity and inclusion within the company culture. This can include training employees on unconscious bias, fostering an inclusive workplace culture, and supporting diversity and inclusion initiatives.
  4. Measure and track diversity: Organizations can measure and track diversity within their technical teams to identify areas where they can improve. This can include collecting and analyzing data on the demographics of their employees, and setting diversity and inclusion goals and targets.

By taking these specific steps, organizations can work towards building more diverse technical teams and creating a more inclusive workplace culture.

Read more here on Quora.

Examining the Fragmented Data on Black Entrepreneurship in North America

Financing Black Businesses in Canada and USA: Challenges and Opportunities

How to stay healthy as a software engineer?

https://en.wikipedia.org/wiki/Retrocomputing

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

How to stay healthy as a software engineer or IT professional?

I am a software engineer like you and by my second year I started feeling the unhealthy behavior of sitting down and coding for long hours.

  1. Exercise regularly: Exercise can help you maintain physical and mental health. Engaging in regular physical activity can help you reduce stress, improve your sleep, and boost your mood.
  2. Eat a healthy diet: A healthy diet can help you maintain your energy levels and focus. Make sure to eat a variety of fruits, vegetables, and whole grains, and limit your intake of processed and sugary foods.
  3. Get enough sleep: Adequate sleep is important for maintaining physical and mental health. Aim for 7-9 hours of sleep per night.
  4. Take breaks: It is important to take breaks from your work to avoid burnout. Step away from your computer, stretch, and take some time to relax.
  5. Stay hydrated: Drink plenty of water to stay hydrated and maintain your energy levels.
  6. Manage stress: Chronic stress can have negative impacts on your physical and mental health. Find healthy ways to manage stress, such as through exercise, meditation, or talking to a therapist.
  7. Practice good posture: Poor posture can lead to muscle strain and fatigue. Make sure to sit up straight, with your feet flat on the ground and your elbows bent at a 90-degree angle.

By following these tips, you can maintain your physical and mental health as a software engineer.

How to stay healthy as a software engineer
How to stay healthy as a software engineer

Below are the steps that I took:

  1. Avoid sitting down for more than 1 hour without getting up for a walk.
  2. Stand up for 15 minutes every hour to code.
  3. Take multiple short walks outdoor during working hours.
  4. Avoid elevators unless you have no choice, use the stairs to go up and down if your office floor is lower than the 5th floor.
  5. Avoid drinking sweet drinks or too much coffee during work hours.
  6. Avoid eating chips or almost anything while working.
  7. Instead of spending long hours reading manuals and documents on your computer, print them out, then take a walk and read them somewhere quiet while standing.
  8. Stretch often while working (extend your legs, arms, rotate your neck).
  9. Take short breaks of 2 to 5 minutes every 2 hours to read something different from your main topic. It can be news, sports, entertainment, or anything else you like. I read or write on Quora during my breaks.
  10. Change your position frequently and don’t hesitate to stand up at your desk from time to time while working.
  11. Make sure that your chair is always comfortable. Don’t hesitate to upgrade or get a better chair if necessary.

Here are the steps that I took to stay active and healthy:

  1. I am committed, no matter what, to playing at least 2 competitive games of soccer or basketball a week, either in an amateur team league or at drop-in sports leagues. Check out one of my drop in league chapter in your city at ShowUpAndPlaySports chapters – Djamga – ShowUpAndPlaySports
  2. I volunteer to organize soccer and basketball games every week via Home – Djamga – ShowUpAndPlaySports
  3. I walk regularly at lunch time, and try to get as much sunshine as possible.
  4. I visit a chiropractor once a month to adjust my back and neck.
  5. I visit a certified massage therapist regularly to work on my neck, back, hamstrings, and feet.
  6. I visit a pedicure clinic once a month for a good pedicure and foot massage.
  7. I eat a healthy diet of mostly vegetables and fish (mostly salmon).
  8. I drastically reduced the carbs in my diet. Every morning, I take one cup of coffee or tea with no sugar or milk and a small cake. Then, I am covered until dinner time. In the evening, I have a large meal of vegetables and fish, usually salmon.
  9. I drink plenty of water.
  10. I don’t drink alcohol or smoke.
  11. It is very important to sleep well; sleep at least 6 hours per day.
    You spend about 25% of your life in your bed, there you need to invest on your mattresses, pillows, bed furnitures and upgrade them regularly.

After adopting these habits, my efficiency came back. I was able to work as hard as when I was a student . I even lost weight!

Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6
Get 20% off Google Workspace (Google Meet)  Business Plan (AMERICAS) with  the following codes:  C37HCAQRVR7JTFK Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more codes)

Active Anti-Aging Eye Gel, Reduces Dark Circles, Puffy Eyes, Crow's Feet and Fine Lines & Wrinkles, Packed with Hyaluronic Acid & Age Defying Botanicals

Now, I can go toe-to-toe with young players and students in their twenties on the soccer field. I easily work more than 60 hours per week and still have enough time to play with my kids and enjoy a fulfilling life with my family.

I highly recommend these life-changing habits to all IT professionals and engineers so they can remain healthy and effective as they get older and busier.

reverse a string on Linux and Windows

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

How to reverse a string on Linux and Windows

On Linux:

  1. Using the rev command: The rev command is a utility that reverses the lines of a file or the characters in a string. To reverse a string, you can use the echo command to pass the string to rev:
echo "string" | rev
  1. Using the sed command: The sed command is a powerful utility that can perform various text transformations. To reverse a string, you can use the sed command with the -r option and the 's/.*(.)/\1/g' expression:
echo "string" | sed -r 's/.*(.)/\1/g'
  1. Using the awk command: The awk command is a programming language that is used for text processing. To reverse a string, you can use the awk command with the {print} action:
echo "string" | awk '{print $1}'

On Windows:

  1. Using the powershell command: The powershell command is a shell that provides a command-line interface for Windows. To reverse a string, you can use the powershell command with the -C option and the '[System.Text.Encoding]::Unicode.GetString([System.Text.Encoding]::Unicode.GetBytes("string"))' expression:
powershell -C "[System.Text.Encoding]::Unicode.GetString([System.Text.Encoding]::Unicode.GetBytes("string"))"
  1. Using the cmd command: The cmd command is the command-line interpreter for Windows. To reverse a string, you can use the cmd command with the for loop:
cmd /c "for /L %i in (1,1,%len%) do @echo !string:~%len%-%i,1!"

These are some ways to reverse a string on Linux and Windows. There are other ways to achieve this, using different utilities or programming languages.

Via shell script on Linux

reverse a string on Linux and Windows

sh-3.2# vi reverse.sh
#### Start Script #####
#!/bin/bash
input_string=”$1″
reverse_string=””

Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6
Get 20% off Google Workspace (Google Meet)  Business Plan (AMERICAS) with  the following codes:  C37HCAQRVR7JTFK Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more codes)

Active Anti-Aging Eye Gel, Reduces Dark Circles, Puffy Eyes, Crow's Feet and Fine Lines & Wrinkles, Packed with Hyaluronic Acid & Age Defying Botanicals

input_string_length=${#input_string}
for (( i=$input_string_length-1; i>=0; i– ))
do
reverse_string=”$reverse_string${input_string:$i:1}”
done

echo “$reverse_string”
##### End Script #####

Let’s run it:


AI Unraveled: Demystifying Frequently Asked Questions on Artificial Intelligence (OpenAI, ChatGPT, Google Bard, Generative AI, Discriminative AI, xAI, LLMs, GPUs, Machine Learning, NLP, Promp Engineering)

sh-3.2# chmod 775 reverse.sh
sh-3.2# ./reverse.sh Etienne
enneitE

Via powershell script on Windows

#Let’s use the script reverse.ps1 below.
######
$string=”Etienne”
$string_array=$string -split “”
[array]::Reverse($string_array)
$string_array -join ”

#####Output#####
PS C:\Users\etienne_noumen\Documents\Etienne\Scripting> .\reverse.ps1

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLF-C02 book

E t i e n n e

enneitE

Via powershell script on Windows in one line

([regex]::Matches($String,’.’,’RightToLeft’) | ForEach {$_.value}) -join ”

Via batch script on Windows

::Note: ReverseStr also calls StrLen
::and string length is not greater than 80 chars
:: but can be changed.

@echo off
SetLocal EnableDelayedExpansion
cls
set Str=Etienne
call :StrLen %Str%
echo Length=%Len%
call :ReverseStr %Str%
echo String=%Str%
echo Reverse Str=%Reverse%
exit /b

::—————-
:: Calc Var Length
::—————-
:: %*=Str to Check
:: Returns %Len%
:: —————
:StrLen %*
set Data=%*
for /L %%a in (0,1,80) do (
set Char=!Data:~%%a,1!
if not “!Char!”==”” (
set /a Len=%%a+1
) else (exit /b)
)
exit /b

::—————
:: Reverse String
::—————
:: %* Str to Reverse
:: Returns %Reverse%
::——————
:ReverseStr %*
set Data=%*
call :StrLen %Data%
for /L %%a in (!Len!,-1,0) do (
set Char=!Data:~%%a,1!
set Reverse=!Reverse!!Char!
)
exit /b

Via perl script on Windows or Linux

Via python script on Windows or Linux

def reverse_string(a_string)
return a_string[::-1]
reverse_string(“etienne”) returns “enneite”
Source:

  1. http://www.computing.net/answers/programming/reverse-a-string-in-dos/26004.html

Windows Boot process

Windows Boot Process

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

What is involved in Windows Boot Process:

The Windows boot process involves several stages, in which the operating system performs various tasks to prepare the system for use.

  1. The BIOS (Basic Input/Output System) runs a power-on self-test (POST) to check the system’s hardware components and to load the bootstrap program.
  2. The bootstrap program, also known as the boot loader, is responsible for loading the operating system kernel and transferring control to it. In Windows, the boot loader is called the bootmgr.
  3. The operating system kernel, which is the core of the operating system, initializes the system and starts the system services.
  4. The system services, such as the device drivers, are loaded and initialized.
  5. The operating system loads the user profile and starts the user interface, such as the desktop or the login screen.
  6. The user can log in and start using the system.

This is a general overview of the Windows boot process. The exact sequence of events may vary depending on the specific version of Windows and the hardware configuration of the system.

Windows_Booting_Procedure

    • Power is turned on.
    • The first process starting when you turn on your computer is BIOS i.e, Basic Input Output System. BIOS has two functions, to conduct POST and read MBR.
      1. POST – POST stands for Power On Self Test. POST checks all the hardware devices connected to a computer like RAM, hard disk etc and make sure that the system can run smoothly with those hardware devices. If the POST is a failure the system halts with a beep sound.
      2. Now BIOS checks the boot priority. We can set the boot priority as CD drive, hard disk or floppy drive
      3. MBR – The next duty of BIOS is to read the MBR. MBR stands for Master Boot Record and its the first sector on a hard disk. MBR
        contains the partition table and boot loader.
    • Functions of Boot loader
      Now BIOS has passed the control to boot loader and boot loader is a small program which loads kernel to computers memory. Actually there are two stages of boot loaders, stage 1 boot loader and stage 2 boot loader. MBR contains the stage 1 boot loader and stage 1 boot loader is a link to the stage 2 boot loader. The stage 2 boot loader resides in the boot partition and it loads the kernel to memory.
    • Boot files and functions
      There are three boot files in a Windows operating system and they are NTLDR, NTDETECT.COM and Boot.ini. The boot files are found in the active partition of hard disk and its normally C drive in a Windows machine.

      1. NTLDR – NTLDR stands for NT Loader and its the second stage bootloader. The path of NTLDR is C:\Windows\i386\NTLDR.
      2. Boot.ini – Boot.ini contains the configuration files of NTLDR. When the operating system is loaded we cannot pass any arguments to kernel, so those arguments are passed through boot.ini. You can edit boot.ini by opening through notepad. The path of Boot.ini is C:\boot.ini.
      3. NTDETECT.COM – This file detect hardware’s and passes information to NTLDR. Using the collected information the NTLDR creates a hardware key and this key is used to detect hardware’s. A new hardware key is generated after each reboot of the operating system and that’s why system asks to reboot after installation of a new hardware. The hardware keys created by NTLDR can be found in Windows registry at
        HKEY_LOCAL_MACHINE -> HARDWARES.
    • Kernel and its functions
      After executing the functions of boot files the control is passed to Kernel. ntoskrnal.exe is the kernel file in a Windows machine and its path is C:\Windows\system 32\ntoskrnal.exe. Kernel acts as a layer between software and hardware. The library file hal.dll (C;\Windows\system32\hal.dll) helps Kernel to interact with hardware’s. HAL stands for Hardware Abstraction Layer and this hal.dll file is
      machine specific. Now the drivers for hardware’s are loaded from the file C:\Windows\system32\config\system and the Kernel is loaded to primary memory.
  • Services and log in procedure
    When kernel is loaded in the primary memory services for each process is started and the registry entry for those services can be found at HKEY_LOCAL_MACHINE – System – Current control set – Services.
    Winlogon.exe (C:\Windows\system32\winlogon.exe) is the last service started during this process.
    Winlogon.exe starts the log in procedures of windows machine. It first calls the library file msgina.dll (C:\Windows\system32\msgina.dll). MSGINA stands for Microsoft Graphics Identification and Authentication and it provides the log in window. Now msginal.dll passes the control to LSA (Local Security Authority), it verifies the username and password from the SAM file. SAM (Security Accounts Manager) contains the information about all users created in a Windows operating system.
    Now the booting procedure is over and we have reached the desktop of Windows operating system.

Source:

  1. Windows Booting Process
  2. Understanding the boot process

Monitor Macbook

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

How to Monitor Macbook with one single command?

$sudo sysdiagnose -f ~/Desktop/




The result is a compressed file named sysdiagnose_YYYY.MM.DD_HH-MM-SS-TTTT.tar.gz and it contains the following:
Accessibility
BluetoothTraceFile.pklg
DiagnosticMessages
Etienne’s SystemConfiguration
airport_info.txt
apsd-status.txt
bc_stats.txt
bootstamps.txt
brctl.tar.gz
breadcrumbs.txt
crashes_and_spins
darwinup.txt
dig-results.txt
disks.txt
diskutil.txt
error_log.txt
filecoordination_dump.txt
footprint-all.txt
fs_usage.txt
fsck_hfs_user.log
fsck_hfs_var.log
gpt.txt
ifconfig.txt
ioreg
ipconfig.txt
kextstat.txt
launchctl-list.txt
locale.txt
logs
lsappinfo.txt
lsmp.txt
lsof.txt
lsregister.txt
microstackshots
microstackshots_lastday.txt
microstackshots_lasthour.txt
microstackshots_lastminute.txt
mount.txt
netstat
nfsstat.txt
odutil.txt
pluginkit.txt
pmset_everything.txt
powermetrics.txt
ps.txt
ps_thread.txt
reachability-info.txt
resolv.conf
scutil.txt
smcDiagnose.txt
spindump.txt
stackshot-last-sym.log
sysctl.txt
sysdiagnose.log
system_profiler.spx
talagent.txt
taskinfo.txt
thermal.txt
top.txt
var_run_resolv.conf
vm_stat.txt
zprint.txt

You can use the top command to monitor the resources of your Macbook in real-time. The top command is a built-in utility that shows the processes that are currently running on the system, along with information about their CPU and memory usage.

To use the top command, open a terminal window and type top. The output will show the list of processes, sorted by their CPU usage, with the most CPU-intensive processes at the top. You can use the q key to exit the top command.

Here are some of the key options you can use with the top command:

Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6
Get 20% off Google Workspace (Google Meet)  Business Plan (AMERICAS) with  the following codes:  C37HCAQRVR7JTFK Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more codes)

Active Anti-Aging Eye Gel, Reduces Dark Circles, Puffy Eyes, Crow's Feet and Fine Lines & Wrinkles, Packed with Hyaluronic Acid & Age Defying Botanicals

  • -o: sort the processes by a particular resource, such as CPU usage or memory usage. For example, top -o cpu will sort the processes by CPU usage.
  • -s: specify the delay between updates. For example, top -s 2 will update the display every 2 seconds.
  • -u: show the process for a particular user. For example, top -u username will show the processes for the user with the specified username.

You can use these options in combination to customize the output of the top command. For example, to monitor the CPU usage of the processes owned by a particular user, you can use the following command:

top -o cpu -s 2 -u username

Pass the 2023 AWS Cloud Practitioner CCP CLF-C02 Certification with flying colors Ace the 2023 AWS Solutions Architect Associate SAA-C03 Exam with Confidence Pass the 2023 AWS Certified Machine Learning Specialty MLS-C01 Exam with Flying Colors

List of Freely available programming books - What is the single most influential book every Programmers should read



#BlackOwned #BlackEntrepreneurs #BlackBuniness #AWSCertified #AWSCloudPractitioner #AWSCertification #AWSCLFC02 #CloudComputing #AWSStudyGuide #AWSTraining #AWSCareer #AWSExamPrep #AWSCommunity #AWSEducation #AWSBasics #AWSCertified #AWSMachineLearning #AWSCertification #AWSSpecialty #MachineLearning #AWSStudyGuide #CloudComputing #DataScience #AWSCertified #AWSSolutionsArchitect #AWSArchitectAssociate #AWSCertification #AWSStudyGuide #CloudComputing #AWSArchitecture #AWSTraining #AWSCareer #AWSExamPrep #AWSCommunity #AWSEducation #AzureFundamentals #AZ900 #MicrosoftAzure #ITCertification #CertificationPrep #StudyMaterials #TechLearning #MicrosoftCertified #AzureCertification #TechBooks

Top 1000 Canada Quiz and trivia: CANADA CITIZENSHIP TEST- HISTORY - GEOGRAPHY - GOVERNMENT- CULTURE - PEOPLE - LANGUAGES - TRAVEL - WILDLIFE - HOCKEY - TOURISM - SCENERIES - ARTS - DATA VISUALIZATION
zCanadian Quiz and Trivia, Canadian History, Citizenship Test, Geography, Wildlife, Secenries, Banff, Tourism

Top 1000 Africa Quiz and trivia: HISTORY - GEOGRAPHY - WILDLIFE - CULTURE - PEOPLE - LANGUAGES - TRAVEL - TOURISM - SCENERIES - ARTS - DATA VISUALIZATION
Africa Quiz, Africa Trivia, Quiz, African History, Geography, Wildlife, Culture

Exploring the Pros and Cons of Visiting All Provinces and Territories in Canada.
Exploring the Pros and Cons of Visiting All Provinces and Territories in Canada

Exploring the Advantages and Disadvantages of Visiting All 50 States in the USA
Exploring the Advantages and Disadvantages of Visiting All 50 States in the USA


Health Health, a science-based community to discuss health news and the coronavirus (COVID-19) pandemic

Today I Learned (TIL) You learn something new every day; what did you learn today? Submit interesting and specific facts about something that you just found out here.

Reddit Science This community is a place to share and discuss new scientific research. Read about the latest advances in astronomy, biology, medicine, physics, social science, and more. Find and submit new publications and popular science coverage of current research.

Reddit Sports Sports News and Highlights from the NFL, NBA, NHL, MLB, MLS, and leagues around the world.

Turn your dream into reality with Google Workspace: It’s free for the first 14 days.
Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes:
Get 20% off Google Google Workspace (Google Meet) Standard Plan with  the following codes: 96DRHDRA9J7GTN6 96DRHDRA9J7GTN6
63F733CLLY7R7MM
63F7D7CPD9XXUVT
63FLKQHWV3AEEE6
63JGLWWK36CP7WM
63KKR9EULQRR7VE
63KNY4N7VHCUA9R
63LDXXFYU6VXDG9
63MGNRCKXURAYWC
63NGNDVVXJP4N99
63P4G3ELRPADKQU
With Google Workspace, Get custom email @yourcompany, Work from anywhere; Easily scale up or down
Google gives you the tools you need to run your business like a pro. Set up custom email, share files securely online, video chat from any device, and more.
Google Workspace provides a platform, a common ground, for all our internal teams and operations to collaboratively support our primary business goal, which is to deliver quality information to our readers quickly.
Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE
C37HCAQRVR7JTFK
C3AE76E7WATCTL9
C3C3RGUF9VW6LXE
C3D9LD4L736CALC
C3EQXV674DQ6PXP
C3G9M3JEHXM3XC7
C3GGR3H4TRHUD7L
C3LVUVC3LHKUEQK
C3PVGM4CHHPMWLE
C3QHQ763LWGTW4C
Even if you’re small, you want people to see you as a professional business. If you’re still growing, you need the building blocks to get you where you want to be. I’ve learned so much about business through Google Workspace—I can’t imagine working without it.
(Email us for more codes)

error: Content is protected !!