The temptation to earn Bitcoins is understandable as Bitcoin is valued as world’s most expensive currency at current rates. But who mints Bitcoins? How are they distributed? and most importantly how can you earn them? these are the questions we will answer in this beginner’s guide to bitcoin mining. But let me give you a little headache first, remember this quote “Bitcoins cannot be earned but learned!” If you are not already familiar with Blockchain technology read this article.

What is Bitcoin Mining?

A large network of peers (miners) make it possible for ordinary users to transact Bitcoins. Every time new transactions are added to Bitcoin’s public ledger one peer (yes exactly one) is rewarded with 25 Bitcoins and some commission. This peer is said to have mined Bitcons.

Who Gets the Reward and How?

New transactions are grouped together into a block. Before a block is added to the blockchain every peer tries to find out SHA-256 of newly created block. But there is a condition, that is, the hash value must start with 17 leading zeroes.

00000000000000000016809681d5da16801d2ff73747bb7bb0e4f4a4846fff29 An Example Hash of a Valid Block

A peer who finds out such a hash first gets the reward. This mechanism called proof of work is required to validate the transactions and keep the spam away. Read more about proof of work here.

How Can I Become a Bitcoin Miner?

You need hardware, software, network bandwidth and electricity to run your mining setup. Following are the steps to start mining:

  1. Download Bitcoin Core software on your desktop or laptop (See requirements)
  2. Around 140 GB of Blockchain is downloaded one time.
  3. Keep your node running and connected!

Can You Really Earn Money With this Simple Setup?

No. People with better hardware have higher chances to solve the puzzle (find the hash) than your simple laptop setup. Dedicated mining hardware is available which is sold for few dollars to thousands of dollars. This hardware is better at finding hashes because it is designed specifically for that job. 25 Bitcoins is a huge reward! People have made huge investments to earn it. But all hope is not lost for you, read on.

Joining a Bitcoin Mining Pool

Small-time miners have united and created mining pools. Mining pool is network of miners within the Blockchain network where miners cooperate with each other to find the hash and any reward is shared among all the participating peers. Many of these pools originates from China where electricity is really cheap. You can check out BTC.com or Antpool.

Should You Become a Bitcoin Miner?

