Ketosis is just fifteen minutes away

Is there intermittent fasting approach to social media apps?

Photo by Igor Omilaev on Unsplash

Eat more, move less you’ll get a real progress!

Photo by Noah Buscher on Unsplash

So, what’s the proper way to lose weight?
Well, check Carbohydrate-Insulin Model (CIM) of obesity. The hypothesis that actually explains weight gain better than EBM and it states that lowering carbohydrates consumption as much as possible is the way to lose weight for good.


For more details, read the paper by prof. David Ludwig below

Ludwig DS. Carbohydrate-insulin model: does the conventional view of obesity reverse cause and effect? Philos Trans R Soc Lond B Biol Sci. 2023 Oct 23;378(1888):20220211. doi: 10.1098/rstb.2022.0211. Epub 2023 Sep 4. PMID: 37661740; PMCID: PMC10475871.

Abstract

Conventional obesity treatment, based on the First Law of Thermodynamics, assumes that excess body fat gain is driven by overeating, and that all calories are metabolically alike in this regard. Hence, to lose weight one must ultimately eat less and move more. However, this prescription rarely succeeds over the long term, in part because calorie restriction elicits predictable biological responses that oppose ongoing weight loss. The carbohydrate-insulin model posits the opposite causal direction: overeating doesn’t drive body fat increase; instead, the process of storing excess fat drives overeating. A diet high in rapidly digestible carbohydrates raises the insulin-to-glucagon ratio, shifting energy partitioning towards storage in adipose, leaving fewer calories for metabolically active and fuel sensing tissues. Consequently, hunger increases, and metabolic rate slows in the body’s attempt to conserve energy. A small shift in substrate partitioning through this mechanism could account for the slow but progressive weight gain characteristic of common forms of obesity. From this perspective, the conventional calorie-restricted, low-fat diet amounts to symptomatic treatment, failing to target the underlying predisposition towards excess fat deposition. A dietary strategy to lower insulin secretion may increase the effectiveness of long-term weight management and chronic disease prevention. This article is part of a discussion meeting issue ‘Causes of obesity: theories, conjectures and evidence (Part II)’.

Weight loss as an engineering

  1. Continue Intermittent Fasting regimen by having 16 hours fast, 8 hours eating window.
  2. Continue eating mostly low carb diet, and restraining from eating food that contains any sugar.
  3. Continue walking outside just for fun, since it’s free and affordable to almost everyone, unlike a gym membership.

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"   :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  : "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