Sign in

i like programming :) https://ryanchou.dev | Top 2000 Writer on Medium | Author of A Beginner’s Handbook to Python

No experience required!

Photo by Boitumelo Phetla on Unsplash

Today we will learn how to send desktop notifications with Python. For this we will just need a computer with Python installed.

Packages and Setup

You’ll need Plyer’s notification for this project:

# In CMD or terminalpip install plyer# In projectfrom plyer import notification

You can send notifications by calling the notify() function from notification.

It takes four parameters:

title The large header text at the top of a notification.

message The longer, smaller text where you put more detailed information.

app_icon The image that appears next to the title and message.

timeout How long the message should show…


Photo by Zdeněk Macháček on Unsplash

What is a two-pointers algorithm?

To put it simply, the two pointers technique is an efficient algorithm on a sorted list which can find a pair of elements in linear time.

Let’s learn about it while solving the famous problem (that we’ve solved before!), Two Sum!

The idea is that you can adjust the pointers in order to find the answer. For example, the steps to find 5 in this list below would be like this.

5
| |
[2, 3, 4, 9]
(Sum is larger: (9 + 2 > 5) so we move the right pointer.) |…


What are they?

Photo by Jens Lelie on Unsplash

The Bare Definition

According to Brilliant, a greedy algorithm is:

“An algorithm that makes the optimal choice at each step as it attempts to find the overall optimal way to solve the entire problem.”

Now this might make it seem like a greedy algorithm is a complicated and intricate algorithm, but this actually isn’t the case!

Let’s take a look at an example problem, and we’ll see how it goes!

Candies

From HackerRank:

Statement:

Alice is a kindergarten teacher. She wants to give some candies to the children in her class. All the children sit in a line and each of them has a rating…


Turning a seemingly trivial problem to a challenging one.

Photo by Maranda Vandergriff on Unsplash

The concept of FizzBuzz is really simple.

Write a program which prints every number from one to one hundred, but:

  • If you encounter a number which is divisible by 3, print Fizz.
  • If you encounter a number which is divisible by 5, print Buzz.
  • If you encounter a number which is divisible by 3 and 5, print FizzBuzz.
  • If you encounter a number which is divisible by neither 3 or 5, print the number.

Now let’s tweak it a bit.

Given an integer N, print the Nth number which isn’t Fizz, Buzz, or FizzBuzz.

Example:

Given:
8
Output:
14
Explanation:
If we were to write out the first…


What’s trending?

Photo by Isaac Smith on Unsplash

When you look something up on Google, you’ll get a flurry of related queries to your search. What are these, and how can we scrape them with Pytrends?

What are related queries?

When you look something up, Google tries to find what search terms you’re interested in. These help Google analyze a popular search with the ones that you’re interested in.

In Google Trends, they have two types of related searches, top and rising.

Top searches are the most frequently searched with a keyword that you’ve put in.

Rising searches are queries which have had the most significant growth in a time period. …


Think like a computer!

Photo by Rob Schreckhise on Unsplash

As technology is taking a more prominent role in our daily lives, it’s important to think of real-world problems in a way that can be translated into an algorithm.

In this article, we’ll walk through the 4 steps of computational thinking described by BBC: decomposition, pattern recognition, abstraction, and algorithms, while solving the popular Leetcode problem, Two Sum.

Decomposition

Let’s break the problem into subproblems.

Since the length of the array we have to look through could be massive:

2 <= nums.length <= 10⁴

It’s probably not good to look at the array as a whole.

Here’s a comparison:

In [2…


Captivate your users

Photo by Harpal Singh on Unsplash

Design is confusing, and after fumbling with your backend, it’s the last thing you want to worry about. Here are 3 tips to give your users the best experience possible!

1. Keep it simple!

Nobody likes an oversaturated interface, your design should define itself clearly.

One great example is Medium.com’s homepage.

This is great because:

  • Navbar makes it easy to get around the site.
  • Navbar is clear and concise. Nothing extra!
  • Consistent font
  • Clear message.
  • Subtle colors.
  • Speaks to both readers and authors.

I have annotated on the image below!


For beginners!

Photo by Nick Morrison on Unsplash

What you will learn:

  • How to host your static website on Github Pages for free!

What you need:

  • A static website to host!

Adding files

To host your website on Github Pages, you need to have a Github account.

You can register for one here: https://github.com/join

Once you’ve signed up, you need to create a public repository.

After signing in to your Github account, there should be a sidebar with all of your repositories (if you have any) and a button where you can create one labeled “New”.

Click that button!


For beginners!

Photo by Cookie the Pom on Unsplash

What you will learn:

  • How to implement memoization in a Fibonacci function.

What you need:

  • Nothing!

Recommended:

  • Knowledge of a programming language.

What is Fibonacci?

A Fibonacci sequence is a sequence where the next number is the sum of the two before it, the first two numbers are 1.

First 5 numbers of Fibonacci:1, 1, 2, 3, 5

Fibonacci with recursion

Every recursive function should have a base case, which makes sure that the function doesn’t call itself endlessly.

In this case, we’ll check if it’s 1 or 2, because we know that those two will have to be 1.

☝ The code stubs below…


with Python!

Image by author.

What you will learn:

  • How to convert a video to text using IBM’s Watson API and Python

What you need:

  • Python installed on your computer.

Packages and Setup

We’ll need ibm_watson to access IBM Watson services and moviepy to strip the audio from a video.

# In command line or terminalpip install ibm-watson
pip install moviepy
# In projectfrom ibm_watson import SpeechToTextV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator, authenticator
import moviepy.editor as mp

Audio time!

We can define a moviepy clip with mp.VideoFileClip,

clip = mp.VideoFileClip("VIDEO_PATH")

and strip it using the write_audiofile() function.

clip.audio.write_audiofile("audio.wav")

Now, our audio is prepared for translation!

API Keys

You’ll have to have…

Ryan Chou

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store