Back to Top

Friday, February 25, 2011

Sorry for the malware warning!

1 comments

If you have tried to visit my blog recently, you might have to a warning like this from your webbrowser:

Warning: Something's Not Right Here!

hype-free.blogspot.com contains content from randaclay.com
, a site known to distribute malware.
Your computer might catch a virus if you visit this site.
...

The source of the warning is the image / link in the comment form, which I have now removed (or more precisely replaced with a local copy). It seems that the randaclay.com has been hacked and thus it is classified as malicious by Google, which in turn leads to all sites linking to it being marked a potentially malicious. So, while I'm sorry for doing this, I will remove the links to their site until they manage to resolve the issue and will mirror their manifesto below:

Almost all blog platforms by default are set up so that a “dead end” piece of code is inserted wherever there is a link in a comment, so that search engines will not “count” the link as they are crawling the internet. This was originally designed to help stop comment spam, but it doesn’t work. What it does is remove some of the incentive for your readers contribute to your site by commenting on your posts. What can you do about it? Turn off “nofollow”. Show your commenters that you appreciate them. Spread the link love.

mytrendyphone.co.uk review

1 comments

My assignment - which I choose to accept :-) - was to review a mobile accessories site, namely mytrendyphone.co.uk. All the signs for this site check out:

  • It was registered a couple of years ago and didn't move around much
  • It has several real seals (real meaning that they are linked to the originating site, where you can check out the referring site is really approved, didn't just faked the seal)
  • Their contact address checks out (based on Google maps) as does their phone number (which is in the London area)
  • I found a couple of complaints about them on this site, however they seem to be very responsive to the negative complaints

After doing the basic safety research I went on to browse the site and I found many interesting items, for example this Jabra headset. What I like about about these models of headsets is the fact that they use standard minijack for headphones, which means that they can easily be replaced in case they stop working (and it is my experience that headphones are the first to go bad).

An other category which I found interesting was the tools section. While some of the tools are clearly overpriced, the more complex kits look interesting and I am tempted to buy something from there.

Full disclosure: this is a paid review from ReviewMe. Under the terms of the understanding I was not obligated to skew my viewpoint in any way (ie. only post positive facts).

Tuesday, February 22, 2011

Setting up IMAP with Yahoo! Mail

2 comments
Mail Snail

I'm a long time Yahoo Mail user. Just to illustrate how long I've been with them: when I joined the space available was a couple of MBs! I staid with them because I was mostly satisfied (never really caught the GMail bug), however recently I started looking for options to consolidate the different email accounts (work / personal / yahoo / gmail / etc). I explicitly wanted IMAP support because I really need to keep in sync between multiple machines.

The common wisdom seems to be on the 'net that Yahoo! Mail doesn't support IMAP (not even for paid accounts) or that various hacks are needed to support it (like sending custom / non-standard commands after login). This information however seems to be outdated, since I was able to find a least 3 IMAP servers (I've tested them all and they all work - with standard email clients with no hacks!):

  • imap.mail.yahoo.com (this is the one Thunderbird configures by default)
  • winmo.imap.mail.yahoo.com (from this article)
  • zimbra.imap.mail.yahoo.com

All of the servers support SSL/TLS encryption, so they are safe to access even from public hotspots. The outgoing server is smtp.mail.yahoo.com, which also supports SSL/TLS (and you should use it!)

The easiest to set up is Mozilla Thunderbird, however Evolution seems to work much better. One important feature in particular is that it works with large (10 000+ emails) folders, while Thunderbird chokes with an error ("UNAVAILABLE] UID FETCH too many messages in request"). To have Evolution work properly, you need to select "IMAP+" (also called IMAPX) as the protocol.

HTH somebody out there.

Sunday, February 06, 2011

Manually enabling IP routing in Windows XP

0 comments

While Internet Connection Sharing is a nifty tool, there are some cases where you would like to do the steps manually. One such case would be if the “primary” network is already using the 192.168.0.1/24 address space, since ICS is hardcoded (as far as I can tell) to use the same network. One concrete case I have encountered was:

ADSL Modem+Router (no wireless) –-> laptop broadcasting over writess –-> ... –-> other laptops

The solution is the following:

It is simple as 1-2-3 :-p. Some caveats though:

  • This setup won’t give you DHCP. So make sure that you configure your other machines with a static IP address
  • It also won’t give you DNS, so configure something like the Google DNS (8.8.8.8 or 8.8.4.4) or OpenDNS (208.67.222.222 or 208.67.220.220) or even your ISPs DNS
  • The ad-hoc wifi connection has reliability issues. It happened multiple times that I had to restart it because it disconnected and wouldn’t connect any more, but it is a good temporary solution.

PS. You can download the drivers and user manual for the SmartAX MT882 ADSL Router here (the link might go dead unexpectedly, since it is served out of Dropbox). This is a standard modem provided by Romtelecom (the Romanian telecom provider) and I couldn’t find it elsewhere because Huawei is very secretive about its stuff (the files were copied from the CD provided with the modem). The driver makes the USB connection work as a network card (which is very elegant and simple).

Is hand-writing assembly still necessary these days?

2 comments

12878535_df4197ea6b_o Some time ago I came over the following article: Fast CRC32 in Assembly. It claimed that the assembly implementation was faster than the one implemented in C. Performance was always something I’m interested in, so I repeated and extended the experiment.

Here are the numbers I got. This is on a Core 2 Duo T5500 @ 1.66 Ghz processor. The numbers express Mbits/sec processed:

  • The assembly version from the blogpost (table taken from here): ~1700
  • Optimized C implementation (taken from the same source): ~1500. The compiler used was Microsoft Visual C++ Express 2010
  • Unoptimized C implementation (ie. Debug build): ~900
  • Java implementation using polynomials: ~100 (using JRE 1.6.0_23)
  • Java implementation using table: ~1900
  • Built-in Java implementation: ~1700
  • Javascript (for the fun of it) implementation (using the code from here with optimization – storing the table as numeric rather than string) on Firefox 4.0 Beta 10: ~80
  • Javascript on Chrome 10.0.648.18: ~40
  • (No IE9 test – they don’t offer it for Windows XP)

Final thoughts:

  • Hand coding assembly is not necessary in 99.999% (then again 80% of all statistics are made up :-p). Using better tools or better algorithms (see the “Java table based” vs. “Java polynomial”) can give just as good of performance improvement. Maintainability and portability (almost always) trump performance
  • Be pragmatic. Are you sure that your performance is CPU bound? If you are calculating a CRC32 of disk files, a gigabit per second is more than enough
  • Revisit your assumptions periodically (especially if you are dealing with legacy code). The performance characteristics of modern systems (CPUs) differ enormously from the old ones. I would wager that on an old CPU with little cache the polynomial version would have performed much better, but now that we have CPU caches measured in MB rather than KB the table one performs much better
  • Javascript engines are getting better and better.

Some other interesting remarks:

  • The source code can be found in my repo. Unfortunately I can’t include the C version since I managed to delete it by mistake :-(
  • The file used to benchmark the different implementations was a PDF copy of the Producing Open Source Software book
  • The HTML5 implementation is surprisingly inconsistent between Firefox and Chrome, so I needed to add the following line to keep them both happy: var blob = file.slice ? file.slice(start, len) : file;
  • The Javascript code doesn’t work unless it is loaded via the http(s) protocol. Loading it from a local file gives “Error no. 4”, so I used a small python webserver
  • Javascript timing has some issues, but my task took longer than 15ms, so I got stable measurements
  • The original post mentions a variation of the algorithm which can take 16 bits at one (rather than 8) which could result in a speed improvement (and maybe it can be extended to 32 bits)
  • Be aware of the “free” tools from Microsoft! This article would have been published sooner if it wasn’t for the fact MSVC++ 2010 Express require an online registration and when I had time I had no Internet access!
  • Update: If you want to run the experiment with GCC, you might find the following post useful: Intel syntax on GCC

Picture taken from the TheGiantVermin's photostream with permission.

How to quickly start up a webserver with Python

0 comments

SONY DSC Sometimes you need to quickly start up a webserver that serves up static files (I will describe such a case in the next post). Python to the rescue (works on both Linux and Windows if you have Python installed):

For Python 2.x (this is what most sites show you):

python -m SimpleHTTPServer 9914

For Python 3.x (thanks to this comment):

python -m http.server 9914

These will start up a webserver on port 9914, and you can access it via the address http://localhost:9914. Warning! The webserver will be available to anyone who can connect to your computer directly (unless there are other mechanisms to restrict it – like firewalls or NAT), so use your judgment!

Picture taken from bob's photostream with permission.

Saturday, February 05, 2011

Why you should use 0.0.0.0 in your hosts file - redux

1 comments

port_80_application

Some time ago I (wow, time files!) I suggested that using 0.0.0.0 for host-file based blocklists would be faster than using 127.0.0.1. Above you can see an other reason for using 0.0.0.0: some applications take up port 80 on the localhost and accessing it can (potentially) create havoc.

In the example above TeamViewer (which is quite a nice remote control application BTW – with support for Linux!) has taken it over and thus it displays a mock page instead of the advertisement (which is very courteous).

PS. This was also mentioned in the original article, I just wanted to give an other example.

Thursday, February 03, 2011

Augmenting Log4J stack traces with class versions

1 comments

If you have multiple versions of your code in production, it is extremely useful for the log to include the version of the classes when producing a stacktrace, otherwise it is very hard to match the lines in the stacktrace with the lines of the source code (sidenote: there is an optimization in the Sun JVM where - if an exception is thrown "too much" - the JVM stops providing stacktrace - see this article about it and to learn how to disable this feature).

If you are using Log4J as your logging framework, with a little magic you can turn the following stacktrace:

17:47:40,208 ERROR [main] [TestLog4jExtendedStacktrace] An exception has occurred!
java.lang.IllegalArgumentException: Test exception
 at ...Callee.called(TestLog4jExtendedStacktrace.java:144)
 at ...Caller.call(TestLog4jExtendedStacktrace.java:136)
 ...

Into this (note the class versions at the bottom):

java.lang.IllegalArgumentException: Test exception
 at ...Callee.called(TestLog4jExtendedStacktrace.java:144)
 at ...Caller.call(TestLog4jExtendedStacktrace.java:136)
 ...

Callee: $Revision: 56 $
Caller: $Revision: 56 $

The main mechanism is as follows:

  • Each class contains a static String field called "VCS_VERSION". This field is set (trough the magic keyword substitution - see the documentation for SVN, CVS) to the last version when the file was committed to your VCS.
  • When a stacktrace is sent to the logger, it will look at the classes and if they have the "VCS_VERSION" field, it will output it at the end (it doesn't annotate the stacktrace itself, because some tools - like IDEs - depend on the stacktrace having a certain format for them to be able to process it - like adding one-click "go-to-line" shortcuts)

As usual, the source can be found in the repository.

Some more implementation details: the current way of modifying the stacktrace is quite hackish (adding a filter and trough reflection modifying the passed in LoggingEvent object). However it has the advantage of being usable without modifying your config files (ie. if you have many config files, but can modify it in only one place in the code, this is a good solution. More "proper" alternatives would be to implement a "wrapper" appender (like AsyncAppender) or a wrapper around Layout, however both of these require you to modify your configuration files.