Sunday, May 15, 2022

Windows recovery drive

Windows Recovery USB
There might be times when you can’t actually get into your Windows Laptop. And while Windows has great recovery tools built in,  at such time you can’t access the recovery tools in the normal way.

That means you can’t roll back or reinstall Windows the normal way either.

As a safety net should something go seriously wrong with your PC, youmust create a Windows recovery drive on a spare USB stick. 

How?

Open the Start menu, and search for “create a recovery drive”. This will bring up the right utility. 

Follow the instructions on screen to copy over the necessary files to your chosen USB drive, but note that these files won’t include your personal files and data.


If disaster strikes, you’ll need to boot up from your recovery drive. 

This is usually done by holding down the Delete or F8 keys while your PC starts.

Opt to boot from your USB drive, then pick Troubleshoot > Advanced Options > Recover from a drive to get Windows reinstalled.

Sunday, March 9, 2014

Rename an Android project in Eclipse


Right click the project, and press F2.
You will get a Dialog box which will let you rename the project alongwith the option to update references

Alternatively,

Right click on your project
In the menu that menu that appears, Select "Refactor"
In the menu that appears, Select "Rename"
You will get a Dialog box which will let you rename the project alongwith the option to update references


Saturday, August 24, 2013

Setting Up Name Based Virtual Hosting in Apache on Ubuntu

Apache is by far the most popluar web server out there. Installing  apache on a Ubuntu machine is straightfoward. However, whats the use of it if we cant make it run multiple sites.

Virtual Hosts are used to run more than one site off of a single IP address. If you want to be able to handle more than one domain with one web server, you'll need to set up a virtual host for each. Here I will show you how to work with Virtual Hosts by setting up 2 different sites on a single apache installation using virtual hosts.

As an example, let us assume we are setting up 2 sites www.testwadt.com and www.testwadt.net

Create 2 separate folders where we will place the files which will serve the 2 sites. Let do this in the /var/www folder

mkdir /var/www/testwadt_com
mkdir /var/www/testwadt_net

Now for each of the 2 domains, put the files in the respective folders created for the same

Also create a log folder in each of the 2 folder created above
mkdir /var/www/testwadt_com/log
mkdir /var/www/testwadt_net/log


Now we need to define to Apache that we’re using name based virtual hosting instead of IP based. You can append the following line to your /etc/apache2/apache2.conf to define this:
NameVirtualHost ip.address:port

typically this would be
NameVirtualHost :80

The next step is to set up Virtual Hosts. Each virtual host needs its own file in the /etc/apache2/sites-available/ directory.
This allows for a clear and specific per-site configuration.

So lets create files for the two sites we wish to host: testwadt.com and testwadt.net

First lets create a file testwadt.com in /etc/apache2/sites-available

vi /etc/apache2/sites-available/testwadt.com

In the file place the following:

# domain: testwadt.com
# public: /var/www/testwadt_com

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin youremail@youremailprovider
  ServerName  www.testwadt.com
  ServerAlias testwadt.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/testwadt_com

  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/testwadt_com/log/error.log
  CustomLog /var/www/testwadt_com/log/access.log combined
</VirtualHost>


Now lets create the 2nd file testwadt.net in /etc/apache2/sites-available

vi /etc/apache2/sites-available/testwadt.net

In the file place the following:

# domain: testwadt.net
# public: /var/www/testwadt_net

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin youremail@youremailprovider
  ServerName  www.testwadt.net
  ServerAlias testwadt.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/testwadt_net

  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/testwadt_net/log/error.log
  CustomLog /var/www/testwadt_net/log/access.log combined
</VirtualHost>

What these settings do is as follows:

ServerName listens for requests asking for a certain domain
ServerAlias defines any additional domains that should match
ServerAdmin is the contact for the site
DocumentRoot is the path to the content for that site


Now that this file is created in the /etc/apache2/sites-available/ folder we’re just about ready to start, but we need to enable it. We can do that by creating a symbolic link in /etc/apache2/sites-enabled/

