How to solve programming tasks with GPT powered chatbot

Photo by D koi on Unsplash

Code generation to the rescue

As you probably have heard by this time ChatGPT a machine learning based chatbot created by OpenAI is very famous. It is based on Generative Pretrained Transformer model, hence, GPT in short. It’s quite successful in various tasks ranging from text summarization, essays generation to questions answering. But did you know that it can also generate working code in various programming languages? If you didn’t then this post will provide you with some ideas to try.

Task at hand

For example, in the JSON Crack online tool below you can see how such a list of objects can look like

To summarize what needs to be done is as follows

Using Java Stream API approach

Java 8 version introduced a powerful Streams API that allows processing of collections in a functional way. For example, it is possible to filter, apply mapping or sorting to a collection in a single line of code using a declarative syntax somewhat similar to SQL. So, accomplishing the task of sorting a list of objects that have a createdDate field of Date type is quite simple and if you google how to do it you’ll find a number of solutions.

For example, this is how it can be done based on the Stack Overflow answer.

List<Order> orders = list.stream().
                        sorted(comparing(Order::getCreatedDate).
                        collect(Collectors.toList());

First prompt

Write a java code to sort a list of objects while converting a string field to date type

and this is the solution that the Bing chatbot provided


Certainly! Here’s an example of a Java code snippet that sorts a list of objects while converting a string field to date type:

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<YourObject> yourList = new ArrayList<>();
        // Add objects to yourList

        // Sort the list based on the string field "dateString"
        Collections.sort(yourList, new Comparator<YourObject>() {
            @Override
            public int compare(YourObject o1, YourObject o2) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date date1 = dateFormat.parse(o1.getDateString());
                    Date date2 = dateFormat.parse(o2.getDateString());
                    return date1.compareTo(date2);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                return 0;
            }
        });

        // Print the sorted list
        for (YourObject obj : yourList) {
            System.out.println(obj);
        }
    }
}

class YourObject {
    private String dateString;

    public String getDateString() {
        return dateString;
    }

    public void setDateString(String dateString) {
        this.dateString = dateString;
    }

    // Add other fields and methods as needed
}

In this example, we have a list of objects of type YourObject that contains a string field called dateString. We want to sort the list based on this field, treating it as a date.

To achieve this, we use the Collections.sort() method and provide a custom Comparator implementation. Inside the compare() method, we parse the dateString of each object into a Date object using a SimpleDateFormat. We then compare the two dates using the compareTo() method and return the result.

Please note that you need to replace YourObject with the actual class name and modify the code according to your specific requirements.

Let me know if you need any further assistance!

Second more nuanced prompt

write code to sort a list of objects while converting a string field to date type using java stream api

Certainly! Here’s an example of a Java code snippet that sorts a list of objects while converting a string field to date type using the Java Stream API:

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<YourObject> yourList = new ArrayList<>();
        // Add objects to yourList

        // Sort the list based on the string field "dateString" using Java Stream API
        yourList.sort(Comparator.comparing(obj -> {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            try {
                Date date = dateFormat.parse(obj.getDateString());
                return date;
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return null;
        }));

        // Print the sorted list
        yourList.forEach(System.out::println);
    }
}

class YourObject {
    private String dateString;

    public String getDateString() {
        return dateString;
    }

    public void setDateString(String dateString) {
        this.dateString = dateString;
    }

    // Add other fields and methods as needed
}

In this example, we have a list of objects of type YourObject that contains a string field called dateString. We want to sort the list based on this field, treating it as a date.

To achieve this using the Java Stream API, we use the sort() method of the List interface and provide a lambda expression as the comparator. Inside the lambda expression, we parse the dateString of each object into a Date object using a SimpleDateFormat. We then return the parsed date for comparison.

Please note that you need to replace YourObject with the actual class name and modify the code according to your specific requirements.

Let me know if you need any further assistance!

Testing the generated code almost as is in an online Java compiler

Well, that last answer was what I needed. We can take it and check that it can run almost as is in an online Java compiler. I made a couple of small adjustments in the generated code:

  • I instantiated three objects with dateString populated.
  • I added these objects to a list and
  • I adjusted println function to print the dateString field, instead of the object itself.

This is how it looked after running

