Using Highland to Throttle

Usually when doing a command line tool you will like to throttle the handling speed, at least if this is a tool that is doing some kind of http request. `Highland` is a library that adds this kind of functionality to your toolkit by working with node streams.
Read More
Oct 2, 2020

Tee in the World of Pipes

Experience has shown that when writing command line tools that handle data, it is worthwhile to log the successfully handled entries. This way if the job dies, you know what you have finished and what you have not finished. This used to be code that I would write into my applications to keep track of the successful and failed entries. Unix has this wonderful tool called `tee` that can help with t...
Read More
Oct 2, 2020

Feeding Data in NodeJS

I used to work the library `readline` when I wanted to feed data into a nodejs command line application. Now I found a slightly niftier solution by using a library called `split`.
Read More
Oct 2, 2020

Concat of Many Files

I had this scenario where I needed to write many small files into one file. My problem was that I only wanted xml files, and the number of files was so big that bash couldn't handle the `*` operator. In the end it meant that I could for the first time use the `xargs` tool to do something useful.
Read More
Oct 2, 2020

Extreme Programming

We've been doing Test Driven Development and Pair Programming at my workplace for quite some time. They are both part of the methodology developed by Glenn Beck called Extreme Programming (XP). I became curious, are we doing extreme programming? Is there more to it then we do? Let's take a look. Extreme Programming is sometimes distilled into five values: Communication, Simplicity, Feedback, Cour...
Read More
Sep 20, 2020

The Python Web Server

There is a simple trick on linux if you want to share the content of a folder on your local computer. You can simply navigate to this folder and run `python3 -m http.server `. This is a great way of being able to share content you have on your computer. It is also great if you, like me, generate html content and then want to check how this content would look, where you also need to serve css...
Read More
Sep 19, 2020

What are Coroutines

I'm reading the Kotlin documentation, and the question arises. What are coroutines actually? The keyword `suspend` is used in the syntax and I think that's a clue. I believe Coroutines are blocks of code that can suspend the execution. Meaning that the thread working on the things in the thread could do some of the things in the coroutine, and then suspend the work to work on other things. How wou...
Read More
Sep 18, 2020

Daemon Threads

Daemon is a term that reoccurs in programming and the computer world. The term comes from Maxwell's demon that was constantly sorting molecules in the backgroun. The idea of something doing something in the background. In java the term `Daemon Thread` exists, and signifies a thread running in the background that doesn't prevent the program from stop execution.
Read More
Sep 18, 2020

Async as Generator

In the good old days, async code was written by creating new threads, and using lock statements to make sure that multiple threads didn't disrupt each other when accessing or writing data. In modern time I have a feeling that the field of async code is becoming a more integral part of programming languages. Different languages help the programmer by creating useful abstractions on top of async cod...
Read More
Sep 17, 2020

Vacuum Me This, Vacuum Me That

I was reading up a bit on postgres vacuum commands. It caught my interest because we had this issue where some operation that should just be a fast search on an index was taking a lot longer than expected, causing performance problems with some of our deletes. Something with the whole story was off, and that's when it sometimes pays off to look at the details. Unfortunately I didn't really get an ...
Read More
Sep 13, 2020

The World of OAuth Part 2

Let's talk a bit more about OAuth. Today I want to know, what is three legged authentication, and what is the alternative? Three legged authentication means that there are three parties involved in the authentication process. These are: `Client`, `Authentication Server` and `Resource Owner`. In this process the `Resource Owner` is directed to the `Authorization Server` to verify that the `Client`...
Read More
Sep 12, 2020

On the Topic of Postgres

I wanted to read up a bit more on Postgres as well, and this is what I found out. There are a couple of important concepts, that one should be familiar with I think regarding `Postgres`. * ACID - Atomic, Consistency, Isolation, Durability * MVCC - Multi Version Concurrency Control * FSM - Free Space Map
Read More
Sep 12, 2020

The World of OAuth Part 1

To prepare for a meeting I needed to read up on OAuth, and I would say it was really nice. Especially I liked how OAuth2 lightened the protocol by pushing the security concern over to the TSL protocol. In my view it seemed that OAuth 1 was giving a bit too much flexibility to the implementer. I also liked how the handshakes were being performed to ensure that the actors were who they said that the...
Read More
Sep 12, 2020

Overlapping Polygons

