Skip to main content

Posts about blog (old posts, page 97)

A Day of Updates

Could not focus much on programming today.
So decided on doing things with Python programs.

Nikola Upgrade

I use Nikola to generate both my websites.
It is an extremely easy to use, no fuss static site generator, which is easy on my server’s resources.
Version 8.1.2 was released a few hours ago and I hopped on and installed it.
I follow a slightly unconventional upgrade path, because I was terrified of breaking my server in the early days, when I was still learning about how to go about installing things on servers.

  • I have Miniconda installed.
  • I use that to generate a conda environment, which I then installed Nikola into.
  • When a new release drops, I create a new conda environment, install the new release in there and run them against my source folders (after backing them up).
  • This lets me revert very quickly to the old data and the older version of Nikola, in case I do something boneheaded and screw things up.
  • If all works fine for a month, I delete the older conda environment along with the old Nikola release.
  • I have been doing this for quite a while now, and while it may be overkill, it gives me peace of mind.
  • As usual, Nikola upgraded with no issues at all.

Pleroma Bot

I always wanted to understand what bots do.
Now I realise they are athromorphic programs that (with the right permissions and the right credentials) look like actual users of a service, doing sets of activities they are programmed to do.
Like your banking app has set of solutions to common queries that it shows you, before it hands off to an actual human, if those solutions don’t fit your needs.
They feel like supercharged scripts to me.
So I decided to see if I could install one.
Since I am learning Python, I love reading the low volume Daily Python Tip Twitter account.
It has surprising, handy, funny, interesting tips and tricks about the Python language and the massive ecosystem around it.
But, I have weaned myself off Twitter for my own sanity.
I only use it sparingly once a day.
And going back to that noise and tumult no longer interests me.
I saw a bot that mirrored tech news accounts to Mastodon and wondered if a bot could get Daily Python Tip to me on my Pleroma timeline.
A quick search led me to Pleroma Bot.
A couple of struggling hours later, (creating a twitter developer account, creating a pleroma account for the bot, figuring out how to get bearer tokens for said accounts) and tada, I got the bot to come alive!
It checks the Twitter account once a day, and mirrors the tweets to the bot account.
You’re most welcome to follow it for a Python tip, daily.
The next thing to do, is to see if I can get a bot to post a tagged pleroma status to my twitter account.
But that is something for another day …
Update, 2020/11/17: figured out how to use the bot to mirror multiple accounts. It now mirrors, Daily Python Tip, RegexTip, and CompSciFact.

P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.

What I Learnt from Antifragile (III)

This post was sent to my newsletter on October 25th, 2020.
You really ought to subscribe :)

What I Learnt from Antifragile (III)

What Does Not Kill Me … Antifragility for the Collective

What does not kill me makes me stronger.
— Friedrich Nietzsche, Maxims and Arrows

The world breaks everyone and afterward many are strong at the broken places.
But those that will not break it kills.
It kills the very good and the very gentle and the very brave impartially.
If you are none of these you can be sure it will kill you too but there will be no special hurry.
— Ernest Hemingway, A Farewell to Arms

That, in a nutshell, explains my learning today.
To become Antifragile, we need to understand be aware of what we do, our actions and then see who it ultimately benefits.


via Greek Myth Fandom

Antifragility, like I imagined in my head, was me getting stronger with every blow that life dealt me, Hydra like.
If you cut off one head, I would just grow another one.
But I realised that everything comes at the expense of something.
If I am growing Antifragile, something else has to give.
If there’s just nature on the otherside, we’re fine. But if there are people, then we better be careful about how we get Antifragile.

There’s also the notion of scale. Something small, dying to make the bigger collective stronger.
So there’s always a balancing act and a constant need to be observant.

This is how I imagine it, in a few scenarios in my life.

My cells need to die, my muscles need to tear in order that I build up my strength.
Here the individual is nature (my cells), dying in order to make me (my body, the collective) much stronger.
Imagine if that did not happen, if each cell decided, why should I die?
Actually, you don’t have to imagine.
That’s what cancer is.

If I die this year, I am insured. My folks get a hefty payout. (Antifragility for my family’s finances)
But the insurance company can only afford to do this, because they have money from a ton of folks placing the same bet as I did. That we would croak this year.
This is again the individual (me) benefiting the collective (the vast pool of people, who do not have enough saved, yet want to provide for their loved ones).

A nasty one is when someone uses this for their own benefit.
They win, but the collective loses.
Scams of various sorts come to mind here, where an unscrupulous person, takes advantage and become antifragile at the benefit of other people.

The flip side is the hero, where the individual takes risks and sacrifices to benefit the collective
Soldiers, Teachers, Firefighters, Tinkerers, Entrepreneurs are all examples of folks who sacrifice individually so that society as a whole benefits.

So this is what I learnt. To see how actions towards antifragility (mine or others) have ramifications on my life.
To always see if I or society benefit. Not someone else taking undue advantage.

