Pull to refresh

All streams

Show first
Rating limit
Level of difficulty

Indexes in PostgreSQL — 6 (SP-GiST)

Reading time11 min
Views9.3K
We've already discussed PostgreSQL indexing engine, the interface of access methods, and three methods: hash index, B-tree, and GiST. In this article, we will describe SP-GiST.

SP-GiST


First, a few words about this name. The «GiST» part alludes to some similarity with the same-name access method. The similarity does exist: both are generalized search trees that provide a framework for building various access methods.

«SP» stands for space partitioning. The space here is often just what we are used to call a space, for example, a two-dimensional plane. But we will see that any search space is meant, that is, actually any value domain.

SP-GiST is suitable for structures where the space can be recursively split into non-intersecting areas. This class comprises quadtrees, k-dimensional trees (k-D trees), and radix trees.
Read more →

Disposable pattern (Disposable Design Principle) pt.3

Reading time15 min
Views4.2K


Multithreading


Now let’s talk about thin ice. In the previous sections about IDisposable we touched one very important concept that underlies not only the design principles of Disposable types but any type in general. This is the object’s integrity concept. It means that at any given moment of time an object is in a strictly determined state and any action with this object turns its state into one of the variants that were pre-determined while designing a type of this object. In other words, no action with the object should turn it into an undefined state. This results in a problem with the types designed in the above examples. They are not thread-safe. There is a chance the public methods of these types will be called when the destruction of an object is in progress. Let’s solve this problem and decide whether we should solve it at all.


This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
Read more →

Estimation of VaR and ConVaR for the stock price of the Kazakhstani company

Reading time8 min
Views1.6K

