NuSOAP together with PHP5-SOAP

Posted by andy

Every once in a while I get to fix/add stuff from my PHP days. Today I installed php5 on a fresh Ubuntu Feisty install I need to host a NuSOAP based service API to a client. However, the Ubuntu php module comes with SOAP support built in. The PHP bundled SOAP implementation is far from complete and I guess most folks still prefer the good 'ol NuSOAP. The problem is this:

Cannot redeclare class soapclient

Both NuSOAP and PHP's SOAP use the same class name for the client implementation. Instead of uninstalling Feisty's PHP module and rolling my own I decided to simply patch the NuSOAP 0.7.2 .php file and rename the class to nusoapclient. Saves a boatload of time IMHO. Patch to NuSOAP 0.7.2

Torturing Ruby (and laughing at your own code) 10

Posted by andy

While cleaning up some code I ran across some obscure code of mine from my Ruby youth. I remembered reading about an ultra cool Ruby tool the other day so I decided to give my code a good flogging. The victim for tonight is a method used to slice ID numbers into chunks of at most 4 characters long. This is required to overcome the typical Linux file system limitation of at most 32000 entries per directory. In this case the project stores roughly a million thumbnail images on disk. We start with the original piece of code:

1
2
3
4
5
6
7
8
def splice_number(number, part_size = 4)
  n = number.to_s
  r = []
  return r if n.size.zero?
  (n.size / part_size).times { |t| r << n[(t*part_size)..((t+1)*part_size-1)] }
  r << n[-(n.size % part_size)..n.size] if (n.size % part_size) > 0
  r
end

Ah yes, WTF was I thinking when I wrote this? Who cares, it seemed very clever then! What does Flog think about this?

Total score = 28.35

none#splice_number: (28)
     7: size
     3: *
     2: %
     2: []
     2: <<
     1: +
     1: -@
     1: -
     1: /
     1: lit_fixnum
     1: zero?
     1: >
     1: to_s
     1: times

Pretty good score. Now it’s time for some torturing. Say hello to my little friend: unpack!

1
2
3
4
def splice_number(number, part_size = 4)
  n = number.to_s
  n.unpack("a#{part_size}" * (n.size / part_size) + ((n.size % part_size == 0) ? "" : "a*"))
end

Flog?

Total score = 13.05

none#splice_number: (13)
     3: size
     1: %
     1: /
     1: ==
     1: *
     1: +
     1: to_s
     1: unpack
     0: lit_fixnum

Yeow, well over half the pain gone!! Perhaps we can still improve by being less clever?

1
2
3
4
5
6
def splice_number(number, part_size = 4)
  n = number.to_s
  r = n.unpack("a#{part_size}" * (n.size / part_size) + "a*")
  r.delete("")
  r
end

More lines, but less code! Hmm?

Total score = 9.25

none#splice_number: (9)
     1: size
     1: /
     1: *
     1: +
     1: delete
     1: to_s
     1: unpack
     0: lit_fixnum
Weeh, a full 2/3 of the pain flogged out of the code! That’s all the torture I’ll do for tonight..

Update: Okay, couldn’t help myself, last blow:

1
2
3
4
5
6
7
8
def splice_number(number, part_size = 4)
  n = number.to_s
  p = "a#{part_size}"
  t = n.size / part_size
  r = n.unpack(p * t + "a*")
  r.delete("")
  r
end
With score:
Total score = 8.05

none#splice_number: (8)
     1: *
     1: size
     1: +
     1: delete
     1: to_s
     1: /
     1: unpack
     0: lit_fixnum

Done..

Old new job

Posted by andy

I accepted a job offer 2 months ago at IndependentIP as "technical teamleader". My "proefperiode" just finished and I'll definitely be staying on, really love the way the company works. Lots of smart and funny (as in: haha) people working there too, time flies when you're having fun!!!! And we're definitely going to change the face of music distribution, keep watching!!

Firmware update gone south 3

Posted by andy

So about 6 weeks ago I happily ran this thing called Apple "Software Update..."

Then after 2 weeks I decided the burn a backup DVD but what's this? Where the heck is my Superdrive?? My burning software can't see it, it doesn't even show up in the system info "Disc Burning" section, WTF? Careful analysis of the log file shows the following: during the Software Update 2 items were downloaded, the Mac OS X 10.4.10 update and the Apple superdrive firmware update 2.1. Here's the scary thing, after the 10.4.10 update was installed it continued on installing the firmware update. However, right in the middle of the firmware update the 10.4.10 update decides it's a good time to reboot my Macbook Pro! I can't remember what I was doing during the update procedure but I guess I just continued working on after the reboot..for 2 weeks. Now comes the worse part, my Macbook Pro warranty expired just 2-3 days before the update!! So there I was, bricked superdrive, no Apple warranty, no AppleCare since I spent the extra €400,- maxing out the Macbook Pro with disk and RAM. Stupid, stupid!!
A quick Google search showed up quite a few posts of people in the exact same predicament as me! However, not a single post offered any sane fix other than bringing the Mac in for repairs, if you were lucky enough to have it under warranty or had AppleCare. Aargh!! Oh well, got nothing to loose so I called Apple Benelux and explained my situation. The kind person on the other side suggested I bring in the machine to an authorized dealer to check it out. Okay, so I brought it to RAF Amsterdam, which is the closest Apple authorized repair service to me. 3 weeks and a lot of calls to RAF later (apparantly their Mac guy went on vacation and they forgot to mention that during the intake) I finally got the verdict, new superdrive required, price tag: €410,- @#$@!!@#$%??!!!! That's got to be the most expensive DVD burner on the planet!
I called Apple again explaining them I was really upset I had to dish out this much money to fix a problem that was clearly caused by not properly testing their update procedure. I mean how hard is it to detect and stop a reboot in a firmware updater?? Firefox annoyingly stops reboots all the time, so a piece of Apple software should definitely be able to do this do. "I understand sir, let me talk to the tech people.. please hold..".. 2 minutes later: "Sir, we have OK'd this repair under warranty..".. WOAAH!!!
One week later I picked up my Macbook Pro, new superdrive installed, everything working. Charge: € 0,00!!
Big kudo's to the Apple Customer Satisfaction department!! That was 2 weeks ago.. It must be said though that a lot of folks around the world did not have this much luck with Apple. As of today there is also not a single official word from Apple regarding this issue, the firmware update was silently pulled from Apple's website and all traces of it have disappeared.

Forum thread 1: Superdrive update 2.1 killed my drive.
Forum thread 2: Superdrive Update 2.1 killed drive.


Still keeping an eye on how Apple handles this...

"What just happened to video on the web?" 11

Posted by andy

Adobe last night announced their flash player will support H.264 as of version 9 Update 3 Beta 2. This is amazing! Die WindowsMedia, die!! The best part is that the complete chain to produce high quality H.264 output can be build eniterely out of free open source based software! Now we only need an open source streaming server which sucks less than DSS. Read the very informative (and long) post by Tinic Uro. Incidentally I remember Tinic from the BeOS days where he wrote the rocking DualPlayer. Some of his scope code is still used inside AlsaPlayer.

Skype trouble

Posted by andy

Well, starting this morning we're experiencing all sorts of connection problems with the Skype network. For a moment there I thought I screwed myself by updating to latest Mac OS X beta 2.7 version, but the problems are not related. This really sucks if you rely on Skype for keeping in touch with your development team. I guess the need for a fallback system is even more pressing now. I'm tempted to try Gizmo again. Ah and yes, I'm baaaack! Update: as of Aug 20 evertyhing seems to be working again.