Monday, November 28, 2016

How to install missing packages of Latex under linux

  1. Download the missing package from Internet.
  2. Extract it somewhere
  3. Look for a file that has .ins format.
  4. Run a command
    latex file_name.ins
    It will generate files with .sty format.
  5. Create a new folder with appropriate package name e.g., curves. Copy .sty to /usr/share/texlive/texmf-dist/tex/latex/new_folder/
  6. Run
  7. texhash

    for reloading latex cache.

Saturday, August 6, 2016

To install the latest flash player in linux

Run command below.

sudo apt-get install adobe-flashplugin

It was working for Mozilla, but not for Chromium.

Wednesday, July 20, 2016

Installing SciPy Stack

in Ubuntu/Debian:

To install Scipy:
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose python-tk

To install Scikit-learn
sudo apt-get install pip
sudo pip install -U scikit-learn

To install NLTK
sudo pip install -U setuptools
sudo pip install -U nltk

To install Pandas
sudo pip install pandas

To install Jupyter notebook
sudo pip install jupyter 

First you have to install setuptools before installing jupyter notebook.

Tuesday, July 19, 2016

After fresh new ubuntu linux installation guide

Ubuntu 16.04 LTS

1. Mouse accelerator was too fast. So I run these commands to make it slower.

to see list of devices:
 xinput --list --short 

to see configuration of my mouse: (my mouse id was 11)
xinput --list-props 11

to set mouse accelerator to 0.5:
xinput --set-prop 11 275 0.5

Here is the full instruction.


2. Installed unity-tweak-tool to add new cool desktop actions such as toggling desktop as mouse approaches the left bottom corner. 

sudo apt-get install unity-tweak-tool

but It was not working, so as advised I installed this:

sudo apt-get install compizconfig-settings-manager compiz-plugins-extra -y

after that type ccs in search bar and run the program. Inside the program go to 'desktop' section, choose
'Ubuntu Unity Plugin', inside go to 'Switcher' tab and uncheck 'Show live previews of windows in the Switcher'.


Afterwards, it worked. But I have no idea the last steps had effected or not.

3. Then I installed terminator with 

sudo apt-get install terminator

4. Install Chrome. Go to https://www.google.com/intl/en-US/chrome/browser
then download appropriate version, and install with command.

cd /~/Downloads

sudo dpkg -i google-chrome-stable-current_amd64.deb

5. Install Keepass, password saver. 


sudo apt-get install keepass2

6. Install Dropbox

Download from https://www.dropbox.com/install?os=lnx

cd /~/Downloads

sudo dpkg -i package-name


7. Install Thunderbird

sudo add-apt-repository ppa:lucid-bleed/ppa
sudo apt-get update
sudo apt-get install thunderbird thunderbird-locale-en-us thunderbird-gnome-support
The latest Thunderbird was installed as default in Ubuntu.

8. Install Apache2 server

sudo apt-get install apache2


9. Install vim

sudo apt-get install vim

10. From Badaa's twitter: I agree that the Ubuntu a spyware is. If you must use it for any reason, sudo apt-get purge unity-webapps-common is a must-do.

It removes unity-tweak-tool, so reinstalled it again.

11. Install Java

First run these commands:


sudo apt-get purge openjdk*
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
 
Create a file /etc/profile.d/oraclejdk.sh with the following content (adapt the paths to reflect the path where you stored your JDK)
 
export J2SDKDIR=/usr/lib/jvm/java-8-oracle
export J2REDIR=/usr/lib/jvm/java-8-oracle/jre
export PATH=$PATH:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export DERBY_HOME=/usr/lib/jvm/java-8-oracle/db

http://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04

https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8

12. Install git

sudo apt-get install git-all






But git was installed as default in Ubuntu.

13. Install apache modules for php7

sudo apt-get install libapache2-mod-php7.0

sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-xml

After this, you can test phpinfo(); on apache server.

14. Install Laravel
install Composer first:

curl -sS https://getcomposer.org/installer | php

move composer.phar file to /usr/local/bin under name composer.

sudo mv  composer.phar /usr/local/bin/composer

15. Clone laravel project from git repository in /var/www/html. Go to the project directory. Run:

sudo composer update

Installing php7.0 with xdebug in Linux Ubuntu

First run these commands to install php 7.0 and all necessary libraries of php 7.0.

