Aspect Ratio is one of the important parameter in photography that determines the quality of a photograph. In this article, we will try to understand what an Aspect Ratio means in photography and how to chose the best Aspect Ratio while taking photographs.
You might be taking your photographs using a dedicated Photographic camera or by using a simple smartphone camera, but what makes a real difference in how these images evolve ultimately depends on the Aspect Ratio of these images. So let us dwell in detail into understanding the concept of aspect ratios in pictures and how you can determine which is the best aspect ratio to use in your pictures, depending on the type of pictures you want to take.
When you look into any photograph, you will notice that it is composed of a two dimensional capture of a moment in time and place. This two dimensional aspect of the subject of the image is then captured and stored in your photograph in two dimension as well. In other words, your photograph has two dimensions associated with it, its width and its height. It is the ratio of this width and height of a photograph that is called its Aspect Ratio.
There exists many different aspect ratios used in photography these days such as the 4:3 Aspect Ratio, 3:2 Aspect Ratio or 16:9 Aspect Ratios. In addition to these, photographers sometimes also use aspect ratios such as 5:3, 5:4 and 1:1 as well for medium or large photographs.
When to use 1:1 Aspect Ratio
With the emergence of various social media platforms such as instagram, facebook or twitter, the unusual aspect ratio of 1:1 has become popular these days. With this kind of aspect ratio, users can record video or capture images while holding the smartphone vertically while still be able to view the resulting video or images horizontally without losing any information in the image.
When to use 4:3 Aspect Ratio
4:3 Aspect ratios are the most commonly used aspect ratio in TVs and films. However, even devices such as iPad and other tablets use 4:3 aspect ratio displays so images taken with aspect ratio 4:3 will view better on ipads and other tablets when compared to other ratios.
When to use 16:9 Aspect Ratio
The 16:9 Aspect Ratio has become a recent standard usually found in high definition pictures and videos that can be best viewed on a HD screen, TVs and monitors. In a HD image with higher resolution, we can get detailed information in an image even when we zoom into the picture.
When to use 9:16 Aspect Ratio
Just like 16:9 aspect ratio used in HD images and videos, there emerged its inverted 9:16 Aspect Ratio that was popularized by Snapchat in its “stories” feature. This is an aspect ratio where in user is expected to record videos in portrait mode (using their smartphone vertically instead of horizontally) and viewed in portrait mode (vertically) as well. With the “stories” feature of Snapchat becoming popular, this ratio has been adopted by other social networks such as Facebook and Instagram as well.
With so many new media applications becoming popular on smartphones, the aspect ratios of photography and videos keep on evolving, so this is not an all inclusive list but something that keeps on emerging as the time progresses.
In this article, we will look at how to write a Python program to add two numbers. This is a very simple Python program that is suitable for even a beginner in Python programming to work on it for getting hands on practice with Python.
In order to add two numbers in Python program, we need to first break down the problem into the following steps:
Breakdown of the problem of Adding two numbers
Receive the first input number from the user and store it in a Python variable.
Receive the second input number from the user and store it in another Python variable.
Store the final result in another Python variable called “result”
Print the value of the “result” variable.
In the above breakdown of the problem, you will notice that the Python program we will be written in such a way that the two numbers that need to be added will not be hard coded directly into the program itself but instead is written in a generic way such that we prompt the user to enter these two input values every time the Python program to add two numbers is run. This type of programming approach is often called general programming as the program is generic enough to receive any two different values each time it is run.
Pseudo-code To Add Two Numbers Using Python Programming Language
num1 = Receive First Input Number From The User
num1 = Receive Second Input Number From The User
result = (num1) Added to (num2)
Print the (result) on the screen
We can see from the above psuedo code that this is a simple program that receives two numbers from the user, adds them and print their results back on the screen. The above pseudo code gives us a nice little framework on how to write our program. The same pseudo-code can now be used to write a program to add two numbers using any programming language and not just Python!
Now that we have our problem broken down and pseudo code written, it is time for us to replace the pseudo code with actual Python programming code instructions.
Python Program To Add Two Numbers And Print Its Result
Fire up your Python IDLE interpreter and start typing in the code along with me for you to be able to understand this program better:
Python 3.5.2 (default, Oct 8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "copyright", "credits" or "license()" for more information.
Once in our python interpreter, let us start typing in our Python program commands. The first thing we need to do according to the pseudo code written above is the receive the first input number from our user. In Python program, the instruction code to be used to receive a value from its user is by calling the input() function. Input function will accept a string as its parameter that will be displayed to the program user when the program is run. So, with this knowledge, our first line of the Python program to add two numbers will be:
>>> num1 = input('Enter the first number\n')
Enter the first number
As you can see from the above code block, we have used the input() function to prompt our program user with the string “Enter the first number“. We are also saving the value entered by the user to a Python variable called num1.
The input function will then prompt with the above string and wait until the user enters a number. In the above code snippet, I had entered a value of 10 which is now stored in the variable num1.
In a similar way, we will write the next line of code which will prompt the user to enter a second input number that is to be added to the first number. This is achieved with the following piece of code:
>>> num2 = input('Enter the second number\n')
Enter the second number
Again over here, I have entered my second number as 20 when prompted.
Now that we have the two numbers in our Python variables num1 and num2, it is time add them to get the final result that we are going to store in our third Python variable called result. This is achieved using the following Python statement:
>>> result = int(num1) + int(num2)
So from the above python code, we have now added the numbers num1 and num2 using the Python arithmetic operator “+” and the typecast operator called “int()“. We had to use the typecast operator int because by default all inputs from the user into a python program will be interpreted and stored as a string. We can check this by issuing the following command in the interpreter:
So, by calling the typecast operator int, we are converting this string value to an integer value.
finally stored the end result in a new variable called result. Since we have not issued a Python command to print the value of result, nothing gets printed on the IDLE prompt yet. So, the final step is exactly that. To print the value of the result variable onto the screen. This is achieved using another Python function called the print function.
>>> print (result)
Here is the full program that we can store in a file called add2num.py and run it using the command python3 add2num.py everytime we want to add any two numbers!
num1 = input('Enter the first number\n')
num2 = input('Enter the second number\n')
result = int(num1) + int(num2)
This concludes our Python program to add two numbers.
Additional Side Notes On Python Programming Language:
Python is an interpreted programming language that gets interpreted and executed on the fly and hence the program written in Python do not need to be compiled like in the case of a C or Java programming language.
If you are just getting started with Raspberry Pi, connecting a simple LED to one of the GPIO pins of a Raspberry Pi and controlling it using software program that you write will give you a very good grasp of how a computer hardware and its program works internally. You will realize how you can control various aspects of a computer hardware using software, how a computer works at the bit level, how to write Python programs to control hardware and more.
In summary, working on getting an led connected to a GPIO pin of your Raspberry Pi will help you in understanding the fundamentals of a computer architecture and computer science in general.
What You Will Learn From This Project?
Connecting an LED to the GPIO pins of a Raspberry Pi to control it is a simple Beginner Raspberry Pi Project that lets you learn more about:
Raspberry Pi hardware internals
General Purpose Input/Output (GPIO) pins of a Raspberry Pi
Raspberry Pi Register Set
Python Library – Raspberry Pi GPIO library
The working of an Light Emitting Diode (LED)
What Hardware Is Required To Set Up A Blinking LED Project?
This a very simple, beginner friendly Raspberry Pi project that can be set up by anyone with minimal hardware or software knowledge. The hardware components required to set up this blinking LED project is also quite minimal. You need the following hardware components available with you to get it going:
Raspberry Pi Module
Raspberry Pi Power Supply
SD Card with working Raspbian OS
Jumper wires for rigging up the circuit
Resistor (1K Ohm)
Theory Behind How The Raspberry Pi Blinking LED Project Work
When you look at the Raspberry Pi board, you will see a bunch of pins protruding out. Among these, there is a row of 40 pins located on one side of the board as shown in the image below.
If you look closely enough in the above image, you will notice the label “GPIO” written right under it. These pins are called the GPIO pins or General Purpose Input Output pins. What the name GPIO implies is that these pins do not have any fixed functionality within the board and hence can be used for general purposes. It means that we can connect our LED into one of these pins and can turn it ON or OFF using these pins. But how?
How to control the Raspberry Pi GPIO pins programmatically?
Raspberry Pi 3 board runs on Broadcom’s ARM CPU chipset BCM2837. Among many other things, this processor chipset has a built in GPIO controller aka General Purpose Input Output controller. The 40 GPIO pins header shown in figure 1 is connected to 40 controllable pins of the GPIO controller. Now, we can control each of these pins individually by programming the appropriate registers inside this GPIO controller.
To understand how to program each of these pins using GPIO controller, we need to look into the Technical Reference Manual or datasheet of the Broadcom ARM chipset BCM2837.
In the BCM2837 SOC (System On Chip aka CPU) datasheet linked above, if we jump into page 89 we come across a dedicated chapter talking about General Purpose Input Output (GPIO). If we go through this chapter, we can learn about all the GPIO registers available and figure out the GPIO registers we need to program to turn ON or OFF the LED we are going to connect to the Raspberry Pi 3 GPIO pins.
As the name implies, GPIO pins can be configured as either an Input pin or an Output pin. When we configure a GPIO pin as an input pin, we are sending data bit (either 0 or 1) into the Raspberry Pi BCM2837 SOC i.e. data signal is sent from outside the board to inside the board (hence the name input). On the other hand, if we configure the Raspberry Pi GPIO pin as an output pin, the board will send the data bit signal (either 0 or 1) from inside the board to the outer world where any device connected to it will receive this signal.
So, if we want to control an LED that is connected to one of the Raspberry Pi’s GPIO pin, we need to configure that pin as a GPIO OUT pin (aka output pin) so that we can send an electrical signal from the Raspberry Pi board to the external LED connected to this pin.
The configuration of a GPIO pin to be an INPUT or OUTPUT pin is controlled by programming the GPIO Controller Register called GPIO Function Select Register (GPFSELn) where n is the pin number.
So for example, if we choose to use the GPIO8 pin to control the LED, i.e. we connect our LED to GPIO 8 pin, we need to program the GPFSEL register for the GPIO 8 pin and configure it as an Output pin. When we check the datasheet at page 91 and 92, we notice that GPIO pin is configured by setting the bits 26 to 24 in the GPFSEL register (that is field name FSEL8). And from the datasheet, we also find that to set the pin as an output pin, we need to set its value as 001 i.e. bit 26 is set to 0, bit 25 is set to 0 and bit 24 is set to 1.
So, if we can somehow set these values in the GPFSEL register using a programming language such as Python, we will be able to start controlling the LED connect to this pin!
If this is all overwhelming to you, do not worry. We will not have to scratch our head a lot for now as we can simply make use of Raspberry Pi’s GPIO Python library that helps us in making most of this work for us. But I just wanted to explain to you as to what this GPIO Python library is doing under the hood.
How To Connect An LED To Raspberry Pi GPIO?
Designing The Circuit
In order to connect an LED to GPIO pin 8 of Raspberry Pi, we need to first design and understand how the circuit is going to work.
Can we connect an LED directly to a Raspberry Pi GPIO pin without a resistor?
The answer is No. Raspberry Pi provides 3.3 Volts of power on its GPIO output pin according to Raspberry Pi datasheet specification. However, if we take a look at a standard LED, we notice that it normally operates at a much lower voltage. If we look at an LED specification, we notice that a typical LED usually operates at just 1.7 Volts and draws 20 mA. So, if we need to connect this LED to the GPIO pin of our Raspberry Pi, we need to bring down the voltage delivered by the pin to our LED to operate at or under 1.7V. How to do that? We connect a resistor in series with our LED so that the 3.3 Volts GPIO output of Raspberry Pi gets split between the resistor and our LED. By choosing a right value of the resistor such that it consumes 1.6 Voltage, we can ensure that LED finally gets only 1.7 Volts.
Calculating the resistor value to connect with LED and Raspberry Pi GPIO
In order to calculate the value of resistor that we should be using, we make use of the Ohm’s Law.
Ohm’s Law is defined using the equation:
V = I/R where V is the voltage, I is the current and R is the resistor value.
So, if we want to have V=1.6 Volts consumed by our resistor so that the current coming from GPIO pin is at I=20 mA, we need to connect a resistor whose value is:
1.6 = (20 mA)/R
or R = 80 Ohms (or approx 100 Ohms)
So, we choose a resistor of value 100 Ohms connected in series with our resistor to ensure that we only get 1.7 Volts and 20 mA of current, the optimum operating values as required by our LED.
A 100 Ohm resistor is identified by the color bands: Brown, Black & Brown.
Hook up the led through 100 Ohm resistor to GPIO 8 pin of Raspberry Pi as shown in the figure below:
Note that when you are hooking up the LED, the terminal pin that is longer is positive. Once you have connected as shown in the figure, it is now time to program the Raspberry Pi GPIO controller to start controlling the LED to turn ON or OFF.
We will be using Python to program our Raspberry Pi GPIO controller. Now, the simplest way to program this is by making use of the Python GPIO library.
To install the Python Raspberry Pi GPIO module, open up your linux terminal and type the following command.
Now the above command will install the required Python GPIO library module onto our Linux development machine. Once successfully installed, It is now time to start programming the Raspberry Pi GPIO controller.
We will be toggling our GPIO pins at 1 second intervals such that our LED will turn ON and OFF forever until the Python program we write will be terminated i.e., we will be running the code to perform infinite loop of toggling the GPIO 8 pin ON and OFF.
Create a new file on your computer by typing the following command in the terminal:
This should create our new program file called blinky.py
Open up this file using nano editor by typing the following command in the terminal:
Now that the file is opened, it is time to start writing our program to control the GPIO Pin 8 using Python GPIO library module.
First thing first, we will import the Python GPIO library module using command:
import RPi.GPIO as GPIO
Next, we will import python time library to perform 1 sec sleep operation between each GPIO toggle
from time import sleep
Next, we need to configure our GPIO library to use our GPIO physical pin numbering as seen on the Raspberry Pi board physically:
This ensures that when we say GPIO pin 8 in the program, it actually maps to the GPIO Pin 8 seen on the Raspberry Pi board.
Next, configure GPIO pin 8 to be a GPIO Out pin and set its initial output value to be low:
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW)
Finally we will start an infinite loop in Python such that we turn ON the GPIO 8 (by setting it HIGH) or turn it OFF (by setting it LOW) after every 1 second delay. This is achieved using the program below:
while True: # Infinite loop
GPIO.output(8, GPIO.HIGH) # Turn GPIO 8 pin on
sleep(1) # Delay for 1 second
GPIO.output(8, GPIO.LOW) # Turn GPIO 8 pin off
sleep(1) # Delay for 1 second
That’s it, this should be all the program that we need to type in our blinky.py file and run it using the command:
This should start turning your LED ON and OFF every second!
Here is the full code for your reference:
import RPi.GPIO as GPIO
from time import sleep
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW)
while True: # Infinite loop
GPIO.output(8, GPIO.HIGH) # Turn GPIO 8 pin on
sleep(1) # Delay for 1 second
GPIO.output(8, GPIO.LOW) # Turn GPIO 8 pin off
sleep(1) # Delay for 1 second
This should conclude our tutorial on how to get a simple LED connected to a General Purpose Input/Output (GPIO) pin turning ON and OFF using a Python program that makes use of Python Raspberry Pi GPIO library. There can be many variants to this such as using other GPIO pins, connecting more than one LEDs to multiple GPIO pins and controlling them all in different ways to display interesting patterns on the LEDs. If we are even more curious, we can also figure out a way to control the BUILT-IN LEDs that are already present on our Raspberry Pi boards to bypass their current usage and be used for by own programs for our purposes.
We will dwell into these and many other interesting ways to make use of our Raspberry Pis to understand and learn more about the computer hardware, its architecture and much more in our future articles.
Jmtpfs is a combination of FUSE (Userspace Filesystem) and MTP (Media Transfer Protocol) stack integrated together to form a filesystem tool. The jmtpfs tool is then used to mount your smartphones or other handheld devices onto your Linux computer so that you can browse the content of your smartphone or handheld device directly from your computer.
What Is A FUSE Filesystem?
FUSE filesystem stands for Userspace Filesystem. In general cases, when you need to create your own filesystems, you need to have knowledge of the Operating System (OS) kernel and block storage device drivers. This would restrict the development of new filesystems to only kernel developers.
In Linux, in order to overcome this, a new type of filesystem model was introduced called the FUSE file system. In a FUSE filesystem, you will make use of a pre-written generic FUSE Linux kernel module, which you as a userspace developer need not have to modify. In addition to this, you will also make use of a pre-written FUSE userspace library that would provide the required API interfaces to the FUSE kernel modules form the userspace.
Using these two modules, it is now possible for the userspace developers to write their own filesystems by inserting the FUSE kernel module into their machine’s operating system and then writing their own filesystem with the help of FUSE library modules.
Such developed FUSE filesystems will place the files and directories exposed by the filesystem in the userspace region of the OS which is accessible by even non privileged users.
What Is Media Transfer Protocol (MTP)?
Media Transfer Protocol (MTP) is a type of protocol used to transfer media files such as audio files, videos files or image files at the file level rather than at the storage level. This protocol became a USB standard to transfer media files between a computer and a USB device.
The main reason why we would use an MTP protocol instead of the USB standard Mass Storage protocol is that when you use a Media Transfer Protocol (MTP) to transfer file, the whole file is transferred from the device to the computer or vice versa. So, the entire transfer of file happens as a single unit, hence transactional. In this way, both the device and host can continue to access the same file simultaneously, which is not possible when using a USB Mass Storage Device Class (MSC) protocol.
In case of an USB MSC protocol, when a USB mass storage device such as a music player is mounted on to a computer, the music player loses control over the files which is stored within itself and is taken over by the host computer’s filesystem. In this situation, the host computer can modify the content of the files and the USB device has no way to prevent it. This may lead to host computer corrupting the files of the USB mass storage device! But this situation is not at all possible when we use an MTP protocol due to its transactional file transfer nature. Hence MTP protocol is preferred over a USB MSC protocol.
JMPTFS tool makes use of both FUSE filesystem and the USB MTP protocol to mount the content of your smartphone onto a local directory on your computer, thereby giving access to the file contents of your smartphone even when you are a non privileged user.
How To Use Jmtpfs tool To Transfer Files From Your Smartphone
In order to use jmtpfs, you first need to create a local directory such as ‘myPhone’ in your computer. Next, you connect your Android or any other smartphone to your computer using an USB cable. Then by issuing the console command ‘jmtpfs myPhone’ you can mount the content of your smartphone onto your mount directory ‘myPhone’. In other words, after issuing the command, you will be able to browse the content of your smartphone within the mount directory ‘myPhone’ just like any other files and folders of your computer.
USB Type C aka USB-C is a new type of USB connector that is getting popular these days in both smartphones and laptops for their high transfer speeds and easy connectivity (You can connect it in any direction you want and it will still work!). In this article, we will try to explain to you what a USB Type C connector and cable is and why everyone are moving to them.
USB-C is a set of new form of USB connectors that comes in two forms namely:
USB Type C Receptacle
USB Type C Plug
Usually, the USB-C Receptacles are found in devices such as laptops while USB-C Plugs are found in smartphones. We will then use a USB Type C cable to connect our smartphone to the laptop.
Why do we need to use a USB-C over micro-USB?
A USB device such as a USB mouse, USB keyboard, USB Pen drives etc all talk to our computers or smartphones using a special language called USB protocol. This USB protocol is designed by an organization called USB Implementers Forum or USB IF for short.
The USB protocol has been evolving over the years and its latest protocol was designed and revealed by USB IF recently. This new protocol called USB 3.0 has increased the speed at which data gets transferred between the computer and USB devices (like smartphones, USB stick) from 480 Mbps in the earlier USB 2.0 specification to 5 Gbps in USB 3.0 specification! This is a huge increase in speed of data transfer between the devices and hence using USB 3.0 was a major upgrade over USB 2.0
USB Type-C is a new type of USB connector that was released almost at the same time as when the new USB 3.0 specification was released. So almost all the USB device manufacturers who wanted to use USB 3.0 specification also adopted USB Type-C connector instead of the usual micro USB connectors used with USB 2.0
Hence, USB-C connector has recently become synonymous to USB 3.0, although you will still be able to find devices with USB-C connector still following USB 2.0 specification.
This has also given raise to a myriad of problems and confusions in terms of choosing the appropriate USB 3.0 cables which we will address and explain how to identify them in the future articles.
How exactly is USB 3.0 connector different from micro USB connector?
A simple micro USB connector which we have all been using all these years simply had 5 pins within itself where two pins were used to power the device (Vcc, Gnd), two more pins where used to transfer the data (D+ and D-) and a final pin was used to detect the device type (Mode Detect).
However, in case of a USB Type-C connector, we have 24 pins in total, each of which had a unique role to play in the data exchange and charging of devices. So in simple terms, USB Type-C connector increased the pin numbers within each connector from 5 pins earlier in micro USB to 24 pins now in USB Type-C connector!
In the upcoming articles, we will go in detail to understand how USB 3.0 protocol works with the new USB-C or USB Type-C connector and how it achieves the extra-ordinary speed of 5 Gbps data transfers, but for now, this should give you enough idea on the USB-C connector type and its difference from the earlier micro USB connector.
In this article, we will learn about how to create a simple Virtual Private Server (VPS) running 64-bit Ubuntu 16.04 Operating System.
In case you have not created an account yet on Vultr, you can do so by visiting the link in the next paragraph and get $50 worth FREE CREDITS that you can use to create and use your Vultr Ubuntu VPS instances
Get Vultr VPS Worth $50 FOR FREE If you too would like to use Vultr VPS instance (which I strongly advise) while following these tutorial series, you can use the following Link to create your Vultr account and get $50 Free Credit which is more than sufficient to use and learn all about Linux, Web Development and much more for FREE!
Once you have created your Vultr account using the link above, you log into your Vultr account by visiting the Vultr Web App. Once you have logged in, you should be in the Products tab which would list all the Vultr instances you have created until now. Since your Vultr account is new, you will not have any instances listed there.
But do not worry, this is about to change now.
Create a new Vultr VPS by clicking on the link that read “deploy now” at the end of that Vultr dashboard web page. You will then be taken to a new web page as shown below:
Do not get perplexed by such a long web page with numerous options. While they may look baffling at first, it is actually pretty easy to use to create your first Vultr VPS instance. We will go through each of these options in a step by step fashion so that it is easier for you to follow and replicate.
Step 1 – Choose Server: Vultr not just provides services to deploy a VPS server, but also many more other products including Bare Metal Machine, Dedicated Cloud etc. However, in our case, we are only interested in deploying a simple VPS server running 64-bit Ubuntu 16.04 OS. Hence, we will simply choose “Cloud Compute” option which is what creates a VPS server.
Step 2 – Server Location: Next, we need to select where we want our VPS server to reside at. Vultr has its data centers spread across the globe and hence we have option to choose our VPS servers from various cities across the world as listed in the option. Choose the one which is closest to your and your web app’s visitors location is. This is because you will get a quick turn around time (time taken by the server’s response to be received) from your server if it is closest to your own location.
Step 3 – Server Type: In this option, we need to choose the type of Operating System (OS) we need to use. If for example we want to install 64-bit Ubuntu 16.04 OS, we select it over here.
Step 4 – Server Size: Next comes the size of the VPS server you want to deploy. This depends on a number of factors such as the amount of data size your app is going to use, the amount of traffic it gets, the speed of the CPU and the number of cores it holds etc. For tutorials and experiments, I usually just use the default selection of $10 per month VPS instance which gives comfortable performance for my requirements.
Step 5 – Additional Features: These are some advanced options which are not selected by default. These includes option to select IPV6 network addresses, backups etc. which I usually leave at its default unchecked state (in other words, I do not use it).
Step 6 – Startup Scripts: This option is useful if you need to run any additional scripts at the startup of your VPS instance. I have never used it until now so I may not be the right person to comment much about it! Sorry!! 😛
Step 7 – SSH Keys: SSH keys are special software keys that are used to create a secured shell protocol connection between your laptop/computer to your Vultr VPS server. In this option, you can generate SSH keys (using this tutorial) for your laptop and take the public part of the SSH keys and paste it here on the Vultr dashboard under this option. This way, you would not need to type in login and password every time you want to connect to your Vultr VPS server from your laptop’s command prompt.
Step 8 – Server Hostname & Label: Finally, you can create a new Hostname and label for your VPS server. This will result in the Vultr dashboard displaying this instance of the VPS server using this Hostname & Label.
Once you are done with filling up with all the above details in your Vultr dashboard, you can click on the “Deploy Now” button to create and deploy your Vultr VPS server. It may take a few minutes since clicking on the button after which your Vultr VPS server should be ready for use!
Hope this article gave you an insight into how to create and deploy a new Vultr VPS instance using Vultr dashboard. If you have any queries or any feedback on this article, do let me know in the comments below. Until next time, happy coding! 🙂
Fast charging of smartphone batteries are a new and must needed feature these days, especially with Android devices supporting it effectively across all variants of smartphones and tablets. Most of the smartphone supports less than 30 minutes of charging sufficient to reach over 75% of battery charge.
How does a smartphone charge so quickly?
Most of these Android smartphones that support this fast charging feature in them makes it possible by using a proprietary USB fast charging technology. These proprietary fast charging technologies while helps in improving the charge time, but because of their proprietary nature, works well only when you use their provided USB chargers and cables. So, as a result if you try to use a different USB charger or a USB cable, the charging time would go slow again, thereby making you lose all the advantages of fast charging capabilities.
Is USB Fast Charging Not Standardized For Smartphones?
This begs the question as to why we are going for a proprietary USB fast charging technologies that limits its usage to only its own USB fast chargers and USB cables. Can’t this not be standardized in such a way that they can be made to work with all USB chargers and USB cables used with our smartphones?
The answer is yes. We do have a USB fast charging capability built into the USB C standards, covered under the category USB Power Delivery (or USB PD for short). This standard states that all smartphones and similar handheld devices such as Android tablets that comes built with USB Type C connectors and cables need to meet and support the USB Power Delivery (USB PD) specification.
The USB Power Delivery specification states that these smartphone/tablet or other handheld devices need to be capable of delivering upto 100W of power.
However, even then, many Android Original Equipment Manufacturers (OEMs) still do not support this USB C Power Delivery (USB PD) specification and still continue to use proprietary USB fast charging technologies.
But recently, Google is coming down hard on these OEMs and trying to enforce USB PD support for all the Android devices manufactured by them, atleast from Android 10 onwards. This, when achieved, should eventually make all Proprietary USB Fast charging technologies redundant and bring in the USB Power Delivery (USB PD) as the industry standard for USB fast charging technology.
When this happen, we will finally be able to move out of proprietary USB Fast charging technologies and be free to use any USB chargers with any USB cables to charge our Android smartphones and tablets and still be able to enjoy the USB fast charging functionality.
Until then, we will have to make do with the warning messages on our smartphone devices that reads “Device charging slowly use original charger” when connected with non original USB chargers and USB cables. 🙁
Motorola One Macro Android smartphone is set to be launched on Flipkart this October 9, 2019. Motorola One Macro is yet another smartphone lined up along the Motorola One series, the Motorola smartphone series running on the Android One platform.
Motorola One Macro smartphone is said to boast a separate camera on its rear side that would be used specifically to capture Macro photography. Macro photography is a style of photography where in the photographer would capture a subject at extreme close up, there by revealing extremely detailed picture of the subject. Macro photography style is very popular in nature photography where one would take and expose a detailed picture of natural subjects such as flowers, leaves, trees, hives etc.
With Motorola One Macro smartphone, now the photographers will be able to achieve this even when they are not carrying their specialized camera equipment everywhere there go but yet have an urge to take macro photographs as and when the opportunity arises.
In order to achieve support for Macro photographs, Motorola One Macro smartphone is expected to feature a dedicated macro photographic camera sensor somewhere around 2 MP in resolution along with its standard 13 MP camera sensor and another 2 MP depth camera sensors, as usually found in all other Motorola One series of smartphones such as Motorola Vision, Motorola Action & Motorola Power.
While Macro photographic camera would be the main highlight of Motorola One Macro smartphone, it is also expected to boast a good 4000 mAh battery for a full day battery performance, a 6 inch plus LCD display and is also expected to run on a Mediatek processor, possibly Helio P60.
On the front camera side, the Motorola One Macro phone is also expected to carry a good high camera with a resolution as high as 8 MP.
As with the recently launched Motorola One Action smartphone in August 2019, the current Motorola One Macro smartphone is also expected to run on Android 9 Pie Operating System.
The Motorola One Macro smartphone is also expected to boast a tear drop type of notch, although we do not have many details to verify this.
The teaser page of Motorola One Macro smartphone is already up on the Flipkart e-commerce website which boasts some interesting features such as magnified details thanks to the Motorola One Macro’s Macro camera sensor, maximized speed for a quick capture even under challenging lighting conditions (read low lighting conditions), rapid charging, highly multitasking capable smartphone and more.
We will further keep you updated on the Motorola One Macro smartphone as soon as we get any further information. Until then, happy shopping!
Everyday, we programmers write hundreds of lines of programming code. But, have you ever stopped to notice if your program is good enough? How do you make sure your programming skill set is up to the mark? How to make sure you are Programming Like A Pro? In this article, we consider these questions and try to answer them each in greater details.
How To Code Like A Pro?
There are many characteristics of a program written by an experienced professional that sets his code apart from a code newbie. A professional programmer would make use of his past learning experience and implement his code that follows a certain set of guidelines and best practices he has learnt over the time since he began programming.
While each of these set of guidelines and best practices may differ from one Professional Programmer to another Pro, there are many common guidelines which more or less all Professional Programmers follow that can make their code set apart from the rest. Here is a list of some of such common guidelines used by almost all Professional Programmers. If you can practice and incorporate these practices and techniques into your daily programming routine, even your program code will start to look more professional.
Best Practices & Guidelines To Write Code Like A Professional
Write code that makes use of the processor efficiently – In other words, write code that runs fast on the processor using lower number of clock cycles. How to achieve this? While there are many things involved in learning to write a highly CPU efficient programs which will be explained in the future articles, some of the most common practices is to use loops sparingly, use efficient looping systems, write programs using instructions that require less clock cycles to accomplish the task at hand etc. You need to have good understanding of the underlying computer system architecture to get a better hold or control on these aspects, so learn more about the computer architecture.
Write code that makes use of memory efficiently – Use the memory of a computer system efficiently and sparingly. It usually takes certain amount of computer clock cycles to read and write data to or from the memory. So if you want your code to speed up, it is better to write code using instructions that uses lesser amount of memory. If your code allocates too many variables, it can start gobbling up a lot of RAM space in your user’s computer, there by slowing down the computer all together, thus giving a had user experience.
Write code that is more readable – This is one of the most important aspect of a professional code. You can write code in a convoluted way to do something extremely smart on its data, but if in the future you move on in your job role and your code is handed over to your junior developers, they will find it extremely hard to read and understand your code. So always write code that is easily readable by anyone familiar with programming. This can also include adding more comments in your source code, naming the variables appropriately etc. Sometimes, writing readable code could result in writing a slightly inefficient piece of code thus contradicting the above 2 points discussed earlier. But however, in such a situation, it is still advisable to give priority towards readable code than saving a few CPU clock cycles.
Write code that is highly modular – What does this mean? It means you need to break down your programming into individual modules such as functions and classes, that does one thing and only one thing but extremely well. Your code need to be split up into several functions, files and libraries that can be made use of in the future for other projects as well.
Write code that is well tested and documented – Each of your code modules need to be very well tested to ensure it fulfills and works under all boundary conditions. It should not break down for some unexpected values but gracefully reject the input under such situations. This is achieved by writing robust test cases that can test for all frequently possible conditions even if it occur only one in a million time (boundary conditions). Make sure that the code is well documented using comments and appropriate variable or function names as discussed earlier.
Write code that is easy to enhance – Before you sit down to write your code, you need to design to program to be highly modular and easy to enhance of its functionalities in the future. This would mean writing code that is modular, with will defined APIs and interfaces such that a function serving that API can be swapped for another function with a different implementation for the same set of input and output values.
There are still many more aspects of a professional’s code that usually depends on his style and taste of coding, but the above list should give you a good fundamental beginning on how to think and write code like a professional programmer.
In the future articles, we will continue to explore some of the fundamental aspects of computer science such as a computer’s architecture, its basic functionality etc that will help us getting a solid understanding the basics of computer science. Do let me know if you have any comments on this or any other topic you would want me to explore and I will be happy to accommodate your requests.
So you have decided to design and develop your own website? Great! But are you aware of all the things that you need to keep in the back of your mind when designing and developing your website? In this article, we will list some of the most important thing you need to consider when developing your website in 2019 & 2020.
1. Domain Name
The internet today is made up of over a billion of websites and web applications. With so many options at the tip of their hand, your website visitors will not be able to remember your website until and unless its name stands out from the crowd. So, pick a catchy website domain name that is easier for your website visitors to recollect in the future. Use the Namecheap’s search bar extensively to identify an easy to remember and available domain name. Ideally, a .com domain name is preferable over other domain name extensions as most of the non technical visitors by default assume the domain name to end with a .COM extension. It is also advisable not to use a name that is too long to remember or too many non interpret able characters such as vooooooooz.com (Here, it will be very difficult for your users to remember how many o’s are there in the domain name).
2. Web Hosting
Web hosting is the web server provider where your website will reside or hosted finally after web development activity is done. Where you host your website is very important as that becomes an important criteria in determining your website visitors satisfaction! Confused? You see, your website visitors will be very happy when your websites loads as quickly as possible. If it takes more than 10 seconds to load a web page, your website visitors will get frustrated and might close your website rather than waiting for it to completely load. As a result, the speed at which your web server delivers your website to its visitors plays a vital role in determining the ultimate customer satisfaction.
So how to determine which is the best web server to use?
Ideally, your web server must be located as close to your website visitor as possible. So for example, if your website visitors are mostly from the United States (US), you should host your website in a server located within the US. If your website is located in a far away location such as Australia, the amount of time required to deliver the web pages of your website from the server ot your website visitor will increase a lot!
What if your website visitors are coming from all across the world?
If you have a very generic website that appeals to all the people across the world, chances are you will have visitors coming into your website from across the globe round the clock. In such a case, where should we host the website? Well, the answer for this is to host your webserver across the globe!
Yeah, you heard it right. If you are getting visitors from across the world, you will still need to deliver your web pages from the web server closer to your user’s location! But how to do that? Allow me to introduce you to the “Content Delivery Network” or CDN for short.
What does a Content Delivery Network or CDN do?
Content Delivery Network or CDN is a type of web service provided by certain set of CDN service providers whose main job is to host copies of your website across multiple web servers around the world. They will take care of determining where your website visitors are coming from and decide upon which CDN web server to use to serve web pages to them. In that way, you are ensuring that all of your visitors coming from across the world will get the same quality of website access as every other user from any other location in the world.
If you are just beginning with your website, you dont normally need to go for a CDN until you are able to determine the geographical locations from where majority of your website user base is located at. So, we will revisit again regarding CDN in the future and ignore it for now.
So now that we understand that our web servers need to be very fast and located closer to the website’s userbase, where do we look for a web server and how to determine a web hosting provider?
How to choose a web hosting provider?
There are different types of web hosting providers in the market. Some of them provide us with a managed hosting where they will manage the entire web server related issues and you will only need to worry about your website related parts. They also usually host not just your website on their server, but many other websites from other website owners as well in the same server. So, in other words, you will be sharing your website’s web server with other websites and hence they are usually called as the Shared Web Hosting service providers. One of the best example of such a Shared Web Hosting provider is the Namecheap shared hosting provider as shown below.
Using a shared hosting provider has its own set of advantages and disadvantages. One of the main advantage of using a shared hosting provider is that in that case the webmaster (aka website owner or website maintainer) need not worry about maintaining the web server part as it will be taken care of by the shared hosting service provider. On the other hand, one of the main disadvantage of a shared hosting provider is that since the same web server will be shared with other websites as well, the speed of the web server will be nondeterministic and usually slower. If one of the website in that shared hosting server gets high traffic, the other websites in the same server will be affected with its response time, thereby frustrating its users.
If you do not want to go for shared hosting, there are other types of web servers available to you. One such option is the Virtual Private Server (VPS).
In case of a Virtual Private Server (VPS), you will be the sole person in control of an entire virtual private server and it will not be shared with anyone else. This results in an increase and deterministic response time, all the time by your website to your website visitors. The other advantage of a VPS server is that since you have access to the complete VPS computer, you can install any software that you choose to, something that may not be possible when using a shared web hosting service provider. The downside, however is that this VPS will not be managed by the service provider and you will be completely responsible for maintaining the VPS server. There are many Virtual Private Server (VPS) providers in the market that are highly competitive and cost effective. One such service provider is the Vultr VPS service provider which provides a VPS server for as low as $2.5 per month! We highly recommend this VPS server if you are looking in to a VPS server option.
3. Design A Responsive Website For Mobiles
Now that we have covered the infrastructure part of a website – domain name and the web server, let us now start looking into the design aspects of a website.
Over 70% of the website traffic these days come from smartphones and tablets. As the mobile data rates continue to fall along with the fall of smartphone prices with excellent technical specs, this number of mobile visitors is only going to increase in the future. So what does this mean to your website?
Make your website responsive and mobile friendly!
What do we mean by a responsive website?
In the early days of web development, where there were not many devices with varying form factor – that is the size of the screen did not vary a lot, designing a website for these computer devices where reasonably easy. But with the advent of smartphone since 2007 – the year iPhone was launched, most of the website traffic started coming from these smartphones and every year this is only increasing. With the introduction of smartphones, web developerf faced a new challenge – huge range of smartphone computing device screen sizes!
By default, what the operating system of these smartphones do – such as the iOS of iPhone or Android is to shrink the size of a website to just fit enough into the screen size of the smartphone.
However, problem with such a scheme is that many of the links and buttons of the websites where user was supposed to take action on, became extremely difficult to click on thereby reducing the user experience (UX) of the website. This can be extremely frustrating to your website visitors and hence, an alternative design had to be thought of to handle mobile visitors to the website. This is when the Responsive Website Design was born!
In a Responsive Web Design, the website is designed in such a way that the size of the buttons, links, texts or images and the overall layout of the web page are determined depending on the size of the device’s screen and rendering accordingly, automatically!
The advantage now is that the visitors of your website need not have to fight with their smartphones and tablets to interact with your website. So always build your website using responsive design strategy.
One of the easiest way to design a responsive website if you do not have the time to learn every aspect of a responsive design is to use a frontend website framework such as Twitter’s Bootstrap. Using Bootstrap framework while building the frontend of your website will ensure that your website is always responsive!
4. Search Engine Optimization (SEO)
Finally, we also need to ensure our website is optimized for search engines such as Google, Bing, Yahoo, DuckDuckGo etc.
What is Search Engine Optimization (SEO)?
Most of the people use search engines such as Google or Bing to find answers to their queries. In return, the search engine will display a list of websites that is expected to answer those queries. In the early days of our website, when not many people will know about its existence will mostly end up on our website mainly through these search engines. If our website has answers to the queries asked by the search engine’s users and the searach engine thinks our website’s answers are better than other websites’ answers, it will display our website link above other websites, there by increasing the probability of the search engine user to click our link and visit our website.
So then, what are the parameters that we need to take care of to ensure the search engine such as Google places our website at the top of the search result? It is these set of parameters that becomes the basis of Search Engine Optimization (SEO).
Search Engine Optimization (SEO) as the name suggests, is the optimization methodology used on our websites to ensure that the search engines can easily traverse throughout our website’s web pages, analyze the content of our website for quality and hopefully determine the best position of our website in its results displayed to its users. The position given to our website in the search result for a particular query is called the search engine ranking of our web page for that query.
Our aim hence, will always be to figure out a way to get our articles to the top of as many search query results as possible. This is usually achieved by ensuring quality of the content of the website, ease of navigation across the web pages throughout the website – both for search engine bots as well as our website users, proper use of appropriate HTML tags depending on the content, easy readable hyperlinks & URLs, good amount of highly authoritative websites linking back (aka backlinks) to our web pages there by signalling the search engines that our articles are highly recommended by them etc.