Menu bars

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, 25 August 2015

Platform overview : Lets get started with Drupal 7 in Ubuntu

Apache2

Apache is the most popular web server on the internet. It is used to serve more than half of all active websites.
Although there are many viable web servers that will serve your content, it is helpful to understand how Apache works because of its ubiquity.
In this article, we will examine some general configuration files and options that can be controlled within them. This article will follow the Ubuntu/Debian layout of Apache files, which is different from how other distributions build the configuration hierarchy.
Here is a wonderful article about Apache2 in digital ocean - Read more

Drupal directory
It was little difficult for me to find out where is the drupal base directory in ubuntu, while installing theme and modules we need to access to these directories. This post help me to locate where it is.




Saturday, 22 August 2015

Resize HD partitions in ubuntu

Partitioning the hard disk is always an difficult task even those guys who are frequently dealing with computer especially when you in linux flavors. Here comest most friendly free software available in the ubuntu repository , gparted  for help.  Install gparted with the command

sudo apt-get install gparted
When you open gparted from your system, you will get the following screen.

Here you can see that all your partitions and corresponding file-system and all other details are given. And if you observe little more you will get confused with the logical and extended partition concept of the partitioning. The real pain comes when you realize that you can create only 4 primary partitions and if you try to create another one they wont allow you. Here we have to delete any of the partition and resize it.

When i was facing this problem this forum helped me out !!


  • The key sign near the FS wont allow us to do any of the operation on that FS, since this is in use right now.
  • If there is key sign on the linux-swap then you can choose swap-off and do the operation.
  • try to make changes to extended partition only, so that you can add many partitions here

  • EXT4 partitions means  Linux FileSystem
  • NTFS partitions means Windows Filesystem
If you want to resize the already booting FS then use a bootable usb and use gparted to change everything.

Friday, 21 August 2015

Create a github repo

Lets create a github repo. so that we can store all our code safe in the repository and share the same across.



See the first step :  (+) sign on top of right side.




Lets continue....



The repository url will be looks like this: 


after the last step it will ask your github username and password. username will be email id normally

and you will get this message at the end



Now you can check the repository created in your account.


Clone a repository

If you wanted to clone the same repo somewhere else then you can follow the following step.

git clone <repo url>

Using git

This is a good resource to look into the git command - the link 

git status
git add <file>
git commit -m "msg"
git push
git pull







Tuesday, 11 August 2015

Scrapy - Get started !!

Scrapy is a python module for web scraping. If you want to scrape data in the websites in a automated way then this is one of the best option available in the techno-space. writing a python script with scrapy will create a crawler and it will scrape the data from the web sites that you intended to scrap.

Here i am listing few interesting links for setting and using the python scrapy !!
  • This is one of the starting place for scrapy, which explains the setup and usage - Check here
  • This is another wonderful article on scrapy !! Explains better - See here 
  • Most probably you will get confused with xPath selection, If you want to look into it in detail then Check this and this

Use developer tools for xPath

Go to the inspect element of the required field in Chrome developer tool and right click+copy xpath




Right-click on the <tr> and copy the xpath and print it on the developer tool console to make sure that whether you got the correct xpath.

Here you can see that the xpath has selected the entire <tr>. now we can easily scrape the data with the scrapy's methods.

Ionic framework for mobile apps - Setup

Hybrid applications are getting popular since we can use the same code for both android and ios applications. Hybrid apps will be written in web programming languages, so it will be no learning curve for a web developer. Otherwise the learning curve of android and ios are comparatively large.So if you have experience in web development hybrid apps are for you.


When not to use Hybrid apps 

If you are planning for a game or graphics intensive app then you will fee some lags in the hybrid apps, because these apps cannot make use of the platform very well. only native application can provide exact performance that is needed for games and memory intensive processes.

When to use Hybrid apps

If you are planning to make a network based application which is getting some information from server or some application which does not make much interaction with the internals of the device can be done perfectly with hybrid apps.

Ionic Framework

Ionic is a Angularjs powered hybrid mobile framework where you can make all kind of mobile applications easily with the help of angularjs. lets dive in and check how to install it.

Follow this link to setup the ionic project

But installing all these dependencies like node,android,ant etc will be kind of pain, but there is a wonderful bash script written by nraboy for ubuntu platform.

Once you run the script follow the commands




























ionic serve - for seeing in the browser
This will launch the android emulator. The error that i have faced was
rm: could not remove directory (code EACCES)
This was happening because my ExampleProject directory does not had execute permission
use this for assigning permissions recursively for sub directories.
sudo chmod -R 755 /path/your/folder
after this command everything started working properly.

Useful links - How to Get the Ionic Framework Running on Ubuntu


                    - Building the Application

                    - Install android in ubuntu

                    - Test your app


Hey..it is not over !! you might have got an error in the emulator like this




This is caused because of the app time out. for solving this error i have followed this link and rebuilt my application and everything started working perfect !!

Saving Data With IonicFramework

Saving data in locally important for small amount of large data. So that even without a database like sqlite you can persist your data.

Getting Started with ngCordova

NgCordova will help to use all the device facilities like camera, locations etc







Linux basics

PATH

It is a environment variable that is present for each user in a linux machine. while you install a linux os in a hardware admin will be having one PATH variable and each and every other user in the system will be having a PATH variable.


