Skip to main content

Posts about dgplug (old posts, page 40)

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.


Getting Back on the Horse

Ok, one more time.
I know there have been lots of one more times before, but I am going to keep at this until I get proficient enough at this to land a job :)
And while I may not be brainy enough, the one thing I can do is be persistent enough to show up.

This time, I will focus on building tiny projects.
I realise my life is too chaotic for #100DaysofCode.
But I can do this, one tiny thing at a time.

Wish me luck!


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


My Experience Learning the Dvorak Keyboard Layout

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


I was wondering about what kind of technical posts, I could write, since I am still learning programming and I did not want to bother you folk, with this is how I learnt to do lists in Python and this is what dictionaries do :)

I then realised that it’s been slightly more than a year, I have been touch typing using the Dvorak layout.

So I thought, why not tell you that story? :)

Why did I switch to Dvorak?

I never learnt to touch type. It was always a some day, maybe cool skill to learn.
Ever since my computer support days in the late 90s, I have always hunted and pecked at my keyboard, using 2-3 fingers.
Or 4.
Or 5.
You get the gist.

And I was pretty comfortable with it, until I broke my back in 2017.

I now have three slipped discs at various point along my back, and one of them was compressing the nerves that go down both my arms a bit.

So the old way of typing, was now causing tremendous pain.

I asked my doctor what I could do and his answer was basically, change professions. (Silly sod)

But my physio sessions where I was strengthening my back muscles to take the load of my vertebrae, lit the bulb of what if I learnt to finally touch type using Dvorak? It was designed to reduce strain on the fingers.

Would that help?

Some Thoughts

I realise that I am in a lucky position, painful fingers notwithstanding.

My native language is English, most of the world types in English, programming is largely done in English and Dvorak was designed for English.

It would not have gone well for me, if I had to type in another language, because most of them adapt off the QWERTY layout.

While I have had no real issues adapting my fingers to shortcuts from my operating system and the various programs I use, I do realise that other folks might have muscle memory, that’s ingrained too deep.

How did I do it?

By switching to it cold turkey.
It was not like I had any other option.
The alternatives were to either endure shooting pains, up my fingers to my arms or give up typing altogether.

I switched my keyboard layout in Linux Mint on the desktop and MacOS on the laptop to Dvorak.
iOS does not natively have support for the Dvorak layout, so I installed Google’s Gboard and then switched that to Dvorak.

I practiced for about 10 minutes daily, using Gtypist on Linux, just to get a feel for where the keys were. I could see them on the phone and the tablet too, so that helped.

It took me a month to get the hang of it.
And the first two weeks, were absolutely miserable.
Emails, messages, writing, practically everything suffered.
I know.
I measured.
I averaged 2 to 5 words per minute.
I got yelled at.
And a few work balls got dropped too.
But that was a small price to pay, for what I hoped would be finger salvation.

But at the end of that month, I could touch type.
At 5 to 10 words a minute.

But I could do it.

A Year Later …

So, did it help?
Absolutely!
I now can type at close to 265 words a minute, with just my right hand.

Just kidding :)

It never was about the speed for me, though that has improved as well.
My good old patent pending hand claw typing, averaged 35 words a minute.
With Dvorak, I was at that speed in two months.
And then I just gave up on getting faster, because at around that speed, my fingers keep up with my thoughts.

The magic though, lies in the fact, that my speed has been on a gradual upward curve over the past year.
Four months ago, I was averaging 45 words a minute.
Today, I do about 55 words a minute.
And yet, like I said, it’s never been about the speed.

The best thing about Dvorak, lay in the fact that my fingers stopped paining.
I still have twinges once in a while, but those are few and far between and definitely a far cry from the daily agony of last year.

The other thing I’ve noticed is my fingers have become semi-autonomous typing appendages, if that makes any sense.
My thoughts flow out my fingers, on to the page. I don’t have to think about typing anymore.
Like I don’t have to think about walking. I want to go someplace and my feet just do it.

Finally, if someone had just told me just how comfortable Dvorak’d be, I would have made the attempt years ago.
It feels almost as good as scribbling notes on a pad to me. My fingers just roll over the keys, forming words.

You might not have crazy, flingin’ flangin’ fingers, but ought you learn to type with Dvorak?
My answer would be an emphatic, Yes!
(Two, no longer painful, thumbs up)


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.