Pages

Sunday, October 5, 2014

Connecting to a new wireless network - settings in windows 7


  1. Go to Start => Control Panel
  2. Click on Network and Internet
  3. Click on Network and Sharing Center
  4. Click on Change adapter settings
  5. Select the required network, right click on it and select Properties
  6. Select Internet Protocol Version 4(TCP/IPv4) and click on Properties
  7. Select Obtain an IP address automatically and click on Ok
  8. Repeat the same for Internet Protocol Version 6(TCP/IPv6) if required and then click on Close

Thursday, August 21, 2014

Compress files in linux


tar -zcvf [name_of_file].tar.gz /var/www/[folder_to_compress]

Saturday, August 9, 2014

Complile and run java programs in command prompt


javac file_name.java
java -cp . class_name

Monday, June 9, 2014

Reset admin password in drupal 7

The password reset method described below uses a PHP script that must be uploaded to the web server to reset the administrator password. The ability to upload a PHP file to the server where the site is hosted is required for successful execution of this method.

Under the hood, the PHP script executes a full Drupal bootstrap in order to obtain access to the necessary functions that generate the administrative password and then update the database with the new password that you specify via the URL when you execute the script through the web browser.

Note: leaving this password reset script on your server after resetting the password constitutes a highly critical security hole that enables anyone to reset your administrator password. Use this script carefully, and always delete the script after you're finished using it.

  1. First, create a file with a random name (gh34tu9.php for example)
  2. Copy and paste the following contents into the file, and save the file
  3. 
    <!--php
    define('DRUPAL_ROOT', getcwd());
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    require_once DRUPAL_ROOT . '/includes/password.inc';
    if (isset($_GET['pass']) && !empty($_GET['pass'])) {
      $newhash =  user_hash_password($_GET['pass']);
    }
    else {
      die('Retry with ?pass=PASSWORD set in the URL');
    }
    $updatepass = db_update('users')
      --->fields(array(
        'pass' => $newhash,
    // Uncomment the following lines to reset the administrative username and/or email address, if necessary.
    //    'name' => 'admin',
    //    'mail' => 'yourmail@example.com'
      ))
      ->condition('uid', '1', '=')
      ->execute();
    print "Done. Please delete this file immediately!";
    drupal_exit();
    ?>
    
  4. Upload the file to the root of the Drupal installation directory (i.e., where index.php, update.php, robots.txt and other files and directories exist)
  5. Execute the script, by requesting the file in a web browser using the following URL pattern:
  6. 
    http://example.com/gh34tu9.php?pass=mypassword
    
  7. In the above URL,
    - replace example.com with your actual domain name,
    - replace gh34tu9.php with the actual file name that you specified in step one above,
    - replace mypassword with the desired new password.
If the script executes successfully, you will see the text "Done" in your web browser. The password of the administrative account created when installing Drupal (i.e., user/1) will be changed to "mypassword" (or whatever value you specify).
Finally, delete the file from the Drupal installation root directory.

Ref: https://drupal.org/node/1556488

Tuesday, May 6, 2014

Fix Windows 7 not genuine error

  1. Open command prompt as Administrator
  2. Type the below command and press Enter to execute
  3. 
    SLMGR – REARM
    
    
  4. Turn off the computer and boot. The error message will be vanished now.

Tuesday, March 25, 2014

Kill a process on a port in ubuntu


sudo kill `sudo lsof -t -i:8080`

If the above does not work, try

sudo kill $(sudo lsof -t -i:8080)

Monday, March 24, 2014

