Kazu's Log

Apr 5, 2016

How I came from Japan to Seattle

I wrote a short Japanese essay on JungleCity, Seattle’s largest Japanese news and community portal. The essay is about how I came from Japan to Seattle, especially on various supports I got from the company.

I’m not sure whether working in the States is easy or not. I’ve been in here for just less than 2 years. However I can say that coming to the States may be easier than you thought, if you are working for a subsidary of an American, probably large company.

I wasn’t aware about things from L-1 visa to relocation agents until I finally made a decision to come to Seattle. I was actually worried about the H-1B cap. So I’d like to share what I learned.

There was another essay that I co-authored with Kenji-san. But, well, hornestly speaking, that one was mostly written by him :)

Apr 2, 2016

My first Slack bot

Slack is the hipster’s IRC. Honestly speaking I don’t know why people love Slack so much, but Samuel Hulick already wrote Slack, I’m Breaking Up with You that might explain my concerns. So I won’t write about that here.

Anyway Slack has become the new normal, and I wrote a small “bot” that forwards Pivotal Tracker’s updates to Slack.

SIJP-ORG/mercer is the repos. The main index.js file is just 69 lines long. Well, I know that putting everyting in index.js is not so great…

SDKs (service clients)

Unlike Amazon Web Services, Slack itself doesn’t provide SDKs for various languages. There are unofficial SDKs, but I’d like to try the official ones first because it might be less troublesome.

Python and JavaScript (Node) are “supported” by Slack.

So I decided to use node-slack-client because I can’t write Python without googling.

For Pivotal Tracker, there is node-pivotal which is not owned by Pivotal, but introduced at Pivotal’s website. However the library’s doc is linked to the API v3 reference and I’m bit concerned about that.

So I decided to use pivotaltracker instead.

Bluemix instead of Heroku

Before I tended to use Heroku because it was free (as in beer) but the new pricing plan is not great for keeping a Slack bot up.

The new free dynos now allow up to 18 hours of activity in a given 24 hour period for 1 web dyno, 1 worker dyno and 1 one-off dyno started by heroku run or Heroku Scheduler. Your application on free dynos sleeps automatically during quiet periods.

So I decided to use IBM Bluemix instead. Bluemix doesn’t have bluemix command, but you can use Cloud Foundry’s cf command to upload apps to Bluemix.

In other words, Heroku-like services are now somehow standardnized. That is acutally surprising for me!

Cooking my breakfast

Writing a small software is like cooking my breakfast by myself. It is quick and fun, even the quality is just “okay” :)

Mar 29, 2016

How does SLF4J know about multiple logger implementations?

One day, I got a small warning from SLF4J.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [...!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [...!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

This was because I had multiple SLF4J implementations in the classpath. So I cleaned up the dependencies to reduce the implementations. Problem solved.

But how does SLF4J know about multiple logger implementations?

LoggerFactory to StaticLoggerBinder

LoggerFactory.getLogger(Class<?>) is the main facade of SLF4J. It ultimately calls bind() to initialize StaticLoggerBinder.

Here is the trick. All SLF4J implementations provide own StaticLoggerBinder. They simply define org.slf4j.impl.StaticLoggerBinder class and it is perfectly fine in Java world when those implementations are in different jar files.

findPossibleStaticLoggerBinderPathSet() is the method that uses ClassLoader to find a possible implementation of the class. The result array is passed to reportMultipleBindingAmbiguity() that shows the warning.

slf4j-api’s StaticLoggerBinder

slf4j-api also defines StaticLoggerBinder as well, but it gets removed by pom.xml. So the jar doesn’t contain the class.

Mar 8, 2016

4 C SDKs for ESP8266

I’ve just opened a pull request on esp-open-rtos. This is one of the SDKs for ESP8266, and I’m going to use it for my upcoming project.

Using esp-open-rtos is not the only way to program ESP8266 in C. First there are non-OS SDK and RTOS SDK from Espressif. ESP8266 Reverse Engineering Wiki has a nice article about the difference between 2 SDKs and their history.

Personally I haven’t used the official SDKs directly. Instead I’m using esp-open-sdk and esp-open-rtos. The former combines the non-OS SDK and free softwares for ESP8266 such as GCC, crosstool-NG, and newlib nicely. The later is the fork of the RTOS SDK and it uses esp-open-sdk as its toolchain.

Mar 6, 2016

Hot Chocolate 15k/5k Seattle

I’m an occasional runner. I sometimes run around where I live. I did Color Run twice (Chiba and Seattle) and I will be in Seattle’s one this year as well. However I hadn’t ran a serious “race”… So I finally did it!

I ran for Hot Chocolate 15k/5k with my wife today. I ran from Seattle Center to Pike Place Market, from the market to Fremont, and from there to back to Seattle Center. It was harder than I thought. Seattle has a lot of hills, it was raining, and 15km was way too long for me. The record wasn’t so impressive probably, but again, that was my first serious race!

I’d like to run a full marathon someday, but I do need more practice even before doing a half marathon.