http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/

Saturday, 8 August 2015

Run windows 7 in a virtualbox from Ubuntu 14.04

Step 1 : Open terminal and type,

sudo apt-get install virtualbox 
Virtualbox will get installed in 5 minutes.

Step 2 : Open virtualbox and create a new virtual machine as you want. Easy steps to be followed and will land in this state



















Step 3 : Right click on the virtual machine listed in the left panel and select settings which will land you in the following page.

Click on storage

Click on Empty

Now you will see this page.












Step 4 : Click on the cd-image on the right panel near CD/DVD


Now choose a virtual CD/DVD file

Choose your iso file

Done !!

Now go to your virtualbox and select the vm and click RUN


Core java interview preparations-Links

These are my notes on Core java while i was preparing for interviews. As you know core java holds an important percentage of questions in a technical interview. Here i am listing all the important portions of core java and corresponding links. The difficulty level is above average and i am not listing the basic topics. This will be helpful to you if you have basics of java and prepare for a technical interview or something.Lets start !

Before that if you want to have general reading about java concepts then read : Link & Link

Special case of long & double with volatile keyword - here

  • Thread vs process - here


  • How HashMap works ?
This is an important topic for technical interviews ,
         Click here 2
  • Executor framework
This link provides all the concurrent util methods of java.

Database interview Links

  • 10 Frequently asked SQL Query


ARP commands

ARP commands

sudo arp-scan -l --interface=wlan0

arp-scan sends ARP packets to hosts on the local network and displays any responses that are received. The network interface to use can be specified with the --interface option. If this option is not present, arp-scan will search the system interface list for the lowest numbered, configured up interface (excluding loopback). By default, the ARP packets are sent to the Ethernet broadcast address, ff:ff:ff:ff:ff:ff, but that can be changed with the --destaddr option.

it is used to find out what all are the hosts that is connected to the local network.Another way of finding out the same with “Ping” with nmap[ nmap -sP 192.168.0.1/24 ]


You can find details about the arp-scan from http://linux.die.net/man/1/arp-scan.
In the above command “ -l ” tells you to scan all local network and --interface tells to use which interface to use.

Quickly if you want to know about the other hosts,Use arp-cache by:


But my ARP-SCAN was not pulling out all the network hosts that are connected !!! Dont know know why ?? NEED MORE RESEARCH !!!

3 ways to find out all the hosts in the LAN :

  • nmap -sP 192.168.0.1/24 [ Works !! need to test against firewall ]
  • sudo arp-scan --interface=eth0 192.168.0.0/24 [ Errors !! not complete list]
  • arp -n [ Accessing already saved arp-cache !! may not be reliable]

Links::
Crack wifi password with aicrack :


Trie data structure




  • Trie is a multi-way search tree where each node represents each character and all the children of the same will be having a same prefix.
 


  • Rather than storing the character each node will be storing the prefix.
  • Structure of the Node :
                   String prefix;
Node[26] children;
Each node will hold an array of 26 nodes where each node represents the each    letter. If some letter is not present then that will be empty. It is an overhead of trie because it used extra memory which is not using.


  • Now we have to think about how to organize or store the array of nodes.
     
   Two possibilities are 1) Store as array
                                     2) Store as linked list


If you store as array we can access it in a indexed way,but we have to waste much memory.


if you store as linked list then access time of the search string will increase( search in linked list of 26 nodes is O(26) and we need to travel m levels where m is the length of search string, that sums to O(m*26)) but memory usage will be optimal.


But if we use HashMap then you can get the time complexity O(1) and memory also will be optimal O(n).

Shortest path algorithm

You might have searched for different routes between two locations in google maps, but have you ever  thought about how would they do this ? finding all those small junctions and even tracking traffic in real time. Sounds crazy !!


Computer Science will have answer to each and every question !! The above scenario can be done with graphs. Say we find all the junction in the map and put those in a graph vertex. now we need to find the shortest path between 2 nodes. We are Done !!. One more application of the same will be in networking finding the shortest path to reach from one computer to another.




In the above image if i want to travel from “u” to “z” then what will be the shortest path ??
u + x + y + z will cause only 3 , if you see all the other paths will be causing more cost.
But what if there  1000 nodes we cannot count it and find which is the best path available. So we have to come up with some algorithm to do this.


There are many algorithms doing the same :


  • Dijkstra’s algorithm
  • Bellman-ford algorithm
  • Floyd Algorithm.

Dynamic Programming


It is considered as a careful bruteforce. And interestingly we will get it in polynomial time.What it does is divide the problem into sub problem and solve the same and reuse the same for larger problem.
Lets take the example of fibonacci number !!

F(n) :
if(n <= 2) :
     f = 1;
else :
     f =  f(n-1)+f(n-2);
return f;

Looks like neat !! But it is not because it running in an exponential time, because each time recalculating many functions.

Eg : F(4) :
f = [ F(3) + F(2) ]
 = [ F(2) + F(1) ] + 1
 = [ 1 + 1 ] + 1
 = 2 +1
 = 3
Here we can see that F[2] is calculated 2 times. Like that there may be many situations where we are recalculating.

Proof exponential time :

T(n) = T(n-1) + T(n-2)+ O(1)
      > 2T(n-2)
          = O(2^(n/2))