Lastly, I have decided to create a new library for .NET core that handles (big) prime numbers. You know - testing, generating and other stuff that could be useful for playing with big numbers.
It is obvious that to accomplish this, I needed a service that should generate a bunch of random values. Easy task? Yep!
The only method I need is to generate random bytes that are placed in a buffer - our numbers could much more beyond int/long range, so I have decided to represent numbers as the byte array (like BigInteger it does).
Usage & Testing
Random provider is used to generate random big integer below a specified range, fe.
See snippet below:
Like a model programmer, I wrote some unit tests ran by xUnit:
Disclaimer: Tests are simple as possible to simplify the case.
I have ran my tests and… Testing has never ever finished. Or even failed. Just like an endless loop.
What went wrong
I have spent couple hours to find out the cause of this weird behavior (my tests % snippets are much more complicated).
Indeed, the problem was an endless loop… here:
It turned out, that xUnit runs tests in separate threads. What’s more, Random.NextBytes is not threadsafe, so… it started to fill bytes with 0 when more than one thread accessed it at the same time.
In a previous blog I have written about my mini-PC that was setup as the server. I have decided to move everything from OneDrive (my OneDrive space was limited from 30 Gb to 7 due to last Microsft rule changes) The most known self-hosted solution is ownCloud. Written in PHP, easy to install - it just fits requirements. Unfortunately, it turned out that the newest version has no Windows support (via FastCGI).
After digging somewhere on the internet I have found syncthing. It offers an alternative approach. There is no central server - everything is based on distributed sharing. Dedicated client for windows (client app is server itself), easy install. So what is the problem? Imagine the situation, when you are at friend’s home. You need to download the file from your cloud. A friend didn’t know about syncthing before. So you need to download the app, allow new client to “join” your devices network and viola. There is no web client that could be very use full in some scenarios.
I could not find any 3rd solutions that could offer some PHP-or-whatever site to integrate with the new cloud. But wait. I’m a programmer!
Syncting Web UI
Syncthing Web UI is web app that reads metadata from syncthing config file and offers basic functionality as web client:
Welcome to my new blog. As you can remember, the old one was setup for DajSięPoznać contest. A quality of posts was low (sic!) so I decided to start from the scratch. No posts will be moved (unless I find some time) but believe me - there is no good content to read ;)
Current blog was setup with jekyll so speed of page load should be like a thunder.
How do you like a dbyll theme?