// Online Java Compiler
// Use this editor to write, compile and run your Java code online

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<YourObject> yourList = new ArrayList<>();
        // Add objects to yourList
        YourObject obj1 = new YourObject();
        obj1.setDateString("2023-09-01");
        
        YourObject obj2 = new YourObject();
        obj2.setDateString("2022-07-02");
        
        YourObject obj3 = new YourObject();
        obj3.setDateString("2021-08-06");
        
        yourList.add(obj1);
        yourList.add(obj2);
        yourList.add(obj3);

        // Sort the list based on the string field "dateString" using Java Stream API
        yourList.sort(Comparator.comparing(obj -> {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            try {
                Date date = dateFormat.parse(obj.getDateString());
                return date;
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return null;
        }));

        // Print the sorted list
        yourList.forEach((obj -> System.out.println(obj.getDateString())));
    }
}

class YourObject {
    private String dateString;

    public String getDateString() {
        return dateString;
    }

    public void setDateString(String dateString) {
        this.dateString = dateString;
    }
    

    // Add other fields and methods as needed
}

Blowing your socks off

How to import code into Commodore 64 emulator

Back to BASIC

Recently, I went to BASICs and I found it fascinating. It is much more interesting programming paradigm then compiled languages development as C like languages since you can program in BASIC interpreter and in assembly at once and get feedback instantly. Also, 6502 CPU is quite easy to understand and memory mapping of the 6502 is also straightforward and interesting to play with.

How can you do it?

Prerequisites

Let’s do it

  • Extract the zip file where you want it and review the contents of the folder

  • Open Windows Command Prompt (aka cmd).
  • Run the command below to convert the text file to prg format.
C64List basic.txt -prg

Now let’s go to the Commodore 64 online emulator website and import our file.

Below comes the video of the process above.

Back to BASICs. Commodore 64 BASIC V2.

Fast-forward to nowadays, I continue to be interested in how hardware and software work and watched quite a few reverse engineering videos on YouTube, like Apollo Guidance Computer restoration series on CuriousMarc channel and others. Due to this YT algorithm suggests me similar videos. A couples of days ago it suggested me to watch the 27c3: Reverse Engineering the MOS 6502 CPU video about how 6502 CPU was reverse engineered by peeling layers from the chip, taking photographs and then reconstructing actual transistors from the photos. The talk was given by Michael Steil who extensively contributed to documenting everything there is about MOS 6502 CPU and various types of BASIC it ran.
The people who reversed engineered the MOS 6502, Greg James, Brian and Barry Silverman also wrote a
JavaScript visualization of the inner workings of the 6502 as it chugs alone.

It turns out that Michael Steil implemented a C based simulation of the MOS 6502 and hooked it up to the Commodore BASIC emulator to see how it worked. And it worked indeed!

Prerequisites

  • Interest in this topic 🙂
  • Operating System: Linux or Windows 10 with Windows Subsystem For Linux 2 (WSL2)
  • Source control software: git (should come preinstalled on WSL) to be able to check out the implementation of the 6502 CPU and BASIC
  • make tool installed
  • C compiler like, gcc installed

What to expect?

Let’s begin

Install WSL and Ubuntu

Clone GitHub repository

Now, that we have Ubuntu installed let’s download (clone) the MOS 6502 repository from GitHub to be able to build it locally.

  • When you navigated to that repository in GitHub click on the code button in the right upper hand side,
  • and click on copy icon

Create directory to clone repository into

mkdir perfect6502
cd perfect6502
git clone https://github.com/mist64/perfect6502.git
Cloning into 'perfect6502'...
remote: Enumerating objects: 643, done.
remote: Total 643 (delta 0), reused 0 (delta 0), pack-reused 643
Receiving objects: 100% (643/643), 997.31 KiB | 4.96 MiB/s, done.
Resolving deltas: 100% (391/391), done.

Install make and gcc on Ubuntu

sudo apt install make
sudo apt install gcc
make
amc@MINE-LAPTOP-130JJTQ6:~/perfect6502$ make
cc -Werror -Wall -O3   -c -o perfect6502.o perfect6502.c
cc -Werror -Wall -O3   -c -o netlist_sim.o netlist_sim.c
netlist_sim.c: In function ‘getGroupValue’:
netlist_sim.c:390:1: error: control reaches end of non-void function [-Werror=return-type]

To fix this issue there is a need to apply Pull Request (PR) one of the users submitted.

git fetch origin pull/10/head:pr_number10
OBJS+=measure.o

Update Makefile using Windows notepad

explorer.exe .

