Thursday, June 30, 2016

Live Streaming & JS

Presentation on Live Streaming & JS is now available by link. Held on IT Weekend Kharkiv. Shows the usage of Media Source Extensions, nginx-rtmp-module, MPEG-DASH and OBS.

Try it out
  • docker run -p 8080:8080 -p 1935:1935 adolgarev/nginxrtmp
  • start OBS and specify RTMP URL rtmp://localhost/myapp and Stream key mystream
  • Goto http://localhost:8080/dash.js/baseline.html
The result

Wednesday, June 29, 2016

The easiest way to use letsencrypt with jwilder/nginx-proxy

At jwilder/nginx-proxy issue can you add Let's Encrypt one can find discussion on how to add letsencrypt support for popular nginx-proxy for docker.
The easy way to do this that works for a while on our production environment is docker-letsencrypt-nginx-proxy-companion. Features follow.
  1. Automatic creation/renewal of Let's Encrypt certificates using original nginx-proxy container.
  2. Support creation of Multi-Domain (SAN) Certificates.
  3. Automatically creation of a Strong Diffie-Hellman Group (for having an A+ Rate on the Qualsys SSL Server Test).
  4. Work with all versions of docker.

Thursday, November 13, 2014

Ftp server with zero configuration

Log in to the server, pip install pyftpdlib and type in python interpreter
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
authorizer = DummyAuthorizer()
authorizer.add_user('test', 'test37', '/some/dir/')
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(('0.0.0.0', 5021), handler)
server.serve_forever()
Try it out
~$ ftp
ftp> open X.X.X.X 5021
Connected to X.X.X.X.
220 pyftpdlib 1.4.0 ready.
Name (X.X.X.X:adolgarev): test
331 Username ok, send password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> passive
Passive mode on.
ftp> ls
227 Entering passive mode (X,X,X,X,X,X).
150 File status okay. About to open data connection.
-rw-r--r--   1 4001     4001      3622358 Aug 20 08:17 xxx
drwxr-xr-x   3 4001     4001         4096 Jul 09 10:57 xxx
-rw-r--r--   1 4000     4000      3585261 Jul 09 12:49 xxx
drwxr-xr-x   3 4000     4000         4096 Aug 20 08:35 xxx
226 Transfer complete.
Even more, it is surprisingly fast, see comparison to other implementations.

Wednesday, October 15, 2014

Tuesday, September 9, 2014

What one can learn from Game AI development

Below is an excerpt from STRIPS: A New Approach to the Application of Theorem Proving to Problem Solving, R. E. Fikes and N. J. Nilsson, Artificial Intelligence 2 (3--4), 1971. (pdf):
STRIPS belongs to the class of problem solvers that search a space of “world models” to find one in which a given goal is achieved. For any world model, we assume there exists a set of applicable operators each of which transforms the world model to some other world model. The task of the problem solver is to find some composition of operators that transforms a given initial world model into one that satisfies some particular goal condition.
The basic idea is that a world model is modified by operators, which have a set of preconditions and side effects. STRIPS planner is used to find out how to apply these operators to achieve the goal given some state. (But don't confuse this approach with a Prolog programming language that operates with formal logic on top of knowledge base without any side effects.) The original algorithm without any optimizations is simple: find which operator achieves the goal, then if operator's prerequisites are not satisfied your new goal is to satisfy those, in the end choose the easiest plan. STRIPS was featured in F.E.A.R. and a number of other games, that was (and to some degree still is) a cutting edge in game AI development.

The main thing one can learn from this is a clear segregation between WHAT and HOW. WHAT is your goal defined in terms of conditions applied to the state (defines a subset of all possible states). HOW is a set of operators that do the job. Everything else does planner that doesn't depend on the domain and can be easily reused from project to project.

An example
Imagine you are about to implement private cloud solution. You can implement a set of operators like bring interface up, make a bridge, obtain address via DHCP, mount volume, create container with lxc, etc. Each of these operators have prerequisites like to obtain address via DHCP an interface must be up and running. Define states in terms of MIBs and use SNMPv3 to get/set state. Then you can easily define goals like provision a vm and planner will do it for you using defined operators. The good news is that if something happens in the middle of vm provisioning (state changed from A to A') planner can deal with this by providing a new plan. If you need to integrate someones solution just add a few new operators and planner will benefit from them immediately. Compare and contrast this approach to OpenStack solution that is obsessed by (micro-)SOA ideas not in the best way.
Can this be applied to the web development? Consider you have a bunch of operators with arguments, prerequisites and side effects defined. In case one does not handle these operators as black boxes and with the bit of introspection understands prerequisites and side effects planner can build workflows by connecting operators together and it can also build an interface to input arguments for operators in the plan and react to unexpected (what if Paypal payment failed, planner can suggest you to pay in another way). The only thing left is to present current state in a nice way to the user.

Final thoughts
One day devs used macro assembler, then C, nowadays OOP and FP hit the fan, but we need to go further and program in terms of business rules and goals. Even AngularJS and Backbone are too low level.