Wednesday, 11 April 2018

GDPR Everywhere: What is GDPR?

Well with everyone talking about GDPR, you are very likely to stumble on some mention of GDPR at some point while browsing the internet. So,  I explain GDPR on a high level using some questions.


What is GDPR?
GDPR stands for General Data Protection Regulation which is a part of European Commission's plans for 'data protection reform' across Europe. Simply put, GDPR aims to give EU citizens more control over their personal data.


When does it come into effect and who does it apply to?
It will come into force on May 25, 2018. All the member nations are expected to have transferred it to their own law by May 6, 2018. GDPR besides applying to organizations operating within the EU will also apply to those who offer goods or services to in EU irrespective of where they are located. This means that any big organization will have to be GDPR compliant by May 25 or else face fines.


What does GDPR bring to the table for a day-to-day user?
  1. GDPR compliance
    • personal data should be gathered legally under strict conditions.
    • Those who collect and manage this personal data will be required to protect it from misuse and exploitation along with respecting the rights of the data owners
  2. Notification of data breach/hack
    • Besides the right to know when and where is a user's data being used for, the organization is also required to inform the concerned nation bodies in case of any data breach (which can lead to loss of privacy) so that EU citizens can take appropriate steps to prevent data from being abused.
    • This notification must be sent out within 72hrs of the organization first becoming aware and if the breach is serious the user/customer must be informed without "undue delay".
  3. Right to be forgotten
    • A user can have his data deleted provided there is no ground for retaining it.
    • This also means that company will have to keep track of entire information graph (what information has been collected and where is stored and being used) of the user and must also provide it to the user upon request.

Now, the part we haven't talked till now are the consequences of being non-compliant. So, this brings us to our next question.


What are the fines for non-compliance with GDPR?
  These fines are by no means small. They can be rather extremely high. The organization may have to shell out as much as 4% of annual global turnover or 20 million euros(whichever is greater) for violations like unauthorized transfer of personal data, failure to put in place procedures for or ignoring user's access requests for their data. For violations like failure to report a data breach, failure to build privacy by design and ensure data protection itself is applied at the first stages of the project and/or failure to appoint data protection officer(if applicable), the fine is 10 million euros or 2% of annual global turnover.


Privacy by Design
I find privacy by design very interesting topic with huge potential to help preserve the privacy of the users. Article 23 (of GDPR) calls for controllers (data collectors and processors) to hold and process only the data absolutely necessary for the completion of its duties (data minimisation), as well as limiting the access to personal data to those needing to act out the processing. The idea is to control access to data, or collect minimal data but these approaches don't go well in certain cases like when data breaches occur and servers are hacked as the malicious party has access to the data which can then be used for harmful purposes. Also in certain cases using additional information available like voter records, mortgage records etc. can be linked to an individual and reveal a lot of information which can lead to loss of privacy.

However, there is a somewhat orthogonal study about preserving the privacy of the user by collecting data in the privacy preserved manner rather than taking steps at a later stage to protect data in order to preserve the privacy. For applications, where the methods to collect data in privacy preserved manner can be used they have a huge advantage. In case of data breaches or models released to the public, the data cannot be linked to a particular user and inverse attacks to extract information regarding an individual can be avoided. More on this in sometime later in another blog post.


Conclusion
I believe collecting data in a privacy preserved manner wherever possible certainly has its own advantages as now you don't have to worry about data breaches (and subsequent use of data thereafter as it's not possible to link a single record to a specific user with certainty. For other cases where there is no workaround for some information, GDPR will definitely put users in more control by giving them rights to know when their data is being collected, where it is being used for, where and how is it stored and right to get their data erased if they want. Also, the organizations will now be legally accountable for any misuse of personal data or carelessness on their part to protect user's data with severe consequences if they fail to do so. All in all, GDPR will certainly be a welcomed move from a user's perspective.

More information about the GDPR regulation can be found at this link.

Wednesday, 21 October 2015

Getting started with Competitive Programming: Understanding Problem Statement


What better way to start than by knowing what does the term "Competitive Programming" mean ?
Competitive programming can be briefly defined as solving a specified problem in one of the permitted programming languages under well defined time and memory constraint.

This post will emphasize on how to interpret various parts of problem presented and subsequently extract useful and necessary information for an effective solution. To give an idea about how problems are presented, I'll go ahead with one of the problems, Chef and Party from the contest CodeTrix II.

The problem is structured as follows:
Problem Statement
There will be a problem statement which will likely have a background story along with it to make the problem statement interesting. Sorry to say this can also be used as a tool to divert the user's thinking away from the fundamental problem. The problem "chef and party" has the following statement.

" Chef has decided to host a party on the eve of Christmas. But at his party more guests have come than he had invited, let the total number of guests who have arrived be N. So he is not able to pay the bill of all the guests. The chef decides to pay the bill of only K guests. Chef tells his best friend to select K guests whose bill the chef will pay.
The maximum bill of a particular guest does not exceeds 2000."


This statement after removing the background story and other unnecessary details can be reduced to:

"Chef will only pay for K out N guests and you need to find those K guests"

Input Description
This section usually explains the structure of the input. Besides input structure it also contains the meaning of the variable used in the problem statement. Sometimes the meaning can also be a part of problem statement. The input description is:

  • The first line of the input contain T test cases.The description of T test cases follows.
  • For each test case, first line contains the total number of guests who came at the party N.
  • The next line contains space separated individual bills of the N guests.
  • The next line contains the value of K
  • The next line contains K space separated integers
 After understanding the input description, you should quickly jump to the "example" section and take a look at the sample input. The following is the input for the problem in example section.

  2                                 // No of test cases (T)
  10                                // total number of guests (N)
  20 30 50 30 10 5 78 98 345 1000   // individual bills of guests
  4                                 // No.of guests chef will pay for
  1 4 7 8                           // the indexes of the guest
  5
  600 700 400 300 230
  2
  2 3
 
