Change apache server's default listening port

Tested on VPS hosting using ubuntu server 10.04.

Change the port number in the following files:
/etc/apache2/sites-enabled/example.com
/etc/apache2/ports.conf
/etc/apache2/sites-available/default
Finally remember to restart apache server:
/etc/init.d/apache2 restart

Question Paper Downloader for Thaparians

Latest Software here
Latest Code here
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.net.URL;

public class FileDownloader
{
 public static void main(String args[])
 {
  if(args.length != 2 && !(args[0].equals(""))){
   System.out.println("Usage: <web-link> <new-filename>");
  }else{try{
   if((args[0].substring(7,10)).equals("172"))
    args[0] = "http://cl.thapar.edu/" + args[0].substring(20);
   System.out.println("FileDownloader: "+args[0]+" "+args[1]);
   URL url = new URL(args[0]);
   java.io.BufferedInputStream in = new BufferedInputStream(url.openStream());
   java.io.FileOutputStream fos = new FileOutputStream(args[1]+".pdf");
   java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
   byte[] data = new byte[1024];
   int x=0;
   while((x=in.read(data,0,1024))>=0)
   {
    bout.write(data,0,x);
   }
   bout.close();
   in.close();
  }catch(IOException e){
   System.out.println(e.toString());
  }}
 }
}

Steps for Java Web Start

  1. Make jar file of your class files and resources like icons, images etc. using following command:
    jar cf JarFileToCreate.jar abc.class def.class ...
    For More details on creating Jar files, see create-jar-file-for-java-app
  2. Make jnlp extension text file with following information:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost/jnlp" href="MyApp.jnlp">
        <information>
            <title>My App Title</title>
            <vendor>MonishVendor</vendor>
        </information>
        <resources>
            <!-- Application Resources -->
            <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
            <jar href="TestApp.jar" main="true" />
    
        </resources>
        <application-desc
             name="DemoName"
             main-class="GUI_QPDownloader"
             width="300"
             height="300">
         </application-desc>
         <update check="background"/>
    </jnlp> 
  3. That's all. Now run jnlp file from any web-browser to test

    How to create jar file for the java app you make.

    Modifying a Manifest File

    You use the m command-line option to add custom information to the manifest during creation of a JAR file. This section describes the m option. The Jar tool automatically puts a default manifest with the pathname META-INF/MANIFEST.MF into any JAR file you create. You can enable special JAR file functionality, such as package sealing, by modifying the default manifest. Typically, modifying the default manifest involves adding special-purpose headers to the manifest that allow the JAR file to perform a particular desired function.
    To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest.

    Warning:  The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

    The basic command has this format:
    jar cfm jar-file manifest-addition input-file(s)

    Effective C++ Ed. 3rd: Item 43: Know how to access names in templatized base classes

    In derived class templates, refer to names in base class templates via
    1. a "this->" prefix
    2. using declarations or
    3. an explicit base class qualification like:
      Base::func()
    The 3rd option should not be used in case of virtual functions.
    prev | next

    Effective C++ Ed. 3rd: Item 42. Understand the two meanings of typename

    What's the difference between the following two declarations:
    template<class T> class Widget;                 // uses "class"
    
    template<typename T> class Widget;              // uses "typename"
    
    
    When declaring template parameters, class and typename are interchangeable.
    But use typename to identify nested dependent type names, except in base class lists or as a base class identifier in a member initialization list.
    prev | next

    Effective C++ Ed. 3rd: Item 41. Understand implicit interfaces and compile-time polymorphism

    • Object-oriented programming revolves around explicit interfaces and runtime polymorphism.
    • In template and generic programming, these are less important. Instead, implicit interfaces and compile-time polymorphism move to the fore.

    Effective C++ Ed. 3rd: Item 40. Use multiple inheritance juriciously

    With multiple inheritance (MI), you may have a class hierarchy with more than one path between a base class and a derived class. For example:
    class basic_ios { ... };
    
    class basic_istream: public basic_ios { ... };
    
    class basic_ostream: public basic_ios { ... };
    
    class basic_iostream: public basic_istream, public basic_ostream
    { ... };
    To restrict inclusion of members of class basic_istream twice into class basic_iostream, use virtual inheritance. Declare the above classes as:
    class basic_ios { ... };
    
    class basic_istream: virtual public basic_ios { ... };
    
    class basic_ostream: virtual public basic_ios { ... };
    
    class basic_iostream: public basic_istream, public basic_ostream
    { ... };
    But try to avoid virtual inheritance because:
    1. objects created using virtual inheritance are generally larger.
    2. Access to data members in virtual base classes is also slower than those in non-virtual base classes.
    Cheers

    Effective C++ Ed. 3rd: Item 39. Use private inheritance judiciously

    A class "is-implemented-in-terms-of" might be achieved by:
    • composition (see prev. item for detail)
    • private inheritance. 
    Now, which to use when? Former should be used whenever possible. Private inheritance would be handy when you need to redefine a virtual member function or need to access to protected base class members.
    Beside the 2 alternatives mentioned above,
    • we may have a design something like:
    class Widget {
    private:
      class WidgetTimer: public Timer {
      public:
        virtual void onTick() const;
        ...
    
      };
       WidgetTimer timer;
      ...
    
    };
    
    In the third alternative's example, we need to redefine onTick() of class Timer.This design is appreciated over private inheritance because 1.the derived classes would not be able to refine onTick(). 2. In case of private inheritance, Widget get compilation dependencies on the definition of class Timer which would force us to #include timer.h Whereas in alternative 3, By defining WidgetTimer class out of the Widget class and placing a pointer to WidgetTimer would require just declaration of WidgetTimer class at the minimum.
    prev | next
    cheers

    Effective C++ Ed. 3rd: Item 38. Model "has-a" or "is-implemented-in-terms-of" through composition

    Composition is the relationship between types that arises when objects of one type contain objects of another type. Composition means either "has-a"(things related to application domain) or "is-implemented-in-terms-of."(things related to your software's implementation domain like mutexes, buffer, search trees etc.)

    prev | next
    Cheers