Tetris on C # in 100 lines

Tetris on C # in 100 lines 
3r3-31. Recently I had an idea - to write a simple game in the minimum number of lines. My choice fell on Tetris. In this article I will describe my code.
 
 
To begin with, it is worth noting that in my implementation I included only the basic features: 3r3333368.  
 
 
movement of figures left /right;
 
the fall of the figures;
 
turn figures;
 
deleting filled figures;
 
ending the game.
 
 
So, first add a PictureBox to the form and create a timer.
 
 
Also, the game will need:
 
 
public const int width = 1? height = 2? k = 15; //Size of the field and size of the cell in pixels
public ...
+ 0 -

Destructive exceptions

 3r3615. 3r3-31.
Once again about why it is bad to throw exceptions in destructors 3r33597. 3r3-3598.  3r3615. 3r3600. Many C ++ experts (for example, 3r337. Sutter's coat of arms
) Teach us that throwing exceptions in destructors is bad, because you can get into the destructor during stack promotion with an exception already thrown, and if at that moment another exception is thrown, the result will be called r3r3591. std :: terminate ()
. The standard of the C ++ 17 language (hereinafter I refer to the freely accessible version of the draft ...
+ 0 -

Thoughts on Rust 2019

 3r3304. 3r3-31. Colleagues, good evening to all!
 3r3304.
 3r3304. We are pleased to offer you a translation of a truly programmatic article from 3r3-36. Rafa Levin
whose titanic work on the development of the Rust language evokes respect and piety:
 3r3304.
 3r3304. Thoughts on Rust 2019  3r3304.
 3r3304. Without false modesty and without hatefulness, the author substantively and enthusiastically responded to the call of the Rust community, published by reference at the beginning of this article. We hope it turned out interesting and life-affirming.
 3r3304. ...
+ 0 -

The story of one experiment with Cython and C ++ vector

 3r33424. 3r3-31. 3r33333. One
warm r3r3255. on a cold winter evening, I wanted to warm up in the office and test the theory of one colleague that the C ++ vector could cope with the task faster than the CPython list. 3r33232.  3r33424. In the company we are developing products based on Django and it so happened that it was necessary to process one large array of dictionaries. A colleague suggested that the implementation in C ++ would be much faster, but I had the feeling that Guido and the community were probably a little steeper than us in C and probably already decided and avoided all the pitfalls...
+ 0 -

Checking the LibrePCB project using PVS-Studio inside the Docker container

Checking the LibrePCB project using PVS-Studio inside the Docker container 3r38080. 3r3669.  
This is a classic article about how our team checked the open LibrePCB project with the help of the PVS-Studio static code analyzer. However, the article is interesting because the check was carried out inside the Docker container. If you are using containers, we hope that the article will demonstrate another simple way to integrate the analyzer into the development process. 3r3669.  
3r311.
3r3669.  
3r3654. LibrePCB
3r3669.  
LibrePCB - this is free software for designing electronic circuits and printed circuit boards. The program code is written in C ++, and Qt5 is used ...
+ 0 -

How Clang Compiles a Function

 3r3308. 3r3-31. I planned to write an article about how LLVM optimizes a function, but first you need to write how Clang translates C or C ++ to LLVM.
 3r3308.
 3r3308. How Clang Compiles a Function
 3r3308. lectures on cyclic optimization :
 3r3308.
 3r3308.
bool is_sorted (int * a, int n) {
for (int i = 0; i < n - 1; i++)
if (a> a[i + 1])
return false;
return true;
} 3rr989.  3r3308. Since Clang does not make any optimizations, and since LLVM IR was originally designed to work with C and C ++, the conversion is relatively easy. I will use Clang ??? (or a close version, since this one has not yet been released) on x86-64.
 3r3308.
 3r3308. T...
[/i]
+ 0 -

The amazing performance of parallel C ++ 17 algorithms. Myth or Reality?

The amazing performance of parallel C ++ 17 algorithms. Myth or Reality? 3r31192. 3r3-31. Good evening! 3r31175.  3r31192. 3r31175.  3r31192. From our course "Developer C ++" We offer you a small and interesting study about parallel algorithms. 3r31175.  3r31192. 3r31175.  3r31192. Go. 3r31175.  3r31192. 3r31175.  3r31192. With the advent of parallel algorithms in C ++ 1? you can easily update your “computational” code and get the benefit of parallel execution. In this article, I want to consider an STL algorithm that naturally uncovers the idea of ​​independent computing. Can we expect a 10-fold acceleration in the presence of a 10-core processor? Maybe more? ...
+ 0 -

Code profiling with LLVM

The Curse of Non-Determinism


 
Code profiling with LLVM  
My first attempt to write an LLVM pass - I love these segfolts
 
 
Recently, I ran into an interesting task - I needed a deterministic and cross-platform method for determining the execution time of C ++ code. By the word "deterministic" I mean that the same code will be executed for the same number of units of time. By cross-platform, I understand that the same code under Windows and under Ubuntu will be executed in the same amount of time units.
 
 
Naturally, the time measurement on the CPU does not satisfy these conditions. The machine code varies depending on ...[/h]
+ 0 -

ASP.NET Core 2.2 has been released. What's new? (2 of 3)

December ? came out
ASP.NET Core ???r3r36. It is included in the delivery of .NET Core 2.2. About .NET Core 2.2 i I wrote recently and now you need to open the topic in depth. Let's see what's new for us.
 
ASP.NET Core 2.2 has been released. What's new? (2 of 3) from the usual place and use both on your development machine and servers. New Windows Server hosting, runtime installers and binary archives for updating servers are available there.
 
This release is dedicated to updating 3r330. .NET Core
, ASP.NET Core and Entity Framework Core up to version ???. The new version of the SDK is ???. The following requirements for the Visual Studio version ...
.NET / C#
+ 0 -

Docker Remote API with certificate authentication with revocation checking

Problem Description
 
For the needs of remote control of Docker, Docker can provide web API.
 
This API can either not require authentication at all (which is highly discouraged), or use certificate authentication.
 
The problem is that native certificate authentication does not provide for certificate revocation checking. And this can have serious consequences.
 
I want to tell how I solved this problem.
3r318.
 
Solution of the problem 3r3203.
 
First you need to say what to say, I will be about Docker for Windows. Maybe Linux is not so bad, but now is not about that.
 
What we have? We have ...
.NET / C# / DevOps
+ 0 -