P.S. Subscribe to my mailing list!
Forward these to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.

Git the Branch

I started playing with a way to control Git via Python.
Kushal had asked me to write a program, that would show me the local git branches.
So here it is!
I call it Git the Branch. (painfully, punny, I know :))

And now I realise why he asked me to do this.
The program itself is trivial.
Here’s the code on my code repo, Gitlab, and Github.
It just consists of me using GitPython to access the current folder via a GitPython Repo object.
And then querying it for its branches.

The important work was done yesterday, when I pored over the documentation and figured out how GitPython actually works.
And I realised that is what Kushal wanted me to do.
Read something and figure out how I could adapt it to my situation.

The other thing I realised, was licensing.
I want my programs to be used, played with and adapted.
So it makes sense for me, to make it as easy to use as possible.
This is why I have decided, that until circumstances dictate otherwise, I shall use the MIT License.
This led me to check if I could then actually license my software as such, if the software that I depend on (in this case GitPython) have different licenses.
My arbitrary and random research suggests that I can do so.
If I learn otherwise, I shall think about what to do next.
If you have anything to suggest, please let me know, by mailing me at jason at this domain.

One other (painful) thing, that I realised is that I cannot focus at all when I am writing code.
This post has come out in a blur of focussed writing.
My academic studies are also something that I can focus for hours on.
Apparently that focus does not translate to programming.
I need to build up this skill for this domain seperately.
Hopefully, this will come with showing up daily.

This was fun to do.
Here’s to writing my way to fluency.

P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.
P.P.P.S. Update, 7pm the same day, The answer to focus, lies in this serendipitous Seth post

A third might be, just for an hour, to turn it off.
All of it.
To sit alone and create the new thing, the thing worth seeking out, the thing that will cause a positive change.

I love it when the universe speaks to me :)

Poem Feed

Update, 2020/11/13: This has been working beautifully! I love the poems as they show up in my feed.

This is a tiny little niche thing, I built all for my ownsome.
It all started, when I got hooked on reading the daily poem, on the Poetry Foundation page.

Learning Python as I am, I wondered if there was a way to have it come to my RSS reader.
And so Poemfeed is a tiny little utility that does just that for me.

It looks up Poetry Foundation’s, Poem of the Day for a new poem.
If there is one, it follows the link to the complete poem, and then gets the link to that page and writes that into an simple RSS entry in an xml file.

I then wrote a simple cron job that executes the python script twice a day, and if an xml file is generated, it moves it to a place that my RSS reader can access.
Et voilà, a brand new poem everyday! (or as often as they publish :))

The code’s here, on my repo, on Gitlab and on Github, if you want to have a look see.

P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.

Starting Work on Git-the-Branch

The Itch

Aiming to write a tool using this which will show all the git branches in the current directory and the last commit date on those branches (and only the local branches :))

What I did today

I had to carry my phone in to the service centre, so I did not quite have as much focussed time as yesterday, with all the coordinating and carrying, but I learned a few new things

Kushal hinted that I could use GitPython to do what I want.
So I spent a little while reading there.
And then decided to test it out.

And then immediately went yak shaving, because I wanted to solve the problem of how to quickly type iterate in Visual Studio Code.
I learnt lots of Python using Reuven Lerner’s courses and I used a lot of Jupyter Notebooks then.
And I love them.
The trick now, is to figure out how to use them in Visual Studio Code.
To my delight, the Python extension in VS Code has support for notebooks. And all works well for the most part.
The only thing that tripped me up was that when I tried importing a module in the notebook after activating my virtual environment, the Jupyter server hiccoughed and threw up some error about not finding the module (which I knew was definitely installed) and then something about it not being in the PYTHONPATH (which I had no clue of which places, it was looking in.)
A little snooping and I realised that the extension loads the server with a default kernel in someplace. And I need to tell it about my environment. Once I told it to use the kernel from my venv, all was fine.
VS Code went and installed a ton of things and found what was already there and everything was hunky dory.
A from git import Repo worked just fine.

I felt good about this piece of dawdling, because I know this is something I am going to do every day and better I spend some time figuring it out, right at the start.

I learnt that I could use the ! mark as a prefix in Jupyter to run shell commands! A !ls will show me the contents of my folder :)

I skimmed the GitPython documentation.
I kind of got what I want.
This will require lots more work, which I shall have to put in.
But even a cursory glance, showed me that GitPython was an exhaustive wrapper, that would let you do practically anything you would want to do with Git.

More tomorrow …

P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.

A Good First Day

Was a really good day to ease back into Python today.
I got my VS Code up and running.
I got a personal Gitea instance up, to host my code, from where I will syndicate it to Github and Gitlab.
And finally I got a projects page up, to slowly fill up with projects.

I also managed to improve an old program I wrote for myself, but I’ll write about that in the next post.
All in all, a day well spent. A journey well begun.

P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.