This is done by calling the a2ensite command

a2ensite testwadt.com
a2ensite testwadt.net

Finally, restart the Apache server to initialize all the changes

/etc/init.d/apache2 restart


Files that configure virtual hosts should be located in the /etc/apache2/sites-available/ directory.

The files should be symbolically linked to sites-enabled/ with the a2ensite tool.

Tuesday, May 14, 2013

Create a Git Repository from an existing non-empty directory and Push Files to a Remote Repository

From the terminal (or command line prompt in Windows) goto the non empty directory where you'd like to create a Git Repository

Run the following commands

git init

git add .

git commit -m 'Initialized my Git Repo'



Get the url of your remote repository.


For E.g in case the url is https://xyz@bitbucket.org/xyz/sample_repo.git

Run the following commands

git remote add origin https://xyz@bitbucket.org/xyz/sample_repo.git

git push -u origin master

Tuesday, February 12, 2013

Bookmarklets

Regular bookmarks (aka favorites) are just locations to visit, like “http://gmail.com”. Bookmarklets are javascript code that the browser runs on the current page, and they’re marked by “javascript:” instead of “http://”.

Technically, a bookmarklet is unobtrusive script written in JavaScript and stored as the URL of a bookmark in a web browser or as a hyperlink on a web page.

Bookmarklets are saved and used as normal bookmarks. As such, they are simple "one-click" tools which add functionality to the browser.

For example, they can:

Modify the appearance of a web page within the browser (e.g., change font size, background color, etc.)

Extract data from a web page (e.g., hyperlinks, images, text, etc.)

Submit the current page to a curation service such as minus, scoop.it, link-shortening service such as bit.ly, or bookmarking service such as Delicious

Query a search engine or online encyclopedia with highlighted text or by a dialog box

Submit the current page to a link validation service or translation service

Set commonly chosen configuration options when the page itself provides no way to do this

"Installation" of a bookmarklet is performed by creating a new bookmark, and pasting the code into the URL destination field. Alternatively, if the bookmarklet is presented as a link, under some browsers it can be dragged and dropped onto the bookmark bar. The bookmarklet can then be run by loading the bookmark normally.

When clicking a bookmarklet, imagine the page author wrote <script>bookmarklet code here</script> — it can do almost anything. There are a few restrictions:

  • Restricted length: Most URLs have a limit around 2000 characters, which limits the amount of code you can run. 
  • No spaces allowed: Some browsers choke on spaces in a URL, so yourcodelookslikethis.


Sunday, July 8, 2012

SEO Tips : Page Renaming - Wordpress

When changing the name of a page via wordpress, keep in mind that the earlier name page URL will not offer a 404 not found request...

This is to be avoided as this completely kills the SEO achieved on the previous URL... crawlers will keep reporting back that the page is down...

3 steps need to be done to prevent any problems:

Step 1: Report within Google Webmaster Tools that the page names have changed

Step 2: Prevent robots/crawlers from finding the problematic page:

This can be done via 2 ways:

1. Use an appropriate WordPress Plugin to ensure that when page names are changed, the Plugin will ensure that WordPress itself will offer the correct pages...

2. Write the appropriate lines in the .htaccess file to ensure that a 301 redirect is offered from the earlier specified URL to the newer URL...


Step 3: Create a custom 404 page which is user friendly and offers an alternative user navigation . The 404 page may say:

We're sorry you didnt find this page:  But you can read about 
A --> Here
B --> Here
C --> Here
etc

Where the links and topics should be the core topics of the business (or SEO chosen keywords)

Friday, July 6, 2012

SSL in Wamp Server

SSL Encryption can be added to your Wamp Server package to make it more secure as well as to test the SSL environment before taking your application to production. 

Note 1: Example given in case the folder in which apache is installed is apache2.2.6  where 2.2.6 is the version of apache installed. In case of another version being installed, say apache 2.2.22, this folder would change to apache2.2.22

