Reading URLs protected with HTTP Authentication with Java

September 23rd, 2008

In Java, you can use URLConnection class to read from an URL. For example, to read the page from google.com, you can do something like this:

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL google = new URL("http://www.google.com/");
        URLConnection gc = google.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                gc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}

If the access to the URL is protected with authentication mechanism, IOException is thrown when you try to read from InputStream associated with URLConnection. In that case, you need to use Authenticator class from java.net package, that makes accessing password-protected URLs as easy as can be.

Read the rest of this entry »

Encoding DVD to MPEG-4 AVI using MEncoder

September 25th, 2006

1. Introduction

MEncoder is a part of MPlayer package, a movie player for Linux that can play most MPEG, VOB, AVI, OGG/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA, Matroska files, supported by many native, XAnim, RealPlayer, and Win32 DLL codecs. MEncoder (MPlayer’s Movie Encoder) is a simple movie encoder, capable of encoding the wide range of fileformats and decoders of MPlayer, to all the codecs of FFmpeg’s libavcodec.

Read the rest of this entry »

Compiling SDL_image with MSYS/MinGW

August 13th, 2006

1. Introduction

SDL_image is an image loading library that is used with the SDL library, and almost as portable. It allows a programmer to use multiple image formats without having to code all the loading and conversion algorithms themselves. SDL_image supports BMP, GIF, JPG, LBM, PCX, PNG, PNM, TGA, TIFF, XCF, XPM and XV image formats.

SDL_image requires JPEG library for JPG image support, PGN libarary and zlib library for PGN image format support, and the TIFF library for TIFF image support.

Note: Current version of TIFF library has some problems compiling under Windows/MinGW, so we will disable support for tif file format in SDL_image library.

Read the rest of this entry »

Setting up MSYS/MinGW build system for compiling SDL/OpenGL applications

August 8th, 2006

1. Introduction

MSYS is a Minimal SYStem to provide POSIX/Bourne configure scripts the ability to execute and create a Makefile used by make on MS Windows operating system.
MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU tool sets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs.
In this tutorial we will setup MSYS/MinGW configuration, and compile libraries needed for development of SDL and OpenGL applications.

Read the rest of this entry »

Flaming Guide

February 18th, 2006

Fueling The Fire

Now, to get a proper flame going, you have to setup people. Normally this is done by approaching with a somewhat non imposing character and bluntly saying something you know will piss people off. Try and be subtle about it. Throw in things like religion, politics and choice of pet. Here are some examples:

  • Damn liberal
  • Damn chicken god lover
  • Damn cat lover

Notice these are pretty laid back. You could substitute a few key swear words as well, should you choose to. Also, try and kindle an old flame as well. Pull up something dirty out of the skeleton closet, and using some kind of excellent finesse, throw it into the conversation:

Read the rest of this entry »

Real Programmers

February 17th, 2006
  • Real Programmers don’t write specs – users should consider themselves lucky to get any programs at all and take what they get.
  • Real Programmers don’t comment their code. If it was hard to write, it should be hard to understand and even harder to modify.
  • Real Programmers use C since it’s the easiest language to spell.
  • Real Programmers have no use for managers. Managers are sometimes a necessary evil. Managers are good for dealing with personnel bozos, bean counters, senior planners and other mental defectives.
  • Read the rest of this entry »