Through the binary

a full stack enthusiast interested in Javascript / Typescript / Kotlin / Python / React / React Native / (Android & iOS) native / Cloud

Today I was migrating a personal project to create-react-app, then I found my RadioButton stops working in production while it works perfectly in development. After I figured out why, I think it worth noticing people why.

Read more »

Binding Props to the component is a tedious work in React. Especially when you create a form. You may wonder, how to automatically bind these props to some components? Yes, you can, by using React elements.
And you can do more things, like creating elements and inserting them. Which means you can modify the component tree during runtime. Let’s start.

Read more »

Once again, I went back from WebStorm because some annoying bugs which I can’t evaluate variables at runtime. But configuration in Visual Studio code could be a little bit tricky sometime. Thanks to my time spent before, I grabbed an old configuration, after modification, it works flawlessly in the current release of Visual Studio Code. Let’s see how to debug Jest test cases in VSC.

Read more »

I have a class reference and a set of data for initializing the class, I need to create instance of that class dynamically. I get the constructor from the class reference, I loop through its parameters and do a match between that set of data. Then call the constructor.callby(param). All is fine, until one of the property is a custom class rather than a kotlin type like kotlin.Int. Let’s see how to solve it.

Read more »

When you start to learn machine learning, linear regression is most likely to be the your best candidate. Not only because you can re-use the according concepts in statistics, but also you can understand many foundation concept which can be adopted to other machine learning algorithms. I think the most efficient way to learn something is by asking questions, and this is why I wrote this blog. After this blog, even you still have some questions, but I think you will have that knowledge-tree to further dig into.

Read more »

Return an error message is a common task for restful API development. But things will get a little bit tricky when you need to deal with some legacy code base. Since their old dependencies will always cause you trouble. Bottle is a light weight python web framework with a long history, so it’s friendly to the traditional view templating rendering idea but not for json response, at least not for error message. And when the framework is old, Stack overflow won’t save you this time. Let’s see how to solve it.

Read more »

Most often in universal javascript project we tends to use passport.js. But a recent project requires to use the official SDK. The article will walk you through the flow with example code. Hope it could get you started. Even you just use passport.js or other languages, after reading this article, you should understand what happens underneath.

We use plain Express as our backend.

Read more »

If the model is just plain schema, there is not much to test about. But with Mongoose, you can add instance methods and static methods which embeds lots of core logic around CRUD. You definitely wanna test this. In this blog, we will use Jest to test Mongoose model methods.

Read more »

Jest’s document says that you could use done as a parameter to test a function which takes a callback function as a parameter, but is it really the answer to every case? Sometimes, errors in your assertion in your callback will yield a timeout with meaningless call stack. I happened to solve a problem with a different approach. The solution here is not only apply to express middleware, but also to any function which consumes a callback.

Read more »
0%