Wednesday, March 4, 2026

A collatz weekend

TLDR; found an opensource python software for printing a graph. My program got referenced by the developer over at the repo discussions page. Understood where ascii and where graphical printing makes sense. I also share a few thoughts on opensource. 

My youtube algorithm suggested a Veritasium video on the collatz conjecture. In it there was a graph - for a long time I wanted to print it. Here is an example of the graph which was shown in the Veritasium video. And what follows are two images I generated using other opensource software.

Fig1. Graph plot from the Veritasium video

Fig 2. pygraphviz plot


Fig 3. Ascii plot using binarytree python library

These graphs are generally called collatz graph or collatz chains. It is built on a simple mathematical rule which we won't discuss here. The specific graph I have printed is called a reverse-collatz graph. But note that the 3rd image is an ascii print of the same graph. 

Oh wait! Do you know what is a "graph"? Or do you know what "ascii" is? I think I must devote some time to introduce some fancy computer science terms. However, I am not going to delve deep into them. The impatient readers can skip the next few sections and directly read from the section called "My opensource library hunt"

Graphs

YOU don't really need to know what a graph is...It has no significance in your day-to-day life! That picture above is an example of a graph. It is a node which is connected to other nodes via lines called edges. In practice, the nodes/edges represent something. I am sure most visitors here have used Google Maps; it uses "graphs". Its neatly abstracted to you, the consumer. 

Binary Tree

The collatz graph which I tried to print is a kind of "binary tree". I have hidden most of the "binariness" to make it look plesant. Another example of a binary tree is the famous pascal's triangle. This is another mathematical term that is of no consequence to people's lives.

Fig 4. Somewhere in Ladakh

Yet it is out there in world. Staring back at you. Oblivious; in plain sight.

ASCII

It is an encoding standard for storing and transmitting information. Simply put if I save some text file (with a few sentences) onto a disk, and, I sent that disk to you...you use your computer to access that disk and read that text file and it contents...if the computer displays the correct sentences - how do you think that is possible?

This is a remarkable invention by human beings. It is the backbone of the internet. It is because of ascii many subtle things happen in life - good or bad:

1. You are able to read this blog post.

2. An expectant father is able to view the first pictures of his new born child while he is located on a different continent compared to his spouse's labour ward.

3. People nefariously indulge in relatively evil practices like pornography, blackmail, riots, etc.

4. Etc.

Shakespear once said, the web of life is of mingled yarn - the good and bad together. Maybe I failed in social science - and today its via ascii that I am coming to realize a lot more about our own species. (And I am a quadrigenarian)

Why print in ascii?

1. I can easily print the graph in a text file

2. I don't have to worry about scale. Most plotting libraries, will take into account the drawing area and auto-scale the plots.

3. I don't need special software to view my outputs. A simple text editor (with word-wrap-off) would do.

My opensource library hunt

In python, we usually have matplotlib for plotting stuff. But instead I thought that I would want to see the graphs better and not be worried about "scale" or drawing-area-sizes. Therefore ascii; there was no further reason than that initially. 

Finally came to discover a small library phart - Python Heirarchial Ascii Rendering Tool. Of course if you are someone who quickly alluded to some nasty things humans and often other mammals indulge in; you are excused.

The version I had got via pypi (i.e. pip install). It had a dependency of another pythonic graph software called "networkx". It was fairly quick for me to setup and get to printing outputs. But later I came to understand that the plots were incorrect. And I posted in on the github repo discussions. I waited for the response. Meanwhile I discovered another graph plotting package. This wasn't a python library. It was a C program called graphiviz. And there were python ports of graphviz which I then explored. And it internally used matplotlib to plot. But then the phart developer of the repo got back with fixes to my issue. And then I got to printing.

What kind of plot to choose and when?

This section won't be useful for anyone unless you are into research involving graph theory or you need to do some graph based computations.

(A) Choose a image-based graph plotting solutions when you need the following:

1. Auto-scaling.

2. High detail in nodes/edges

3. Aesthetics

(B) Choose ascii graph plotting when you need the following:

1. Searchability

2. Plotting to scale is not needed

3. Simple text file based sharing is important.

Most people will choose approach A. However, the final say is really a matter of requirement. I was doing it as a weekend fun project. If I were a PG student writing a research paper on the Collatz conjecture, I'd probably do both ascii printing and graphical renderings. But I'd use the latter when I write my research paper.

Opensource Affairs

Here is a small appreciation to phart developer and opensource

When I first tinkered with phart it was buggy. My output wasn't coming right. I thought it may be my incorrect use of the APIs. I posted onto the repo discussions page, and, in fact shared by whole program there and asked the developer if I was doing it wrong. He admitted his code had a bug. And he fixed it in a span of few days. It didn't matter if he took a month, or, even a year. He got back to me. These are qualities I adore.

Fig 5. ascii plot using phart

I have posted issues and interacted in developer forums and slack groups of other opensource software. The larger they are it is likely that the issue you post (or raise) is not given enough attention. There are many reasons why this can happen, but, I leave it to you the reader. And there are a few issues I have raised in some repos that belong to a few infamous organizations that need attention.


Sunday, February 8, 2026

[Rant] Google Photos Library API ens***tification

TLDR; Google Photos Library API is intentionally limited. Most tutorials will show how you can access your entire data. They are outdated. This is the state in Feb 2026.


I am a Google one customer. Most people know that this means I rent a finite amount of cloud storage. My Google Photos takes a significant amount of storage space. Now that storage is becoming full. 


So naturally I wanted to off-load. It is somewhat possible through their website app; but that can be cumbersome. Google Photos Library API showed some promise. I believed that I could access data on Google programmatically. I had experiencd with Google Apps Scripts before, and, believed this was possible.


Being the relatively lonesome developer that I am...I thought I could quickly hack some python program to help me out with this task. 


The choice of "python" is inconsequential. Most google searches related to this topic will result in some pythonic script which understands how to talk to the library api. But make note, that I have never tried this before, and, I have heard or had a faint memory that google allows you to programmatically access your data stored on its various services.


Therefore I thought this farce objective of mine was achievable. And I set about a journey to learn how to work the python code and learn from video tutorials and blogs on the subject. 


This is where you walk into a realm of oauth authentication. If you aren't a developer you can skip over this paragraph. And I am not going to go into this topic deeply either. There is a technical term associated with it called permission scopes (aka permissions) which controls your access to your "resource". Most tutorials say that "you have to this specific scope" and you magically can access your "resource".


Lo and behold...when I tried the tutorial examples myself, I was unable to access my data on Google photos. I initially got "request forbidden" or that I am "unauthorised". I understood that this meant I misconfigured some permission. I later fixed it. (After referring to documentation). And on the next trial, the script executed without errors and said that I had no albums!!?


That is when I took a closer read of the documentation. There was a link to an update. That further confirmed more disappointment. They have sunset the ability to entirely access since March 2025. I am trying to learn all this, with the mislead hope, in Feb 2026! And now I wonder why the tutorials weren't updated! 😖


So the state of affairs now is that you can script and upload data, and, download/access that data you have uploaded via that script. This hardly solves my requirement. There was probably a time developers had access to entire data. But Google has now intentionally limited this. I am frustrated at this pattern of capitalism that I decline to comment further on this.


I could have used AI to help. But honestly it was too early for that. I was simply on a exploration spree and I hit mildly sad news. However all internet searches prior to being "saddened" said that my goal was achievable. 


For those who have reached this paragraph, Google Takeout is the only option for a complete backup. I hear that it thorns and caveats. I shall leave it for the world to rant on that subject.