logo

ZiffurComputers and stuff, made simple.

API-First: How to Write Useful Functions in JavaScript

Functions are the bread and butter of a computer program. They help encapsulate business logic, allowing you to easily reuse and build on your existing code. If done wrong, however, functions can easily become confusing, repetitive, and frustrating to use. In this article I'll lay the foundation for you to consistently create intuitive and useful functions.

Each function has a pre-determined way that it can be called. A signature, footprint, or interface, if you will. In this article, I'll be

Composing with React Hooks

Custom hooks are a wonderful tool to have when you're building interactive applications with React. Over the last few months and years, I've developed a few patterns and made a few observations I wanted to share. You see, I spend an unreasonable amount of effort trying to organize and de-clutter my code (far more than I do adding features, at least when I'm off-the-clock). If you're interested in doing the same, I have a few tricks you might find useful.

A Counter App

For the sake of demon

Code-Along: Use Basic Python to Simulate a Card Game

In this article we will write a Python script to simulate a simple card game and collect some statistics about it. By doing this, we hope to provide an overview over some basic programming concepts (variables, data types, loops, and functions) and how they come together in Python to make a useful script.

The Card Game

The game we will be simulating is very simple. In Iceland it is known as "Langavitleysa", which translates to "long nonsense" (if you recognize the rules and know the game by

Functions: How to Simplify, Reuse, and Expand your Code

This article assumes that you know some basic concepts in computer science as well as how to read code written in Python. If you've read and understood the previous article in this series, you're good to go. If you're not so confident, feel free to check out some of the previous articles to catch up. Moving on!

Writing code to accomplish simple tasks (like counting to five) is cool and all, but that's not what we call "real software", is it? That depends. Regardless of what various experts in

The ElGamal Encryption

The ElGamal Encryption is an asymmetric key encryption which means it uses public and private keys. The public key is ment to encrypt a message and the private key can then be used to decrypt it again. The choice of these keys is based on the pulic key system of the Diffie-Hellman key exchange.

The alorithm is prooven to be IND-CPA secure under the assumption that the Diffie-Hellman problem (the solving of the discrete logarithm) is nearly impossible

Control Flow Basics: How to Write Computer Programs (using Python)

If you've made it this far in the series, great! This is where the real fun begins. If you're new, no worries! In this series on computer science, we make sure not to overwhelm you with too much information at once. Instead, we take only the concepts which we deem essential and try to stack them on top of each other to quickly build up to something meaningful and practical.

So far, we've covered:

  • Binary numbers and their significance in computer science.
  • Booleans, the most basic binary da

Getting Started with Python: A Minimal Set-up Guide

Want to keep reading without running any code yourself? Feel free to skip ahead to the next article.

One of Python's strengths as a programming language is its intuitive syntax, making it easy and predictable for beginners to read and play around with. As with many other programming languages, though, getting set up to write your first line of code can be a frustrating challenge.

This guide is written with the intention of getting you started with Python code as smoothly as possible. To do

The Diffie-Hellman Key Exchange

The Diffie-Hellman Key Exchange is one of the first widely used algorithms to exchange keys publicly. That raises two questions: What is a key exchange? and Why would you do that publicly?.

Let's start with the first one. Some information, e.g. private messages or corporate secrets, are not meant to be accessible by everyone. To ensure that only certain people (or machines) can read this kind of information, one can use various cryptographic systems. These systems allow two or more par

Variables and Data Types: How to Talk to Computers

If you've read the previous articles in this series, we're almost ready to start looking at some interesting code examples. Before we do, there's one more topic to cover: Data types. Since computers operate exclusively within the realm of ones and zeros, data types help distinguish between different types of data. Let's find out what this means.

In the previous article, we covered the most basic data type: Boolean. W

How can I Recognize a Phishing E-Mail?

Phishing is the type of cyber attack that can hit anyone anywhere at any time. But if that is true, is there a way we can protect us against such attacks? How can we recognize a mail as phishing?

As you might have guessed, there is no cookie-cutter recipe on how to recognize phishing. However, there are a few checkpoints by which we can categorize an e-mail as "likely phishing" and then carefully read and process it.

In this article we will take a closer look at suspicious signs in an e-mail

True or False? An Introduction to Boolean Algebra

An android walks up to a street food stand and asks: "One small fries, please". The vendor asks back: "Ketchup or mayo?", to which the android responds "yes".

This joke's a bit of a long shot so please bear with me. To get to the bottom of it, we're going to talk about Boolean algebra, a branch of mathematics first introduced by English mathematician George Boole in 1847. Although the word "Boolean" was coined as an adjective to describe this branch of mathematics, modern programmers often u

What is Phishing?

[Phishing is] an attempt to trick someone into giving information over the internet or by e-mail that would allow someone else to take money from them, for example by taking money out of their bank account.

— Cambridge Dictionary

The Cambridge Dictionary gives a rather vague definition for a complex topic such as phishing but let's have a closer look at the quote above.

Phishing is indeed an attempt to trick someone into giving information to someone else (who we'll call a

Binary Numbers: A Gentle Introduction

There are 10 types of people in this world: Those who understand binary and those who don't.

Hilarious. 10 out of 10. If you don't understand this joke, that's okay. We're not here to judge. We're here to learn. So let's learn binary.

What is Binary?

Binary is a numeral system. What's a numeral system, then? A numeral system is a method for representing numbers. The one humans use every day is called the decimal system. This system uses ten symbols, 0–9, to represent all real numbers. I

A Gentle Introduction to Computer Science

We've written this series on computer science basics for anyone to read, including beginners. Instead of going into every detail we try to maintain easy and concise reading, focused on building an intuitive grasp on basic concepts as well as an overview of how they come together in the real world.

Articles in this Series:

  1. Binary Numbers: A Gentle Introduction
  2. True or False? An Introduction to Boolean Algebra
  3. [Variables and Data Typ

Mental Arithmetic for Dummies (Using Binary Numbers)

Let's imagine a scenario: Your friend just discovered a cool new problem and decides to test you.1^1 He asks you the following question:

If you could fold an infinitely large sheet of paper an infinite number of times, after how many folds would it be thick enough to reach the moon?

Seems impossible to calculate in your head, right? It's actually relatively easy. "Relative" is a flexible term, after all. The above situation did happen to me a couple of years ago and I was able to answer it