Tuesday, January 27, 2026
What are the weaknesses of developing a web application in react instead of using jQuery with html5 and a python backend ?
Sunday, May 15, 2022
Windows recovery drive
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
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
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
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
Friday, July 6, 2012
SSL in Wamp Server
1. Create SSL Certificate and Key
2. Copy the server.key and server.crt files
3. Edit the httpd.conf file and php.ini
4. Edit the httpd-ssl.conf file
5. Starting the HTTPS Server and Putting it Online
Monday, June 18, 2012
PHP to handle inputs copy pasted from MS Word
{
$invalid = array('Š'=>'S', 'š'=>'s', 'Ð'=>'Dj', 'd'=>'dj', 'Ž'=>'Z', 'ž'=>'z',
'C'=>'C', 'c'=>'c', 'C'=>'C', 'c'=>'c', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A',
'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E',
'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y',
'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a',
'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i',
'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b',
'ÿ'=>'y', 'R'=>'R', 'r'=>'r', "`" => "'", "´" => "'", "„" => ",", "`" => "'",
"´" => "'", "“" => "\"", "”" => "\"", "´" => "'", "’" => "'", "{" => "",
"~" => "", "–" => "-", "’" => "'");
$str = str_replace(array_keys($invalid), array_values($invalid), $str);
return $str;
}
Details from the PHP Manual:
$in_charset
, string $out_charset
, string $str
)Parameters
-
in_charset - The input charset.
-
out_charset - The output charset.If you append the string //TRANSLIT to
out_charsettransliteration is activated. This means that when a character can't be represented in the target charset, it can be approximated through one or several similarly looking characters. If you append the string //IGNORE, characters that cannot be represented in the target charset are silently discarded. Otherwise,stris cut from the first illegal character and anE_NOTICEis generated. -
str - The string to be converted.
Return Values
FALSE on failure.
Saturday, May 5, 2012
array_pop and array_push in PHP
array_push — Push one or more elements onto the end of array
array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed.
Has the same effect as:
<?php
$array[] = $var;
?>
repeated for each var.
array_pop — Pop the element off the end of array
array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Will additionally produce a Warning when called on a non-array.
Note: This function will reset() the array pointer of the input array after use.
Saturday, March 17, 2012
Redirecting based on the URL string using PHP
Also in many other cases a company has multiple domains and multiple page addresses to service clients and prospects from different countries, demographics and walks of life.
And the need of the hour is that one wants to send a user to a different folder on your web site, based on what domain they use? Here we will explain a simple way to do this using PHP.
For instance on my VPS, I have 2 domains pointing: one domain called sampleno1.com and the other one called sampleno2.com. Both point to the IP of the VPS.
We have an index.php file in the root of the web server on the VPS containing the following code.
<?php
if (($_SERVER['HTTP_HOST'] == “sampleno1.com”) || ($_SERVER['HTTP_HOST'] == “www.sampleno1.com”))
{
header("location: folderforsampleno1");
}
if (($_SERVER['HTTP_HOST'] == “sampleno2.com”) || ($_SERVER['HTTP_HOST'] == “www.sampleno2.com”))
{
header("location: folderforsampleno2");
}
?>
The code asks the PHP server to see what the HTTP_HOST header is. If it is sampleno1.com or www.sampleno1.com, then it redirects to the folder on the server which contains the code for the site sampleno1.
If it is sampleno2.com or www.sampleno2.com, then it redirects to the folder on the server which contains the code for the site sampleno2
Saturday, March 3, 2012
Find a File containing a specific text string in Ubuntu
The format is
grep “text string to search” directory-path
Some Examples
Simple String Search in a directory:
Search for a string called "star wars" in all text files located in /home/movies/*.txt directory, use
$ grep "star wars" /home/movies/*.txt
Search for a string in all files in all contained folders
For this, you can search for a text string all files under each directory, recursively with -r option:
$ grep -r "star wars" /home/movies/
Monday, February 6, 2012
Determine file size with du
du takes a single argument, specifying a pathname for du to work; if it is not specified, the current directory is used. The SUS mandates for du the following options:- -a, display an entry for each file (and not directory) contained in the current directory
- -H, calculate disk usage for link references specified on the command line
- -k, show sizes as multiples of 1024 bytes, not 512-byte
- -L, calculate disk usage for link references anywhere
- -s, report only the sum of the usage in the current directory, not for each file
- -x, only traverse files and directories on the device on which the pathname argument is specified.
Examples
Sum of directories in kilobytes:
$ du -sk *
152304 directoryOne
1856548 directoryTwo $ du -sh *
149M directoryOne
1.8G directoryTwo $ du -sk .[!.]* *| sort -n $ du -sk .[!.]* *| sort -nr $ du -d 1 -c -hThursday, February 2, 2012
node-static for Serving Static Files with Node.js
npm install node-static
var static = require('node-static'),
http = require('http'),
util = require('util');
var webroot = './public',
port = 8181;
var file = new(static.Server)(webroot, {
cache: 900,
headers: { 'X-Powered-By': 'node-static' }
});
http.createServer(function(req, res) {
req.addListener('end', function() {
file.serve(req, res, function(err, result) {
if (err) {
console.error('Error serving %s - %s', req.url, err.message);
if (err.status === 404 || err.status === 500) {
file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res);
} else {
res.writeHead(err.status, err.headers);
res.end();
}
} else {
console.log('%s - %s', req.url, res.message);
}
});
});
}).listen(port);
console.log('node-static running at http://localhost:%d', port);- the directory we want it to serve files from by way of the `webroot` variable (defaults to serving files from the current directory unless you tell it otherwise)
- a cache value of 900, so each file served will be cached for 15 minutes (default value for cache is 3600, meaning files are cached for 1 hour)
- a custom ‘X-Powered-By’ header (I’ve used X-Powered-By solely as an example – you may, or may not, want to disclose the software you’re server is running)
- we check err.status, and serve either 404.html or 500.html accordingly
- if there’s an error and the status code is something other than 404 or 500, we send the status code and the headers back to the client explicitly – when you pass a callback function to file.serve and there is an error, node-static will not respond to the client by itself.

strfromin_charsettoout_charset.