# remove php5 modules
apt-get autoremove --purge php5-*
# add php-7.0 source list by [Ondřej Surý](https://github.com/oerdnj)
add-apt-repository ppa:ondrej/php
# Update index
apt-get update
# Install php7.0-fpm with needed extensions
apt-get install php7.0-fpm php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-mysql php7.0-phpdbg php7.0-mbstring php7.0-gd php7.0-imap php7.0-ldap php7.0-pgsql php7.0-pspell php7.0-recode php7.0-snmp php7.0-tidy php7.0-dev php7.0-intl php7.0-gd php7.0-curl php7.0-zip php7.0-xml

After that, download stable release of x-debug extension.

wget -c "http://xdebug.org/files/xdebug-2.4.0.tgz"

Extract archive

tar -xf xdebug-2.4.0.tgz

Build extension

cd xdebug-2.4.0/
phpize
./configure
make && make install

Add following lines to /etc/php/7.0/apache2/php.ini config file

# Added for xdebug
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0

Check whether xdebug is enabled from phpinfo().




Sunday, June 5, 2016

if you are experiencing apportcheckresume error in Ubuntu.

So far the only thing that has actually worked is:
Purge the apport program with its configuration
sudo apt-get purge apport 
Remove packages that are no longer needed (ex. auto-installed dependencies of apport)
sudo apt-get autoremove 
Clean APT cache from old packages
sudo apt-get clean 
Install back apport
sudo apt-get install apport 

Hopefully that will work for you.

Monday, May 30, 2016

If your linux is experiencing crash from upwoerd upon startup.

If your linux is experiencing crash from upwoerd upon startup. This is a known bug in Linux caused by your i-devices (iphone, ipad...). If you're experiencing this error try this command. It seems fixing the error.

sudo apt-get install libimobiledevice-utils

If you want to mount a partition upon startup in linux

