How to redirect base url addresses to another base URL

Say you have http://abhinav.spsdarj.org/2017/12/how-to-redirect-base-url-addresses-to-another-base-url/ as a url on your old website (abhinav.spsdarj.org) and now you want the link to redirect to new website. Say abhinav.ga but the url following abhinav.ga should stay the same and when typing the old url, should magically redirect with rest of the link intact to the new website.

Here’s what you do. Go to the old site’s folder in your file manager, access the .htaccess and add this:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^abhinav\.spsdarj\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abhinav\.spsdarj\.org$
RewriteRule ^(.*)$ "http\:\/\/blog\.abhinav\.ga\/$1" [R=301,L]

This supports multiple redirects.

What the Hell is Linux?

Alright. Here we go! I’ve done some itty bitty research and will shortly forget what Linux is all about cuz I vaguely remember searching the same info before. So yeah! Let’s Start!

Unix: Initially, it was a AT&T built operating system. Now, It’s a family of operating systems that derive from it, like

  • BSD/Berkeley Software Distribution (386BSD (FreeBSD, NetBSD…), Darwin (macOS, iOS), SunOS))
  • GNU
  • Linux (Android, Chrome OS)
  • QNX (BlackBerry 10)

Based on its design, Unix like operating systems have come to exist. Most Famous: Linux.

Linux releases a new version of their “kernel” every now and then. And due to the flexibility, customizability, free and open-source nature of Linux, it becomes possible to highly tune Linux for a specific purpose or just make a general purpose version. There are different foundations/groups who pick up the kernel release, modify it and package it along with a bunch of mostly free (called GNU stuff) or paid software in a form known as a Linux distribution (or distro for short) for both desktop and server use. You cannot use Linux without a distro since Linux by itself is just a kernel. Read more here.

Linux Distribution timeline 2016
Linux Distribution timeline 2016. Btw, the image is Ctrl + F able.

General purpose Linux distributions: Some of the most popular are Debian, Fedora, Ubuntu (which is itself based on Debian) together with commercial distributions such as Red Hat Enterprise Linux.

Specialized Linux distribution: There are two main methods for creating them: building from scratch (i.e. Pure Linux) or from a general-purpose distribution as a base. Linux distributions built from scratch do not have general-purpose bases; instead, they focus on the JeOS philosophy by including only necessary components and avoiding resource overhead caused by components considered redundant in the distribution’s use cases. Eg of Specialized distros: Kali Linux for digital security (Based on Debian).

Packages: Each distro, while they may be based off of one another need to be “binary compatible” to allow packages (or softwares/apps) from one distro to be used in another. So care for that must be taken.

DIGIT Magazines

Stable Web archive version: Here.

Beyond this, any backed up version of this page on web archive will appear broken. Actually, the links still work but it’ll take you an extra click. So if you’re currently viewing this page on web archive, go to the above linked url for best experience.


2001

200106_digit 200107_digit 200108_digit 200109_digit 200110_digit 200111_digit 200112_digit


2002

200201_digit 200202_digit 200203_digit 200204_digit 200205_digit 200206_digit 200207_digit 200208_digit 200209_digit 200210_digit 200211_digit 200212_digit


2003

200301_digit 200302_digit 200303_digit 200304_digit 200305_digit 200306_digit 200307_digit 200308_digit 200309_digit 200310_digit 200311_digit 200312_digit
Hosted on archive.org: 200307


2004

200401_digit 200402_digit 200403_digit 200404_digit 200405_digit 200406_digit 200407_digit 200408_digit 200409_digit 200410_digit 200411_digit 200412_digit


2005 (start converting links here)

200501_digit 200502_digit 200503_digit 200504_digit 200505_digit 200506_digit 200507_digit 200508_digit 200509_digit 200510_digit 200511_digit 200512_digit


2006

200601_digit 200602_digit 200603_digit 200604_digit 200605_digit 200606_digit 200607_digit 200608_digit 200609_digit 200610_digit 200611_digit 200612_digit


2007

200701_digit 200702_digit 200703_digit 200704_digit 200705_digit 200706_digit 200707_digit 200708_digit 200709_digit 200710_digit 200711_digit 200712_digit


2008

200801_digit 200802_digit 200803_digit 200804_digit 200805_digit 200806_digit 200807_digit 200808_digit 200809_digit 200810_digit 200811_digit 200812_digit


2009

200901_digit 200902_digit 200903_digit 200904_digit 200905_digit 200906_digit 200907_digit 200908_digit 200909_digit 200910_digit 200911_digit 200912_digit
Hosted on archive.org: 200904, 200912


