What is a JSON feed? Learn more

JSON Feed Viewer

Browse through the showcased feeds, or enter a feed URL below.

Now supporting RSS and Atom feeds thanks to Andrew Chilton's feed2json.org service

CURRENT FEED

Bloggus Doekmanni

This is Bloggus Doekmanni, or Doekman's blog if you like. A bit of drivel about computer programming; some dead serious, some not so much...

A feed by Doeke Zanstra

JSON


Jump around

Permalink - Posted on 2018-09-13 00:00

There are more ways to navigate the file system in bash than I imagined when I still was using cmd.exe. Let me name some:

  • cd navigates to the home folder. Like cd /users/$(whoami) or cd "$HOME" but shorter.
  • cd - navigates to the previous directory. It’s like the zap-button on your television remote control!
  • cd ~/Doc tab-completion works like Visual Studio’s intelli-sense, but without the dropdown and it’s case sensitive. If there is one choice, it will complete it. If there is more, you need to press tab twice, and it will show a list.
  • pushd/popd/dirs save/load/show a directory to/from the stack. Especially handy in complex scripts.

However, I noticed I was always navigating to not that many different number of folders. I thought, wouldn’t it be handy if one could save/load folders to some kind of dictionary. I did extensive research and couldn’t find anything, so I created go. It was great. Typing go gh performed cd ~/prj/GitHub. To save the current folder under the name “here” would be performed by go here .. And go would show all the current stored definitions.

As I mentioned before, I performed thorough extensive research. I didn’t take it lightly. However. Apperently, the subject sometimes needs time to sink in. As today I learned from a guy I have known some time, that he created a tool called markjump. This is basically what I made, only for powershell. But his work was inspired by Jeroen Janssens’ shell script, from five years ago. And he’s a Dutchie too! How could I have missed that? And his code is 1500% better!

To complete my story line: Half a year ago I ran into the z-utility (can’t remember how), which has the description jump around. I was intrigued! I learnt descriptions of utilities are pretty important. And it turns out to be a pretty clever and helpful utility. It automatically remembers where you navigate to; no need to keep a list manually. And it will also keep statistics.

It uses regular expressions to find which folder you want to navigate to. And it’s case-insensitive, so z dow will navigate to ~/Downloads. No need to type a capital-D. When the regular expression matches multiple folders, it uses the statistics (how recent and how frequent) to decide where to navigate to.

I must say I was a bit hesitant to use it, because it seemed so… technical. In the beginning of the man-page it says something like “Tracks your most used directories, based on ‘frecency’..” But the “jump around” reeled me in. I never used my own go-utility, and only just now looked back. Thanks rupa!


Emoji's missing from emojis.wiki

Permalink - Posted on 2018-08-28 00:00

The following entries are supposedly missing from emojis.wiki. However, you could also read this article as a proposal for alternate descriptions of a part of the Miscellaneous Technical range of the Basic Multilingual Plane of the Unicode standard.

  • Chin on fist on arm
  • Super happy
  • Moustache concealing mouth
  • Disbelieve
  • Big surprise
  • Unsure
  • Talking frolicsome

If you have any corrections or addendums, please let me know on Twitter.


To vowel case

Permalink - Posted on 2018-07-08 00:00

There already was Sentence case, lower case, UPPER CASE, Capitalized Case, AlTeRnAtInG CaSe and Title Case.

And nOw YOU cAn dO vOwEr cAsE tOO!

function toVowelCase(text) {
  return text.toLowerCase().replace(/[aeiouy]+/g, match => match.toUpperCase());
}

Updated: a correct implementation of toVowelCase is locale-dependend. In English, the letter y is sometimes a vowel, and at other times a consonant. The above works for the Dutch language and some other languages. Your mileage may vary.


To refactor, or not to refactor

Permalink - Posted on 2018-06-29 00:00

The code iteration below is a contemporary comment on the use of refactoring.
We start with this code:

function isLeapYear(year) {
  if (year % 4) {
    return false;
  } else {
    if (year % 100) {
      return true;
    } else {
      if (year % 400)
        return false;
      else return true;
    }
  }
}

All code has to be unit tested, so we write this (normally I start with this before writing actual code, but you know…):

