MakerSpace Kanpur

<A Hangout Place for Geeks/>

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

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 display indian currency properly in pdf in Magento 2.x

  • Download the font that support Indian Rupee symbol. please download dejavu-sans font.
  • copy  DejaVuSans.ttf place the above font folder in lib/LinLibertineFont/ directory.

./vendor/magento/module-sales/Model/Order/Pdf/AbstractPdf.php

./vendor/magento/module-sales/Model/Order/Pdf/Items/AbstractItems.php

$font = \Zend_Pdf_Font::fontWithPath(
// $this->_rootDirectory->getAbsolutePath(‘lib/internal/LinLibertineFont/LinLibertine_Re-4.4.1.ttf’)
$this->_rootDirectory->getAbsolutePath(‘lib/internal/LinLibertineFont/DejaVuSans.ttf’)
);

(in _setFontRegular()_setFontBold()_setFontItalic() functions in both files.)

What is Yii 2.0?

What is Yii 2.0?

Yii is a high performance, component-based PHP framework for rapidly developing modern Web applications. The name Yii can be considered as the acronym for Yes It Is!. Yii 2 inherits the main spirit behind Yii for being a simple, fast and highly extensible PHP framework.

Whether you are one developer building a fairly simple Web site, or a team of distributed developers building an extremely complex Web application, using Yii is like augmenting your development team with additional experienced, professional, and efficient resources. All for free!

Yes It Is(Yii 2.0)

  1. Yii is a generic Web Development framework
  2. Yii can be used for developing all kinds of Web applications based on PHP
  3. Yii is component-based architecture and sophisticated caching support
  4. Yii is especially suitable for developing large-scale applications.
    such as portals, forums, content management systems (CMS), e-commerce projects, RESTful Web services, and so on
  5. Yii implements the MVC (Model-View-Controller) design pattern
  6. Strong core developer team
  7. Forum support available in yii site

Yii2.0 Requirements

Yii 2.0 requires PHP 5.4.0 or above.

It is better to setup Wamp server in your local  system.

Wamp server is complete PHP web development stack.It is also notice that please install Visual C/C++ 2011,12,13,14, and 2015 before wamp server setup.

Yii2.0 Features

You can stay focused on the tasks specific to your business requirements, and let Yii provide an implementation strategy for all of the following:

  1. Active Record Supporting Relational
  2. MVC (Model View Controller)
  3. RBAC
  4. RESTful API
  5. Validators
  6. Security Helper
  7. Session
  8. Sessions storage in database
  9. AJAX-enabled widgets
  10. Cookie
  11. Caching
  12. CSRF Tokens for security
  13. DAO
  14. Error Handling
  15. Gii
  16. i18n support
  17. Multi-tier caching support
  18. Namespaces, Traits features available
  19. NoSQL databases support like mongoDB
  20. Pure OOP-based framework
  21. Query builders
  22. skinning and theming
  23. URL Manager

Installing Yii2.0

We can install Yii in two ways, using Composer or downloading an archive file. The former is the preferred way as it allows you to install new extensions or update Yii by running a single command.

Step 1

Install via Composer(one time only)

The installer will download composer for you and set up your PATH environment variable so you can simply call composer from any directory.

Download and run Composer-Setup.exe – it will install the latest composer version whenever it is executed.

and run following command

php composer  global require "fxp/composer-asset-plugin:^1.2.0"

or 

composer  global require "fxp/composer-asset-plugin:^1.2.0"

Now choose one of the application templates to start installing Yii 2.0. An application template is a package that contains a skeleton Web application written in Yii.

To install the basic application template, run the command below in the www folder of wamp server:

composer create-project yiisoft/yii2-app-basic yii2basic

or 

php composer create-project yiisoft/yii2-app-basic yii2basic

Above commands will take 10-15 min for installation. please wait….

To install the advanced application template, run the command below:

composer create-project yiisoft/yii2-app-advanced advancedyii2

or 

php composer create-project yiisoft/yii2-app-advanced advancedyii2

Above commands will take 10-15 min for installation. please wait….

Install from an Archive File

Download one of the following archive files, and then extract it to a Web-accessible(www folder of wamp):

  • Yii 2 with basic application template
  • Yii 2 with advanced application template

    important Installing from an Archive File

    Installing Yii from an archive file involves three steps:

    1. Download the archive file from yiiframework.com.
    2. Unpack the downloaded file to a Web-accessible folder.
    3. Modify the config/web.php file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer):
      // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
      'cookieValidationKey' => 'enter your secret key here',

       

      Verifying the Installation

      After installation is done, either configure your web server (see next section) or use the built-in PHP web server by running the following console command from  the project  directory:

      php yii serve
      

      Note: By default the HTTP-server will listen to port 8080. However if that port is already in use or you wish to serve multiple applications this way, you might want to specify what port to use. Just add the –port argument:

      //if you want to change the default port otherwise leave it
      php yii serve --port=<portnumber>
      php yii serve --port=8080

      You can use your browser to access the installed Yii application with the following URL:

      http://localhost:8080/

       

Yii2 Basic Applications Structure

The most important directories and files in your application are (assuming the application’s root directory is basic):

basic/                  application base path
    composer.json       used by Composer, describes package information
    config/             contains application and other configurations
        console.php     the console application configuration
        web.php         the Web application configuration
    commands/           contains console command classes
    controllers/        contains controller classes
    models/             contains model classes
    runtime/            contains files generated by Yii during runtime, such as logs and cache files
    vendor/             contains the installed Composer packages, including the Yii framework itself
    views/              contains view files
    web/                application Web root, contains Web accessible files
        assets/         contains published asset files (javascript and css) by Yii
        index.php       the entry (or bootstrap) script for the application
    yii                 the Yii console command execution script