Install tomcat 7 manually in ubuntu and integrate with eclipse

  1. Download Tomcat 7 tar.gz
  2. Run the following commands
  3. 
    cd /path/to/downloaded/file
    tar xvzf apache-tomcat-7.0.52.tar.gz
    sudo mv apache-tomcat-7.0.52/ /usr/share/tomcat7
    sudo gedit /usr/share/tomcat7/bin/catalina.sh
    
  4. Add following two lines after the first line and close gedit after saving the changes
  5. 
    JAVA_HOME="/usr/lib/jvm/java-6-openjdk-i386"
    JRE_HOME="/usr/lib/jvm/java-6-openjdk-i386/jre"
    
  6. To integrate with eclipse
  7. 
    cd /usr/share/tomcat7
    sudo ln -s /var/lib/tomcat7/conf conf
    sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
    sudo ln -s /var/log/tomcat7 log
    sudo chmod -R 777 /usr/share/tomcat7/conf
    
  8. Start the Tomcat server using following command to check if it is working
  9. 
    sudo /usr/share/tomcat7/bin/catalina.sh run
    
  10. Stop the server by pressing ctrl+c
  11. To change the port number, open server.xml in gedit
  12. 
    sudo gedit /usr/share/tomcat7/conf/server.xml
    
  13. Change all the occurrences of <connector port="8080"> to <connector port="8081">
  14. Verify installation at: http://localhost:8081/

Sunday, March 23, 2014

Configure tomcat 6 for eclipse in ubuntu

  1. Install tomcat 6 in ubuntu by running the below commands
  2. 
    sudo apt-get update
    sudo apt-get install tomcat6
    sudo service tomcat6 stop
    cd /usr/share/tomcat6
    sudo ln -s /var/lib/tomcat6/conf conf
    sudo ln -s /etc/tomcat6/policy.d/03catalina.policy conf/catalina.policy
    sudo ln -s /var/log/tomcat6 log
    sudo chmod -R 777 /usr/share/tomcat6/conf
    
    
  3. In the eclipse main menu go to Help ->Install New Software...
  4. Make the settings as below by selecting the highlighted plugins under Web, XML, Java EE and OSGi Enterprise Development select option
  5. Select Windows -> Preferences -> Server -> Runtime Environments
  6. Click on Add…
  7. Select "Apache Tomcat v6.0" and click on Next
  8. Enter “/usr/share/tomcat6″ into the “Tomcat installation directory” field
  9. Click Ok
  10. Now Right click on your project and Run As -> Run on Server

Create dynamic web project in eclipse for ubuntu platform

  1. Install eclipse from Ubuntu Software Center
  2. Open eclipse and select the required workspace
  3. In the main menu go to Help->Install New Software...
  4. Make the settings as below by selecting the highlighted plugins under Web, XML, Java EE and OSGi Enterprise Development select option
  5. Make sure to select 'All Available Sites' in the dropdown
  6. Now on click of File->New->Project.. a select wizard shows up
  7. Scroll down to find Web option. Click on the arrow to find 'Dynamic Web Project' option. Click on it to create a new Dynamic Web Project

Wifi not working in ubuntu

  1. Connect to a wired internet connection to first install the additional drivers.
  2. Check if all the hardware drivers are installed. Go to System Settings -> Additional Drivers (Under Hardware Group). It will automatically check for missing drivers and ask to activate.
  3. If the above method does not work, go to Ubuntu Software Center and type 'additional drivers' in the search box. There will be results like Additional Drivers (jockey-kde) and Additional Drivers (jockey-gtk). Make sure both are installed.
  4. Go to Network Connections either from Dash Home or by clicking the network icon at the top right menu of the desktop.
  5. Under Wireless tab click on 'Edit...' if the connection details has already been added else click on 'Add'.
  6. Under Wireless tab enter SSID as given by your internet provider. Leave all the other settings as is. Make sure 'Connect automatically' is checked.
  7. Then under Wireless Security tab, select WEP for Security dropdown and enter the key as given by your internet provider. Leave all the other settings as is.
  8. After the changes click on Save.
  9. Wifi connections must now be detected automatically.

Thursday, March 6, 2014

