Tag Archives: learning

Decimal numbers to other integer base

A decimal number can be easily converted to any other integer using the method of repeated division.

Repeated Division

  • Divide the decimal number by the desired base. Write down the integer quotient and keep the remainder.
  • Convert the remainder to its equivalent in the new base (0-9 for bases 2-10, then A-F, etc. for higher bases).
  • Repeat steps 1 and 2 with the quotient, treating it as a new decimal number. Stop when the quotient becomes 0.
  • Read the remainders in reverse order. This will be your number in the new base.

Example1: Convert 255 to base 8 (octal).

  • 255 ÷ 8 = 31, remainder 7
  • 31 ÷ 8 = 3, remainder 7
  • 3 ÷ 8 = 0, remainder 3

Therefore, 255 in octal is 377.

Example2: Convert 255 to hexadecimal.

  • 255 ÷ 16 = 15, remainder 15 (F)
  • 15 ÷ 16 = 0, remainder 15 (F)

Therefore, 255 in hexadecimal is FF.

Numpy Broadcasting

Broadcasting is a powerful feature in NumPy that allows you to perform arithmetic operations on arrays of different shapes. It essentially stretches the smaller array to match the dimensions of the larger array, enabling element-wise operations. This avoids the need for explicit looping and makes the code concise and efficient.

Let’s study it using some examples:

Example 1: Adding a scalar to a 2D array

Python

import numpy as np

scalar = 5
array = np.array([[1, 2, 3], [4, 5, 6]])