function unitTests() {
  describe("leapYear tests", function() {
    expect(isLeapYear(1900)).toBe(false);
    expect(isLeapYear(1971)).toBe(false);
    expect(isLeapYear(1972)).toBe(true);
    expect(isLeapYear(2000)).toBe(true);
    expect(isLeapYear(2003)).toBe(false);
  });
}

And to stay very agile, I wrote some minimal unit testing “library” (individuals over tools, anyone?):

function describe(testName, tests) {
    var groupTitle = 'Name: '+testName+' - Start: '+(new Date).toISOString();
    console.group(groupTitle);
    expect.nr = 0;
    expect.errors = 0;
    tests();
    if (expect.errors == 0) console.info('All %s tests OK', expect.nr);
    else console.error('%s of %s tests failed', expect.errors, expect.nr);
    console.groupEnd(groupTitle);
}

function expect(x) {
    return {
        toBe: function(y) {
            if (x === y) console.info("%s: OK 👍", expect.nr++);
            else console.error("%s: Error 👹", expect.nr++), expect.errors++;
        }
    };
}

The unit tests all passed. Can’t wait to start with refactor step 1: removing unnecessary nesting. One step at a time.

function isLeapYear(year) {
    if (year % 4) {
        return false;
    }
    if (year % 100) {
        return true;
    }
    if (year % 400) {
        return false;
    }
    return true;
}

Yes…, much better! All tests pass. Refactor step 2, fold down into one if:

function isLeapYear(year) {
    if (year % 4 || (!(year % 100) && year % 400)) {
        return false;
    }
    return true;
}

And for the heck of it, remove the unnecessary if as well:

function isLeapYear(year) {
    return !(year % 4 || (!(year % 100) && year % 4000));
}

Oopsy. The fourth test failed. Just a typo, no worries. And since there’s already too much negativity around, I’ll fix that in the next iteration, and while we are at it, move the negation to another function.

function isLeapYear(year) {
    return !isCommonYear(year);
}
function isCommonYear(year) {
    return year % 4 || (!(year % 100) && year % 400);
}

The committee unanimously decided: don’t rely on javascript’s truthiness, we want explicit code! So fixing that:

function isLeapYear(year) {
    return !isCommonYear(year);
}
function isCommonYear(year) {
    return year % 4 != 0 || (!(year % 100 != 0) && year % 400 != 0);
}

Refactor step 6, the overload of negativity was back. Fixing:

function isLeapYear(year) {
    return !isCommonYear(year);
}
function isCommonYear(year) {
    return year % 4 != 0 || (year % 100 == 0 && year % 400 != 0);
}

Refactor step 7 should be a charm. I still don’t like the code at all, so f$*# it, just use the native function:

function isLeapYear(year) {
    return new Date(year, 2 - 1, 29).getDate() == 29;
}

Done!

Code can also be found here on GitHub.


Jekyll template for JSON Feed

Permalink - Posted on 2017-05-19 00:00

When I learned about JSON Feed, I immediately liked the idea. It’s like RSS/Atom, with the good parts (it’s de-central) and without the bad parts (no more XML, well thought of standard attributes).

I’m not to sure how it will be used in practise, but it was easy enough to create a Jekyll template (source on GitHub). I learned it’s handy to add a base-tag to the content_html-attribute, after trying this app.

And I made myself a nice square logo too.


JSON, the game #2: The parsings

Permalink - Posted on 2017-05-14 00:00

For some reason, I imagined the next step in the development of the game was to make the ‘block’ move. Like up and down, and sliding to the left. For agile reasons, I want to make progress that is reflected and visible in the software. So no spending time at writing libraries first. You probably end up writing stuff you don’t even need. But when starting, I realized the partial-JSON part needed to be worked on first.

To display the partial-JSON, I need a model of that JSON. That model should be capable of annotating the partial-JSON with grammar issues (like missing bracket/comma, incomplete strings or just plain errors). Indentation should be addressed too. Also some dimension-data is needed, so we can determine whether the block can move up/down and when it has reached the partial-JSON surface (sorry, I can’t stop thinking in planet metaphors).

When pondering on these requirements, I realized a tokenizer/parser was necessary. A library! Not very agile, right? Perhaps skipping the grammar issues first and add it later would have been a wiser choice. We will never know. Writing a parser does takes some time, but it sure is fun.