2010

201001_digit 201002_digit 201003_digit 201004_digit 201005_digit 201006_digit 201007_digit 201008_digit 201009_digit 201010_digit 201011_digit 201012_digit
Hosted on archive.org: 201006, 201007, 201012


2011

201101_digit 201102_digit 201103_digit 201104_digit 201105_digit 201106_digit_1
201106_digit_2 201107_digit 201108_digit 201109_digit 201110_digit 201111_digit 201112_digit
Hosted on archive.org: 201101, 201104, 201111


2012

201201_digit 201202_digit 201203_digit 201204_digit 201205_digit 201206_digit 201207_digit 201208_digit 201209_digit 201210_digit 201211_digit 201212_digit
Hosted on archive.org: 201205, 201206, 201207, 201208


2013

201301_digit 201302_digit 201303_digit 201304_digit 201305_digit 201306_digit 201307_digit 201308_digit 201309_digit 201310_digit 201311_digit 201312_digit


2014

201401_digit 201402_digit 201403_digit 201404_digit 201405_digit


Archive.org Hosted file page: https://archive.org/details/digitPDFover32mb

What’s with 32 bit systems supporting max 4GB of RAM?

So you know that RAMs contain storage space. Common sense. Every byte of memory on RAM requires to have an address allocated to it. A 32-bit machine uses 32 bits long address to designate each byte of memory. And a memory that does not have an address allocated can not be seen by the machine.

Now let’s understand how these addresses work.

Each bit has a value of 0 or 1. If you have 1 bit long address, you have two possible addresses: 0 or 1. A two-bit system has four possible address: 00 =0, 01=1, 10=2, 11=3. 2^2=4. Three bits have 8 possible addresses: 000=0, 001=1, 010=2, 011=3, 100=4, 101=5, 110=6, and 111=7.

Each bit doubles the potential address space, which is why 2^n tells you how many addresses you use for a given number of bits. 2^1 = 2, 2^2 = 2*2 = 4, 2^3 = 2*2*2 = 8, etc. By the time you get to 32 bits, you have allocated address to 2^32 = 4294967296 bytes of RAM space which is equal to 4GB.

(((2^32bytes/2^10)KB)/2^10)MB)/2^10)GB = 2^2GB

Okay, so if the processor, and the operating system designed for that processor, can only handle 4GB, why can’t your PC (if it’s 32-bit) see that much practically?

Because not all of those addresses are available for RAM. There are other pieces of hardware inside your computer that need addresses, such as the PCI bus and the USB host adapter, Graphics card, etc.


Whenever you store something in the memory, you need to save the address to be able to read or manipulate it. Usually, the CPU uses only one register (32 bit in size) to store this address. Since there are only 2^32 different addresses, anything exceeding the 4GB mark remains unused.

However, there are techniques like Physical Address Extension (PAE) that allow a 32-bit OS to address more than 4GB of RAM.


Source of some info, More Source

What is the best strategy to improve my skills in competitive programming in 2-3 months?

Answer by Sachin Gupta:

This post has been taken from the blog post  Learn to Code by Competitive Programming written by MV Kaushik when he was interning at HackerEarth