# Broadcasting adds the scalar to each element of the array
result = scalar + array
print(result)
Output:
[[6 7 8]
 [9 10 11]

In this example, the scalar 5 is added to each element of the 2D array array. Broadcasting automatically stretches the scalar to match the shape of the array, resulting in the output array.

Example 2: Multiplying a 1D array with a 2D array

vector = np.array([1, 2, 3])
array = np.array([[1, 2, 3], [4, 5, 6]])

# Broadcasting multiplies the vector element-wise with each row of the array
result = vector * array
print(result)
Output:
[[1 2 3]
 [4 10 18]]

In this example, the 1D array vector is element-wise multiplied with each row of the 2D array array. Broadcasting automatically stretches the 1D array to match the number of columns in the 2D array, resulting in the output array.

Example 3: Adding two arrays of different shapes

array1 = np.array([[1, 2, 3]])  # 1D array
array2 = np.array([[4], [5], [6]])  # 2D array

# Broadcasting stretches the 1D array to match the 2D array shape
result = array1 + array2
print(result)
Output:

[[5 6 7]
 [5 6 7]
 [5 6 7]]

In this example, the 1D array array1 is added to the 2D array array2. Broadcasting stretches the 1D array to match the shape of the 2D array, resulting in the output array.

My favorite books of 2021

I want to end the year by sharing my favorite and recommended books of 2021:

  1. Liftoff: Elon Musk and the Desperate Early Days That Launched SpaceX by Eric Berger
  2. The Cult of We by Eliot Brown
  3. Play Nice But Win by Michael S. Dell and James Kaplan
  4. The Code Breaker – Jennifer Doudna, Gene Editing, and the Future of the Human Race by Walter Isaacson
  5. The Minimalist Entrepreneur by Sahil Lavingia

As always, you can find my entire reading list here whereas a subset of my all time favorite and recommended books can be found here.

Learning online for free

There has never been a better time in history to learn things online. Through this post I will show you how you can access almost any great learning resource without spending a dime. This includes reading books, magazines, newspapers, comics, learning a new language, listening to audiobooks and watching video courses completely free of cost.

So it turns out that most public libraries in the United States allow their users to borrow digital content absolutely free of cost. Disclaimer: The resources mentioned in this blog have been explored using a public library located in Silicon Valley aka Bay Area (California) so apologies in advance if the exact same options are not available in your public library.

Kids

Best to time to learn is when you are a child so let us start with kids. Believe it or not but you can access ABCmouse completely free of cost via your public library account and help your child learn everything he or she needs using newer and more intuitive techniques.

Books

Almost all available eBooks can be borrowed from the library using apps like Overdrive, SimplyE, HyRead (for Chinese eBooks) and Odilo (for Spanish eBooks). Depending upon your platform (Kindle, Mac, Windows, iOS or Android), one of the above options should allow you to access the book you want to read. Apart from these options my favorite one is O’reilly for public libraries where you can access all the great O’reilly books and their other video content.

Audiobooks

Using your public library account, you can access almost any available audiobooks through apps like Overdrive, SimplyE or Libby. I use the OverDrive app to listen to audiobooks and it allows me to check out 10 digital items and place a hold on 12 items for a maximum period of 21 days. After 21 days, you can place a new hold on your previous book in case you weren’t able to finish it. In my experience the deadline of 21 days acts like a motivation and forces you to finish a book before your checkout expires.

Magazines

Just like eBooks, you can access many magazines online and free of cost from the library via Overdrive, Libby, HyRead and Flipster app on many different platforms.

Video courses

You can access LinkedIn Learning and Universal Class via your public library account to access the massive collection of their video courses. You can also access a good amount of video tutorials using O’reilly for public libraries.

Learning a new language

You can learn a foreign language and become multilingual by using Rosetta Stone via your public library account.

Newspapers

You can also access and read several newspapers like Mercury News (Bay Area) and New York Times free of cost.

Comics

You can access several comics using ComicsPlus via your public library account.

Free movies

You can even watch some movies including movies for kids on Kanopy.

YouTube and Google

Last but not the least, the world’s biggest library is YouTube and there is video for almost everything. Also, using Google you can search and find a solution for almost anything.

Final thoughts

To conclude there is no shortage of resources in the present age but what is scarce is your attention and motivation to learn. If technology enables you to access things easily, it also makes it easy for you to get distracted by it. So stay focused and have self discipline while using technology to learn and grow.

Teaching programming to kids

Scratch is a very good option for kids if you want to teach them programming at a young age.

Here is an example of a very simple game made using Scratch where the aim of the hero in the game is to catch as many stars as possible.

Thus the hero tries to fly and spin at the same time. And while moving if it touches a star then it gets a point.

The above game was made using the video tutorials listed over here which I would definitely recommend if you want to get started with Scratch and before you jump into any exercise.

Also, you can follow the below steps if you want to practice making the above game:

  • Open the Scratch editor. Although you don’t need an account and you can continue without signing in, I would still recommend making an account. This would allow you to save your project or export the project file which you can load later.
  • Select Heros and make the following block. Once done press the green flag to test your code.
  • Select Buildings and make the following block. As before, you can test your code by clicking the green flag.

  • Finally select Objects and make the following block. You may also want to change the setting of the Objects to make it visible by default if it is already not.

Homework: If you manage to make this game then try to also add arrow key controls to it such that you can now use up, down, left or right arrow keys to change the direction of the hero to catch even more stars.

Happy learning and welcome to the beautiful world of programming.

Teaching kids at home

These are some of the good resources that can be used to either homeschool or teach important concepts to your kids:

ArgoPrep books

I recently came across ArgoPrep books in Costco and thought of gifting it to my elder one as his Christmas gift who will be going to Kindergarten in Fall 2022. After helping my son understand and solve some first 30-40 worksheets of their Kindergarten book, I can say without a doubt that this is one of the best books you will find if you are planning to teach your kids at home.

Khan Academy

My favorite one is Khan Academy and it covers more or less everything. It starts from Kindergarten, covers all the grades of both K-8 & High school and goes all the way till the final year of university. Pretty incredible isn’t it?

Currently Khan Academy is completely free and I hope it stays the same because there are many underprivileged countries and children with no access to proper education. So if you want to help them stay free and resourceful then please try to make any donation of your choice.

ABCmouse

Believe it or not but you can access ABCmouse completely free of cost via your public library account and help your child learn everything he needs using newer and more intuitive techniques.

Note: I plan to keep this page updated as and when I will find new resources so stay tuned.

SciShow Kids

SciShow Kids is a great YouTube channel to introduce science, nature and many other topics to your kids that will increase their curiosity . Videos are usually short (4-5 mins) which is just perfect for kids specially the ones who are just getting started and thus have a short attention span.

More YouTube Channels

Following are some of the other YouTube channels for kids which have been recommended to me by friends/colleagues but I am yet to review it:

Daily ToDo list 2022

Planning your day and kids are mutually exclusive specially if you have two kids under 5. Jokes aside, I honestly want to have some planning and structure in my daily schedule in 2022. And one way to achieve some direction is to have a daily ToDo list. I won’t mind even if I spend a few minutes a day on each item of my ToDo list and continue to make some progress on a daily basis.

So here are some of the things which I want to do everyday in 2022:

  1. Spend at least 30-60 mins a day reading/writing/exploring something new with my kids.
  2. Spend at least 15 minutes working on my side project.
  3. Spend at least 10-15 minutes a day learning the topics of my 2022 learning goals.
  4. Spend 15 mins per day watching Cosmos documentaries (A Spacetime Odyssey and Possible Worlds)
  5. Write something everyday for 15 mins so that I can post at least one blog per week.
  6. Go to the gym everyday or walk 10000+ steps if I end up skipping the workout.
  7. Watch at least one video on nutrition (15 min) and one video on fitness from my shortlisted YouTube channels.
  8. Tweet something useful everyday.
  9. Read all the new emails of the day for both my personal and work email accounts.
  10. Read this ToDo list everyday.

Learning goals 2022

TL;DR: Topics I want to learn and explore in 2022:

  1. Advanced Python (Book: Fluent Python, 2nd Edition)
  2. Design Patterns (Book: Python Design Patterns)
  3. Full Stack Web Development (Book: Flask Web Development, 2nd Edition)
  4. Crypto/Web3 (Books: DeFi and the Future of Finance, Mastering Ethereum)
  5. Security (Book: Web Security for Developers)
  6. Go programming (Book: Learning Go)
  7. JavaScript (Book: Eloquent JavaScript)
  8. Google Cloud (Courses: LinkedIn Learning)
  9. Science & Space (Books: The Blind Watchmaker, Why Evolution is True, Cosmos: Read the book and rewatch the documentaries: A Spacetime Odyssey and Possible Worlds)
  10. Venture capital (Books: Venture Deals, 4th Edition)
  11. Stock Market (The Intelligent Investor, Rev. Ed, A Beginner’s Guide to the Stock Market)
  12. Vocabulary (Book: Word Power Made Easy)

Note that all the O’Reilly books listed above can be accessed through a public library account. So these resources actually don’t require a huge money investment but what they do need is discipline and commitment. I often make the mistake of picking too many things to learn than I can handle. But the other big mistake which I have made in the past is not making any learning plan and schedule.

So for this coming year (2022), I want to make a list of 12 things which I would like to continue to learn till the end of that year. For now, my current plan is to spend 5-10 mins per day on each of the above topics. Doing the math, it should take me around 60-120 minutes per day to explore these 12 shortlisted areas. If this approach doesn’t work for me then I may switch to tackling each topic on a monthly basis as opposed to dealing with all the 12 topics on a daily basis. What matters to me is that I continue to spend time on these 12 things in the coming 12 months in one way or the other. And I am calling it my 12-in-12 game plan.

Anyways the main reason I am posting this is to share and bookmark the list of things which I want to learn for the next year (2022) and hold myself accountable if I am not able to finish my learning goal by the end of the year. Also, my current plan is to do the same drill every year going forward.

Dealing with leaking showerheads

I still remember the day when my bath shower started continuously leaking the water and turning the handle won’t do anything. I was a new home owner and kinda freaked out. The thing which annoyed me the most was that I couldn’t see water getting wasted. Also closing the water supply until some contractor came to fix it seemed daunting as sometimes it may take a few days for a contractor to show up.

However over the years, I have learned a few tricks to deal with a leaking shower head. This strategy doesn’t waste water and also doesn’t require me to turn off the water supply.

To begin with every time you have a leaking showerhead, chances are that the cartridge sitting inside the shower handle needs to be replaced.

But what if you don’t know how to open and replace the cartridge. Also, you don’t want to waste any water for hours or maybe days.

So here is what you can do to deal with a leaking showerhead as a temporary solution:

  1. Turn off the main water supply.
  2. Take off the showerhead.
  3. Measure the diameter of the pipe.
  4. Also note the brand of the shower handle which is not working. In my case, it was Moen as shown in the picture below:
  1. Head to Home Depot with your removed showerhead to purchase these things: water pipe cap or ball valve, tefton tape, wrench and a shower cartridge (optional).
  2. First get the water pipe cap which you will need to close the pipe where the showerhead is attached. I once made the mistake of getting a gas pipe cap instead of a water pipe cap so make sure you are getting the right one. Also if you are not sure about the diameter of the cap then just grab a small pipe at Home Depot and test if it fits into your showerhead which you must have brought with you. And then test if the cap also manages to close the same sample pipe.
  3. Alternatively you can get a ball valve instead of a water pipe cap. The advantage is that with the ball valve, you can still use the showerhead by attaching it to the valve’s head. And once done with the bath, you can turn off the knob to stop the water. Basically the knob on the ball valve acts as a temporary shower handle.
  4. You will also need a wrench and the tefton tape to create a secure seal while putting the pipe cap or the ball valve.
  5. Now at this point you may also decide to also shop the possible cartridges for your brand of shower handle. And I would highly recommend purchasing the cartridges too as contractors usually add a heavy markup to get the parts for you. Now if you are not sure which specific cartridge would go then just buy all the cartridge models matching your shower handle brand and then just return the unused ones after the fix. For my Moen shower handle, Moen Posi-Temp 1222 cartridge worked:
  1. Refer to YouTube to find countless videos on how to use tefton tape and wrench to close the water pipe using either the water pipe cap or the ball valve. Note: If your bathtub also has a spout (tap) then just pull the diverter to divert the flow of water towards the showerhead.

You are all set. You can now turn on the water supply while you wait for your contractor to arrive without wasting any more water.