Should you count calories?

Most correct answer to this question is No. There are lots other tools that you can use to achieve your goals. For some purposes, those tools are sometimes not good enough, so calorie counting comes as a last resort.

Note: you have to take care of lots of other things first before you can have benefit from calorie counting.

Go read many other articles that talk against calorie counting, [1] and many more. Be familiar with all the points that people are making, nothing should surprise you.

Eat whole foods, rather than processed foods. Eliminate sugar, starch. And while you are at it eliminate food that has excessive simple carbohydrates. Look into low carb, keto etc. Eat sufficient protein, don't be afraid of healthy fats.

Establish a fitness workout routine that you are doing consistently.

Fix your sleep and sleep 8 hours or more per night.

Understand that your calorie estimation is going to be wrong, and food labels are wrong, and preparation of food maters, which can result in different calories numbers.

Understand that your body might want to fight you if you are trying to lose weight too fast and might reduce your base metabolism, which results in overall reduction of your used up daily calories. Don't let yourself feel stressed, weak, or depressed as a result of your diet. Look into intermittent fasting and low-carb if you are trying to lose weight.

Be fully aware of water weight that your body may add extra water depending on how much carbohydrates you are consuming. If making changes to your macronutrient ratio, be aware of this effect, and let some time pass for your body to stabilize.

Don't rely on fitness trackers to tell you how much calories you burned, they are all wrong. Instead just keep your fitness levels consistent week-to-week.

Situation looks bad for calorie counting, what can you do?

Use calorie counting as a feedback mechanism. Track changes to your body weight week-to-week. Even though your calorie estimation is wrong, you are generally eating same type of food, therefore you can corelate how does your calorie values affect changes to your weight. (Your levels of: fitness, sleep, overall energy should remain constant.)

Your calories should not be compared with other people, but compared with your own numbers from previous weeks.

Energy (food) = Base metabolism + Activity + Change to body weight

In order to relate changes to your body weight with food, you must keep other things constant and eat similar food on a weekly basis. Beware of water weight retention, and beware of changes to your base metabolism.

My tracker is at:

But why do you need it?

Most of the time you don't need calorie counting if you are doing other things right (whole foods, resistance training, intermittent fasting, avoiding simple carbohydrates, or eating low-carb).

Two scenarios:

1) if you are trying to shred down to very low body-fat percentage, more precision in your diet will help you.

2) excess calories (more than your body needs per day) is used when adding muscle mass to your body, and in this scenario you want to be careful how much excess calories you are adding otherwise you'll put on more fat than necessary.



Commuting with VLC player

I spend 3 hours per day in commute. And while generally it's tempting to be on my laptop, or staring at my phone, it's not healthy for your eyes. (And you get headaches etc).

Solution consists of noise-cancelling headphones and audio files to listen. Regular music and audio books are handled by iTunes, that's not an issue. But I want to have a separate application for lectures that I find on youtube or elsewhere, or stand-up commedians, meditation and breathing exercises.

VLC iPhone App to the rescue

Good things about VLC mobile:

Some bad quirks of the VLC mobile:

With that being said my solution consists 1 python helper script and a following directory structure with all mp3s:

./Comedian 1/skit 1.mp3
./Comedian 1/skit 2.mp4
./Comedian 2/background.jpg
./Comedian 2/skit 1.mp3
./Lecture 1/background.jpg
./Lecture 1/Lesson 1.mp3
./Lecture 1/Lesson 2.mp3

I made a helper script to

Big warnings:

How to copy?

Use iTunes file sharing while iPhone is connected to laptop with lightning cable.


import os
import sys
import subprocess
import re
import mutagen, mutagen.id3

D = '/Users/emir/Commute Audios/'

for d, dirs, files in os.walk(D):
    videos = [f for f in files if f.endswith('.mp4') or f.endswith('.webm')]
    if d:
        d += '/'
    for video in videos:
        mp3 = video.rsplit('.', 1)[0]+'.mp3'
        if os.path.exists(d + mp3):
            print('Consider deleting: ' + d + video)
            "-i", d + video,
            "-c:a", "libmp3lame",
            "-q:a", "4",
            d + mp3,

def check_and_apply(filename, edits, APIC=None, PRIV=None):
    id3 = mutagen.id3.ID3(filename)
    mutation = False
    for name, value in edits.items():
        if name not in ['TIT2', 'TRCK', 'TPE1', 'TALB']:
            raise Exception("not implemented")

        cur_frame = None
        for frame in id3.values():
            cur_name = repr(frame)[0:4]
            if cur_name == name:
                cur_frame = frame

        if cur_frame is None:
            cur_frame = mutagen.id3.Frames[name](encoding=3, text='')

        cur_value = cur_frame.text[0]
        if value != cur_value:
            print('Diff', name, value, cur_value)
            cur_frame.text[0] = value
            mutation = True

    if APIC is not None:
        with open(APIC) as f:
            apic_data =
        existing_apic_data = None
        for frame in id3.values():
            cur_name = repr(frame)[0:4]
            if 'APIC' == cur_name:
                existing_apic_data =

        if apic_data != existing_apic_data:
            print('Diff APIC', filename)
            mutation = True

    if mutation:

for d, dirs, files in os.walk(D):
    if '/.git/' in d:
    mp3s = sorted([f for f in files if f.endswith('.mp3')])
    assert d.startswith(D)
    album_name = d[len(D):].replace('/', '_').replace('"', '_')
    if not album_name:

    for i, mp3 in enumerate(mp3s):
        track_num = str(i + 1)  # .zfill(3)
        artist = album_name
        title = mp3

            d  + '/' + mp3,
                "TALB": album_name,
                "TPE1": artist,
                "TIT2": title,
                "TRCK": '{}/{}'.format(track_num, len(mp3s)),
            APIC=(d+'/background.jpg') if os.path.exists(d + '/background.jpg') else None,


CallGraphs with PerfTool

Goal is to show callgraphs of any process

perf record -g ./foo
perf script | ./ -f perf | dot -Tpng -o foo.png

This utility comes from jrfonseca's Gprof2Dot page, direct download link is: (local mirror).


And test program

#include <stdio.h>

int sum = 0;
#define LOOP()                    \
  {                               \
    int j;                        \
    for (j = 0; j < 10000; j++) { \
      sum += j;                   \
    }                             \

int f() { LOOP(); }
int d() { LOOP(); f(); }
int e() { LOOP(); f(); }
int c() { LOOP(); d(); LOOP(); e(); }
int b() { LOOP(); c(); }
int a() { LOOP(); c(); }

int main() {
  int i;
  for (i = 0; i < 10000; i++) {


My jekyll installation for a personal website

You'll find this post in your _posts directory - edit this post and re-build (or run with the -w switch) to see your changes! To add new posts, simply add a file in the _posts directory that follows the convention: YYYY-MM-DD-name-of-post.ext.

Compiling jekyll blog:

jekyll serve --detach
jekyll build --watch

Jekyll extensions

<script type="text/javascript"

\begin{equation} \sqrt{4} + 1 \ne 5 \frac{1}{2} \end{equation}

def print_hi(name)
  puts "Hi, #{name}"
#=> prints 'Hi, Tom' to STDOUT.

Check out the Jekyll docs for more info on how to get the most out of Jekyll. File all bugs/feature requests at Jekyll's GitHub repo.

See it on this site at /projects