Archive

When I first heard about Bolt Browser for J2ME mobile phones, I couldn’t wait to try it out and see how it compares to Opera Mini 4.2.

I’ve used WebKit based browsers such as TeaShark and the native Nokia S60 browser before and as far as rendering speed is concerned, these browsers take as much as 5 times the amount of time Opera Mini takes to render a page.

So it was interesting to test Bolt against Opera Mini and Webkit browsers.

Startup:

Bolt’s installation procedure is similar to Opera Mini’s but it takes a lot more time to start than Opera Mini.
Here’s how the startup screens look like:

Loading Screens

Start Screens

Both start-screens are alike, except that Opera Mini displays History, Bookmarks and Feeds vertically while Bolt displays it horizontally.

Rendering Performance:

Bolt’s Rendering accuracy is really good, however it does mess up a few images i.e. the colour of the images is a little different from the original.

Speed-wise, Bolt is a lot faster than Webkit based browsers but is slower than Opera Mini. Although Bitstream claims that it is faster than Opera Mini, I didn’t think so. It is fast, but not as fast as Opera Mini.

It’s interesting to note that Bolt works flawlessly with Bloglines while Opera Mini and Webkit browsers don’t work.

However, on many pages Bolt throws up errors almost every time.

Although errors like this can be resolved with a refresh, I encountered another error that announced that Bolt had an unrecoverable error and sent an error log to their server. I couldn’t take a screenshot as I couldn’t reproduce it again.

Data Reduction:

Although Bitstream claims that its data reduction ratio is 23:1, there’s really no way of verifying this as Bolt has no option to view web-page information. Opera Mini’s Page Information looks like this:

Features:

To be honest, Bolt’s features are basic at best. The only feature that is unique to Bolt and sets itself apart from other browsers (including Opera Mini) is the Split-Screen feature.

In Split-screen mode the screen is horizontally divided into half. The top half has the zoomed-out view of a page while the bottom-half shows a full-zoomed area of the page around the cursor and it looks like this:

Other than this, Bolt doesn’t have much to brag out. Bolt’s Bookmark and RSS Feed Managers are similar to other browsers.

If the current webpage has a number somewhere, Bolt detects it and allows you to either call or send an SMS to that number. Opera Mini also detects numbers but only allows the user to call the number. Both browsers are terrible at recognizing phone numbers though, phone models (such as P230, N70, N95), addresses and version numbers are confused as telephone numbers.
Opera Mini on the other hand has Opera Link for bookmark synchronization, is skinnable, allows pages to be saved on phone or memory card, supports HTTP Authentication (bolt doesn’t) and supports multiple search-engines and even custom Search Strings like this:

fdsf

Customization:

Again, a no show. There’s hardly any options to choose from.

That’s it. There are no more options in Bolt. Compare this with Opera Mini’s options:

Final Word:

For a browser in its beta stage, Bolt is pretty good and I expect the final version to be a little faster and more feature-rich. Even in its beta stage it’s better than most Webkit based browsers. However, it lacks many basic features (such as tabbed browsing, copy-pasting and page saves) and if the final version doesn’t include any new features, then there’s absolutely no way Bolt can be an Opera Mini killer. Bolt has the potential, but only time will tell.

I wanted to post this a few years back but I just didn’t have the time.

This is something really interesting and it seems that nobody else has come across this little secret.

Many members from dreamincode.net Forums asked me how I could make my signature show videos running in the background and I’ve finally found time to explain how.

This is how my Forum Signature looks like (or looked like when I was writing this post) :

To see how this works, follow these steps:

Open your favourite media player and play any video file.

Ensure that the media player window is covering the image above.

Now, minimize the media player.

You should now see a portion of the video being played on the image as if the image itself were a media player.

Awesome, isn’t it?

I figured this out while I was experimenting with an application of mine which tried to modify Media Player Classic on-the-fly.

It seems that in Windows XP (might also be true for other windows OSes and other OSes), Video files can only be displayed on a portion of the screen that has a particular colour. The video can only be displayed on a portion of the screen which is currently displaying a specific colour.

That specific colour is RGB(16,0,16).

Try it out for yourself. Create an image with a background colour of RGB(16,0,16) like this:

Now play any video over this image and minimize the video player. The video should now be visible on the image.

My guess as to why this works is that Windows (or other OSes) needs to be able to figure out where a video should be displayed when a media player requests for playback. According to me, this has been intentionally included in the video playback design.

If the media player just provided co-ordinates of a rectangle to the OS for displaying the video, that would mean that if any other application was placed on top of the media player window, the video would be displayed over the application’s interface which would not allow the user to see the application’s user interface (forms, controls etc.)

Here’s what I think they did to fix the problem.

The principle behind this design could have been that “if a video could be displayed only within a rectangle that displayed only a specific colour, no overlapping application would be affected.”

But which colour would be best suitable for this purpose? Black is the first colour that comes to my mind for obvious reasons but black is a common colour and is used frequently in desktop wallpapers or in user interface elements.

Hence they chose a colour that’s technically not black but would look just like black and hence they must have come up with the colour RGB(16,0,16)