amc@MINE-LAPTOP-130JJTQ6:~/perfect6502$ make
cc -Werror -Wall -O3   -c -o perfect6502.o perfect6502.c
cc -Werror -Wall -O3   -c -o netlist_sim.o netlist_sim.c
cc -Werror -Wall -O3   -c -o cbmbasic/cbmbasic.o cbmbasic/cbmbasic.c
cc -Werror -Wall -O3   -c -o cbmbasic/runtime.o cbmbasic/runtime.c
cc -Werror -Wall -O3   -c -o cbmbasic/runtime_init.o cbmbasic/runtime_init.c
cc -Werror -Wall -O3   -c -o cbmbasic/plugin.o cbmbasic/plugin.c
cc -Werror -Wall -O3   -c -o cbmbasic/console.o cbmbasic/console.c
cc -Werror -Wall -O3   -c -o cbmbasic/emu.o cbmbasic/emu.c
cc -o cbmbasic/cbmbasic perfect6502.o netlist_sim.o cbmbasic/cbmbasic.o cbmbasic/runtime.o cbmbasic/runtime_init.o cbmbasic/plugin.o cbmbasic/console.o cbmbasic/emu.o
cbmbasic/cbmbasic

What can you do now?

You can do even more pretty trick using BASIC to print “Hello, world!” in Assembly code. I saw this implementation in the “Hello World” on Commodore 64 in Assembly Language, Machine Code video.

You can watched how it worked in real time below

Some useful commands to know

PRINT CHR$(147)
NEW
SYS 64738
LIST

To update particular line there is a need to retype it in this emulator, while in other emulators you can edit them. As you can see on the C64 online emulator

SUMMARY

REFERENECES

Get clarity about what JWT, JWS, JWK are and how to use them

What is an encoded JWT?

jwt.io

I need to understand this in depth

The best source to learn about the JWT and the like is the The JWT Handbook by Sebastián E. Peyrott from Auth0 company. You also can download it for free, by providing them with your email and filling in a basic form here. This book provides very detailed explanation about JSON Web Token with lots of practical examples. Some of them we’ll use next.

Use OpenSSL to generate private and public keys

Private key generation

openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
test@xyz:~$ ls
private_key.pem

Public key generation

openssl rsa -pubout -in private_key.pem -out public_key.pem
amc@MINE-LAPTOP-130JJTQ6:~$ ls
private_key.pem  public_key.pem

Generating JWK

The steps below rely on the the tutorial about how to use Nimbus JOSE + JWT open-source library from connect2id company.

import java.security.*;
import java.security.interfaces.*;
import java.util.*;

import com.nimbusds.jose.jwk.*;
import com.nimbusds.jose.jwk.gen.*;

// Public and private keys from a file. The method calls below are for example only
PublicKey publicK = getPublicKeyFromFile(path);
PrivateKey privateK = getPriavetKeyFromFile(path);

// Convert to JWK format
JWK jwk = new RSAKey.Builder((RSAPublicKey)publicK) 
    .privateKey((RSAPrivateKey)privateK) 
    .keyUse(KeyUse.SIGNATURE)
    .keyID(UUID.randomUUID().toString())
    .issueTime(new Date())
    .build();

