Mailinator and DodgeIt Don’t Work

I just tried using dodgeit and mailinator (services which let you use a throwaway email address which you can check on their websites) to register to a forum board and neither of them got the registration email, whereas a more typical yahoo mail account got the email without any hassle. I’ve come to the conclusion that these services (along with some  others) are probably already well-known enough that sysadmins who care are not sending mails to them. A service which provides a checkable random email domain will be best in this scenario, and there may be sites that offer this already.

So, just don’t use one of these well-known throwaway email services to register for something and expect to actually receive the mail.

Leave a comment

Use PHP DOM Parser for more robust screen scraping

I’d just like to put this out there, as I just “failed” a “do-at-home” interview assignment which was to implement a screen scraper using Java/PHP. I had previously (1-2 years ago) done screen scrapers in PHP, so I proceeded to do this assignment the same way – using regexes. Little did I know that using regexes would be one of the weak points of my submission – they wanted me to use a DOM parser instead. In hindsight, I guess I should have looked into that, but it just never occured to me because I already used other methods in the past.

So the moral of the story is to use DOM parsers when writing screen scrapers, they should be more robust than regex parsing in most cases. Here is an example tutorial.

Leave a comment

POV-Ray Renderings in Space

While using POVRay in my Graphics class, stumbled upon this story where apparently Mark Shuttleworth (of digital certificates and Ubuntu fame) rendered some POVRay scenes in space on the International Space Station – awesome!


2 Different ways of iterating through a hash in Perl with different pros/cons

Leave a comment

Overview on C/C++ type promotion

These are some very helpful comments I came across from Stack Overflow. Thanks to Martin York and Adam Liss for providing these useful and concise comments.


Question 1: Float division

int a = 2, b = 3;
float c = static_cast(a) / b; // need to convert 1 operand to a float

Question 2: How the compiler works

Five rules of thumb to remember:

* Arithmetic operations are always performed on values of the same type.
* The result type is the same as the operands (after promotion)
* The smallest type arithmetic operations are performed on is int.
* ANSCI C (and thus C++) use value preserving integer promotion.
* Each operation is done in isolation.

The ANSI C rules are as follows:
Most of these rules also apply to C++ though not all types are officially supported (yet).

* If either operand is a long double the other is converted to a long double.
* If either operand is a double the other is converted to a double.
* If either operand is a float the other is converted to a float.
* If either operand is a unsigned long long the other is converted to unsigned long long.
* If either operand is a long long the other is converted to long long.
* If either operand is a unsigned long the other is converted to unsigned long.
* If either operand is a long the other is converted to long.
* If either operand is a unsigned int the other is converted to unsigned int.
* Otherwise both operands are converted to int.


Overflow is always a problem. Note. The type of the result is the same as the input operands so all the operations can overflow, so yes you do need to worry about it (though the language does not provide any explicit way to catch this happening.

As a side note:
Unsigned division can not overflow but signed division can.

std::numeric_limits::max() / -1 // No Overflow
std::numeric_limits::min() / -1 // Will Overflow



In general, if operands are of different types, the compiler will promote all to the largest or most precise type:

If one number is… And the other is… The compiler will promote to…
——————- ——————- ——————————-
char int int
signed unsigned unsigned
char or int float float
float double double


char + int ==> int
signed int + unsigned char ==> unsigned int
float + int ==> float

Beware, though, that promotion occurs only as required for each intermediate calculation, so:

4.0 + 5/3 = 4.0 + 1 = 5.0

This is because the integer division is performed first, then the result is promoted to float for the addition.

Leave a comment

Matching new lines (\n backslash n) in grep

Spent some time getting this to work. Say you want to match "1\n;", the way to do this is:

Leave a comment

VIm alternative to the ESC key

It can be a pain reaching up to the ESC key everytime to exit insert mode in VIm. An alternative that’s built-in by default is Ctrl+[

Leave a comment

Paste into VIm without screwing up formatting

Often pasting text into vim from an external source screws up the formatting (especially tabs). To prevent this, do:
:set paste

Keeping this setting on screws up auto indentation while in insert mode, though. So to turn off, use
:set nopaste

Leave a comment

Piping command outputs into script arguments

command | ./myscript does not work as expected.
Use ./myscript $(command) instead

Leave a comment

Wow, Abiword, just, wow…. (aka Abiword Sucks)

Forgive me for not being constructive and not submitting bugs to the devs and that sort of thing (I may later on…), but for now, I just have to let off some steam… and from the experience I’ve got using this application, I believe I have every right to!

So I was looking for Wordpad’s equivalent in Linux-world, and according to a post in the Ubuntu forums Abiword was it. So I apt-get install it, and try it out… (running Ubuntu 8.10)

1) I copy some text into the page… then I realize the font size is too big, so I Ctrl+A and highlight the “font size” box and replace the “12″ with “10″… voila! the TEXT I selected gets replaced with “10″ instead of the number in the “font size” field. Genius! So I guess I will just have to use the arrows to change font sizes…

2) Then I wanted to change the font. I look at the “font” bar, and there’s no way to type in it! I can’t even enter an ‘M’ to get to the fonts that start with ‘M’… I have to SCROLL through the 100 or so fonts on my system to find the one I want. This is not a bug per se, but c’mon!

3) Then I needed to paste in more text. I do so, then to look at the bottommost text I use my mousewheel to scroll all the way down. Good, its there. But… when I scroll back up, Abiword keeps slowly scrolling the screen down! I tried using my keyboard arrows and a bunch of other things to try to make it behave but it just wouldn’t quit. At this point I had no choice but to close the whole abomination.

Looks like I will just stick to the heavier OpenOffice for now. I am just in complete shock and awe that this software is in the Ubuntu repos and is classified as a “finished product”. It would be poor even if it was in beta. Lesson of the day: Beware of Abiword!

1 Comment