Thursday, April 23

Custom Virtual Host in Apache2 in Ubuntu

 
cd ~
mkdir public_html
 
Now for each domain create a folder with following template
 
mkdir -p public_html/domain1.com/{public,private,log,cgi-bin,backup}


 
NameVirtualHost *:80
Listen 80
 
Make sure this setting is set either in ports.conf or apache2.conf or httpd.conf or in sites-available/default
 
Now create the vhost file for domain1.com in /etc/apache2/sites-available/domain1.com

with the following settings

<VirtualHost *:80>
  
  ServerAdmin webmaster@domain1.com
  ServerName  domain1.com
  ServerAlias www.domain1.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html
  DocumentRoot /home/username/public_html/domain1.com/public


  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/username/public_html/domain1.com/log/error.log
  CustomLog /home/username/public_html/domain1.com/log/access.log combined

</VirtualHost>
 
 
Now to enable the site in sites-enabled
sudo a2ensite domain1.com
 
and then restart the apache2 server
sudo service apache2 restart
 
Modify the host file '/etc/hosts' 
 
127.0.0.1    localhost 
127.0.0.1    domain1.com
 
 
 Now set the owner permissions

~/public_html/domain1.com$ sudo chown -R username:www-data cgi-bin log public
~/public_html/domain1.com$ sudo find ./public -type d -exec chmod 775 {} \;
~/public_html/domain1.com$ sudo find ./public -type f -exec chmod 774 {} \;

likewise for log and cgi-bin
 
 

References

1. Apache Virtual Hosts
2. Permissions for /var/www/html 
3. Chmod only to folders and its subfolders 

Thursday, February 12

Wireshark NPF driver isn't working

Wireshark is an network analyzer. Wireshark depends on another utility process called WinPcap.

If the WinPcap service is not running in the background then we get the error "The NPF driver isn't running.  You may have trouble capturing or listing interfaces."



Solution


  1. Open Command prompt by right clicking on it  and "Run as administrator".
  2. Goto "cd Windows\System32" directory
  3. Start the "net start npf"
  4. After the success message, Restart the Wireshark

Friday, October 31

Codenameone Flow Order

This is the flow order of functions that is loaded when an application created using codenameone framework starts

 1. ImmuntiyMeterApp.init(Object context)

 2. ImmuntiyMeterApp.start()

 3. StateMachine.initVars(Resources res)

 4. StateMachine.beforeMain(Form f)

 5. StateMachine.postMain(Form f)

 6. StateMachine.StateMachine(String resFile)

Saturday, October 25

The Web Developer's must have Tool - Firebug



Without Firebug i wouldn't have learned the HTML, CSS, Javascript or the working of Web very quickly.

Firebug is a add-on that is available with  firefox browser and a firefox-lite with chrome.

So what is so great about the Firebug? 

1.  Firebug lets you inspect each HTML elements (like <a>, <div>, <table> ...) and when you inspect the element then the element, its margin, padding, border gets highlighted.

2. On inspecting a element, you can also the view the CSS used to style that part. You can also manipulate and tweak the css to view the result on the fly.

3. To see what all resources are loaded when a page is requested.To find out the time taken and the order in which the resource is loaded. To find out the status, url, domain, ip, size and Header info.

4. To debug JavaScript, to trace the stack flow of the script, to break the script and inspect the DOM and other elements at that time.

Tuesday, July 29

Irony of Science in Eid al-Fitr

In today’s world, the science has grown incredibly that we have Hubble Space Telescope  launched into space watching the universe in different spectrums. We have satellites for weather predictions; we have Terrestrial Space observatory Telescope's watching for flares in sun and climate in Jupiter. We have even accurately and safely landed man on the moon. 

We can even accurately predicate solar and lunar eclipse, the exact points in earth where it would be visible. We have even predicated the next arrival of Halley's Comet  and also the distance away from the earth. The next arrival of Halley's Comet is on 28th July 2061, and then on 7th May, 2134  and it will pass within 13.9 million km from earth.

Halley's Comet May 29 1910


In spite of all these feats, we still haven’t been able to predicate accurately the Eid al-Fitr. In India, all banks and govt office calendars marked 28th July as Eid al-Fitr holiday but it was predicted a day earlier.

The date of Eid al-Fitr for a region is confirmed by the sighting of the new moon.in that particular region. In countries like India, where even the whole nation has same time-zone can't still predicate when the new moon will occur.

Saturday, July 26

How much is the Advertisment Revenues in Media


Advertisment is the primary revenue for most media.


Industries that are spending  in online medium.
  • Electronics
  • Fashion - Men
  • Fashion - Woman
  • Baby Care
  • Video Games
  • Fitness
  • Health Care
  • Car
  • Bike
  • Jewellery
  • Dating

Sunday, July 13

To insert debug code in all functions using regular expression


Lets illustrate with a Javascript  Source Code and Notepad++ IDE

Regular Expression to Find functions

((\w*)\s*[:|=]\s*function\(\w*\)\s*\{)

Debug Code to insert inside each functions

console.log("functionName");

Regular Expression to Insert Debug Code inside Functions

$1 \n\tconsole\.log\("$2"\)\;

Note: Please enable "Regular expression" and ". matches newline" in Search Mode in Replace box in Notepad++ for inserting inside more than 1 function using regular expression.


A sample Javascript before inserting Debug code

var SyntaxHighlighter = function() {
    var sh = {
        all: function(params)
        {
            attachEvent(
                window,'description'
            );
        }
    };
}();

Javascript code after inserting Debug code using Regular Expression

var SyntaxHighlighter = function() {
      console.log("SyntaxHighlighter");
    var sh = {
        all: function(params)
        {
            console.log("all");
            attachEvent(
                window,'description'
            );
        }
    };
}();


To know more about How this Regular Expression Works and Customisation


Saturday, June 21

Eclipse IDE Shortcuts

1.   System.out.println();


syso + Ctrl + Space

2.  Toggle Comment

Ctrl + Shift + C

3.  Run Application

Ctrl + F11

4.  Import all packages

Ctrl + Shift + O

5.  Auto Complete

Ctrl + Space

6. Generate Getter and Setter

Ctrl + Shift + G

But this shortcut is not default one, so you have to set it in eclipse.

Steps to map a command to desired key combination:
  1. Goto 'Windows' menu -> 'Preferences' ->'General' -> 'Keys'
  2. In 'type filter text', type 'getter'
  3. Select command 'Generate Getters and Setters'
  4. Below in 'Binding' field, press CTRL + SHIFT + G
  5. In 'When' selection below, select 'In Windows'
  6. Click 'Apply'.
  7. If in any case there shows Conflicts then either unbind the old one or change your key combo.
  8. Click 'OK'


Saturday, May 31

Protect your Privacy in Internet from Google and other Service Providers


DNS Servers
Usually there are two DNS Servers

Prefered  DNS server : 5.135.165.179
Alternate DNS server : 8.8.8.8

Here 8.8.8.8 is the Public DNS service provided by Google.


So best way to protect yourself is by using DNS servers of your ISP or OpenDNS

BSNL DNS Server 1 :  218. 248.240.208
BSNL DNS Server 2 :  218. 248.240.23

or

OpenDNS Server1    :  208.67.222.222

OpenDNS Server2    :  208.67.220.220



More detailed reasoning at How you have no privacy from Google and other service providers