It is an interesting problem. As I said in an earlier post, there is already a widespread implementation for when the polygons are convex. The question is when dealing with general polygons. In my thinking, which might be wrong, I'm thinking that two polygons overlap when: 1. One point from one polygon is inside the other polygon 2. Any line from the two polygons intersect a line from the other p...
Read More
Sep 6, 2020

Introducing an Enum

In my work with my geometry library I noticed that some of the more basic classes, like `LineSegment`, `Line`, `Interval` etc. had basic functions, where a specific behaviour for the edge cases made implementation of the more complex classes like Polygon simpler. Of course, since every developer likes simplicity, I used these conventions when doing the implementations. My problem was that after ...
Read More
Sep 5, 2020

Tmux to the Rescue

Well, not for free. But today I wanted to copy some text from my tmux session to the clipboard of my machine, which unfortunately didn't work. From what I learned, the clipboard of tmux is simply separate from the system clipboard. But. There is this nice command one can run called `tmux show-buffer`, which outputs the current clipboard of tmux. Working on my mac, I could combine this with the `pb...
Read More
Sep 5, 2020

Slow Postgres?

Well, not completely. But I encountered a problem which I find interesting. A query is performed that return 0 rows. The query performs an `index scan` to find this out. Now, if the query tries to return all the rows from the table it is really slow. If it only returns a few rows (some that might not even be part of the index I believe), the query becomes around 400 times faster. In my imagination...
Read More
Sep 3, 2020

The Age of the Home Office

Obviously I'm late to the party, but I just came back to work and have now realized that everything is different. Gone is the office, the coffee breaks after the meetings. In comes instead the moving image of a beach for the Zoom meetings. It is like a whole new world. I'm curious to see how one can adapt to it to learn as much as possible, be as efficient as possible, but still stay sane and huma...
Read More
Sep 2, 2020

XSRF in the World

I remember learning about XSRF ("Cross Site Request Forgery") at work, and seeing how spring for example help you mitigate these attacks by generating an extra parameter to a form that is difficult to predict for a potential hacker. Looking at it now though, I still need a brush up on what actually enables the hacker to perform this attack. So first, the idea behind the XSRF is that a hacker make...
Read More
Aug 30, 2020

Postgres vs MySQL

I'm no way an authority on this topic, but as part of refreshing my knowledge I wanted to dive into the topic once again. I have had experience using both, and in the end of the day the systems that I've been working with have just needed to use databases through the simplest SQL use cases. No complicated joins, not even transactions have been a big requirement. One time we decided to migrate fro...
Read More
Aug 29, 2020

Change Directory in Vim

You can always use `:cd` to change the working directory for vim. Sometimes you simply want to change the directory to the one where the file that corresponds to the active buffer is in. You can do this by using `:cd %:p:h`. So, what does this mean? Well `%` I believe means the path of the current file. Then we first use the modifier `:p` which makes it the full path, and `:h` which removes the la...
Read More
Aug 26, 2020

Evaluating Programming Knowledge

Today I did a test to evaluate my programming skills. It was a classic test where you implement some algorithmic solutions, much in line with the kind of problems you can solve at `Hackerrank` or `LeetCode`. It made me think about how you can actually evaluate somebody's skills. I found the test well written and good, but at the same time I believe that the skill to implement smart algorithms is...
Read More
Aug 25, 2020

Back to Typescript

After finishing my tutorial on C-graphics, I have shortly returned to the world of `Typescript` to make a small layout library. I quite like both `C` and `Rust`, and if I could chose I would prefer professionally to work with them. This being said, it doesn't take long to notice that the flexibility of `Javascript` really boost productivity in terms of making it very simple to write things that de...
Read More
Aug 22, 2020

Git Diff Current File

It is brilliant how `Vim` easily allows you to execute shell commands. Just enter `last line mode` and write `! `. If you want to check the git diff on the current file you also want to know the filename of the file you are editing. This can be done by using `%`. So by entering `last line mode` and typing `!git diff %` you get a quick git diff of the current file.
Read More
Aug 21, 2020

Typedef Struct

In my digging around in C graphics programming I'm encountering examples where they sometimes define structs as `typedef struct {...} A` and sometimes as `struct A {...}`. I was a bit confused as to what the difference was. After googling it online my understanding is this: When you `typedef` something, you create an alias for that type, and that protects the type name in the compiler (i.e. you a...
Read More
Aug 20, 2020