My reasoning probably isn’t correct but I’m pretty sure that the real reason is based somewhere along the lines.

I just find it ironic that something that behaves just like a green screen doesn’t even have a hint of green in its colour code (its 16,0,16 in RGB) 😉

As I’m still not sure if this works on other operating systems, I’d appreciate it if you could test this on your operating system and post the result as a comment to this post. Thanks.

A friend gave me his CD which had broken into two pieces and asked if I could fix it.

Looking at it I knew there was no way I could recover all the files correctly, but there was a possibility that some files could be recovered. So I took up the challenge.

The first thing that I wanted to do was to attach the CD using Pidilite’s FeviQuick but I didn’t have any so I used FeviCol instead to attach the two pieces together.

There were way too many scratches and the portion near the crack had vanished so I wasn’t too optimistic about the result. But I had way too much time on my hands so I thought I’d go all the way just to see what happens.

After an hour or two, the glue had hardened but the CD would still bend when lifted. I then used cellotape to ensure that the CD remained in one piece.

After the cellotape fix, I realized that I had spilt some of the Fevicol on the CD layer.

I used a combination of cologne and my mom’s nail polish remover to remove the glue and it even managed to remove a few scratches.

That’s it. The CD was firm, relatively clean and seemed ready for the Acid Test so I inserted it in my laptop’s CD drive.

Obviously with the amount of damage the disc had taken there was no way Windows would even detect it as a CD.

I used some of the free tools from here and I managed to recover a few text files, pictures and portions of a video.

You’ll probably have more luck with your recovery process if your CDs are in better condition. 😉

VB6 calls control events in a very specific way. It’s impressive but the design of event handling results in losing a certain number of guaranteed bytes per control used. By losing bytes, I am referring to the addition of redundant bytes in the executable code.

I studied the entire structure with Disassemblers and debuggers and found out that the total number of redundant bytes is governed by the following formula:

where:N = Total Number of Controls UsedNumber_Of_Events = Total Number Events Supported by a Control (Different for each control)Events_Used = Number of Events Used for each control.

So Imagine a simple form having two text boxes and 1 command button for a simple login box, considering that only the following events are used:Form_Load()
Command1_Click()
The Total number of Redundant Bytes is:
(4*(31+6-1)) + 2*(4*(24+6)) + (4*(17+6-1)) = 472
1 FORM + 2 TEXT BOXES + 1 CMD BTN

That’s 472 unnecessary bytes just for a simple login box using absolutely no user-written code.

I’ve come across a few people who believe that minesweeper lays down only half the number of bombs and only adds the other half on the board as the game progresses.

I debugged the game myself and have found that it is completely false. However, the game ensures that you don’t click a bomb on the first click. Hence, if the first click is a bomb, it is removed from the grid and placed at the first empty location from the coordinate (0,0) i.e. the top-left location.

Hence, if you clicked on (3,2) which originally had a bomb, it would be removed from (3,2) and placed at (0,0) if that location were empty.

This can also be verified without using a debugger. Use the xyzzy cheat to enable the white pixel at the top-left corner of the screen. Then, find a location which contains a bomb (ie. black pixel at top-left corner of the screen) but don’t click it. Now, move your cursor to the top-left corner of the screen and check if it has a bomb.

Now click on the previous location which had a bomb and you’ll notice that there isn’t a bomb once you click it. Then move your cursor to the top-left corner of the board and you’ll notice that the bomb has been shifted to the top-left location.

Minesweeper cheats FOR you and not against you to ensure that you can start the game without clicking a bomb everytime.

We’ve all heard of one-way Hash Functions sometime or the other.
Most of us have heard about them from books.
An Algorithm’s explanation is usually followed by its applications and most books mention only one major application (in security) ie. implementing password checks and storing them in a database.

I used to wonder:”That’s it? One Application in Security?”, and searching on the internet (and some more books) didn’t help either.

Luckily, I’ve finally found my answers. Now, I’m able to appreciate one-way Hash functions a lot more because I’ve seen it in action. If I had read this application in a book I’m sure that I wouldn’t have realized its importance.

A few days ago, Nokia Corporation issued a notice to all customers that some of its BL-5C Model Batteries had some manufacturing defects which could cause it to explode. It asked customers to check if their batteries were manufactured between December 2005 and November 2006 and if so, get the battery replaced for free.

Nokia also allowed its customers to type in their 26 Character Battery Code on their website (www.nokia.com/batteryreplacement) to see if their battery was faulty or not.

I decided to check the script which finds out when the battery was manufactured. I thought that by looking at the source code, I could figure out exactly which batteries were faulty.

This code is awesome because, even after reading the source code, nobody can figure out which models are faulty. At the most what we can understand is that Battery Information (Date of Manufacture, Location of Manufacture) is present between the 8th and 17th characters. The characters between 18 and 26th positions could hold the amount of batteries manufactured by the factory before the current unit. We also know that the battery is faulty for some 334 combinations of characters between the 14th and 17th positions. But having this knowledge is futile.