You have to enter your partition information to /etc/fstab file. Then your disk will be mounted automatically!
Just go for following step:
  • First take back up of /etc/fstab
    sudo cp /etc/fstab /etc/fstab.backup
    
  • Execute following command to get your partition UUID information that will help you to configure /etc/fstab file.
    sudo blkid
    
    Search for your partition's UUID which you want to mount automaticall. Your HDD partitions shouls be displayed like:
    /dev/sda1: LABEL="Backup" UUID="00A0CE7EA0CE7A24" TYPE="ntfs"
    /dev/sda5: LABEL="40GBTWO" UUID="00A0CE7EA0CE7A24" TYPE="ntfs" 
    /dev/sda6: UUID="7550252c-3da7-4cd9-8da3-71e9ba38e74a" TYPE="ext4" 
    /dev/sda7: UUID="088fd084-a011-4896-aa93-c0caaad60620" TYPE="swap" 
    /dev/sdb1: LABEL="SaurK" UUID="0DB6254A58CEF6F7" TYPE="ntfs"
    
    and so on. It is just an example but format will be same.
  • Now copy the UUID of the partitions which you want to insert in /etc/fstab file.
  • Now open /etc/fstab file and insert entry for your HDD partitions on the last line of /etc/fstab file. Take help from previous entry, for format etc:
    sudo gedit /etc/fstab
    
    When opened your entry would be like this:
    UUID=<your_UUID_for_Disk_partitions> /media/<location_where_you_want_to_mount>             ntfs    errors=remount-ro 0
    
    Just an example:
    UUID=00A0CE7EA0CE7A24 /media/Backup               ntfs    errors=remount-ro 0
    
    you may have to replace ntfs to ext4 or fat32 according to the file system of your partition. It displays in blkid output.
  • Now create location where to mount your disk partitions. Create a folder for each partitions to mount. ((note: a directory may be already created, if so ignore this step.) For example:
    sudo mkdir /media/Backup
    
  • Then execute this command once finished:
    sudo mount -a
    
You can refer this link for further help: Auto mounting with /etc/fstab Hope it works for you..
From:
http://askubuntu.com/questions/343438/why-are-partitons-not-automatically-mounting

Terminator

There is one very interesting tool in Linux. It is called terminator and you can open multiple terminals within it. Before starting using it, it has been messy to work with multiple terminals at once. So to install this tool, run this command.

sudo apt-get install terminator

And you can split your screens just by clicking right mouse and choosing which way you want to split it (horizontally | vertically)


If your system settings is missing in Ubuntu

After I installed fresh copy of Ubuntu 14.10 on my machine I had only few settings on my settings panel, and I went like this for months. But it was child's play to fix this. I found command this from internet.

sudo apt-get install ubuntu-desktop

basically it re-installs Unity (Desktop environment of Ubuntu I guess). And you don't even need to restart and you have everything back.

Monday, March 28, 2016

Notes on DBMS File structure and Index



  1. In DBMS, data and information is stored in file formats on physical storage level.
  2. A file is a sequence of records stored in binary format. 
  3. Records are table rows of relational databases. Collection of records are contained in pages which are the internal basic structure to organize the data in the database files. (Page is the smallest unit of data for memory management in a virtual memory operating system.)
  4. A single file may contain several pages. 
  5. Each record has a unique identifier called a record id, or rid for short. 
Heap files

The simplest file structure is an unordered file or heap file. The data in the pages of a heap file is not ordered in any way, and the only guarantee is that one can retrieve all records in the file by repeated requests for the next record. Every record in the file has a unique rid (record id), and every page in a file is of the same size.

Supported operations on a heap file include create and destroy files, insert a record, delete a record with a given rid, get a record with a given rid, and scan all records in the file. To get or delete a record with a given rid, note that we must be able to find the id of the page containing the record, given the id of the record. In modern Dbms, record ids are implemented as page id and slot number.

We must keep track of the pages in each heap file in order to support scans, and we must keep track of pages that contain free space in order to implement insertion efficiently.

Intro to Indexes

Sometimes we want to find all records that have a given value in a particular field. If we can find the rids of all such records, we can locate the page containing each record from the record's rid; however, the heap file organization does not help us to find the rids of such records. So here comes an index which is an auxiliary data structure to help us find rids of records that meet a selection condition.

This notion is just similar to library catalog which helps reader search a book by many criteria such as author, name, and published date.

In another word, index is a file containing search key, which is a collection of one or more fields on which we are building index; values of those fields are organized according to particular search efficient data structures (B+ tree) that also includes a low-level disk block address (data entries) or direct link to the complete row of data in data files.



In most cases, an index is used to quickly locate the data record(s) from which the required data is read. In other words, the index is only used to locate data records in the table and not to return data.
But in some cases, index that is used could contain required data fields and return data. (2) Example of indexing could be like that if we wanted to build an index to improve the efficiency of queries about employees of a given age, we could build an index on the age attribute of the employee dataset. The records stored in an index file, which we refer to as entries allow us to find data records with a given search key value.

One could build multiple indexes on a single dataset. For example; if we wanted to build indexes on both of age and salary fields of employee dataset, at most one of the indexes can contain data entries which are actual data records, and another one is separate index file with left field as search key. 

Properties of indexes

Non clustered

The data is present in arbitrary order, but the logical ordering is specified by the index. The data rows may be spread throughout the table regardless of the value of the indexed column or expression. The non-clustered index tree contains the index keys in sorted order, with the leaf level of the index containing the pointer to the record (page and the row number in the data page in page-organized engines; row offset in file-organized engines).

In a non-clustered index,
The physical order of the rows is not the same as the index order.
The indexed columns are typically non-primary key columns used in JOIN, WHERE, and ORDER BY clauses.

There can be more than one non-clustered index on a database table.

Clustered 

Clustering alters the data block into a certain distinct order to match the index, resulting in the row data being stored in order. Therefore, only one clustered index can be created on a given database table. Clustered indices can greatly increase overall speed of retrieval, but usually only where the data is accessed sequentially in the same or reverse order of the clustered index, or when a range of items is selected.

Since the physical records are in this sort order on disk, the next row item in the sequence is immediately before or after the last one, and so fewer data block reads are required. The primary feature of a clustered index is therefore the ordering of the physical data rows in accordance with the index blocks that point to them. Some databases separate the data and index blocks into separate files, others put two completely different data blocks within the same physical file(s).

Types of indexes

Dense versus Sparse Indexes

An index is said to be dense if it contains (at least) one data entry for every search key value that appears in a record in the indexed file. A sparse index contains one entry for each page of records in the data file. 





Primary and Secondary Indexes

An index on a set of fields that includes the primary key is called a primary index. An index that is not a primary index is called a secondary index. Two data entries are said to be duplicates if they have the same value for the search key field associated with the index. A primary index is guaranteed not to contain duplicates, but an index on other fields can contain duplicates. Thus, in general, a secondary index contains duplicates. 



Used references:

(1) https://en.wikipedia.org/wiki/Database_index
(2) Raghu Ramakrish - "Database Management Systems" 2nd