This is more of an economical question than technical one. Bitcoin mining involves expenses of running costly hardware setup, good network, and uninterrupted power supply. Electricity costs can be an issue in developed world whereas network bandwidth and availability of quality power supply can be tricky questions in developing countries. Fluctuating Bitcoin prices can be another concern see the graph:
baseUrl = “https://widgets.cryptocompare.com/";
var scripts = document.getElementsByTagName(“script”);
var embedder = scripts[ scripts.length - 1 ];
(function (){
var appName = encodeURIComponent(window.location.hostname);
var s = document.createElement(“script”);
s.type = “text/javascript”;
s.async = true;
var theUrl = baseUrl+’serve/v1/coin/chart?fsym=BTC&tsym=USD’;
s.src = theUrl + ( theUrl.indexOf(“?”) >= 0 ? “&” : “?”) + “app=” + appName;

Alternatives to Bitcoin Mining

Bitcoin is the most popular cryptocurrency but it is not the only one. Its popularity can be a disadvantage to a miner who has to spend more resources simply because the competition is high. You can choose alternative cryptocurrencies such as Ethereum. Whetever cryptocurrency you choose, the fundamentals remain the same.


Bitcoin mining involves solving straight forward but time taking mathematical puzzle that is finding out a hash value with leading 17 zeroes. A miner profits from reward and commissions when he successfully solves the puzzle. Mining in a stand alone mode requires high initial investments. Therefore, individuals more often choose to be part of a large mining pool where miner cooperatively work as one entity on the Blockchain network and share the reward.


  1. Blocks Mined Today, Blockchain.com
  2. Minimum Requirements for Running a Full Node, Bitcoin.org
  3. Mining Profitability Calculator, Alcula.com
  4. Data Mining Rigs Comparison, 2018, Techradar

If you have questions please feel free to discuss in the comments section.

Proof of Work (PoW) is a consensus algorithm used in the original Bitcoin implementation. In a Blockchain system new transactions are periodically added by packaging these transactions in a block. This block is then added to the Blockchain. Please read What is Blockchain Technology if you don’t already know.


Users send each other digital tokens (e.g. Bitcoins). All such transactions are stored in a public ledger which implemented on Blockchain. But before transactions are added to the ledger they need to be confirmed. There are special nodes in the network called peers or more popularly miners who are responsible for confirming transactions and adding them to blocks. A block generally contains multiple transactions.

How It Works?

When a new block needs to be added to the Blockchain, every peer in the network tries to solve a puzzle. Whoever solves the puzzle first is given a reward and the block is added to the Blockchain. The puzzle is nothing but finding a SHA-256 hash of given block data in such a manner that the hash value must start with certain number of zeroes. This is known as target hash. A random number (called nonce) is attached to the original data and the peer keeps trying different nonces until it finds target hash. Current target in Bitcoin is 17 zeroes. Setting a higher target value will make it more difficult to find a required hash. This requirement of certain number of leading zeroes in the hash is known as target. Finding target hash requires enormous computing power but verifying it is easy. Suppose peer A finds target hash and sends it to peer B, peer B can easily verify it because nonce value is also known.

Why is Proof of Work Needed?

In the absence of Proof of Work, the Blockchain system can be spammed with illegitimate transactions. It is from Proof of Work that Bitcoin gets its value. A peer who successfully adds a block, gets 25 Bitcoins! There is another popular alternative to Proof of Work known as Proof of Stake. More on it later.

What is blockchain technology? is perhaps the most buzzing question in tech right now. A blockchain as the name suggests is a chain of blocks. Each block contains some information; a blockhain can store complete information about a financial transaction, a contract or a medical record. Important property of blockchain is that the data stored in it cannot be modified, backdated or tempered by any means. You can think of blockchain as a real-life notary. This technology is the backbone of cryptocurrencies such as Bitcoin. But its usage is not limited to cryptocurrencies and it is rapidly growing in other areas.

How does it work? Each block in the blockchain stores three things:

  1. Data
  2. Hash
  3. Hash of the previous block

1. Data : It can be any piece of information. For example, in case of Bitcoin it is transaction Amount, sender and receiver.

2. Hash : is a small piece of text which calculated from data. Important properties of hash value is that it is unique means two data will have same hash. When data changes hash also changes. If we make even a minor change in the data, hash value will change.

3. Previous block’s hash : Each block will store hash of its previous block along with its own. Storing hash of the previous blocks creates a chain of blocks. This is where security comes from. The first block is an exception because it doesn’t store hash of the previous block; this block is called Genesis block.

Why is it secure? Changing a single block will make all following blocks invalid because next block knows current block’s hash by next block. You may think why cannot we temper all the blocks? Well, there is another layer of security: peer-to-peer distribution of the blockchain. Peer-to-peer distribution means that entire blockchain is stored in multiple copies in a network of peers which doesn’t have a central control. This network is open for all, anyone can be a peer.

Proof-of-work Creating blocks require solving a mathematical equation which is time-consuming. You need great deal of computing power. Buying powerful computers is costly and so is running them. This process is call Proof-of-work. When a new block is added, all peers have to build consensus on validity of the new block. If you want to temper with a block you need to control at least 50% of the peer network.

In a nutshell If you want to temper with a block, you need to:

  1. Temper with all blocks in the chain
  2. Rebuild the proof of work
  3. Take control of more than 50% of peers

All of the above is nearly impossible to achieve. Blockchain technology is continuously growing and changing. Smart contracts are the new addition to it. A smart contract is a program stored on blockchain which can automatically transfer cryptocurrency if certain conditions are made.

Please feel free to comment below if you have questions.

MapReduce real world example on e-commerce transactions data is described here using Python streaming. The example does not require Hadoop installation. However, if you have Hadoop already installed it will run just fine on it. Python programming language is used because it is easy to read and understand. A real world e-commerce transactions dataset from a UK based retailer is used. The best way to learn with this example is to use an Ubuntu machine with Python 2 or 3 installed on it.


  1. The dataset consists of real world e-commerece data from UK based retailer
  2. The dataset is provided by Kaggle
  3. It contains 5.42k records (which is not small)
  4. Our goal is to find out country wise total sales
  5. Mapper multiplies quantity and unit price
  6. Mapper emits key-value pair as country, sales
  7. Reducer sums-up all pairs for same country
  8. Final output is country, sales for all countries

The Data

Download:Link to Kaggle DatasetSource: The dataset has real-life transaction data from a UK retailer. Format: CSV Size: 43.4 MB (5,42,000 records) Columns:

  1. InvoiceNo
  2. StockCode
  3. Description
  4. Quantity
  5. InvoiceDate
  6. UnitPrice
  7. CustomerID
  8. Country

The Problem

In this MapReduce real world example, we calculate total sales for each country from given dataset.

The Approach

Firstly, our data doesn’t have a Total column so it is to be computed using Quantity and UnitPrice columns as Total = Quantity * UnitPrice.

What Mapper Does

  1. Read the data
  2. Convert data into proper format
  3. Calculate total
  4. Print output as key-value pair CountryName:Total

What Reducer Does

  1. Read input from mapper
  2. Check for existing country key in the disctionary
  3. Add total to existing total value
  4. Print all key-value pairs

See this article on how to run this code

Python Code for Mapper (MapReduce Real World Example)

#!/usr/bin/env python
import sys

# Get input lines from stdin
for line in sys.stdin:
# Remove spaces from beginning and end of the line

line = line.strip()

# Split it into tokens

tokens = line.split(',')

#Get country, price and quantity values
country = tokens\[7\]
price = float(tokens\[5\])
qty = int(tokens\[3\])
print '%s\\t%s' % (country, (price\*qty))
except ValueError:

Python Code for Reducer (MapReduce Real World Example)

#!/usr/bin/env python
import sys

# Create a dictionary to map countries to totals
countrySales = {}

# Get input from stdin
for line in sys.stdin:
#Remove spaces from beginning and end of the line
line = line.strip()

# parse the input from mapper.py
country, total = line.split('\\t', 1)

# convert total (currently a string) to float
total = float(total)
except ValueError:

#update dictionary
countrySales\[country\] = countrySales\[country\] + total
countrySales\[country\] = total

# Write the tuples to stdout
for country in countrySales.keys():
print '%s\\t%s'% (country, countrySales\[country\])


Country Score
Canada 3599.68
Brazil 1143.6
Italy 16506.03
Czech Republic 707.72
USA 1730.92
Lithuania 1661.06
Unspecified 4746.65
France 197194.15
Norway 34908.13
Bahrain 548.4
Israel 7867.42
Australia 135330.19
Singapore 9054.69
Iceland 4299.8
Channel Islands 19950.54
Germany 220791.78
Belgium 40752.83
European Community 1291.75
Hong Kong 10037.84
Spain 54632.86
EIRE 262112.48
Netherlands 283440.66
Denmark 18665.18
Poland 7193.34
Finland 22226.69
Saudi Arabia 131.17
Sweden 36374.15
Malta 2503.19
Switzerland 56199.23
Portugal 29272.34
United Arab Emirates 1877.08
Lebanon 1693.88
RSA 1002.31
United Kingdom 8148025.164
Austria 10149.28
Greece 4644.82
Japan 34616.06
Cyprus 12791.31


  • Mapper picks-up a record and emits country and total for that record
  • Mapper repeats this process for all 5.42k records
  • Now, we have 5.42k key value pairs
  • Reducer’s role is to combine these pairs until all keys are unique!

If you have questions, please feel free to comment below.

Arduino serial communication is one of the many ways Arduino talks to other devices. Arduino uses asynchronous serial communication to send-receive data to and from other devices. Arduino Uno supports serial communication via on-board UART port and Tx/Rx pins. Generally this transmission happens at 9600 bits per second which is termed as baud rate. [caption id=”attachment_840” align=”aligncenter” width=”424”] Arduino Uno Shown with UART port and Tx,Rx Pins[/caption] Arduino may communicate with many devices including:

  • Another Arduino
  • A computer
  • LCD display
  • Modem
  • Or any device that supports serial communication

How to do it? In this example we’ll connect Arduino and a computer using UART port. For this we are going to use Arduino IDE’s Serial Monitor. Serial Monitor will display data we sent from Arduino Uno. Code:

void setup() {

void loop() {
Serial.println(“Hello World…”);

Upload this code and select Tools > Serial Monitor (Shift+Ctrl+M). You should see this output. [caption id=”attachment_841” align=”alignnone” width=”579”] Serial Monitor output on the computer[/caption] Further Reading:

  1. Wikipedia: Serial communication
  2. Arduino Reference: Serial

Arduino pushbutton example shows how to read a pushbutton with Arduino Uno. Pushbuttons (also spelled push-buttons) are widely used in calculators, phones and appliances. It closes the circuit when pushed and keeps it close until it is pressed. As soon as you release the button the circuit is open again. Here, we are going to use a push-button to flash built-in LED on Arduino Uno. The circuit is pretty simple! [caption id=”attachment_832” align=”alignright” width=”300”]Circuit diagram Circuit Diagram Showing Connection of Arduino Uno and a Push-button[/caption] Parts needed:

  1. Arduino Uno
  2. A push-button

Approximate Cost: ₹ 30 ($ 0.50)



// Declare the pins for the Button and the LED
int buttonPin = 12;
int LED = 13;

void setup() {
// Define pin #12 as input and activate the internal pull-up resistor
pinMode(buttonPin, INPUT_PULLUP);
// Define pin #13 as output, for the LED
pinMode(LED, OUTPUT);

void loop(){
// Read the value of the input. It can either be 1 or 0
int buttonValue = digitalRead(buttonPin);
if (buttonValue == LOW){
// If button pushed, turn LED on
} else {
// Otherwise, turn the LED off
digitalWrite(LED, LOW);


  1. What is internal pull-up resistor?
  2. Wikipedia: Push-button
  3. Same project with an external pull-up resistor

In this article we’ll learn displaying hello world on LCD; Interfacing 16x2 LCD with Arduino Uno and display some text on it. Writing Hello World pleases the gods of any new programming language that you want to learn. But in case of Arduino it is the LED blinking program that is generally written first. Any ways, Hello World can certainly be second if not the first so let’s roll!

Parts needed:

  1. Arduino Uno
  2. 16 x 2 LCD
  3. Some jumper wires

Approximate Cost: ₹ 125 ($ 2)

The Code:


//Initialize LCD with interface pins
LiquidCrystal lcd(0, 1, 8, 9, 10, 11);

void setup() {
//Initialize LCD's number of columns and rows (16,2)
lcd.begin(16, 2);

void loop() {
//Set the cursor to column 0, line 0
lcd.setCursor(0, 0);

lcd.print("Hello World to Circuitry!");

//Delay of 0.75 sec

//Shift data to the left

Finally check and upload the code. Read this article to know how to upload and run the code.


  1. 16 x 2 LCD Datasheet
  2. My simulation of this project on Tinkercad
  3. Arduino Howto

LED Blinking on Arduino Uno should be your first Arduino project. Arduino Uno has an on-board or built-in LED, in this project we will see how to blink it.

Parts you will need:

  1. An Arduino Uno


  1. Connect Arduino with your computer.
  2. Download, install and open Arduino IDE. (See how)
  3. Within IDE chooose File Menu > Examples > 01. Basics > Blink
  4. Now click Verify button and wait for it finish the verification
  5. Finally click on Upload button, and you’re done!
  6. See the LED blinking!


  • Built-in LED is referenced by pin number 13.
  • In setup(), we declare this pin as output pin as we want to use it as so.
  • Next, in loop(), we turn it on, then wait for some time (delay) and than turn it off.
  • This process repeats infinitely.

Remember that this is your first Arduino project, do not worry much if you don’t understand every piece of it. If you are facing difficulties and need help, use comments section below.

Arduino is an open-source hardware prototyping platform. It is widely used today in electronics projects because it is easy to learn, simple in design, well documented and cheaper. We call it platform because it is both hardware circuit as well as piece of software, the IDE. It also has its own programming language. All these open-source components collectively makes the Arduino platform.

Bit of History: It all started at IDII, Ivrea, Italy in 2003 when some students at the institute started working on creating a low cost prototyping tool for digital projects. Arduino’s sturdy design tells us that it is created by design people and not hardcore electronics guys. You know how bad they are :P! The project witnessed steady rise in its popularity and today it has become the most popular prototyping tool.

Arduino Circuits: As of writing this there are 58 different types of Arduino circuits (simply referred to as Arduinos). You can choose from this variety of circuits the one which fits your application needs. The most popular of them is Arduino Uno.

Arduino IDE: This piece of software helps you write application logic with a fancy editor, compile it and burn it on the circuit board. It can be installed on Windows, Linux and Mac OS platforms. There is also a web based IDE (if you just want to try).

Arduino Programming Language: Arduino programs are called sketches. A sketch is divided into two parts setup() and loop(). Numerous built-in functions are available to make the job easy. The language is largely inspired by C, try to see the code displayed in IDE!

Arduino Culture and Community: Arduino has a strong community helping each other on forums and sharing project ideas. The official website itself is a great resource for learning basics. Arduino day is a world-wide event celebrated in April each year that brings together developers, enthusiasts, students, teachers and novices.

Suggested Reading:

  1. The Untold History of Arduino by Hernando Barragán
  2. Arduino - Products
  3. Arduino Language Reference
  4. Arduino Web Editor
  5. Arduino Forums
  6. Arduino Day at Department of Computer Science, KSKVKU
  7. Download this Article as PDF

A major threat to your privacy emanates from your smart phone. These devices have become central medium of social interaction for everyone. Android is the only open source platform among the popular smart phone operating systems. But even with Android your privacy is under attack as large corporations have figured out that data is the new oil. Android privacy threats, for the scope of this article, are of three kinds: emanating from the device itself, emanating from third-party apps, emanating from your carrier. In this article I try to explain how to counter these three categories of threats to an extent where you can still use your phone, you don’t need any technical knowledge and you don’t pay anything. Privacy threats from the device itself: A new device may contain pre-loaded apps and services from carrier or from the manufacturer. Such apps are referred to as bloatware. These preloaded apps have a potential to share your data with your carrier or manufacturer. Solution: You should simply disable all such apps. Privacy threats from third-party apps: Majority of third-party apps are not open source which means you don’t know what these apps actually do with your phone. YouTube, Instagram, PayTM are all examples of such apps. In fact majority of apps sold on Google Play Store are proprietary in nature. Solution: Use only open source apps from F-Droid or other providers. Stop using Play Store, only first few days would be painful, you will slowly discover the beauty of being free from proprietary software. Using F-Droid for example you replace YouTube with NewPipe which is way better than official YouTube app in terms of functionality. Now, there are apps which you simply cannot do without e.g. Facebook, Instagram etc. Such apps can be replaced with their web version using WebApps. Privacy threats from carrier: Everything you do on Internet using your phone is recorded by your carrier. All data traffic from your phone has to go through carrier’s servers. Carriers maintain logs of all websites you visit, every video you play and sometimes even your passwords can be stored. There are definite laws in India as to what can and what cannot be logged by carriers! In short, they have got you! Solution: Use an anonymous VPN which doesn’t keep a log. With VPN in place, carrier cannot see your data or requests, i.e. now carrier doesn’t know which website you visit or how long do you stay there. Free VPNs such as can be used. If you have questions, please feel free to comment below.