Here are some steps to get started and be good at it.

    • Get comfortable writing code in either of one of these languages C, C++ or Java. Why only C, C++ or Java? Because these are the standard languages allowed in any programming competition.
    • If you are already good at C, it is suggested to learn C++. It is the most popular language among competitive programmers because of its speed and an excellent library in the form of STL (Standard Template Library).
    • Pick an online judge. Recommended ones are Topcoder and Codeforces. These sites have high quality of problems and also allow you to see other’s code post contest completion. These also categorize problems based on the topic. Some other popular judges include SPOJ, CodeChef (powered by SPOJ) andHackerEarth.
    • To begin with, start with simple problems that typically require transformingEnglish to code and does not require any knowledge on algorithms. Solving Div 2 250 (Division 2, 250 points) in Topcoder or Div 2 Problem A in Codeforces is a good start.
    • At the early stages of programming one tends to write long pieces of code, which is actually not required. Try to keep codes short and simple.
    • Practice these problems until you become comfortable that you can submit it for 240 odd points on any day.
    • Start implementing basic(or standard) algorithms. It is suggested to read them from Topcoder tutorials or Introduction to algorithms.

      1) Graph algorithms: Breadth first search(BFS), Depth first search(DFS), Strongly connected components(SCC), Dijkstra, Floyd-Warshall, Minimum spanning tree(MST), Topological sort.

      2) Dynamic programming: Standard dynamic programming problems such as Rod Cutting, Knapsack, Matrix chain multiplication etc.

      3) Number theory: Modular arithmetic, Fermat’s theorem, Chinese remainder theorem(CRT), Euclidian method for GCD, Logarithmic
      Exponentiation, Sieve of Eratosthenes, Euler’s totient function.

      3) Greedy:  Standard problems such as Activity selection.

      4) Search techniques: Binary search, Ternary search and Meet in the middle.

      5) Data structures (Basic): Stacks, Queues, Trees and Heaps.

      6) Data structures (Advanced): Trie, Segment trees, Fenwick tree or Binary indexed tree(BIT), Disjoint data structures.

      7) Strings: Knuth Morris Pratt(KMP), Z algorithm, Suffix arrays/Suffix trees. These are bit advanced algorithms.

      8) Computational geometry: Graham-Scan for convex hull, Line sweep.

      9) Game theory: Basic principles of Nim game, Grundy numbers, Sprague-Grundy theorem.

      The list is not complete but these are the ones that you encounter very frequently in the contests. There are other algorithms but are required very rarely in the contests.

    • You can find description and implementation of standard algorithms here
    • Once you have sufficient knowledge of popular algorithms, you can start solving the medium level problems. That is Div 2 all problems in Topcoder and Codeforces. It is advisable not to go for Div 1 500 at this point.
    • Learning to code is all about practicing. Participate regularly in the programming contests. Solve the ones that you cannot solve in the contest, after the contest. Apart from Topcoder and Codeforces you can also look at HackerEarth Challengesor Codechef contests.
    • Read the codes of high rated programmers. Compare your solution with them. You can observe that it is simple and shorter than your solution. Analyse how they have approached and improve your implementation skills.
    • Read the editorials after the contest. You can learn how to solve the problems that you were not able to solve in the contest and learn alternative ways to solve the problems which you could solve.
    • Always practice the problems that you could solve in the contest. Suppose if you are able to solve Div 2 250 and 500 in the contest but not Div 2 1000 then practice as many Div 2 1000 problems as as you can.
    • Do not spend too much time if you are not getting the solution or are stuck somewhere.
    • After you feel that you have spent enough time, look at the editorials. Understand the algorithm and code it. Do not look at the actual solution before you have attempted to write the code on your own.
    • Programming is a very practical and hands on skill. You have to continuously do it to be good at it. It’s not enough to solve the problem theoretically, you have to code it and get the solution accepted. Knowing which algorithm/logic to use and implementing it are two different things. It takes both to be good at programming.
    • Programming learning phase is going to take a lot of time and the key is practicing regularly. It takes some time before you can attempt Div 1 500 and other tough problems. Do not give up on reading the editorials and implementing them, even if it takes many hours/days. Remember everything requires practice to master it.

It takes considerable amount of time before you get good at it. You have to keep yourself motivated throughout. Forming a team and practicing is a good choice. Not giving up is the key here.

What is the best strategy to improve my skills in competitive programming in 2-3 months?

What was Anudeep Nekkanti’s Competitive Programming strategy to become 35th in Global ranking, in just 6-7 months?

Answer by Anudeep Nekkanti:

What I did ?

Result ?

  • Became very good with C++ and STL
  • Got introduced to most Competitive programming KEYWORDS (like DP, maxflow, sets, hashing, etc)
  • Learned Standard Problems and Algorithms
  • Indenting code
  • Fast typing 😛

How ?
Before starting programming, I searched about how and where to start, many said “Learn an Algorithm, implement it, solve  problems related to it”. I did not do it that way, If you know what algorithm to use you generally think in that direction and leave about correctness.  I did them problem by problem, easy to hard, I spent 1 – 4 hours on a problem.
I get the idea, I code it, Get it Accepted. (I used to test a lot, I always wanted to get AC on first go)

I do not get the idea, I save that problem and try it after a month again. If I still do not get them, then search for hints. If it clearly needed some algorithm which I never used then I first smile (? I could not only because I did not knew the algorithm 😛 ) and then start reading about that algorithm. TopCoder had tutorials of almost all common algorithms. This is where I did a BIG MISTAKE. I never cared about correctness or run-time analysis proof, I always learned how to solve the problem using that algorithm, I hardly learned about how the algorithm works. I feel bad about it now, but that is how I solved those problems then. I solved max-flow, convex hull, etc., problems using described algorithms but I did not UNDERSTAND those algorithms then.

