An Interesting Task for an Interview. Currying and Partial Application of a Function
Written by Nick Makarov
I am currently attending some job interviews. Some of them are boring, others are interesting. During one of the interviews they asked me to write a function that could add two numbers. So, I wrote: it ('should add two numbers', function () { var add = function (a,b) { return a + b; }; assert.equal(add(2,3), 5); }); — «But what if that the function signature should be something like add(num1)(num2)?» — «No problem!» I think that they want to check whether I know about returning functions from functions. So, I wrote the following: it ('should be called like add(num1)(num2)', function () { var add = function (a) { return function (b) { return a + b; }; }; assert.equal(add(2)(3), 5); }); — «But what is we know the first addend beforehand and the second one will be known later? Then what?» I think that they’re talking about currying, soA Cheat Sheet for HTTP Libraries in C++
Written by tangro
Unfortunately, standard C++ library provides no tools for working with HTTP protocol. Therefore, when we want to run some REST service, parse a webpage or write a simple bot or web crawler, we always wonder which library is better and faster in use. Sometimes a project already uses some framework (or even several). But how do we create an HTTP request using available facilities? Not to get confused each time performing such tasks, I decided to make a cheat sheet with examples of HTTP requests in C++ using different libraries. I guess Kukuruku is the best place for keeping such cheat sheets. We’re going to take a look at the following libraries: WinInet WinHttp Casablanca Qt POCO wxWidgets Boost.Asio libcurl neon .NET (С++/CLI) IXMLHTTPRequest HappyHttp cpp-netlib WinInet Website: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385483(v=vs.85).aspx Platform: Windows 95 and later Example #includeSome Useful and Interesting Things for Web Developers
Written by Kukuruku Hub
Dear %username% , I have recently come across several interesting and useful tools/libraries/events I would like to tell you about. DC.js This library allows creating great multi level/scalable cross-platform charts and diagrams providing instant feedback on user's...
Bead Sort
Written by Valery Makarov
Today we’re going to review an algorithm that was invented 11 years ago. Its “prototype” is a counting device with three thousand years of history. Authors The sort was presented in 2002 by three mathematicians from the University of Auckland, New Zealand. They are Joshua J. Arulanandham , Cristian S. Calude and Michael J. Dinneen . They work in such fields as discrete mathematics, the theory of number, quantum computations, the information theory and combinatorial algorithms. I’m not sure, which one of them was the first to come up with the idea. Perhaps, Calude, since he also professes the History of Computing Mathematics. Everybody knows that the progenitor of counting in Europe was abacus. It moved on from Babylon to Egypt, then to Greece, Rome and, finally, the whole Europe. The appearance and operating principle of the ancient “calculator” is reminding of the “simple” sort behavior so much that it’sWhat is Rust for?
Written by Dzmitry Malyshau
Rust is a system programming language. It runs blazingly fast, prevents almost all crashes and removes the ambiguities associated with sharing access to data. Mozilla developed it as a tool to create a new generation browser engine – Servo . Similar Facilities The given language definition sounds like a fairy tale, since the henceforth tools have always balanced between speed and reliability. At one point, C++, in which speed and facilities are compensated by constant access errors outside the allocated memory to the reclamated memory. Or the unexpected results of reading data that is being written in-parallel by another thread. On the other hand, there’s Haskell, a “stronghold” language (on the principle “since it compiles, it operates”), which can’t brag about speed, though. Somewhere in-between balance Java, Python, C# and other popular (due to their usability) languages. As for me, Rust is a successful crossing of the best C++Introduction to Elixir
Written by Kukuruku Hub
Who This Article Is For I would say that the article is mainly for people who already have an experience with some other programming languages, but they want to look around. Also, functional programming is a trending thing nowadays. So if you want to see what it actually is, welcome. If you...
Teaching the File System to Read
Written by kmu1990
What I’m Going to Tell You About In the previous article we constructed the environment needed to get familiar with the kernel. Then we took a look at loadable kernel modules and wrote a simple “Hello World!”. Finally, we wrote a simple and useless file system. Now it’s time to go on. The main aim of this article is to teach the file system to read from disk. For now it will read the operating information only (the super block and index nodes). Doesn’t seem like much, eh? The thing is that in this post we’ll have to define the structure of our file system – the way it will be stored on disk. Besides, we’ll also get familiar with SLAB and RCU. All of this will require some explanations – a lot of words and little code. Therefore, the post will be quite long. A Boring Beginning OurErlang for the Little Ones. Modules and Functions
Written by HaruAtari
Dear %username% , Let’s continue to learn Erlang. In the previous post we’ve reviewed the basic data types, lists and tuples. We also learnt how to use pattern matching and lists generator. In this post we’ll move on to the next level and review modules and functions. All...
Masking a Class in Boost Graph. Part 3: Finding the Path
Written by Vadim Androsov
In the previous articles of the series we’ve reviewed the adaptive process of the square game field for concepts of boost graphs. Now we’ll consider the process of finding the path in the square field. Implementation of boost search allows adapting the algorithm quite accurately. In this article...
2048 in Erlang
Written by peinguin
This article is about a WebSocket server on Erlang rather than about the game itself. I’ll tell you a small prehistory. When I began playing 2048 I couldn’t stop. It was to the detriment of both my job and family. So I decided that a bot should play instead of me. But the problem was that it’s a user game, there’s no global rating and it’s not comfortable to play without a browser. That’s why I decided to create the server part so that there would be rating and my bot could play without a browser. It’s my first project in Erlang. Many programmers are afraid of it. They suppose that it’s difficult to use it. But it’s actually not. I’ll try to highlight some things that are not obvious for Erlang beginners. I’ve hard coded a lot of things for simplicity. But anyway, I’ll be glad to read yourMasking a Class in Boost Graph. Part 2: Completing the Implementation of Concept Support
Written by Vadim Androsov
I’ll briefly remind you of the task. There’s a two-dimensional game field consisting of squares. Some of them are vacant and others are occupied. We should find a path through vacant squares from one field position to another one. We implemented the search algorithm in Boost . But it requires...
Erlang for Beginners. Data Types, Variables, Lists and Tuples
Written by HaruAtari
Dear %username% , It’s the first article of the series. For many of you it may seem terribly trite as I’ll review the very basis of the subject. But this tutorial is going to be really useful for Erlang beginners. I’ll also dwell on some interesting things that aren’t obvious. In...
Premature Optimization is Evil
Written by Kukuruku Hub
There were no signs of trouble until we noticed a mix of 200 and 500 HTTP statuses in Kukuruku's web server logs. We were a bit confused when we started to look into it. The weird thing was that the server responded with either 200 ( OK ) or 500 ( Internal Server Error ) statuses even to requests...
Masking a Class in Boost Graph. Part 1: Let the Interface Be
Written by Vadim Androsov
I had to rebuild a pathfinding algorithm for our game recently. The previous one ( Boost Concepts ) was bad as any sidestep was dangerous. So I wanted to take a ready algorithm from a good source. That’s exactly when I remembered about boost as there’s functionality for working with graphs. Unfortunately “find a function, call it and everything will work” approach wasn’t meant to be realized. The library is focused on the maximum use flexibility which has badly affected its simplicity. But it’s better than creating it from scratch (then fixing it). I didn’t want to bother with other libraries, while boost has already been used in the project. The following is given: a game field class with the following (significant for this article) interface: class GameField { public: GameField(); bool canPass(int x, int y) const; int getWidth() const; int getHeight() const; }; The field is a regular gridLightweight HTTP Server in less than 40 Lines on libevent and C++11
Written by NYM
Looking through programming articles sometimes I see posts about creating your own HTTP server. I am most interested in C++ so I often read blogs about it. After looking them through you could easily write you own web server “on sockets” using boost.asio or something else. I also examined libevent and libev. Each of them has its advantages. Libevent is of great interest to me for developing a small HTTP server. Considering some innovations in C++11 the code becomes much more space-efficient and allows for the creation of a basic HTTP server in less than 40 lines. (adsbygoogle = window.adsbygoogle || []).push({}); The information of this post will be useful for those not familiar with libevent and those who want to quickly create an HTTP server. There’s nothing innovative in this post, so you can use it as material for working in the right direction. libevent is better thanBoost Concepts
Written by Vadim Androsov
I was always scared to use C++ templates due to the absence of standard mechanisms for setting parameter limits. In other words, when a developer writes the following function: template
Lock-free Data Structures. The Inside. Memory Management Schemes
Written by khizmax
As I’ve already mentioned in the previous articles , the main difficulties when implementing lock-free data structures are ABA problem and memory reclamation. I will separate these two problems even though they are connected as there are algorithms that can solve only one of them. In this article I am going to review popular methods of safe memory reclamation for lock-free containers. I’ll demonstrate the application of one or another method of the classic lock-free queue by Michael-Scott [MS98]. Tagged pointers Tagged pointers is a scheme introduced by IBM for to solve the ABA problem. Perhaps, it’s the most popular algorithm for this problem’s solution. According to this scheme each pointer represents an atomic pair of the memory cell address and its tag (32-bit integer number). templateLock-free Stack for Windows
Written by Vengo
It is common practice not to like Windows. But, as a rule, phrase: “I haven't read the book but still condemn it” describes this situation well. Despite the tendency of not like Windows, there are still some things that are implemented well. I’d like to tell you about one of them. I’ll...
Haskell. Testing a Multithread Application
Written by Ankuzik
I guess it’s no secret for anyone that multithread applications writing is connected with many problems you wouldn’t face when developing single-thread programs. One of the problems lies in an application testing. We can’t control the order in which operations are performed. Therefore, we...
or