Grab the keys for success on Medium

Medium 101

Medium is a popular blogging platform. It attracts almost 200 million unique visits monthly.

It is a wonderful place to start your writing career. You have a huge audience and a great community on your side.

This piece shows you everything you need to know about writing Medium.com. I wish…

CODEX

Learn eight useful tricks to write professional-looking code.

I’ve collected a list of useful tips and “tricks” you can use to write professional Swift code.

I hope you enjoy it.

1. Shorter If…Else Statements with Ternary Operators

Ternary operators allow us to make if...else statements shorter.

The syntax is:

condition ? true : false

For example, let’s compress this if-else expression:

let money = 100

Step by step guide

An animated gradient on an iOS device

Here is the link to the complete code for the animated gradient ViewController.swift. To learn how it’s done, stick around.

Set Up the Gradient

Choose the colors

A gradient is a powerful effect. Choosing colors that look good together is essential to make it stand out. You may find color samples in uiGradients useful.

Define the Colors in Your Project

I use these…

The with statement in Python helps you with resource management. It ensures no resources are accidentally left open.

The with statement is a replacement for commonly used try/finally error-handling statements.

A common example of using the with statement is opening a file.

To open and write to a file in…

You can see a staggering 200+ miles from a commercial airplane

The distance to the horizon depends on how high you are observing it.

If you are 5'6'’, standing on the shoreline, the horizon appears 2.75 miles away from you.

In this article, you learn how to calculate the distance to the horizon with a simple formula.

How Far Can You See From a Plane

How to find the inverse function

To find the inverse function, follow these four steps:

  1. Write the equation as a linear equation (swap f(x) with y).
  2. Swap variables x and y.
  3. Solve for y.
  4. Apply the inverse notation (replace y with f^(-1)(x)).

Example

Find the inverse function of

How to calculate cube volume

To calculate the volume of a cube with a side length a, use the following formula:

How many quarts are in a gallon

There are 4 quarts in 1 gallon.

This is easy to remember. Consider the word “quart”. It refers to a quarter.

When speaking about volumes, a quart is a quarter of a gallon. In other words, it is one-fourth of a gallon—so there are four of them in a gallon.

What Is the Resolution for 4k

The resolution for 4k is

3840 x 2160

This means a 4k screen has a whopping 8.3 million pixels in total. This is 36 times more than a good old 480p SD screen!

Why Is It Called 4k?

The 4k refers to 4000. But the resolution of 4k is “only” 3840 x 2160.

The reason…

Learn everything about structural pattern matching in Python

Switch Case in Python

Python switch-case statements are here! And they are actually called match-case statements.

This means you can soon replace this type of if-else mess:

With a more compact match-case statement:

In some situations, the latter approach is better. It can make the code more readable and less repetitive.

Notice…

Artturi Jalli

I’m a tech expert, entrepreneur, and software engineer from Finland. I write about programming, tech, and science. Visit my blog at www.codingem.com.

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