Kartones Blog

Be the change you wanna see in this world

Migrated to VS Code and so happy

Since I left .NET development I've tried using a few IDEs, but mostly sticked to Jetbrains suite for work and Sublime Text for personal projects. Jetbrains products require some setup for non-trivial projects, and Sublime's power came with its extensibility via packages (e.g. it's very easy to setup Python linting). In 2018 I decided to test Visual Studio Code after reading so much good feedback about it. At first I tried it at home, just for Python and basic web development, but after a few weeks, not only I uninstalled Sublime, but even decided to try it at work (instead of PyCharm). The results cannot be more satisfying.

I've come to terms with myself regarding what I can get from IDEs other than the real Visual Studios; In my opinion nothing will ever get as good as Visual Studio 2008 upwards (or even as the old Turbo C. But if I at least can have a tool that is fast, does the job, helps me being productive and has a few shiny extras, then it's fine.

I've installed nice extensions which allow me to just keep minimized CSS for my websites, and then re-format it in a second, change whatever I need and then re-compress & minimize. I can navigate through Python object definitions and have mypy type hint warnings. I can even now do live code editing and pair programming with the just discovered VS Live Share extension! I'm so glad I tried that last one, as in the past I've had to rely on the basic tmate + vim combo.

I might still sometimes suffer to attach to a debugging statement and have to rely on SSHing and a terminal to do it instead, but while Pycharm took ages to index and reindex and index again, VS Code just boots up and I get my last opened files and get back to coding in no time.

As a final note, I've setup a extensions and configuration blog page, so I can keep track of which extensions I use and keep at hand my customized editor config in JSON (to just copy & paste). It is nothing special, just a mixture of React, Python, Docker and miscellaneous web related plugins.

Course Review: AWS Certified Developer Associate (Udemy)

Although since mid-2018 I haven't touched much AWS except for personal projects (and just a few services), I had the AWS Certified Developer - Associate 2018 purchased and forgotten, so as a way to refresh some of the services and learn new ones I took it during the past weeks.

Note: I confess I either skipped or quickly went through most of the labs as I have already done the AWS Certified Solutions Architect - Associate course and many are very similar. There are some differences like an in-depth multi-video section about Elastic Beanstalk.

I learned about a few services, like X-Ray (tracing and some metrics, like a lightweight DataDog), Step Functions (Lambda "ui"), about the fact that API Gateway supports importing and updating API definitions from Swagger definition files, DynamoDB Accellorator and DynamoDB Streams (too bad events data is only kept for 24h). SQS FIFO queues (new from 2018) also sound cool as they guarantee order and exactly-once processing, too bad they are restricted to 300 transactions per second; still really great to have such power in an easy to use service. More interesting topics were an intro to CI/CD using AWS services (CodeCommit, CodeBuild, CodeDeploy and CodePipeline), how to build Docker containers with CodeBuild and ECR, Cognito and Identity Access Management (IAM) services.

As usual you probably won't use all of them but the amount of pieces you have available as services is incredible, if you don't care about vendor/cloud lock-in, you can perfectly build your whole business on AWS probably for years to come until you might need something more "powerful".

The quiz questions good to practice, as many depict real world-like scenarios and ask you the best service or proper configuration to solve a problem or match existing (but non-AWS) requirements, but I found some of the questions quite bad, as they are as dumb as asking you the exact name of an API method call, or some numbers which might get asked in the certification exam, but also change as Amazon softens some limitations.

Overall, a great and interesting course, with more than 25 hours of videos, exercises, labs, exam tips, and fresh & updated content whenever something new appears. I still recommend going first for the Solutions Architect Associate one if you want breath-first services knowledge, but I enjoyed both.

Course Review: English Vocabulary Launch (Udemy)

English Vocabulary Launch: Upgrade your speaking is, as you might have guessed, about improving vocabulary. The course is from the same author of English Grammar Launch and English Grammar Launch Advanced so, as I liked them, I gave it a try.

The "joke, fact & quote" idea is not bad in theory, but the jokes are a) terrible and b) way too "deeply" explained up to the point they feel like a waste of time. The fact and the quote are better but still too much time is spent explaining them. On the other hand, the pronunciation videos (zoomed so we can see the speaker mouth move) are a really cool idea, and in general the vocabulary was interesting and I learned quite a few new words, so I recommend it.