Note 2: the foldername appName used below should be changed to whatever is the foldername where your application is placed which should be served to users connecting via https://

1. Create SSL Certificate and Key

Open the DOS command window and change directory to bin directory of wamp apache directory by using the DOS command

cd c:\wamp\bin\apache\apache2.2.6\bin

Now the DOS prompt should look like: C:\wamp\bin\apache\apache2.2.6\bin>

To create a server key with 1024 bits encryption, enter this command:

openssl genrsa -des3 -out server.key 1024

It’ll ask you a pass phrase, enter a passphrase of your choice which you will remember

Remove the pass phrase from the RSA private key (while keeping a backup copy of the original file). Enter these commands:

copy server.key server.key.org
openssl rsa -in server.key.org -out server.key

It’ll ask you the pass phrase you entered earlier, enter it

Create a self-signed Certificate (X509 structure) with the RSA key you just created. Enter the command:

openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt -config C:\wamp\bin\apache\apache2.2.6\conf\openssl.cnf


You'll be asked to fill in information after entering this command.

2. Copy the server.key and server.crt files


In the conf folder of apache2.2.6 folder, create two folders named as ssl.key and ssl.crt

Copy the server.key file to ssl.key folder and server.crt file to ssl.crt

3. Edit the httpd.conf file and php.ini


In httpd.conf file, remove the comment definer # at the line which says:
LoadModule ssl_module modules/mod_ssl.so

In httpd.conf, remove the comment definer # at the line which says:
Include conf/extra/httpd_ssl.conf

Then move that line after this block <IfModule ssl_module>…. </IfModule>

Open the php.ini file located in apache2.2.6/bin folder, remove the comment definer; at the line which says:
extension=php_openssl.dll

4. Edit the httpd-ssl.conf file


The httpd-ssl.conf file is located at C:\wamp\bin\apache\Apache2.2.6\conf\extra

This should be edited as follows

Find the line which says "SSLMutex …." and change it to SSLMutex default without quotes

Find the line which says: <VirtualHost _default_:443>.
Right after it, change the line which says DocumentRoot … to DocumentRoot "C:/wamp/www/appname" with quotes.  
Change the line "ErrorLog…." to Errorlog C:/wamp/logs/sslerror.log without quotes
Change the line "TransferLog …." to TransferLog C:/wamp/logs/sslaccess.log without quotes

Specify the SSL crt file:  Change the line "SSLCertificateFile …." to SSLCertificateFile "C:/wamp/bin/apache/apache2.2.6/conf/ssl.crt/server.crt"

Specify the SSL key file: Change the line "SSLCertificateKeyFile …." to SSLCertificateKeyFile " C:/wamp/bin/apache/apache2.2.6/conf/ssl.key/server.key"

Change the line which says <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin"> to <Directory "C:/wamp/www/">
and add the following lines inside those <Directory … >…</Directory> tags:

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

Make sure the line CustomLog "C:/wamp/logs/ssl_request.log" \  is uncommented (remove the #).

In the DOS Command window, enter httpd -t . If it displays Syntax is OK, then proceed, else you have made a syntactical error and will need to troubleshoot

Go to C:/wamp/logs and create the following 3  files
                                i.            sslerror.log
                              ii.            ssl_request.log
                             iii.            sslaccess.log

5. Starting the HTTPS Server and Putting it Online


Restart the Apache server

If restart is successful, then open the browser and enter https://localhost

If you want to allow put your HTTPS secure server online then in the httpd_ssl.conf file, change the line which says "ServerName localhost:443" to "ServerName www.yourwebsitename.com:443" or  "ServerName X.Y.Z.A:443" without quotes where yourwebsitename is your registered internet domain name and/or  X.Y.Z.A is your WAN IP Address

The DocumentRoot you modified in Step 4 points to the correct website folder on your server.

If your server is connected to a router, setup the router to allow port 443 forwarding to your server.

If your server has a firewall enabled or behind a network firewall, set up the firewall to allow incoming port 443 connection