First I started writing a tokenizer. And since it’s not your average code, I used the most annoying coding convention I could think of. I learned this style with Turbo Pascal in my BBS days. Years later I discovered you can use it with languages like JavaScript, CSS, C# and even PL/SQL. But it’s too annoying for everyday use. Not only do you get The Eye from your colleagues; every editor I’ve tried actively works against you by messing up the indentation. Again, and again. With. Every. Single. Edit.

The tokenizer splits the JSON into tokens like a string, boolean value or comma. With the parser we then can reason about tokens instead of characters, which makes life much simpler. Because we work with partial JSON, the tokenizer is made to recognizes unfinished strings and other values. Every token has an is_complete-attribute, so when rendering we can show if a brace is missing, or a string is unfinished.

HTML/CSS mock

The parser was a dragon to me. I made a lot of diagrams to create a state machine, see above, and played with GraphViz (which is pretty cool, and a little weird). Finally I thought the state machine was right, and started coding. After writing some unit tests and identifying some failures, I did realize I went in the wrong direction. A state machine is apparently not the best solution to parse JSON and the answer was right in front of me. While I was focussing on the nice flow diagram at json.org (which I coincidently also knew from the Turbo Pascal manual; I know, grandpa speaking), the program I needed to write was listed as an inset on the right of that same web page! object := {} | { members }… Elementary, dear Watson…

A well, adventures in failure. Start all over, and everything will be fine. At the moment, I have a validating parser (source here). It says whether the JSON is correct or not. There are still loose ends, which I will fix when needed. For example, I ignored Unicode for a big part and focussed on ASCII for now.

On a side note: I also wanted to check out those new EcmaScript 2016 features, since every browser seems to be supporting them. It’s nice to see the language is evolving, after multiple timespans of stagnation. The best feature IMHO is string interpolation.

Next step is adding code to the parser for annotating tokens, and insert missing-tokens. And render the thing in HTML naturally.


JSON, the game #1: Bootstrapping it

Permalink - Posted on 2017-04-30 00:00

Around a year ago, I had the daft idea to create some nerdy JSON-game. I had good fun thinking about some concepts, made some notes, and that was about it. Until now that is. The game: It’s coming… It has already started. To keep me focussed, I will keep a journal of the creation, and you’re reading the first part.

I got the ideas from series like the Brent Simmons’s Vesper Sync Diary and Jon Skeet’s Reimplementing Linq to Objects. I found them enjoyable; a bit of a nerdy soap opera. And now is the time for me to get of my comfy sofa and produce some soap of my own.

The idea of the game: JSON tokens are coming in, and you need to place them correctly. The initial form of the game will be Tetris-like with your head on your right shoulder: the tokens come in from the right and go to the left (alternative gravity you can think). However, this form might change from level to level (I’m thinking of the partial JSON document as a starship, crashing into JSON stars/tokens as it cruises through the JSON universe).

The first step is to create some user interface mockup. A guy gotta start somewhere. My weapon of choice is HTML/CSS. At the top we have a dashboard providing some game details. Unformatted JSON will do for now. The playing field (where the partial JSON is) will have a fixed width, while the height might grow during gameplay when tokens are inserted between lines.

HTML/CSS mock

Positioning is done with the em and ch CSS units with a position relative/absolute container-combo, so I can position things absolute within the relative container. Every character is one ch and every line is one em. One little problem though: em is font-height, not line-height. And a line-height of 100% just doesn’t look right. But there is no such thing as a line-height unit. (Or is there?) This is easy fixable with a calculation, but line-height will appear in multiple places in CSS.

Also some color coding needs to be added, so we can identify unbalanced grouping tokens, missing separators, incomplete tokens and downright errors. That’s why I’m not using a pre-element. I don’t have a definite idea about gameplay, but some ideas come to mind. An obvious solution for an error would be “Game over”. This can also be postponed by counting “lives”. The error will vanish and you loose a life. Or an error could be cleared with the incoming JSON token \b. That choice will depend on the level. But I digress.

This is not all markup we need (we will need a dialog-box, for the start and end of a level), but it will do for now. I put the source-code on GitHub, and every instalment will point to a commit so you can see how this game comes to shape. You can also “run” the game here (nothing to play for now).