// Output the private and public RSA JWK parameters
System.out.println(jwk);
{
  "kty" : "RSA",
  "kid" : "cc34c0a0-bd5a-4a3c-a50d-a2a7db7643df",
  "use" : "sig",
  "n"   : "pjdss8ZaDfEH6K6U7GeW2nxDqR4IP049fk1fK0lndimbMMVBdPv_hSpm8T8EtBDxrUdi1OHZfMhUixGaut-3nQ4GG9nM249oxhCtxqqNvEXrmQRGqczyLxuh-fKn9Fg--hS9UpazHpfVAFnB5aCfXoNhPuI8oByyFKMKaOVgHNqP5NBEqabiLftZD3W_lsFCPGuzr4Vp0YS7zS2hDYScC2oOMu4rGU1LcMZf39p3153Cq7bS2Xh6Y-vw5pwzFYZdjQxDn8x8BG3fJ6j8TGLXQsbKH1218_HcUJRvMwdpbUQG5nvA2GXVqLqdwp054Lzk9_B_f1lVrmOKuHjTNHq48w",
  "e"   : "AQAB",
  "d"   : "ksDmucdMJXkFGZxiomNHnroOZxe8AmDLDGO1vhs-POa5PZM7mtUPonxwjVmthmpbZzla-kg55OFfO7YcXhg-Hm2OWTKwm73_rLh3JavaHjvBqsVKuorX3V3RYkSro6HyYIzFJ1Ek7sLxbjDRcDOj4ievSX0oN9l-JZhaDYlPlci5uJsoqro_YrE0PRRWVhtGynd-_aWgQv1YzkfZuMD-hJtDi1Im2humOWxA4eZrFs9eG-whXcOvaSwO4sSGbS99ecQZHM2TcdXeAs1PvjVgQ_dKnZlGN3lTWoWfQP55Z7Tgt8Nf1q4ZAKd-NlMe-7iqCFfsnFwXjSiaOa2CRGZn-Q",
  "p"   : "4A5nU4ahEww7B65yuzmGeCUUi8ikWzv1C81pSyUKvKzu8CX41hp9J6oRaLGesKImYiuVQK47FhZ--wwfpRwHvSxtNU9qXb8ewo-BvadyO1eVrIk4tNV543QlSe7pQAoJGkxCia5rfznAE3InKF4JvIlchyqs0RQ8wx7lULqwnn0",
  "q"   : "ven83GM6SfrmO-TBHbjTk6JhP_3CMsIvmSdo4KrbQNvp4vHO3w1_0zJ3URkmkYGhz2tgPlfd7v1l2I6QkIh4Bumdj6FyFZEBpxjE4MpfdNVcNINvVj87cLyTRmIcaGxmfylY7QErP8GFA-k4UoH_eQmGKGK44TRzYj5hZYGWIC8",
  "dp"  : "lmmU_AG5SGxBhJqb8wxfNXDPJjf__i92BgJT2Vp4pskBbr5PGoyV0HbfUQVMnw977RONEurkR6O6gxZUeCclGt4kQlGZ-m0_XSWx13v9t9DIbheAtgVJ2mQyVDvK4m7aRYlEceFh0PsX8vYDS5o1txgPwb3oXkPTtrmbAGMUBpE",
  "dq"  : "mxRTU3QDyR2EnCv0Nl0TCF90oliJGAHR9HJmBe__EjuCBbwHfcT8OG3hWOv8vpzokQPRl5cQt3NckzX3fs6xlJN4Ai2Hh2zduKFVQ2p-AF2p6Yfahscjtq-GY9cB85NxLy2IXCC0PF--Sq9LOrTE9QV988SJy_yUrAjcZ5MmECk",
  "qi"  : "ldHXIrEmMZVaNwGzDF9WG8sHj2mOZmQpw9yrjLK9hAsmsNr5LTyqWAqJIYZSwPTYWhY4nu2O0EY9G9uYiqewXfCKw_UngrJt8Xwfq1Zruz0YY869zPN4GiE9-9rzdZB33RBw8kIOquY3MK74FMwCihYx_LiU2YTHkaoJ3ncvtvg"
}

Quick decoding of JWT or JWS

If you need to be able to review the content of JWT or JWS then go no further then JWT Token website
For example, if you have the key below

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
HEADER:ALGORITHM & TOKEN TYPE

{
  "alg": "HS256",
  "typ": "JWT"
}
PAYLOAD:DATA

{
  "sub": "1234567890",
  "name": "John Doe",
  "iat": 1516239022
}
VERIFY SIGNATURE

HMACSHA256(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),

  your-256-bit-secret

) secret base64 encoded

Understand the system. How does fasting work?

Why is it 16 hours long fast mostly useless?

If you fast without knowing how it works then you probably are doing the infamous 16 hours long fast (aka 16:8).

Moreover, if you fast 16:8, but haven’t changed what you eat then it’s almost certainly that you won’t lose much weight.

The are a couple of issues with this mechanistic approach to fasting.

Without knowing how it works you do not have a true motivation to succeed, and you don’t know what to tweak to influence your progress.

But the main issue has to do with the food you eat.

First, let’s look at some physiological facts.

1. When you eat sugar, starchy food, drink sugary drinks, generally eating processed food the carbohydrates in it are stored in the body as glycogen.

On average body stores about 600 grams of it, mostly in muscles (~80 %) and the rest in the liver.

2. On average adult requires about 2500 calories (kcal) a day.

Now, let’s do some calculation:

1. How much calories our body needs an hour: 2500 cal / 24 hours ~ 105 cal an hour.

