Archive for the 'hacks' Category

Memcached on Solaris

Thursday, February 7th, 2008

If you observe memcached exhibiting strange behavior while running under Solaris, you should try upgrading to the latest version of libevent.

I experienced a problem while testing my application on the excellent Joyent Facebook Accelerator, which runs Solaris Nevada snv_67 X86, has memcached 1.2.2 with libevent 1.3b2 installed by default.

My memcached usage is pretty low and I refresh the cache often to keep it from going stale, but somehow I still get lots of cache misses. By elimination, I ruled out the possibility of faults on the python memcache module, or memcached version (tried the latest 1.2.4 compiled against the libevent-1.3b2 and it still had the same problem.) When I connected my app to the memcached instance running on my FreeBSD box, though, the problem doesn’t exist.

Eventually, it turns out that memcached disconnects the client and all I got from the python memcache module was:

  File "/opt/local/lib/python2.5/site-packages/memcache.py", line 846, in recv
    'read returned 0 length bytes' % ( len(buf), foo ))

Well, that’s another bug. The above foo should really be rlen, but fixing that only proved that memcached always disconnects the client after sending 66887 bytes in response to a get.

After some poking around (by inserting prints and running memcached in foreground mode), it was apparent to me that memcached was getting an error from libevent, so I upgraded libevent and problem was solved.

Hope this helps anyone who may run into the same problem (as I couldn’t find any clue in the googs.)

GearSaver Reloaded

Monday, August 6th, 2007

The GearSaver Bookmarklet was not that useful since there was no easy way to use the saved data. Since this is an itch that I’d really like to be able to scratch, I reached further and improved on it to the point that I can now write this post in a GearSaver-enabled textarea. Added features are:

  • uses jQuery - I have no intention of working around browser DOM quirks more than I already have to
  • displays previously saved versions
  • ability to preview a version and apply to current textarea content
  • ability to delete versions

Eventually, I hope to be able to provide the script as:

  • ad-hoc inclusion into any page - this already works in the current version
  • as a bookmarklet - so that you can enable any page
  • as a greasemonkey script - so that you can automatically have it turned on on the sites that you want it

So, without further ado, you can try it out…

1. Here’s a textarea


2. Make sure you have Google Gears installed.

3. Click here to enable GearSaver.

4. Gears will ask you whether to allow http://dready.org/ to write data

Please report any bugs / suggestions.

Update 20070812: Updated to use new and improved version 0.4

IDProxy.net

Monday, January 29th, 2007

From the innovative mind of Simon Willison comes IDProxy:

idproxy.net, launched today, is my attempt at speeding up the process. It uses Yahoo!’s Browser-Based Authentication API to allow you to sign in with a Yahoo! account, then lets you create one or more OpenIDs (of the form something.idproxy.net) to use with sites that support the OpenID standard.

Basically, it’s an OP that authenticates against Yahoo - call it an intermediate IdP, Proxy OpenID Provider, OpenID-Yahoo bridge, whatever.. it rocks!

Skype Reverse-Engineered

Friday, July 14th, 2006

VoIPWiki reports that the Skype protocol was successfully cracked by a company in China, who promised to release a demo version by end of August. This is amazing – not the news itself, but the extent to which they have gone. Several reverse-engineering reports have been issued but no one has built a working prototype until now.

This goes to show that: obfuscation is obfuscation – it will not last, not if you’re as popular as Skype.

What does this mean?

Many are predicting / recommending that the eBay company documents its protocol. I can safely say that they will not. This is only news to techies; it may make its way to NYT but people will forget. In fact, as long as it works, they will not lose any market share.

However, it would be great if the Chinese company would publish their findings so that the protocol can be enhanced by others and a more efficient, and certainly open protocol can be created to benefit users.

Think about the 3 main advantages that Skype possesses:
1. Proprietary protocol – which allows them to have tight control over the evolution of the protocol.

2. Good NAT traversal technology – this is the main point. This is critical to their success.

3. Good codec – the GIPS codecs work extremely well. This also ties back to the first point – they know what codecs their clients can support which is much better what gets negotiated in a heterogenous SIP environment.

It’s all in the app. Now, I’d like to see an open source effort is dedicated to making a product work well with the protocol design rather than wasting time trying to obfuscate it!

Using XML-Stream without Encode.pm

Monday, March 7th, 2005

I needed to write a notification script for AMMS, so that a mail server administrator can be notified by IM when the MTA is down.

So I set out to install the popular Net::Jabber module, but soon found it to be tricky. I was using Perl 5.6.1, and chasing the dependency tree led me to XML::Stream, which listed Perl 5.8 as a pre-requisite.

The thing is, the only feature from Perl 5.8 required by XML::Stream is the Encode.pm module. I found the Unicode::UTF8simple module, which was created exactly to fill that gap for us late adopters.

So, here it is, if you wish to install XML::Stream on Perl 5.6 (may work on other versions but I have not tested), you can apply this patch to lib/XML/Stream.pm before running perl Makefile.PL.

p.s.: Had I used the ever-”useful” CPAN shell to install Net::Jabber, I guess it would’ve proceeded to build a new Perl distribution on my humble Pentium 300Mhz laptop with 32MB of memory.

SLUG Code Con

Tuesday, August 10th, 2004

Note to self: Get your ^ss there.

“Code Con is intended to be a low cost conference, with a focus on developers doing presentations of working code, rather than on companies with products to sell.”

You can’t get much more low cost than this:

Frazer Beach is located in Munmorah State Conservation Area and is managed by NPWS. It features a beautiful sandy beach, rock shelves for fishing, fabulous waves for surfing, amazing rocks for photographing, numerous sea caves and walking tracks to explore, and even a blow hole at high tide. All this is just 2 hours north of Sydney CBD by car.

At $10 a night? You bet I’ll be there!

Great Hackers…

Thursday, July 29th, 2004

are a rare find, but this article by Paul Graham (of “A Plan For Spam” fame) tells you how to sniff them out, how to manage them and be like one of them if you wish. Better yet, get the book.

This is a magnibrilliant article, and echos many of my beliefs. That is not to say that I’m one of those that he speaks about – if not for the fact that I do program Windows applications and use the Java programming language. I do, however, share the same ideals.

While we’re on the topic of Java programmers and employment and how they relate to the variation in wealth, I ran some simple queries on SEEK (AU/NZ’s job search site) today. The findings for various programming languages are as follows:

Java: 315 jobs
Python: 4 jobs
Perl: 87 jobs
C++: 108 jobs
C#: 88 jobs
PHP: 22 jobs
COBOL: 62 jobs
VB: 171 jobs

Eliminating some duplicates from multiple agencies commissioned to fill the same vacancy, we can see that Java has at least a factor of 20-50 openings more than other types of programming jobs. For a while, I was contemplating whether to sell out to the J2EE hype (flame me!!!) but the article has inspired me to stay true to my path. The sky brightens up again.

I Love Hacking

Friday, June 18th, 2004

I can spend hours, even days or months if the project is interesting enough, the more challenging the better.

Created this section to file hacks of my own, as well as interesting ones that I discover elsewhere. I would also post up any ideas of interesting hacks, so people can comment on or pick up and develop further. This sort of thing would probably be better off in a Wiki, but I don’t have time to install one yet (actually, two weeks ago I found one that belongs to a old abandoned project in my cgi-basement.)

Of course, viWord and IDN-OSS gets a mention here since they are technically hacks. (They each have their own section under the Projects hierarchy.)