I hope to find a good balance between enjoyability, a bit of fun and some technical remarks. And I like to hear your thoughts on Twitter.

The next instalment will be about moving those incoming tokens.


Only my warnings

Permalink - Posted on 2016-09-08 00:00

Don’t you hate to be put in a situation like the following?

You are assigned by your company to add some functionality to some software at some client. The client has standards and practices in place stating you can’t checkin code that produces warnings, only to find out that a clean checkout produces loads of warnings when building!

But you can’t fix 😢 those warnings. You, the super star programmer™ (whose boss is getting paid big dollars for high quality, virtually bug-free software), cannot get rid of those pesky lines of inability…

For starters, why judge those warnings in the first place. You’re just the new guy, you don’t want to get into any trouble. Also, by solving warnings, you may introduce new bugs (even though you’re super competent, after all creating bugs is just a matter of probability). Nobody wants that! And finally, you’re a professional. The client is only paying for the new functionality, not for you to clean up the place. And about your collegues, you don’t want to hurt anyones feelings. So in short: the man says no. No way fixing those warnings, José!

Situations like these inspired us to envision a new kind of solution to those issues at hand. Let me introduce to you, without further ado, the Visual Studio extension Only My Warnings.

When your solution is under source control a new list button is added to the Error List pane, with the options All, Only Mine and Local Only. With the option Local Only selected, the pane will only show errors, warnings and messages caused by local changes, i.e. by you! All other messages are hidden, so you don’t have to deal with them. Victory!

screen shot

The extension doesn’t get in the way; it only adds this one list button. When selecting Only Mine-option, the tool will gather all messages from your checkins, and show only the messages caused by you. And it follows branches, so you can focus at the feature that is imporant at any given moment.

Now you can be productive, and still have a chat with your collegues without having an argument! While using this extension, you will contribute to your team’s productivity. You will be a team productivity enabler! That’s how 10× developers are bred! In a way, only my warnings contributes to world peace.

For now, the extension is still in its early alpha phase. If you want to participate in the beta-program, or want to get notified when the extention will be released to the Visual Studio Gallery, please fill out this form.

(this is a blog post in the series: I’m perfect, communicate better with tools)


A console.log() adventure; pimped

Permalink - Posted on 2016-03-06 12:45

Over a year ago, my interwebfriend secretGeek created a thing. I created a fork, and pimped it into this (and copied some of his blog lines too). I urge you to go and try it out before you read on. Unfortunately you’ll need to be on a desktop computer, not a mobile phone.

Go there now.

In case you don’t have a desktop computer anymore (woah, futuristic!), or have already tried it out, I’ll give some spoilers and discussion now.

Spoilers

Actually, I’ll give some space before the spoilers. Scroll now for spoilers.

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

↓ spoilers ahead ↓

Here is secretGeek’s blog-entry. When playing the game I had loads of fun. Keeping a map on graph paper, just to make sure the map is deterministic and doesn’t use some random numbers. After some more playing, I started looking at the code and wanted to tinker with it. So I forked it. I had some wild and interesting ideas.

But somehow, nothing happened.

I guess I was overthinking it. A year later, I remembered one time at work while being bored, I created the so called mini-webventure. I didn’t think too much back then, so why do it now?

So I just started. After running around in the forest (in the game, that is), I got tired of entering parenthesis. And with properties around in all browsers nowadays, there’s no need for it. So instead of typing n(), you now can enter n to go north.

An other thing: in a JavaScript game, I don’t consider inspecting and modifying variables cheating. So I prevented that with an iife and some help of strict mode (to eliminate global variables).

Multiple lines are now returned after entering a command, so they are displayed in the same font and color. And deaths are a bit more dramatic now. You should really try it, if you haven’t already…

After dying too often, implementing load/save was next. First I just saved the game state, but then I realized this was another way to cheat, so now only the entered commands are stored. Then I realized, a demo-mode is very easy to implement. Couldn’t resist it, but it’s hidden somewhere in the game.

I didn’t want to change the map or story. Just wanted to share the fun I had, both playing and pimping the game.


First post!

Permalink - Posted on 2016-01-09 19:30

OK, I started yet another blog.

Here are the predecessors (and thank my public backup service for most of this):

I also have a Tumblr micro-blogging thing called dd3v.