Hence by using a one-way Hash Algorithm (MD5 in this case), we can hide such information (factory codes of factories which manufactured the faulty batteries) even in the source code. This way we can protect such vital information from being stolen by anyone even if he has access to the complete source code, and this according to me is one of the most brilliant applications of One-way Hash functions.

This is a typical assignment given to students who are learning C/C++.
“Write a function that copies the contents of one string into another.”
Note that in this example a string is referred to as a character array.

Can you notice that something is missing in the copy() function? Yes, the null termination character was not appended at the end of the new string. I corrected a friend of mine who the same mistake and he asked me why the code works for other strings as well such as “Sanch”.

Luckily, we were near a computer so I could demonstrate my examples straight away to convince him.

Observe the declaration of this character array:

char name[10]=”Sanchit”;

Internally, this String is stored like this:
S,a,n,c,h,i,t,,,

Yes, if the string initial declaration is less than the size provided in the square brackets, the rest of the elements are filled with zeros. This is applicable for arrays of any data type.

Since the ASCII Value of is 0, I can represent my array like this again,

S,a,n,c,h,i,t,0x0,0x0,0x0

Does this ring any bells?

If you create another array of the same size (here: 10) and copy this string to it using the code given above, the rest of the elements after the String are already . So there is no need to the character as C would know where the string terminates.

But what if the String is larger? Assuming “Sanchit Karve” is stored in the same Array, it will look like this:
S,a,n,c,h,i,t, <space> ,K,a,r,v,e, , , …

If you notice, that inspite of the string being larger than the array size, it is stored completely after occupying the space after the array. Since, now the space outside the array has been accessed, the data out there is not zero. Instead they contain garbage values. So, for such situations, we need to append the character at the end of the string, so that C can figure where the string ends. Otherwise, C will output all bytes till a zero is encountered.

So, appending the character is not required if we assume that the string length is lesser the array size. However, we should also ensure that we declare enough space before input larger than the allocated size because of the following reasons:

Hackers make the most of such types of errors, known as Buffer Overflow Errors, and launch Buffer Overflow Attacks where the string is inserted with shellcode (yes, in hex), and the return address of the function is overwritten to the address of the string. This results in the processor passing control to the shellcode and executing it after the function returns. But just because we append the character does not mean that Buffer Overflow Errors don’t occur. But it’s done just as a safety measure so that the program can run without faults.

Now using pointer q:
3 4 5 6 7 8 9 10 0 4239532
Now change the number 2 in the array declaration to 5 like this:

int x[][5]={1,2,3,4,5,6,7,8,9,10};

Run the code and observe the output:1 2 3 4 5 6 7 8 9 10

Now using pointer q:
6 7 8 9 10 0 4239532 0 4235541 1

As you can see, the output using the pointer p remains unchanged because we’re setting it to the first element of the array itself, so it iterates to every element after it.

But q is set to the first element of the 2nd row.
Now which one is the first element of the second row? It’s 6. How do we know it?
It’s because we’ve placed 5 in the column bracket to specify the bounds of each column.

So if we don’t place any value, the compiler gets confused as to how many numbers can be grouped into one column.
Hence whenever such confusion occurs, the compiler generates the error: size of the int[] is unknown or zero.

I’ve come across a lot of people who wonder why a number stored in a variable, if exceeds its range, turns into a weirder negative number.
To explain this phenomena they offer a conclusion without showing any evidence and this conclusion is in no way close to the truth.
Here’s what happens.

The numbers change because of the complement notation that the computer uses to store negative numbers.

And it’s not the compiler’s fault but the processor’s limitation.
This code will give negative numbers on 32-bit,16-bit and 8bit Microprocessors as each register can hold 32/16/8 bits respectively.
You won’t encounter this problem on 64-bit processors as each register can hold a maximum of 64-bits. (Actually, you will encounter the same problem since the value of INT_MAX will be a 64-bit number for a 64 bit processor….but it’ll work fine with 32-bit numbers)

Adding a Number to a maximum value set in these registers creates the problem.
Have a look at this printf statement (I’ve typecasted it for portability)

Now, the values in the first 2 push Instructions is the binary representation of INT_MAX (2147483647 for 32-bit systems). Note that it is comprised of only ONE’s.

When 1 is added to INT_MAX, look what happens to the next two push instructions.
This number is 2147483648 but in unsigned notation…but in signed notation it’s -2147483648 since the Most Significant Bit decides the Sign of a Number.

And since by default the compiler assumes that a variable is signed, you get the negative value.

Try the same C code after replacing %d with the %u format specifier.
You’ll notice that 2147483648 will be the output.

Remember, there’s nothing like postive or negative numbers…It’s all about interpretation. 111 (for a 3 bit architecture) could mean 7(without using MSB for sign-convention…ie. unsigned) as well as -1 (using MSB for sign ie. signed).

You might wonder why I’ve blamed the Processor and not the compiler in spite of the fact that the Compiler has precalculated the result of addition and passed it to printf.
The reason is that I’ve compiled the above code in Aggressive Optimization, so the compiler generates push instructions.
Normally the Compiler plays safe and lets the processor take care of such values by generating the following code: