Install JDK on Ubuntu in 6 Steps

The Java Development Kit (JDK) is an implementation of either one of the Java Platform, Standard Edition, Java Platform, Enterprise Edition, or Java Platform, Micro Edition platforms released by Oracle Corporation in the form of a binary product aimed at Java developers on Solaris, Linux, macOS or Windows.The JDK includes a private JVM(Java Virtual Machine) and a few other resources to finish the development of a Java Application

We need JDK because it is a bundle of software components that is used to develop Java based applications and it includes JRE , the compilers and tools (like JavaDoc, and Java Debugger) to create and compile programs.

To install it on Ubuntu we need to follow some steps : –

Step 1-First of All we need to download JDK file using this link  (Don’t forget to Accept License Agreement) and Download bin.tar.gz file

Step 2– Now go to terminal (Ctrl + Alt + T) then go to where file is downloaded in my case

$ cd ~/Downloads/

Step 3– Now to extract use command

$ sudo tar xvzf jdk-10_linux-x64_bin.tar.gz -C /installDirectory

Step 4– Now we have to add Oracle JDK 10 to  PATH environment variable. Otherwise we will have to specify the full path when we run the Oracle JDK 10 commands.

To add Oracle JDK 10 to  PATH environment variable, we need to create a new file jdk10.sh in /etc/profile.d with the following command:

so use any editor in my case i am using “nano”

$ sudo nano /etc/profile.d/jdk10.sh

Step 5– Add following lines in JDK10.sh (Don’t forget to enter your directory where you have installed JDK in place of installDirectory) after this press cntrl + X ( ^X ) then Enter y

export JAVA_HOME="installDirectory/jdk-10"
export PATH="$PATH:${JAVA_HOME}/bin"

 

Step 6– Now you have to restart your computer for the changes to take effect and to check JDK correctly installed use these commands

$ echo $JAVA_HOME
$ echo $PATH
$ java -version

That’s all these are the 6 steps to install JDK on Ubuntu

Safe Off Switch to Power Down Your Raspberry Pi

Some time it is hard to find solution for raspberry pi.

This time we are solving issue : how to Power Down Your Raspberry Pi using GPIO.

Step1:

copy script from power_hold.py

Step2:

sudo apt install python3-gpiozero

#connect button GPIO 21 and GND

#run below command to test

python3 power_hold.py

# hold button(gpio21 and GND) for 2 second . your pi will be shutdown.

If it is ok then power on your pi3 again

Step3:

Now execute your script ,when raspberry pi power on every time.

sudo nano /etc/rc.local

in rc.local file at the end your code must be look like this

python3 /home/pi/power_hold.py &

exit 0     

Thats it now . restart your pi again and test it….

Adding GPS tracking to your Raspberry Pi-based projects

Hi geeks some time it is hard to manage gps connection to Raspberry PI.

dont worry we need following item needs for connectivity

  1. Raspberry pi 3
  2. USB to TTL adapter (Prolific PL2303)
  3. Neo 6M-0-001 Ublox GPS Module

Step:1

Connect your GPS module to USB to TTL adapter(Tx and Rx cross connection Required dont get confused)

GPS Module USB to TTL adapter
5v 5v
VCC 5v
Rx Tx
Tx Tx

Step:2

connect USB to TTL adaptor to raspberry pi and login to raspberry pi using putty or terminal.

Step:3

Now run following command to detect usb to ttl

ls /dev/ttyUSB*
sudo lsusb

I am assuming that USB to TTL connected on /dev/ttyUSB0. so run following command to get data from GPS.

sudo cat /dev/ttyUSB0

you will get data like above screenshot.Ctrl+C to stop output.

Optional Steps

Step 3

Installing a GPS Daemon (gpsd)
sudo apt-get install gpsd gpsd-clients python-gps

The next step is installing some software on your Raspberry Pi that understands the serial data that your GPS module is providing via /dev/ttyUSB0.

then run

//this command with tell actual gps data
gpsmon /dev/ttyUSB0

sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

above will run gps data service in background

now see the data

cgps -s

 

article source 

 

How to Install Ubuntu

UBUNTU

Ubuntu is an open source operating system for computers. It is a Linux distribution based on the Debian architecture. It is usually run on personal computers, and is also popular on network servers, usually running the Ubuntu Server variant, with enterprise-class features. Ubuntu runs on the most popular architectures.

Things That Ubuntu Does Better Than Windows

1- Ubuntu is different. Everything is done via repositories and it uses a dedicated update manager to update both the operating system and all of the applications installed. So you only ever have to manage your updates from one place.

2-Ubuntu is also a lot less popular than Windows. That means that the bad guys who make all the viruses don’t really care about it, so they don’t bother writing much malware for Ubuntu: that’s great news for us users!

3-Desktop customization is also cool in Ubuntu there are several themes available over the internet

4-We can also use as a live environment

5-Ubuntu is 100% free. It won’t cost you a penny (although you can make a donation on their download page)

Bootable pen drive for ubuntu ?

 

 

https://www.ubuntu.com/download/desktop

Firstly visit above link and download ubuntu ISO file and make bootable pen-drive ( U can use softwares like powerISO ,unetbootin and in ubuntu u can use Startup disk creater) Now there are two options if u wants to use as a live environment then TRY UBUNTU option otherwise INSTALL UBUNTU

Use something else if u wants to customize partitions then click on install now button after that

Swap Area ( Linux-swap)

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.

For more modern systems (>1GB), your swap space should be at a minimum be equal to your physical memory (RAM) size “if you use hibernation”, otherwise you need a minimum of round(sqrt(RAM)) and a maximum of twice the amount of RAM

Now proceed according to instructions . . .

Finally Ubuntu is installed on your system

How to create Barcodes in python

What is a Barcode?

barcode is an optical, machine-readable , representation of data , the data usually describes something about the object that carries the barcode . Traditional barcodes systematically represent data by varying the widths and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D) ,we can quickly test on console (mac, tested on ubuntu , debian).

PyBarcode ships with a little commandline script to generate barcodes without knowing Python. The install script detects your Python version and adds the major version number to the executable script. On Python 2 it is called pybarcode2 and on Python 3 pybarcode3. When installing in a systemwide direction, you can have pyBarcode installed in Python 2 and 3 at the same time without trouble.

Requirements

  • Setuptools/distribute for installation (new in version 0.7beta4)
  • Python 2.6 or above (including Python 3.x)
  • On Python 2.6, 3.0, 3.1: argparse (for the commandline script)
  • Program to open SVG objects (your browser should do it)
  • Optional: PIL to render barcodes as images (PNG, JPG, …)

Installation

Make sure you have setuptools/distribute installed.

Unpack the downloaded file, cd into the pyBarcode directory and run python setup.py install. Or just copy the barcode dir somewhere in your PYTHONPATH.

The best way is to use pip:

pip install pyBarcode

Provided Barcodes

EAN-8, EAN-13, UPC-A, JAN, ISBN-10, ISBN-13, ISSN, Code 39, PZN

 

Usage form command line

pybarcode{2,3} create “My Text” barcodename

If you know which python version your system have then run accordingly.I am assuming python3.x

pybarcode{2,3} create -t png "My Text" outfile

 

pybarcode3 create "My Text" outfile

or

Sample example to generate QR code and save in svg file in python.

 

ean13 is EAN or European Article Number and 13 representing it is 13 digit number

>>> import barcode
>>> ean = barcode.get('ean13', '123456789102')
# Now we look if the checksum was added
>>> ean.get_fullcode()
u'1234567891026'
>>> filename = ean.save('ean13')
>>> filename
u'ean13.svg'
>>> options = dict(compress=True)
>>> filename = ean.save('ean13', options)
>>> filename
u'ean13.svgz'

Now we have ean13.svg and the compressed ean13.svgz in our current working directory. Open it and see the result.

 

To generate barcodes as images, you must provide the ImageWriter to the get function. Without any options, the images are rendered as PNG.

>>> import barcode
>>> from barcode.writer import ImageWriter
>>> ean = barcode.get('ean13', '123456789102', writer=ImageWriter())
>>> filename = ean.save('ean13')
>>> filename
u'ean13.png'

 

source : Pythonhosted.org

join our python training in kanpur for Zero to Hero in Python.

How to create QR code in Python

What is a QR Code in nutshell?

A Quick Response code is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric)

its very simple on console (tested on mac, debian and ubuntu latest OS)

below command will install all required module including pil (Python Imaging Library):pillow

pip install qrcode[pil]

then

Usage form command line

qr "Some text" > image_name_with_extention
qr "makerspacekanpur.com" > msk.png

or

Sample example to generate QR code and save in png file in python.

import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('http://makerspacekanpur.com')

qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")

img.save('msk-site.png') 

Sample example to instant preview of QR code in python.

import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('Some data')
qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")

img.show()

 

source : Python.org

join our python training in kanpur for Zero to Hero in Python.

Visualization of DataSet is fun in Orange

 

Visualizing Data Set is fun using Orange


Introduction:

Data has become powerful source of earning and predict future and people will seek to utilize it even if they don’t know exactly how. Machine learning will become a usual part of programmer’s resume, data scientists will be as common as accountants. Now a days and for the next approximately two decades, we will continue to see a major need for machine learning and data science specialists to help apply machine learning technologies to application areas where they aren’t applied today.


Now a day people prefer GUI based tools instead of more coding stuffs . Orange is one of the popular open source machine learning and data visualization tool for beginners. People who don’t know more about coding and willing to visualize pattern and other stuffs can easily work with Orange.

Why Orange:

Orange is an open-source software package released under GPL that powers Python scripts with its rich compilation of mining and machine learning algorithms for data pre-processing, classification, modelling, regression, clustering and other miscellaneous functions.

Orange also comes with a visual programming environment and its workbench consists of tools for importing data, and dragging and dropping widgets and links to connect different widgets for completing the workflow.

