image
In this article, I'll talk about the components that make up applications for Android, and about the ideas behind this architecture.
Articles series:

How Android works, part 1
How Android works, Part 3
...

Papay 16 october 2017, 10:49

On this Wednesday, August 30, at the office of Oracle, meeting JUG with Oleg Shelaev, Developer Advocate in the company ZeroTurnaround, which makes JRebel and XRebel. The topic of the meeting is the tools for creating multi-threaded Java programs (from designing bikes and starting threads to handles, to ForkJoinPools, green threads and transactional memory).
Of course, we asked which Java 9 chips are considered the most useful in ZeroTurnaround. As a result, they got hold of the article that you are reading right now. The original article Oleg published in the blog RebelLabs , there are many more interesting.
Papay 14 october 2017, 11:49

C++ language is constantly evolving, and for us, as for developers of a static analyzer, it is important to track all its changes, in order to support all new features of the language. In this review article, I would like to share with the reader the most interesting innovations introduced in C++17, and demonstrate them with examples.

image

Now, developers of compilers are actively adding support for the new standard.

Fold expressions

I would like to start with a few words about what a fold is (also known as reduce or accumulate).
Fold is a function that applies the assigned combining function to sequential pairs of elements in a list, and returns a result. The simplest example is the summing up of elements in the list using a fold:

Example from C++:


std::vector<int> lst = { 1, 3, 5, 7 };
int res = std::accumulate(lst.begin(), lst.end(), 0,
[](int a, int b) { return a + b; });
std::cout << res << '\n'; // 16

If the combining function is applied to the first item in a list and to the result of the recursive processing of the tail of a list, then the fold is called 'right'. In our example, we will get:

1 + (3 + (5 + (7 + 0)))
If the combining function is applied to the result of the recursive processing at the top of the list (the entire list without the last element) and to the last element, then a folding is called 'left'. In our example, we will get:

(((0 + 1) + 3) + 5) + 7
Thus, the fold type determines the order of evaluation.

In C++17 there is also folding support for a template parameters list. It has the following syntax:
(pack op ...) A unary right associative fold
(... op pack) A unary left associative fold
(pack op ... op init) A binary right associative fold
(init op ... op pack) A binary left associative fold

op is one of the following binary operators:


+ - * / % ^ & | ~ = < > << >> += -= *= /= %=
^= &= |= <<= >>= == != <= >= && || , .* ->*

pack is an expression containing an undisclosed parameter pack

init - initial value

For example, here's a template function that takes a variable number of parameters and
calculates their sum:


// C++17
#include <iostream>

template<typename... Args>
auto Sum(Args... args)
{
return (args + ...);
}

int main()
{
std::cout << Sum(1, 2, 3, 4, 5) << '\n'; // 15
return 0;
}

Note: In this example, the Sum function could be also declared as constexpr.
If we want to specify an initial value, we can use binary fold:


// C++17
#include <iostream>

template<typename... Args>
auto Func(Args... args)
{
return (args + ... + 100);
}

int main()
{
std::cout << Func(1, 2, 3, 4, 5) << '\n'; //115
return 0;
}

Before C++17, to implement a similar function, you would have to explicitly specify the rules for recursion:


// C++14
#include <iostream>

auto Sum()
{
return 0;
}

template<typename Arg, typename... Args>
auto Sum(Arg first, Args... rest)
{
return first + Sum(rest...);
}

int main()
{
std::cout << Sum(1, 2, 3, 4); // 10
return 0;
}

It is worth highlighting the operator ',' (comma), which will expand the pack into a sequence of actions separated by commas. Example:


// C++17
#include <iostream>

template<typename T, typename... Args>
void PushToVector(std::vector<T>& v, Args&&... args)
{
(v.push_back(std::forward<Args>(args)), ...);

//This code is expanded into a sequence of expressions
//separated by commas as follows:
//v.push_back(std::forward<Args_1>(arg1)),
//v.push_back(std::forward<Args_2>(arg2)),
//....
}

int main()
{
std::vector<int> vct;
PushToVector(vct, 1, 4, 5, 8);
return 0;
}

Thus, folding greatly simplifies work with variadic templates.
Kate Milovidova 13 october 2017, 14:23

image

Performing daily tasks of the system administrator is considered safe when working through the SSH session. This article will discuss modern tools for conducting MITM attacks on the SSH protocol and how to protect against them.
Papay 13 october 2017, 12:18

You've probably heard of Project Quantum ... This is a project for substantial reworking of Firefox's insides to speed up the browser. In parts, we implement the experience of our experimental browser Servo and significantly improve the rest of the engine elements.
The project was compared with the replacement of an aircraft engine on the fly. We make changes to the Firefox component behind the component, so you can evaluate their effect in the next release of the browser as soon as it is ready.
image
Note. There are many illustrations under the cut. All of them are clickable (for viewing in higher resolution). If you stumble upon inaccurate translation and other errors - I will be grateful if you report this in the comments or in PM.
Tags: transfer
Papay 13 october 2017, 12:16

Let's move on to the most interesting - a selection of the most useful and interesting, in our opinion, tricks and hidden features of Chrome DevTools.
Layout
1. We inspect the animation
The animations in DevTools will allow you to slow down all the animations on the page or to move the "hands" animation.

image
Skull 12 october 2017, 15:04

In modern software very often there is a need to perform various operations with all kinds of money. However, until now, I have never found documentation, which would have brought together the basic rules for presenting amounts and implementing financial calculations. In this article, I will try to formulate those rules that have been compiled on the basis of personal experience.

image
Skull 11 october 2017, 9:40

image

WebRTC can work Peer-to-Peer and Peer-to-Server, where in the role of a feast, usually acts as a browser or mobile application. In this article, we'll show you how WebRTC works in Server-to-Server mode, what it does and how it works.
Skull 11 october 2017, 9:37

The artists painted bright graphics, the programmers built it into the game, the animators added movements - it would seem, everything is ready. But no, managers do not like:
You need to remove gray spots and white lines. Then the pulsating button jerks, there the progress bar goes with a ladder.
You look at the game resources - there is nothing in them, all sprites are cropped. You read the code - the formulas are correct, there is enough shader accuracy. But the result was still unimportant. Where is the mistake?

image

A small poll for those who already know where the artifacts come from. What to do in this situation?


You need a powerful graphics card and fresh drivers;
It is worth making downloadable sets of graphics for all possible screen resolutions;
Square textures with the sizes of a degree of two do not have such problems;
This is all due to the compression of graphics (PVRTC / DXT5 / ETC1 / ...);
In the graphics editor you will have to smudge the edges slightly;
This should have happened, because we did not prepare graphic data;
Only antialiasing will help;
You need textures and targets in the premultiplied alpha mode.

What is the correct answer, why exactly and how to overcome the artifacts of graphics read under the cut.
Skull 10 october 2017, 10:21

I will introduce you to the full tutorial on HTML5 with a demo on the algorithm of machine learning the video game Flappy Bird. The purpose of this experiment is to write an artificial intelligence controller based on neural networks and a genetic algorithm.

That is, we want to create an AI robot that can learn the optimal game in Flappy Bird. As a result, our little bird can safely fly through obstacles. In the best scenario, she will never die.

After reading the theory behind this project, you can download the source code at the end of this tutorial. All code is written in HTML5 using the <a title="Phaser Framework" href="http://phaser.io/"> phaser </a> framework. In addition, we used the Synaptic Neural Network library to implement a neural network so that it would not be created from scratch.
Demo
First, look at the demo to evaluate the algorithm in action:

image

Run in full-screen mode
MeLavi 10 october 2017, 9:05
1 2 3 4 5 ...