Posts

Proof of Work (PoW)

Image
Proof of Work (PoW) is a central part of cryptocurrency and blockchain technology. But what is Proof of Work (PoW) and why is it so important to cryptocurrency? Here’s everything you need to know about the protocol that gave us Bitcoin (BTC). What Is Proof of Work? Proof of Work (PoW) is a protocol designed to make digital transactions secure without having to rely on a third party. Essentially, PoW requires members of a community to solve challenging puzzles. This work builds on previous puzzle solutions. As a result, PoW is a way of verifying current and past transactions. Additionally, the work that goes into solving the puzzle generates rewards for whoever solves it. In the world of cryptocurrency, that’s basically what “mining” is. Proof of Work (PoW) is a foundational concept for anything having to do with blockchain. Background The concept behind Proof of Work (PoW) was originally invented by Cynthia Dwork and Moni Naor. More specifically, they explained the i...

JavaScript Promise

Nothing weights lighter than a promise This maybe true regarding to human promises, however in the programming domain, promises are always kept. Following this optimistic note, today we'll be talking about JavaScript promises. Event Handling Problem Let's see what promises are good for and their basic capabilities starting with a problem they come to solve. Events are great for things of a repetitive nature like keydown , mousemove etc. With those events you don't really care about what have happened before you attached the listener. On contrary calling services and processing their response is a completely different kind of beast. Have a look at the following function, which reads a json file and returns it's content or an error in case of something goes wrong. function readJSON(filename, callback) { fs.readFile(filename, 'utf8', function (err, res) { if (err) { return callback(err); } try { res = JSON.parse(res); ...

Operation Timeout in MongoDB

Today I'd like to talk about a problem every MongoDB developer should be aware of - operation timeout. I have surely risen a lot of eyebrows and a few snide remarks, but let me reassure it's worth reading. Connection vs Operation Timeout So where do we start? The main problem with operation timeout in any database, not specifically to MongoDB, is the developer's confusion between connection timeout and operation timeout. So let's clear the air right away by clarifying the difference. Connection timeout is the maximal time you wait until you connect to the database. Whereas operational timeout is the maximal time you wait until a certain operation is performed, usually CRUD . This happens after you're already connected to the database. Post MongoDB 2.6 If you've just started using MongoDB or had a luck to upgrade your existing instance to the newest version, that being 2.6 at the moment of writing, then you should know there is a build-in support ...

Dimension reduction with Python

Image
Introduction Sometimes, no matter how good an algorithm is, it just doesn’t work. Or worse, it doesn’t pick up anything. Data can be quite noisy, and sometimes it’s just about impossible to figure out what went wrong. It's worth noticing that the most interesting machine learning challenges always involve some sort of feature engineering, where we try to use our insight into the problem to carefully craft additional features, that the machine learner hopefully picks up. Garbage in, garbage out, that's what we know from real life. Not surprisingly this pattern also holds true, when applying machine learning methods to training data. To tackle the issue, we will go in the opposite direction with dimensionality reduction involving cutting away features that are irrelevant or redundant. There are several good reasons to trim down the dimensions as much as possible: Most of the models hate high-dimensional spaces and superfluous features, which often irritate or mislead th...

JavaScript Singleton Design Pattern

Image
In the previous articles we discussed Factory , Builder  and Prototype design pattern . Today it's time to draw a line under creational design patterns by talking about Singleton Pattern . Even though it's the most well known design pattern among the developers, the thought of writing one in JavaScript, makes most developers tremble. Naturally there is no reason for that and in fact implementing it is not that big of a deal. But first, let's see how it looks in the following illustration: Basically our singleton contains one instance of itself and returns only it. Client cannot create a new instance or get other instance then one proposed by singleton. So how do we implement it? The same way, like in any other language - using static classes. To brush off the rust, please read Object Oriented JavaScript article. var Singleton = (function () { var instance; function createInstance() { var object = new Object(); return object; } ...

What does “permissionless” mean?

Image
At the heart of the much-hyped “blockchain” technology lies not a blockchain, surprisingly, but a consensus mechanism. A consensus mechanism does what it says; it helps everyone on the network agree, or reach consensus, on a shared computation and records of that computation. In the Bitcoin network, for example, the shared computation is the continual creation of a list of digital currency transactions made between users. In Ethereum it’s the state changes of a globally-accessible virtual machine. A fundamental question in the design of any consensus mechanism is who can participate and how do they participate in order to reach consensus over some shared computation. For many years it was assumed that useful consensus mechanisms could only be developed if the participant computers were identified through channels outside of the decentralized computing system itself. In other words, it had been assumed that useful consensus mechanisms could only be designed as closed or permissioned ...

Hyperparameter optimization with Python

Image
Introduction In the previous articles we introduced several linear techniques, where as you have probably noticed, we provided the algorithms with several parameters. The dependence of machine learning algorithm upon learning parameters is a common case though and one has to check the performance of various parameters to achieve the best results. The task of course is no trifle and is called hyperparameter optimization or model selection. It is the problem of choosing a set of hyperparameters for a learning algorithm, usually with the goal of optimizing a measure of the algorithm's performance on an independent data set. Implementation Grid Search The traditional way of performing hyperparameter optimization is a grid search, or a parameter sweep, which is simply an exhaustive searching through a manually specified subset of the hyperparameter space of a learning algorithm. Scikit-learn provides us with a class GridSearchCV implementing the technique. Let's try to ...