The last decades the world economy regularly falls into this vortex of financial crises that have affected each country. It almost led to the collapse of the existing financial system, due to this fact, experts in mathematical and economic modelling have become to use methods for controlling the losses of the asset and portfolio in the financial world (Lechner, L. A., and Ovaert, T. C. (2010). There is an increasing trend towards mathematical modelling of an economic process to predict the market behaviour and an assessment of its sustainability (ibid). Having without necessary attention to control and assess properly threats, everybody understands that it is able to trigger tremendous cost in the development of the organisation or even go bankrupt.


Value at Risk (VaR) has eventually been a regular approach to catch the risk among institutions in the finance sector and its regulator (Engle, R., and Manganelli S., 2004). The model is originally applied to estimate the loss value in the investment portfolio within a given period of time as well as at a given probability of occurrence. Besides the fact of using VaR in the financial sector, there are a lot of examples of estimation of value at risk in different area such as anticipating the medical staff to develop the healthcare resource management Zinouri, N. (2016). Despite its applied primitiveness in a real experiment, the model consists of drawbacks in evaluation, (ibid).


The goal of the report is a description of the existing VaR model including one of its upgrade versions, namely, Conditional Value at Risk (CVaR). In the next section and section 3, the evaluation algorithm and testing of the model are explained. For a vivid illustration, the expected loss is estimated on the asset of one of the Kazakhstani company trading in the financial stock exchange market in a long time period. The final sections 4 and 5 discuss and demonstrate the findings of the research work.

Read more →

7 Interesting startups in IoT

Reading time9 min
Views2.7K
The “winner takes all” principle seems to be less relevant to a startup business model than to a corporate business. Why so? The thing is that a cumulative advantage inherent in a contemporary globalized economy when the bigger you are the more chances you have for a further growth works beyond poorly regulated environments to which startups belong. The startup phenomenon in general and the IoT startups in particular are too immature in terms of a business-model history. In contrast to corporations, startups feel good in a Black-Swan-friendly uncertainty of emerging innovations. They operate in risky fields, they gamble oftentimes. But an immense focus on their own topics is what helps them survive. Indeed, dedication is an antidote to risks.

Originally article was posted here — 5 IoT startups in Logistic
Read more →

Visual Studio 2019 .NET productivity

Reading time2 min
Views1.8K

Your friendly neighborhood .NET productivity team (aka. Roslyn) focuses a lot on improving the .NET coding experience. Sometimes it’s the little refactorings and code fixes that really improve your workflow. You may have seen many improvements in the previews, but for all of you who were eagerly awaiting the GA release here’s a few features you may enjoy!


Read more →

Hack Your XiaoMi Vacuum Cleaner

Reading time2 min
Views65K
image

Laziness moves the world. And today we have more and more robotic vacuum cleaners that are saving our time for something more pleasant than just vacuuming.

The robots were marketed as internet/Bluetooth/smartphone connected devices with a speaker and camera to report and explore the environment. They also have different sensors to dodge barriers and such. But that’s only some ordinary stuff everyone knows about the robotic vacuum cleaners.
But the most interesting thing about them is their software. The owners can reprogram these devices and implement different settings as well as voice acting that has a huge number of options, including funny ones. And all you need to “upgrade” your vacuum cleaner is a PC, an internet connection, and a smartphone:
Read more →

BGP perforating wound

Reading time2 min
Views2.4K
It was an ordinary Thursday on 4.04.2019. Except that at some point of the midday timeline an AS60280 belonging to Belarus’ NTEC leaked 18600 prefixes originating from approximately 1400 ASes.

Those routes were taken from the transit provider RETN (AS9002) and further announced to NTEC’s provider — RU-telecom’s AS205540, which, in its turn, accepted all of them, spreading the leak.

image
Read more →

Wireshark 3.x: code analysis under macOS and errors review

Reading time9 min
Views1.9K

Picture 1

Wireshark Foundation released the final stable-version of the popular network traffic analyzer — Wireshark 3.0.0. The new release fixes several bugs, it is now possible to analyze the new protocols, apart from that the driver on Npcap WinPcap is replaced. Here is where quoting of the announcement ends and our note about bugs in the project starts off. The projects authors definitely haven't done their best in fixing bugs before the release.

Let's collect hotfixes right now to give a motive in doing a new release :).

Introduction


Wireshark is a well-known tool to capture and analyze network traffic. The program works with the vast majority of known protocols, has intuitive and logical graphical interface, an all-powerful system of filters. Wireshark is cross-platform, works in such OSs, as: Windows, Linux, macOS, Solaris, FreeBSD, NetBSD and many others.

To do the source code analysis, we used PVS-Studio static code analyzer. To analyze the source code, first we needed to compile the project in an OS. The choice was wide not only due to the cross platform nature of the project, but also because of that of the analyzer. I chose macOS for the analysis. You can also run the analyzer under Windows and Linux.
Read more →

Flightradar24 — how does it work? Part 2, ADS-B protocol

Reading time9 min
Views8K
I’m going to have a guess and say that everyone whose friends or family have ever flown on a plane, have used Flightradar24 — a free and convenient service for tracking flights in real time.

image

In the first part the basic ideas of operation were described. Now let's go further and figure out, what data is exactly transmitting and receiving between the aircraft and a ground station. We'll also decode this data using Python.
Read more →

Liza Alert: volunteers, who save lives

Reading time6 min
Views4.9K


Liza Alert search-and-rescue team has existed for eight years. It’s a volunteer organization, the fellowship of the ones who care, that searches for missing people effectively collaborating with the Ministry of Emergency Situations and the Ministry of Internal Affairs. Liza Alert collects the entries on missing people; they conduct various educational events, search management and search operations themselves. The team isn’t involved in any business activities, doesn’t have a checking account and doesn’t accept monetary donations.

Mail.Ru has recently provided Liza Alert with a free platform for services, extensively used for search-and-rescue operations. We decided to talk to Sergey Chumak — the head of Liza Alert IT branch — about the work of the volunteer emergency response group and how high-tech solutions aid them.
Read more →

Particle systems: a Christmas story

Reading time6 min
Views2.7K


Christmas has always been one of my favourite times of the year. For me, Christmas is a season that brings so much love, laughter, happiness, and other magical things into our lives.

I was born and raised in Spain, more specifically in Tenerife, a sunny subtropical island in the middle of the Atlantic Ocean just off the African coast. I have to say that Christmas in Tenerife is very different to my the last two Christmases I’ve spent in London since joining Badoo.

One amazing plus of living in London is that I have got to see snow for the first time in my life, real snowflakes falling from the sky. Just incredible!

Talking of snowflakes, I have an interesting story to tell you about something that happened to me one day in the office the last Christmas.  It was right before I was heading home to Tenerife to spend a few days with my family.

It just so happened that last December I’d been assigned a very interesting ticket with the following description

Ambient music and its effects on writing code

Reading time6 min
Views2.7K
In this post I’d like to talk about our background music choices for writing code. The developer soundtrack, if you will. To narrow it down, I’m going to discuss one specific genre, ambient music.


Homo laborans and music


Today the effect music has on all living creatures, humans included, is a fairly well-researched topic. It’s been common knowledge for a while that classic music helps people to calm down and relieves stress, while high-energy tunes of various genres can make your workout results way more impressive.

Plenty of scientific papers have been published that explore this phenomenon, especially by medical researchers and psychologists (use of music as a part of treatment plan, the way different organs respond to it, etc.). Naturally, many of those you gotta take with a grain of salt as there’s always the risk of crossing the line into pseudoscience, but there’s no shortage of reliable sources that confirm that link.

You don’t need to go further than Habr to find plenty of insightful articles that talk about the influence music has on a working environment and attention span of the workers. But this particular one has a slightly different intent.
Read more →

Memory and Span pt.2

Reading time9 min
Views3.3K


Span<T> usage examples


A human by nature cannot fully understand the purpose of a certain instrument until he or she gets some experience. So, let’s turn to some examples.


ValueStringBuilder


One of the most interesting examples in respect to algorithms is the ValueStringBuilder type. However, it is buried deep inside mscorlib and marked with the internal modifier as many other very interesting data types. This means we would not find this remarkable instrument for optimization if we haven’t researched the mscorlib source code.


What is the main disadvantage of the StringBuilder system type? Its main drawback is the type and its basis — it is a reference type and is based on char[], i.e. a character array. At least, this means two things: we use the heap (though not much) anyway and increase the chances to miss the CPU cash.


Another issue with StringBuilder that I faced is the construction of small strings, that is when the resulting string must be short e.g. less than 100 characters. Short formatting raises issues on performance.


This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
Read more →

How I discovered an easter egg in Android's security and didn't land a job at Google

Reading time11 min
Views34K
Google loves easter eggs. It loves them so much, in fact, that you could find them in virtually every product of theirs. The tradition of Android easter eggs began in the very earliest versions of the OS (I think everyone there knows what happens when you go into the general settings and tap the version number a few times).

But sometimes you can find an easter egg in the most unlikely of places. There’s even an urban legend that one day, a programmer Googled “mutex lock”, but instead of search results landed on foo.bar, solved all tasks and landed a job at Google.

Reconstruction
image

The same thing (except without the happy ending) happened to me. Hidden messages where there definitely couldn’t be any, reversing Java code and its native libraries, a secret VM, a Google interview — all of that is below.
Read more →

How iOS Developers Are Seeking To Up The Ante With Cloud Computing

Reading time4 min
Views1.5K
image

As a platform, many enterprises are leveraging iOS to realize the amazing benefits of cloud computing. This is one aspect of digital transformation that has been rocking the entire industry in recent times. Generally, there is only a few internet-based development and deployment service performed on the platform that is not concerned with cloud application development. Nowadays, there is a growing population of iOS developers and app development companies that are steadily adopting cloud computing.
Read more →

Indexes in PostgreSQL — 5 (GiST)

Reading time22 min
Views10K
In the previous articles, we discussed PostgreSQL indexing engine, the interface of access methods, and two access methods: hash index and B-tree. In this article, we will describe GiST indexes.

GiST


GiST is an abbreviation of «generalized search tree». This is a balanced search tree, just like «b-tree» discussed earlier.

What is the difference? «btree» index is strictly connected to the comparison semantics: support of «greater», «less», and «equal» operators is all it is capable of (but very capable!) However, modern databases store data types for which these operators just make no sense: geodata, text documents, images,…

GiST index method comes to our aid for these data types. It permits defining a rule to distribute data of an arbitrary type across a balanced tree and a method to use this representation for access by some operator. For example, GiST index can «accommodate» R-tree for spatial data with support of relative position operators (located on the left, on the right, contains, etc.) or RD-tree for sets with support of intersection or inclusion operators.

Thanks to extensibility, a totally new method can be created from scratch in PostgreSQL: to this end, an interface with the indexing engine must be implemented. But this requires premeditation of not only the indexing logic, but also mapping data structures to pages, efficient implementation of locks, and support of a write-ahead log. All this assumes high developer skills and a large human effort. GiST simplifies the task by taking over low-level problems and offering its own interface: several functions pertaining not to techniques, but to the application domain. In this sense, we can regard GiST as a framework for building new access methods.
Read more →

Checking the Roslyn Source Code

Reading time21 min
Views1.6K
PVS-Studio vs Roslyn

Once in a while we go back to the projects that we have previously checked using PVS-Studio, which results in their descriptions in various articles. Two reasons make these comebacks exciting for us. Firstly, the opportunity to assess the progress of our analyzer. Secondly, monitoring the feedback of the project's authors to our article and the report of errors, which we usually provide them with. Of course, errors can be corrected without our participation. However, it is always nice when our efforts help to make a project better. Roslyn was no exception. The previous article about this project check dates back to December 23, 2015. It's quite a long time, in the view of the progress that our analyzer has made since that time. Since the C# core of the PVS-Studio analyzer is based on Roslyn, it gives us additional interest in this project. As a result, we're as keen as mustard about the code quality of this project. Now let's test it once again and find out some new and interesting issues (but let's hope that nothing significant) that PVS-Studio will be able to find.
Read more →