2. Since glycogen is a carb and 1 gram of carb contains 4 calories of energy, then how much energy is stored in the glycogen in the body?

600 grams * 4 cal = 2400 cal!

3. To burn this energy you need 2400 cal / 100 cal an hour = 24 hours

Do you see what’s going on here? It means that to be able to burn all the stored glycogen in the body you need about 24 hours!

It means that doing 16 hours long fast won’t cause your body to switch to burning fat at all within that time frame.

Now, let’s understand why it’s important to change what you eat

As, soon as you stop eating sugar, drink sugary drinks and stop eating bakery, pasta etc. Insulin hormone level will go down in your body which will signal to your body to switch to use fat as an energy source.

But before this can happen you body will first use glycogen stored in muscle and the liver.

As we said, at most it can store 600 grams, but if you changed what you eat this amount would be much smaller, let’s say 300 grams.

It means 300 gram * 4 calories = 1200 calories. And if you burn 100 calories an hour, it means that you need only about 12 hours of fasting for your body to switch to fat burning mode.

Now there you have it

Doing blindly 16 hours long fast possibly won’t help you lose much fat if you continue to eat sugar and starch containing food.

When you understand how fasting works you know what you are doing and can influence the process and the progress you make.

And lastly, on average 18 hours long fast is the least amount that can cause your body to switch to fat burning mode. It’s better to go for 19, 20 hours a day.

And do extended fasts from time to time.

Books that could change your health for better

These are good books to begin with when you start your Intermittent Fasting journey

  1. Fast. Feast. Repeat by Gin Stephens is the book for beginners on an Intermittent Fasting journey. It’s the book that started it all for me.
  2. Why We Get Sick by Benjamin Bikman is a must read if you want to really understand metabolic syndrome origins and what to do about it.
  3. The Complete Guide To Fasting by Jason Fung is the book that tells you everything there is to know about fasting. I review it from time to time it to this day.

Now that you’ve read first three books, below come additional three you couldn’t miss

  1. Why We Get Fat by Gary Taubes tells you why the obesity and diabetes 2 are caused by sugar and starchy food.
  2. Fat Chance by Robert Lustig will teach you why we get fat from biological point of view. And fructose is poison.
  3. The Intermittent Fasting Revolution by Mark Mattson talks about evolutionary origins of fasting and delves into physiology of fasting. Mark fasts for mor than 30 years himself doing 18:6.

It’s time to delve a little bit into history of why sugar (fructose) is bad for you

  1. The Case Against Sugar by Gary Taubes talks about history of sugar usage and why it’s the main cause of diabetes 2 and other diseases.
  2. The Case For Keto by Gary Taubes is an opposite of the book above.
  3. Metabolical by Robert Lustig looks at the obesity and metabolic syndrome in a systematic way and again highlights that sugar and particularly fructose is poison.

The books below will be helpful in applying practical advice to lose weight by fasting

  1. The Every Other Day Diet by Krista Varady is dated, but still has good advice about alternate day fasting. Pay attention, that she is a representative of the flawed and wrong hypothesis of calories in equal calories out.
  2. The Obesity Code by Jason Fung will explain you why we get obese and what to do about it.
  3. Drop Acid by David Perlmutter explains why fructose is the main culprit behind elevated levels of uric acid which causes gout and what to do about it.

How to achieve a goal? A simple working algorithm

How to achieve a goal? A simple working algorithm


1. Set a goal with a deadline
2. Write a plan on how to get there
3. Track your progress daily
4. Consider sharing you goal publicly
5. Bet with someone

Now, to act on my own advice


1. I set a goal of getting a visible abs by August 30th 2023
2. My plan is to
2.1 Continue doing 18:6 intermittent fasting daily and walk in a fasted state
2.2 Do resistive training with dumbbells at least 3 times a week
2.3 Eat low-carb food and avoid processed food as much as possible

Finally, thank you for your support since you are my peer pressure.

Take the first step and continue doing one more step each day

Why is that we don’t achieve the goals that we set to ourselves like losing weight, getting fit etc. Maybe, it’s because we never take the first step towards a goal in the first place. Then those of us who take that first step usually stop right after doing it. What is missing is the determination to continue to make small steps, day after day after day. As they say the road of 10,000 miles starts with the first step, but as I mentioned it’s more important to continue making step after step.