Mistake: Once I started taking part in contests, I completely stopped practice.

35th in Global Ranking

  • CodeChef long contests are comparatively easy ( Which is good, You can learn a lot), you get a lot of time to think about a problem, search for resources. You only need KEYWORDS to search for similar problems.
  • I gave a lot of time for each contest. I used to solve 4 easy problems in 2-3 days, then take 5-6 days for other 3 problems.
  • CodeChef rating system is not good. It is highly Volatile.

If I am to start programming now, I would do it this way

  1. Solve 200 most solved problems on SPOJ, Problem by problem. In 2 months.
    (This will teach all standard problems, algorithms and implementation skills)
  2. Solve problems from CodeChef and CodeForces for 2 months.
    (This will teach variations, we can read others solutions and learn better ways. Skip easy problems)
  3. Solve problems from TopCoder for 2 months.
    (This will teach  Dynamic Programming. Div 1 500p)
  4. Check past ACM ICPC Regional’s Problems
    (Great quality problems)

If I am to learn a new Algorithm now, I would do it this way

  1. Read it from at least 3-4 different sources.
  2. Understand correctness proof and run-time analysis.
    (This is very very important, you will know it only when you  deal with non standard  and hard problems)
  3. Question yourself on every step for correctness. Try to tweak the implementation.
  4. Check other implementations.

Final Note
Thought I became good in solving problems and had good rank. I later(Feb 13) realized that I learned it the wrong way. I then started learning again. I learned all the algorithms again this time gave importance to the algorithm itself, correctness proof and mathematical analysis. It is worth the time.

Lucy and the Flowers – Problem from December long contest, Try to solve it with suffix arrays. You can only if you understand suffix arrays and LCP completely.

I was able to solve a not-so-obvious medium level Max-Flow problem at ACM KGP Onsite only because I completely understood how the algorithm works. It was at 4 hour 25 minutes I got 5th problem accepted, then I read this problem and got it accepted 4 minutes before end. Learning the algorithm helped. Dot.


What was Anudeep Nekkanti’s Competitive Programming strategy to become 35th in Global ranking, in just 6-7 months?

What are the best-kept secrets of great programmers?

Answer by Jeff Darcy:

Never reveal all that you know.

OK, seriously this time.  I think there are really a few things that distinguish great programmers.

  1. Know the concepts.  Solving a problem via memory or pattern recognition is much faster than solving it by reason alone.  If you’ve solved a similar problem before, you’ll be able to recall that solution intuitively.  Failing that, if you at least keep up with current research and projects related to your own you’ll have a much better idea where to turn for inspiration.  Solving a problem “automatically” might seem like magic to others, but it’s really an application of “practice practice practice” as Miguel Paraz suggests.
  2. Know the tools.  This is not an end in itself, but a way to maintain “flow” while programming.  Every time you have to think about how to make your editor or version-control system or debugger do what you want, it bumps you out of your higher-level thought process.  These “micro-interruptions” are small, but they add up quickly.  People who learn their tools, practice using their tools, and automate things that the tools can’t do by themselves can easily be several times as productive as those who do none of those things.
  3. Manage time.  Again it comes back to flow.  If you want to write code, write code.  If you want to review a bunch of patches, review a bunch of patches.  If you want to brainstorm on new algorithms . . . you get the idea.  Don’t try to do all three together, and certainly don’t interrupt yourself with email or IRC or Twitter or Quora.  😉  Get your mind set to do one thing, then do that thing for a good block of time before you switch to doing something else.
  4. Prioritize.  This is the area where I constantly see people fail.  Every problem worth tackling has many facets.  Often, solving one part of the problem will make solving the others easier.  Therefore, getting the order right really matters.  I’m afraid there’s no simple answer for how to recognize that order, but as you gain more experience within a problem domain – practice again – you’ll develop a set of heuristics that will guide you.
  5. Reuse everything.  Reuse ideas.  Reuse code.  Every time you turn a new problem into a problem you already know how to solve – and computing is full of such opportunities – you can save time.  Don’t worry if the transformed solution isn’t absolutely perfect for the current problem.  You can refine later if you really need to, and most often you’ll find that you’re better off moving on to the next problem.

A lot of these really come down to efficiency.  As you move through more problems per day, you’ll gain more experience per day, which will let you move through more problems per day, and so on.  It’s a feedback loop; once you get on its good side, your effectiveness (and value) will increase drastically.

What are the best-kept secrets of great programmers?