Tuesday, March 30, 2010

Find latitute and longitute in google maps.

To make this script work the map must have some point to the center. Else, click on the center of the map of whose you want longitute and latitute and then paste the following in your browser. You will get your result.

javascript:void(prompt('',gApplication.getMap().getCenter()));

Posted via web from Tutorial Universe

Wednesday, February 17, 2010

Converting Latex document to HTML / ODT / DOC

I do all my documents in Latex. Actually i usually use emacs org-mode first and later convert it to Latex, but when it comes to using bibtex, it's all latex. It works great and the output dvi/pdf files look so professional. However recently i had to submit the file in .doc format, and i had a real hard time finding good tools to do that.

There are no direct Latex to .doc converters, so the best bet is to go Latex -> HTML -> DOC. There are lots of Latex to HTML converters like latex2html, tth and hevea, but most of them either don't produce good HTML or mess with bibliography references. But after some research i found the best: TeX4ht

TeX4ht is available in ubuntu/debian repo, so to install

sudo apt-get install tex4ht
Conversion is simple:
htlatex document
(please note, there is no .tex suffix)

This will generate document.html, css and bunch of .png files.

Now to convert it to wordprocessor files (odt, doc..),
1. Open the html file with OpenOffice.org
2. File > Save as
3. Choose the format you want to save it in (odt, doc)

If you have images in the document, they will be linked instead of embedded in the document. To fix this: (source)
1. Edit > Links
2. Click "Break Link" for each image link

Posted via web from Tutorial Universe

How to host a website for free?

You want to have your own website, but you want it for free, right ? There are different services that provide free web hosting. But there are so many of them that, sometimes, it's difficult to make a choice. Before signing up for any free web hosting provider, consider the following:

  • What kind of web site do you want, a static HTML and CSS based or a more robust, dynamic one?
  • What platforms and programming languages do you need to use? For example, PHP, Python, Perl, Ruby on Rails, ASP.NET, CGI scripts, ColdFusion etc. What database server do you need, like MySQL ? Operating System, like Windows or Linux ?
  • Consider the availability of features like FTP upload, CPanel, SSH access, email accounts and aliases (web based, SMTP, POP, relay etc), phpmyadmin.
  • How much disk space do you need, and how much bandwidth?
  • Do you need to have custom configuration facility like with .htaccess, php.ini etc ?
  • Will you use CURL and/or cron jobs?
  • Do you want to install scripts and applications (like drupal, joomla, wordpress, django, movable-type) or want them provided by the hosting provider ? Do you need website statistics, logs, website builder, custom error pages, templates etc provided by the hosting provider?
  • What about backups and support ?
  • Do you need SSL (shared or private)?
  • Do you need free subdomains? Will you also park multiple domains in the same hosting server?
  • Do you like to have ads in your website, placed by the hosting provider? In what forms? Are banner-ads fine?
  • How often is the provider down? If the uptime is not satisfactory, signing up may be a bad idea, unless you have other reasons.

Normally, all of these facilities aren't available in "free" hosting option. Of those available, not all features are offered by a single provider. You have to choose from combination of the subset of these features.

Remember, web space and domain name aren't the same thing. Both are necessary to build a website, and in this post, we discuss only about web space, ie. hosting. You have to obtain a domain name separately. Hosting services sometimes also provide free domain names, or a subdomain like yourname.domain.com.

There are many free hosting providers, one needs to be careful to make a choice. Many hosting providers have stopped or closed their service altogether. This may result in a loss of your files and a change in your web-address, old-links not working and a lot of work finding a new, reliable provider and migrating files. Before making a choice, ask yourself the following questions:

  • For how long has this provider been in service, and for how long does it look like being able to exist? Normally, the more, the better
  • How many users/websites is this provider serving? The more, the better
  • Is this provider making profit? You would want to choose a profitable company that is more likely to continue the business. Providers serving ads, paid hosting services or paid upgrades are generally more likely to be making profits compared to the ones without ads or paid services.
  • How good is the support system? Are there good forums and discussions going on? How fast and frequent are the replies?
  • What is the account-termination and notification policy? Do they notify users before terminating account or their service, and do they allow sufficient time to make backups? Do they help users in this process?
  • How strict are the terms of usage? Some providers dont want to allow anything other than plain HTML pages and would terminate your account if you violate.

Here is a list of some good free hosting providers that we have compiled. The entries are in no particular order or preference and we suggest you to check with them for more information and confirmation. Their features, configurations and policies may change any time. Spend enough time to collect all necessary information before signing up.

I hope this was helpful. More resources on free hosting are available at: Freewebhosts (list of CGI hosts), Freewebspace .

Tuesday, February 16, 2010

How to make HTTP Auth work with PHP CGI

From PHP manual:
The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not available in the CGI version. In an Apache module PHP script, it is possible to use the header() function to send an "Authentication Required" message to the client browser causing it to pop up a Username/Password input window. Once the user has filled in a username and a password, the URL containing the PHP script will be called again with the predefined variables PHP_AUTH_USER, PHP_AUTH_PW, and AUTH_TYPE set to the user name, password and authentication type respectively. These predefined variables are found in the $_SERVER and $HTTP_SERVER_VARS arrays. Both "Basic" and "Digest" (since PHP 5.1.0) authentication methods are supported. See the header() function for more information.
Here is a fix:
  1. Upload a .htaccess file with the following content:
    <IfModule mod_rewrite.c>
         RewriteEngine on
         RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    </IfModule>


  2. Upload a test file with the following php code to verify that HTTP AUTH is working:
    <?php
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
       header('WWW-Authenticate: Basic realm="For testing only"');
       header('HTTP/1.0 401 Unauthorized');
       die ('Sorry, you have to login to view this page');
     } else {
       echo "You enered, Username: ".$_SERVER['PHP_AUTH_USER']." and password: ". $_SERVER['PHP_AUTH_PW']." " };
    ?>
  3. Similar code can be used in cases where HTTP auth validation is required.

Note: Web Hosts like Dreamhost and Godaddy (Linux Shared Hosting) use PHP CGI. In such cases, this fix solves the following error:

401 Unauthorized

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

How does Leadership work

A short 3-minute talk at the TED Conference 2010. Here is the transcript of the video.

Posted via web from Tutorial Universe

How to Convert a LaTeX file to an Office Format

The following steps are for a GNU/Linux operating system. This will help convert a .tex file to popular office formats like .doc , .odt and HTML format.

Run the following commands:
  1. $ bibtex example.bib
  2. $ latex example.bib
  3. $ tex4ht example.tex
  4. $ mk4ht oolatex example.tex
The odt file will be prepared. This file can be converted into various other formats with OpenOffice.org.

If you are using LyX, there are various conversion options in File -> Export menu. One of them is OpenDocument which will export the file into .odt format.

Note: For the above procedures to work, the package tex4ht should be installed in your system. Some formatting might be lost while converting.