Nov
22
2008

Output buffering PHP Apache mod gzip mod deflate

Till recently most of my php scripts were working fine on the servers with instantaneous outputs as and when a echo statement came. One issue that popped a lot on localhost was that of chunky outputs; that is the outputs of big scripts came out in chunks rather than smoothly with every echo or print statement. After some research flush() was found to be the solution for this output buffering issue. So what happened was [...]

Nov
19
2008

Remote Login with Curl PHP

The curl extension of php can be used to open remote webpages by both GET and POST methods. There are many situations when you need a php script to login into a website and open a certain page. For example when you are writing a bot or web scraper. To login we need 2 important piece of information : 1. The URL to which login data should be submitted. This can be for example : [...]

Oct
13
2008

wxPython stderr/stdout window

While executing a wxpython script if a error occurs then a white window popups with some message, and it disappears fast enough before it can be read. So here is a fix to pause it and read it what and where the error in the code is : app = wx.App(redirect=False)MyFrame(None).Show()app.MainLoop() The wx.App takes this parameter called redirect which can be True or False.It defaults to True for Windows and MacOS. Another argument is filename=(None/) [...]

Oct
12
2008

PHP Script to find visitor’s location

Hello All Here is a simple php script that lets you track the location of the visitor’s on your site. Lets get to the code straight away : So basically what we did was, used the free geo ip api from IPMango The syntax being http://www.ipmango.com/api.php?ip=a.b.c.d where a.b.c.d is the ip address.

Sep
29
2008

Write Excel Files in PHP – Simple and Easy Way

Hi So this time my simple task was to extract some data from some websites and write them into an excel file and submit. So I simply googled up and found a class calledMS-Excel Stream Handler. With it I went really happy as it was very easy and simple to use, with just a include file. After writing and writing excel files suddenly I noticed that some fields in the excel file were messed with [...]

Apr
4
2008

Execute an SQL Script in JDBC

The SQL Script should have comments starting with – or — only on new lines and each command should end with a ; . Reading a sql file and putting all of it in a string variable and feeding to the execute command would result in an exception. All instructions must be executed individually. A proper sql script should have all instructions starting on a newline and all comments on a newline. Start with an [...]

Apr
2
2008

Reading Writing and Saving Configurations to a File in Java

Configuration files are used in applications to store settings, user preferences and other configuration parameters of an application so that. When configurations are changed from within the application these need to be saved so that next time the application starts with these new settings. In Java reading and writing to a configuration is pretty simple and straight forward. A configuration file can store data in many ways. One simple technique is : key=value Apart from [...]

Jan
13
2008

Raw Sockets – Packets with Winpcap

A previous post mentions how to send raw packets using winsock api on windows xp. Winpcap is a packet driver useful for packet capturing and sending raw packets on the windows platform. Raw means we have to cook the whole packet ourselves. A TCP packet for example consists of: 1. Ethernet header 2. IP header 3. TCP header 4. The data supposed to be send PACKET = ETHERNET_HEADER + IP_HEADER + TCP_HEADER + DATA Each [...]

Jan
13
2008

Tcp syn portscan code in C with Linux sockets

Port Scanning searches for open ports on a remote system. The basic logic for a portscanner would be to connect to the port we want to check. If the socket gives a valid connection without any error then the port is open , closed otherwise (or inaccessible, or filtered). This basic technique is called TCP Connect Port Scanning in which we use something like a loop to connect to ports one by one and check [...]

Jan
13
2008

BSNL Broadband – Connecting 2 computers to the MT882 ADSL Modem

The Huawei MT882 ADSL Modem that you might have received with your BSNL Broadband connection can be used to connect 2 computers to the internet simultaneously since it is a router. It has a USB interface and an Ethernet interface both of which can be simultaneously used but with a few setting changes. First of all one PC must use the usb interface and another must use the ethernet interface via a network adapter. That [...]