Resize an existing virtualbox hard drive in guest windows xp using host windows 7


  1. Create a new hard disk 
    1. Click on Settings in virtualbox 
    2. Select Storage tab 
    3. Click on Add Hard Disk icon
    4. Set a sufficient amount of dynamically expanding disk space
  2. Clone your old hard disk
    1. Check the location of VBoxManage and your old hard disk .vdi file [ex: in my computer i have VBoxManage at G: and old_hard_disk.vdi at C:\Users\acer\VirtualBox VMs\old_hard_disk_dir\old_hard_disk.vdi]
    2. Open up cmd in windows 7, go to the location of VBoxManage and type as below:
    3. 
      C:\Users\acer>G:
      G:\>VBoxManage clonehd "C:\Users\acer\VirtualBox VMs\old_hard_disk_dir\old_hard_disk.vdi" "C:\Users\acer\VirtualBox VMs\old_hard_disk_dir\new_hard_disk.vdi" --existing
      
    4. You see something like this:
    5. 
      Oracle VM VirtualBox Command Line Management Interface Version 3.2.12
      (C) 2005-2010 Oracle Corporation All rights reserved.
      0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
      Clone hard disk created in format 'VDI'. UUID: ee28ab8b-8232-4c76-8c1b-184afdd1dd27
      
  3. Replace the old guest hard disk with your new hard disk (i.e. new_hard_disk.vdi)
    1. Go to the settings for the guest VM and choose the “Storage” options
    2. Select the new disk created and make it IDE Primary Slave under the Attributes column
    3. Select the old disk and remove it by clicking on - icon at the bottom
  4. Start the guest os i.e windows xp
  5. Resize the Guest File System
    1. Install partition manager tool in windows xp
    2. Select the newly created drive. Right click on it and select Resize Partition
    3. Follow on screen instructions to finish the partitioning
  6. Restart the guest os if required

Tuesday, March 4, 2014

Eclipse menus are cut off in ubuntu 13.10


  1. Open your eclipse.desktop file
  2. 
    sudo -H gedit /usr/share/applications/eclipse.desktop
    
    
  3. Replace the Exec= line with this
  4. 
    Exec=env UBUNTU_MENUPROXY= eclipse
    
    

    (If you can't find it in this path, try in ~/.local/share/applications/eclipse.desktop. Otherwise, you could have to find yours using locate command).

    NOTE: If you can't find your eclipse.desktop file, you can simply create one from scratch in the above path, and fill it with these lines:

    
    [Desktop Entry] 
    Type=Application 
    Name=Eclipse 
    Icon=eclipse 
    Exec=env UBUNTU_MENUPROXY= eclipse 
    Terminal=false 
    Categories=Development;IDE;Java;
    
    
  5. Save the file

Friday, February 28, 2014

Install ubuntu in external hard drive using windows 7


  1. Create a bootable usb[ex: pendrive] or disc[ex: cd/dvd] which contains the iso
  2. Insert the external hard drive into usb slot and start windows 7 and immediately get to the boot menu by pressing F12 and select the bootable pendrive/cd/dvd
  3. Follow the on screen instructions when ubuntu loads
  4. Choose 'Something else' option when asked while installing
  5. Carefully choose the external hard drive. The naming could be something like sdb/sdc.. etc.
  6. After that under the selected drive, make the below partitions by clicking + button:
    1. swap - select type as 'Swap Area' from the dropdown and size as 4000 MB(4GB)
    2. home - select type as 'ext4' [probably this is the default option], mount point as '/home' and size as required [ex: 4000 MB(4GB)]
    3. root - select type as 'ext4' [probably this is the default option], mount point as '/' and size as required [ex: 8000 MB(8GB)]
  7. Select 'Device for boot loader installation' as the external hard drive [ex: /dev/sdb HD(16GB)]
  8. Then click on 'Install Now'
  9. Follow the onscreen instructions during the setup
  10. Finally when it asks for 'Restart' do a restart by removing the pendrive/cd/dvd and get into the boot menu and select the external hard disk
  11. It should now boot from Ubuntu

Monday, February 10, 2014

Friday, February 7, 2014

Ubuntu desktop console

To work in ubuntu desktop console press

ctrl + alt + F1

To revert back to gui mode press

ctrl + alt + F7

or

alt + F7

or

ctrl + alt + F8

Wednesday, January 22, 2014

Method overloading in codeigniter / php

Correct way to overload a method in codeigniter/php:


function mymethod($id = null)
{
   if (isset($id))
   {
      echo "My method with one parameter";
   }
   else
   {
      echo "My method with no parameters";
   }
}

The above method can be invoked by:


mymethod();
mymethod(true);