Orange uses common Python open-source libraries for scientific computing, such as numpy, scipy and scikit-learn, while its graphical user interface operates within the cross-platform Qt framework.

 

Getting Started:

Download Orange

=> Go to https://orange.biolab.si and click on Download.

For Linux Users:

Anaconda

If you are using python provided by Anaconda distribution, you are almost ready to go . If not, follow these steps to download Orange :

conda config –add channels conda-forge

and run

conda install orange3
conda install -c defaults pyqt=5 qt

PIP

Orange can also be installed from the Python Package Index. You may need additional system packages provided by your distribution.

pip install orange3

Run short code to verify you setup Orange successfully. Open your Python Terminal and run the following code :

 import Orange
 Orange.version.version
 ‘3.2.dev0+8907f35’

Note: If You find result shown above then you successfully setup Orange. In case you get error like this

from Orange.data import _variable
ImportError: cannot import name '_variable'

 

Kindly Follow These Steps : Install Orange From Source

Mac and Windows user can easy setup orange in their system step by step just follow official docs of Orange:

Official docs for setup Orange

After installation let’s start working with Orange

Visualization of Data Set in Orange:

A primary goal of data visualization is to communicate information clearly and efficiently via statistical graphics, plots and information graphics.

“Main goal of data visualization is to communicate information clearly and effectively through graphical means. It doesn’t mean that data visualization needs to look boring to be functional or extremely sophisticated to look beautiful. To convey ideas effectively, both aesthetic form and functionality need to go hand in hand, providing insights into a rather sparse and complex data set by communicating its key-aspects in a more intuitive way. Yet designers often fail to achieve a balance between form and function, creating gorgeous data visualizations which fail to serve their main purpose — to communicate information.”
-Friedman (2008)

Open Orange on your system & create your own new Workflow:

After you clicked on “New” in the above step, this is what you should have come up with:

In this tutorial we are going to learn Visualization of Data Set in few steps as given below:

Step 1: Without data there is no existence of Machine Learning. So In our first step we import our data set in this tutorial I uses example data set available in Orange Directory.
We import zoo.tab data set in file widget.

Step 2: In next step we need data tables to viewing our data set. For this we use Data Table widget.

When we double click on the data table widget we can visualize our data in actual format :

Step 3: This is the last step where we will understand our data, with the help of visualization. Orange make visualization pretty much easier. We just add one more widget and choose in which format we would like to visualize our data like Scatter Plot.

This completely works on the concept of neurons, data transfer from one layer to other layer when we connect data table to scatter plot widget then we find actual representation of our data in the form of scatter plot.

Closing Note:

Orange is most powerful tool used for almost any kind of analysis and visualization of data. The default installation includes a number of machine learning, preprocessing and data visualization algorithms in 6 widget sets (data, visualize, classify, regression, evaluate and unsupervised). Additional functionalities are available as add-ons (bio-informatics, data fusion and text-mining).

Hope this tutorial help you to understand data visualization with the help of Orange. It is very important to understand the flow of data, this helps you to figure out problems easily.

Keep Practice with Orange

Happy Coding!

 

How to Connect LCD to Raspberry PI

This code will tested on this product of iotwebplanet.

sudo rm -rf LCD-show
git clone https://github.com/vivekaris/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/

Then Run Following command as per you screen size.

In case of 2.8″ LCD
sudo ./LCD28-show

In case of 3.2″ LCD
sudo ./LCD32-show

In case of 3.5″ GPIO Display
sudo ./LCD35-show

In case of 3.5″ HDMI Display-MPI3508
sudo ./MPI3508_480_320-show
or
sudo ./MPI3508_600_400-show
or
sudo ./MPI3508_720_480-show
or
sudo ./MPI3508_810_540-show
or
sudo ./MPI3508_960_640-show

In case of 3.5″ DPI Display-MPI3510
sudo ./MPI3510-show

In case of 3.97″ LCD
sudo ./LCD397-show

In case of 4.3″ LCD
sudo ./LCD43-show

In case of 5″ LCD
sudo ./LCD5-show

In case of 7inch(B)-800X480 RPI LCD
sudo ./LCD7B-show

In case of 7inch(C)-1024X600 RPI LCD
sudo ./LCD7C-show

If you need to switch back to the traditional HDMI display
sudo ./LCD-hdmi

Wait a few minutes,the system will restart automaticall , enjoy with your LCD.

 

Flutter and its Setup

What is Flutter

Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.


Join MakerSpace Kanpur

Who is it for?

Programmers
Students and Teachers
Beginners

System requirements for (Mac)

  • Operating Systems: macOS (64-bit)
  • Disk Space: 700 MB (does not include disk space for Xcode or Android Studio).
  • Tools: Flutter depends on these command-line tools being available in your environment.
    • bashmkdirrmgitcurlunzipwhich
  • Clone the repo

    If this is the first time you’re installing Flutter on this machine, clone the beta branch of the repository and then add the flutter tool to your path:

  • git clone -b beta https://github.com/flutter/flutter.git
    $ export PATH=`pwd`/flutter/bin:$PATH
  •  flutter doctor
  • export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH