Friday, November 10, 2017

The rise of localhost

I noticed a pattern in dex world, where you build client backend to participate in the network, and then build a web app that simply connect to localhost:someport for the UI.

To check my scuttlebutt updates, I opened up http://localhost:8027/. For those using Ethereum Parity wallet, they can open it at http://localhost:8180/. ZeroNet users are browsing at http://localhost:43110/.

But Parity for example, try to make it seamless, they still provide a dns - web3.site which then redirected to home.web3.site which simply resolved to 127.0.0.1. But this I think bring up some problem, especially non-tech user which think that Parity is a website hosted by Parity Technologies. I seen this in a some articles about the latest bug.

Wednesday, October 11, 2017

The first step in learning new programming language

Is to prepare the basic environment where you can freely try and experiment with the new language features and tools. Maybe because I'm not programmer type person, but more as tinkerer/builder, I hate learning the language syntax and stuff.

For years after I started "learning" Python, I can't barely write any Python code. But I have manage to try lot of Python cool apps because I have that environment for me to experiment with all Python based applications. All these cool apps that get me hooked to the language, not the syntax or whatever language features. And in my experiences, this is one reason why people failed to get hooked on the new language they want to learn. They started learning with some of the language syntax and eventually get bored, because not so much interesting stuff there. In whatever programming language, it's the ecosystem that made it lively, and where the real work happened.



Early this year, I made it a point to learn Go programming language. It's almost a year now and similar to my Python experience I mentioned above, I can't barely write any Go code. But I have an environment where I can try a lot of Go based applications, and this is the reason I'm still hooked to the language even I haven't manage to write my own code yet. Back with Python experience, I'd only manage to know Python and write Python code after I got my first Python job. That was years after I started learning the language.

The reason this work I think similar to when learning human language. To master the language, you need to practice it. And to practice the language, you need to be in an environment where the language being used. That's it, the environment. So instead of trying to understand the for loop or the class syntax, I spent time to understand how packaging and deployment work, so I can actually run the application for other people to make use of it.

So start to invest your time in having the environment first, whenever you want to learn any new programming language.

Thursday, September 14, 2017

Notes on AWS Lightsail

Finally, I'm trying Amazon Lightsail. Just few notes:-




1. The direct console is great. This is basically what EC2 should have, instead of web ssh console. You need this console to verify the ssh key fingerprint before connecting through ssh first time.
2. There's simple firewall manager. Only port 22 and 80 opened by default. Click Manage from the instance menu to get into the firewall manager.
3. Now there's apac region !

Friday, September 8, 2017

A brief look into nginx unit

So nginx has come out with it's own application server that can run multiple types of application from PHP, Python and Go, with more languages support coming soon. Deployment is always my topic of interest so this kind of news definitely caught my eyes.

There's not much technical information yet, other than the official blog post. I'm quite interested to know how the python support being implemented. The Application model also remind me to the Webfaction hosting model and with unit HTTP API, it provide possibility to implement something like Webfaction hosting panel where you can add new application and manage it all through just a web interface.

Reading through the source code of python module support, it look like python wsgi application is being executed in-process through python C API (my guess), particularly if you look at the line 337:-

result = PyObject_CallObject(nxt_py_application, args);

For Go application however it simply execute the Go built-in http server and communicate through that. The current implementation is merely 100 lines compared to python implementation which is almost 1000 lines.

Enough with all the theories, I decided to give it a try. It has deb packages for Ubuntu Xenial. Just follow the documentation how to install it through apt. The docs however seem missing on how to start unit after installing it. After scouring around the apt file then I know the binary is named as unitd, so to start it:-

sudo systemctl start unitd

After that you can start communicating with unitd through the HTTP JSON API:-

sudo curl --unix-socket /var/run/control.unit.sock http://localhost/

Btw, it also through this I learned that curl has unix socket support !

For the rest, you can just follow the docs. I did try with simple wsgi applications and discovered few issues:-
  • https://github.com/nginx/unit/issues/17 - How to apply changes to our app script ?
  • https://github.com/nginx/unit/issues/16 - All applications and listeners lost after restarting unitd
  • https://github.com/nginx/unit/issues/12 - How to inject environment variables ?
  • https://github.com/nginx/unit/issues/15 - How to add venv packages ?
That's all for now. Next probably trying it from source instead of packages to get all the latest changes.

Tuesday, August 15, 2017

List of DNS server software

It's been quite a long time I'm not following the recent development in dns scene, especially on the server software itself. In the past, I did try setting up my own BIND installation just to understand how all these things work.

I tweet reminded me back:-
So what else dns server software we have these days other than BIND 9 ?

  • PowerDNS (as in tweet above).
  • CoreDNS - now also a server type plugin of Caddy. It's a successor of SkyDNS.
  • SkyDNS - SkyDNS is a distributed service for announcement and discovery of services built on top of etcd.
  • Knot
  • NSD

Monday, July 24, 2017

How smart-contract is possible in blockchain ?

The idea was derived from the scripting support in bitcoin. Part of bitcoin transaction contain a Script, a stack based language that will be executed to verify the transaction. Complex conditions can be expressed in this language, which has 80 different opcodes including arithmetic, bitwise operations, string operations, conditionals, and stack manipulation.

This language however still pretty limited, such as not having loop and thus not Turing complete. So new blockchain implementation like Etherium expand the idea further to include support for real programming language, thus enabling more complex conditions to the blockchain transaction, which now commonly known as smart-contract.

Sunday, June 11, 2017

How to build your own programming language

I've always fascinated in how programming languages are built and have made it into my 2017's new year resolution to learn building one myself. So here are all the notes collected along the way.

My presentation at Malaysia Open Source Conference - How to build your programming language ? I plan to extend this presentation at upcoming PyCon APAC in this August with an example in Python.

A write up in Malay - Bagaimana bahasa pengaturcaraan dibina ?

A series on building simple interpreter in Python by Ruslan Plivak - Let's Build a Simple Interpreter !

A book on writing an interpreter with Go (Golang). I'm still making up my mind whether to buy this or not - https://interpreterbook.com/.

Free book on building interpreter using Java and then C. This is not complete yet but the author also recommend Interpreter book above in his reply to my reddit's comment.

A classic on building compiler, the original essay was using Pascal. This is my first time trying Pascal and to my surprise the example code (from 1986) still compile in the modern FreePascal - Let's Build a Compiler.

A question on reddit on how to build own programming language.

Creating toy programming language using Python PyParsing library.

An Intro to Compilers - A step by step guide on how a simple "Hello World" in C get pre-processed, tokenized, parsed, optimized and finally compiled to machine language using LLVM frontend and backend tools. Very interesting read and easy to understand.