Kazu's Log

Dec 30, 2016

See you!

My new blog will be in blog.8-p.info. See you!

Sep 12, 2016

Moving my Japanese blog

I started a new Japanese blog on blog.8-p.info.

I had been using the domain from 2005 to 2011, then I started a one-domain-per-year experiment. But 2016.8-p.info would be the end of the experiment.

Jul 25, 2016

Who is writing response headers on Tomcat?

org.apache.coyote.http11.AbstractHttp11Processor#prepareResponse() is writing HTTP headers. This method knows a lot about HTTP, such as which status codes have a response body.

        int statusCode = response.getStatus();
        if (statusCode < 200 || statusCode == 204 || statusCode == 205 ||
                statusCode == 304) {
            // No entity body
            getOutputBuffer().addActiveFilter
                (outputFilters[Constants.VOID_FILTER]);
            entityBody = false;
            contentDelimitation = true;
        }

Then the method adds/removes some of the headers based on the knowledge.

A Tale of Two Responses

response here is org.apache.coyote.Response which is declared in org.apache.coyote.AbstractProcessor. But the class doesn’t implement HttpServletResponse. Instead Tomcat has org.apache.catalina.connector.Response which implements the interface and prepares org.apache.coyote.Response inside.

Both org.apache.coyote.Response#setHeader() org.apache.catalina.connector.Response#setHeader() have checkSpecialHeader(). The special headers such as Content-Length and Content-Type are treated differently.

Jul 9, 2016

The first half of 2016

There are 2 reasons to write this post. First, this week’s the Stranger is about Best of the First Half of 2016 and it reminds me that the first half is over. Second, I tend to use my blog to say “hey, I’ve started this cool thing” but some of them lose the momentum after that. So I need to confess about.

IoT

I was playing with NodeMCU in Q1. That was fun, but the project had been ceased these days. Meanwhile I bought Arduino MKR1000. I know that’s crazy…

Also I went Ada’s Technical Books and Cafe. That was a pretty cool place!

Java

I’ve been using Java and the below posts are by-products.

Java 8 is okay for me. The historical baggages make the language uncool. For example, Collections.unmodifiableList() returns a list which is immutable, but the class of the list is mutable!

OS X

As like Java, I’ve been using OS X and there were by-products.

Again, as like Java, OS X (or macOS?) is okay for me. Apple is making that different from “just Unix”, by introducing launchd and System Integrity Protection. On the other hand, there are a few shiny new options like Chromebook, Windows Subsystem for Linux (Running i3 Window Manager on Bash For Windows was interesting) or Dell’s Linux laptop.

JavaScript, Go and Perl

I learned JavaScript and Go a bit. Also there was a news from Perl.

I personally don’t like them. I like statically-typed, functional-flavored languages. That’s sad to realize I haven’t write anything about Scala yet.

Visualization and Machine Learning

That’s a sad section. I wanted to spend some time on them, but I didn’t. I dropped out of Andrew Ng’s Coursera class.

I’m not sure what I can do in Q3 and Q4.

Other than that…

On the first post in the list, I wrote

I will focus on technical topics in a few areas to market myself.

The one of the areas was IoT, but apparently it didn’t work well…

Japanese

I started my blog as an English blog, but there were few Japanese posts.

To be honest, I thought that writing Japanese would result more reaction because most of my readers are still Japanese, but I admit that I was wrong. I don’t have much readers compared to, let’s say 2012 or 2013. Also I got readers by writing about tech, not about myself.

What’s next?

I haven’t decided anything, but there are a few things I’d like to keep in mind…

  • Writing something and getting reaction is fun and interesting.
  • There was no focus in the half of this year, at least from my writings.
  • I won’t be super-active as a blogger. I don’t have to be.

See ya!

Jul 8, 2016

Ansible or Fabric?

Maybe that’s apples and oranges, but I tried both of them recently and decided to use Ansible to configure my Digital Ocean server.

Ansible has a thick abstraction layer. The configuration which is called “playbook” is in YAML, there are commands like package, file or synchronize. I didn’t get that first. Why didn’t you just use a general-purpose programming language and Unix commands?

So I started from Fabric, which used Python mostly as is. Then I wanted to skip some of Unix commands based on the state of the server, such as “don’t do ‘ln -s’ if the exact symlink is already there”.

That’s where Ansible’s playbook excels. Writing the procedures to reach the desirable state, with possible “skip X if A” checks is difficult and it would be different from what you do in ssh. Just write Unix commands would result either a slow or verbose script.

The playbook and the commands are desiged to write the desirable state itself, not the steps to reach the state. And skipping unnessary parts is Ansbile’s job. The learning curve might be steep, but I now think that is worth to do.