Course Review: Communication Fundamentals (Udemy)

For a change, I recently did a different Udemy course, Communication Fundamentals: How To Communicate Better.

Learning to more effectively communicate with others, specially in work environments. We get explanations and tips to detect and handle different personalities, styles of communication, being empathic, "the power of silence", among other topics. It includes a role-playing scenario acting, and some exercises to do by yourself.

My only complain is that the speaker goes quite fast across the content, even at 1x speed sometimes you have to pause to digest a slide or what was just said. On the other hand is a good way to practice english, as it is very well spoken.

The duration is 1.5 hours so, as a colleage named it, a "knowledge pill" you can quickly take and learn the basics about something without needing to spend too much time.

Double-Linked List Python implementation

A while ago I read an article about implementing linked lists on Python and to practice I reproduced the same interface with some additions (adding a tail, mypy type hints and a few tests).

Then I forgot about it, until recently I read something about sorting linked lists (I think in the DOOM source code analysis book I've read but it's not relevant) and I thought "I have this Python implementation, why not practice ordering that list?", so I grabbed the code, started working on it and, apart from a bugfix (tests are wonderful but you need to do proper ones and not just happy cases), I ended up adding new functions like insert_after(), sort(), flip(), clear(), making the linked list iterable and improving some operations performance along the way (also refreshing the big-O notation).

The beauty of having spent some time iterating on adding those new functions and "enhancements" is that now the code looks so slick and still useful, as you can specify your own sorting logic, normal or reverse, etc.. Here's for example the relevant code to make the list iterable and sortable:

def __init__(self) -> None:
    self.head: Optional["LinkedListNode"] = None
    self.tail: Optional["LinkedListNode"] = None

    self._iteration_cursor: Optional[LinkedListNode] = self.head

def __iter__(self) -> "LinkedList":
    self._iteration_cursor = self.head
    return self

def __next__(self) -> LinkedListNode:
    if self._iteration_cursor:
        current_node = self._iteration_cursor
        raise StopIteration
    self._iteration_cursor = self._iteration_cursor.next_node
    return current_node

# ...

def sort(self, comparison_function: Callable, reverse: bool = False) -> None:
    ordered_list = sorted(self, key=comparison_function, reverse=reverse)


    for node in ordered_list:

And a sample usage taken from the tests:

def node_comparison_function(node):
    return int(node.data["id"]) if node else 0

node_1_data = {"id": 1}
node_2_data = {"id": 2}
node_3_data = {"id": 3}
node_4_data = {"id": 4}

linked_list = LinkedList()

# 1 2 3 4 -> 4 3 2 1
linked_list.sort(comparison_function=node_comparison_function, reverse=True)

It was a nice exercise and after yesterday a friend sending me a link to Nicholas Zakas Javascript implementation of a single linked list I like how my approach is quite extensible and fast, but in exchange requires you to explicitly find the nodes before being able to remove() or insert_after(). Although having to write list.remove(list.find(xxxx)) instead of list.remove(xxxx) doesn't feels terrible to me (explicit over implicit?), and the list interface becomes more tight as uses nodes everywhere possible instead of raw data, leaving that for inserts and searches only.

All of this was just meant to say that if you want a Python double-linked list implementation quite deeply tested, type annotated, with reversing, inserting at head/tail/anywhere, searching and sorting by custom function in both directions, I built one: https://github.com/Kartones/PythonAssorted/tree/master/double-linked-list .

Previous entries