So 2 denotes the total number of test cases. From the input description we can conclude that each test case will be of 4 lines.  The test case 1 has been made bold. So your program must take input in this form itself.
After this it's better to the read the explanation for the test case if it is present.  This should give you a fair idea about what is expected from you in the solution.

Output Description
Along the same lines output description specifies the structure of the output. Read the output description very carefully as you'll have to strictly abide by the specification. Any deviation will lead to wrong answers. The output description for problem is:

  • For each test case, output a single line containing the total bill the chef will pay

Now again jump to the output section in the "example" section to understand the output better.


Constraints
This section will is meant to give an idea about what data type you'll need to use to accommodate the input of the problem and other variables used in your solution program. 
  • 1 ≤ T ≤ 100
  • 1 < N ≤ 100
  • 1 < K < N

Since all of these variables (numbers) are well within the range of 'int', so taking 'int' would suffice.
Finally, the time and memory constraints of the problem statement mean that your solution should terminate properly within the time limit and should not use more memory than that specified besides obviously outputting the correct answer to get your solution accepted. More details on this sometime later...

For your reference a solution to the above problem is given below:

#include<stdio.h>
 
int arr[101]; // as there can be maximum of 100 guests
 
int main()
{
    int t, i;
    scanf("%d", &t);  // take input for number of test cases
     
    while(t--)
    {   // for each test case: take input, calculate and print output
        int n;
        scanf("%d", &n);
        for (i =0; i < n; i++)
            scanf("%d", &arr[i]);
        int k, index;
        int sum = 0;
        scanf("%d", &k);
        for (i = 0; i < k; i++)
        {
            scanf("%d", &index);
            sum += arr[index-1];
        }
        printf("%d\n", sum);  // print the output per test case
    }
    return 0;
}

Wednesday, 14 January 2015

Getting Started with VIM

Vim is an awesome text editor, oh wait it's just much more than a text editor.
Before i begin this post doesn't not include commands and all but just an advice as to how to approach learning Vim.

VIM as such provides just bare minimum functionality and is not so cool, but again it's upto you to configure  Vim according to you and make it cool. Vim also supports tons of plugins that bring along a lot more functionality than just simple Vim.

What not do do...

One of the biggest mistake one can make while starting with Vim is to approach it just like other text editors like sublime, Gedit etc and it is because Vim is different is that is why it's awesome.

Vim is a modal editor which means it has different modes and a key may take special role according to the mode.

Also in Vim you simply do everything from Keyboard so say Goodbye to you mouse. Everything you do in vim is doable by not moving your fingers from the home row, yes exactly you don't even need arrow keys because moving is done using h,j,k,l keys and this is the main reason behind increase in productivity as you are not wasting time moving you hand back and forth between your mouse/arrow keys. 

How to begin ?


Vim stores the configuration in a file called .vimrc (also know as a dot file, literally because of the dot) present in your home directory. This simply text file dictates what will the behavior of Vim when launched.  Initially you should use somebody else's dot files and once you get your hands on and have fair bit experience you can start to tweak the configuration according to your needs.

Initially if you want you can use my vim setup: https://github.com/harsimrans/dotvim

Also initially you should not make Vim as your primary text editor because if you do so you'll hate Vim, like from the bottom of your heart. your productivity will drop not because vim is complicated but because you are just not used to it. So take out some free time and start playing around with Vim and probably after a few days you'll feel comfortable.

Browse through the Internet, there are tons of articles about basic Vim commands and go through a couple of them before you start using Vim.

REMEMBER invest some time in Vim , play with it and get comfortable with Vim. Then make Vim your primary editor. Believe me you will realize your productivity increase than before even if it's little.

Productivity after vim  = c * productivity before vim, where Obviously c >> 1 :P

Things to do before and after installing Ubuntu

After almost running out of space allocated for Ubuntu and somewhat messing my machine (started to crash a lot) just because I'm not a good maintainer, i decided to change the partition structure for the new install.

Deciding on how much space you need

This is a crucial step in installation. You should try and allocate enough space for the Linux distribution you are installing to avoid the pains of resizing the partitions. Sometime people even reinstall the whole distribution instead of resizing the partitions.

In my previous install i had allocated 40GB for the Linux partition. Installing software and a couple of virtual machines i was on the verge of running out of space. Also since i was to re-install so i decided to given even more space.

 

How my partitions are laid out

Also i decided to make a separate home partition, so that i don't loose my data if i need to reinstall or shift to a different distribution.

So i decided to make 3 separate partitions:

  1. About 40GB partition for root, where all the software installations will reside.
  2. About 60GB partition for home, so that my data resides in a separate partition.
  3. Since i have 6GB RAM , so about 5GB of swap space.
This is how my partitions are laid out on the disk.


Installation Process

The installation process is very easy for Ubuntu and now a days almost every distribution has made their installation process easier than before. So no problems here once your know how to layout your partitions.

After Installation

Surprisingly this time out of the box i could manipulate brightness settings otherwise you'll need to fix that too.
There are a few things you might want to do after you install Ubuntu. Here is a list of what i did.

  1. After installation adjust basic settings according to your need. Go to settings and make changes to power management, display, launcher settings etc.
  2. Enable Mutiverse.
  3. There are some 3rd party codecs or plugins required for essential softwares to work. Install "ubuntu-restricted-extras", this should take of almost everything you'll need from flash to codecs for audio and video files. But be warned that it might not be legal in some countries, because of software patents.
  4. When ever you install a package or remove a packages, remember there may be packages that are no longer needed (mostly installed along as dependencies). Make sure to remove those too.
Hopefully this time i will try hard not to screw my installation.