So, start small. Make a goal, say you want to lose weight. First, understand that most diets alone don’t work. Second, if you have no physical constraints start doing intermittent fasting going from long eating window to a short one. Then as you get used to fasting start incorporating walking into your fasting routine. Walking in a fasted state helps to lose more weight and also makes you feel good.

Write down your goal on a paper or digitally. Each day document the small step your took that day, summarize your progress. You can consider sharing your goal and your progress as you make it on social media which may help you to stick to your commitment due to peer pressure.

You can consider joining a support group or starting one yourself. Having other people engaged in the same activity, seeing their progress and how they overcome difficulties along the way could motivate you and provide you with a desire to persevere and move forward towards your goal.

In short, try to do something each day that moves you towards your goal just a little bit. Remember, that doing nothing is not going to help you in any way. But incremental steps in the end sum up to a long way you’ve made. The way that is taking you to where you want to be. Yes, it’s not easy. Yes, it takes will power. Yes, it’s uncomfortable at times and frustrating, but there is no other way.

Below comes a quote from Contact movie that summarizes it good

This is the way it’s been done for billions of years. Small moves, Ellie. Small moves.

‘Contac’, 1997

A user friendly introduction to math

For people who got scared of math in a school or college when it was taught in a such a way when no curiosity is fostered it is easy to dislike math. But if you still want to give math a try or even curious about mathematics then the How To Bake Pi book by Eugenia Cheng is maybe what you need.

This book is a gentle introduction to a wide audience of the Category Theory which is a part of pure mathematics. It does not require from a reader to be a math expert, but it does require at least a certain interest in math. Each chapter of the book starts with a recipe, usually related to pastries and then proceeds at looking how that recipe could be related to some aspect of mathematics in the first part of the book and to some aspect of Category Theory in the second part of the book.

What I particularly like about this Eugenia’s book is that it talks about sets, rings, groups and categories which are advanced concepts in math, but it is able to explain them in a friendly manner, by providing real world related examples and analogies. For example, she reminded a reader about how it’s possible to use a Pythagoras’s theorem to calculate a vertical and horizontal distances that a ‘real’ taxi cab travels in a city.

What I found most interesting to myself is her layered model of mathematical thinking that consists of three parts: knowledge, understanding and belief. Where understanding is in the middle and binds together knowledge and belief. Put in her own words:

We have knowledge, which is what the outside world sees, belief, which is what we feel inside ourselves, and understanding, which holds them together.

Cheng, Eugenia. How To Bake Pi. Profile Books, 2016: p. 272


What is interesting that Eugenia Cheng has written recently a new book on Category Theory which builds upon the foundations she laid in the How To Bake Pi book. The new book is The Joy Of Abstraction and it can be seen as a textbook for Category Theory presented in a user friendly manner that very much retains the spirit of How To Bake Pi.

Physical activity alone won’t help. Change what you eat first.

Photo by Content Pixie on Unsplash

The usual advice to eat less and move more is completely wrong and is against scientific evidence. I won’t go into detail here and you can read about it in the books by Jason Fung The Obesity Code or Gary Taubes Why We Get Fat.

What I do want to discuss is the fact that workout on its own won’t help you losing weight, since it contributes only a very small fraction of the energy that is burnt by the body when doing physical activity, especially, if you aren’t an athlete exercising twice a day every day.

If you are an average person who is not doing any sport usually and working mostly sitting in a chair then starting doing some exercise won’t make you slim. It won’t gonna happen. What you need to think of first is changing what you eat and when you eat it. Because this change can really be a drastic change in you life that can bring you weight down, help you loss excessive fat and feel better.

For example, if you exercise even three times a week, but still continue eating processed food full of any type of sugar, added or not, drinking soft drinks, diet or not, eating sweets, pastries etc., then no amount of exercise will ever help. You are doomed to stay overweight or obese. This is because eating these products raises Insulin hormone level which causes you body to store what you eat as fat. Then fructose which is a part of sugar or high fructose corn syrup, causes you liver to become fat, and raises Uric Acid which makes Insulin resistance even worse. So you get a double whammy here.

If instead you stopped eating sugar and starchy food in any form, then transition to eating meat, eggs, cheese and vegetables and some fruit. Do it during eating window of no more than 6 hours, then incorporating some physical exercise during you fasting hours can be a real boost to your weight loss.

So the bottom line is that you can’t outrun a bad diet. And this is true.