codewut

warning: Creating default object from empty value in /home/pulsar/webroot/htdocs/modules/taxonomy/taxonomy.pages.inc on line 33.

Local IIS Dev-Server + Firefox = slow request response times

If you run into the same issue, disable IPv6 support in Firefox:
about:config -> network.dns.disableIPv6 -> true
Apparently Firefox and Microsoft Internet Information Server do not like to play together nicely on Vista without human intervention.

One more reason why I love local initializers

  1. public static IDictionary<RequestTypeEnum, RequestGroupEnum>
  2. RequestTypeToGroup= new Dictionary<RequestTypeEnum, RequestGroupEnum>()
  3. {
  4. {RequestTypeEnum.RegisterAccount, RequestGroupEnum.Account},
  5. {RequestTypeEnum.UnregisterAccount, RequestGroupEnum.Account},
  6. {RequestTypeEnum.RegisterInetAccess, RequestGroupEnum.InetAccess},
  7. {RequestTypeEnum.UnregisterInetAccess, RequestGroupEnum.InetAccess},
  8. {RequestTypeEnum.RegisterMailbox, RequestGroupEnum.Mailbox},
  9. {RequestTypeEnum.UnregisterMailbox, RequestGroupEnum.Mailbox},
  10. {RequestTypeEnum.RegisterRLA, RequestGroupEnum.RLA},
  11. {RequestTypeEnum.UnregisterRLA, RequestGroupEnum.RLA}
  12. };

Scheduling encrypted backups with Windows (to unix)

Atomic RouterAtomic RouterThis issue has been puzzling me for some time. I have this Atom based home-brew router sitting on the shelf with a 2TB drive attached to it. So yes, it does also serve as a NAS, Meda-Server etc. All the good stuff. So theoretically it should be also a good place to backup my data to – in case one of the workstation harddrives fails – been there, done that. No IBM drives for me since that incident.

So, where is the catch? Backing up private and sensitive data to that device would be almost insane, this nice piece of hardware is directly connected to the internet and thus exposed to a variety of break in attempts. What if one of these is successful? Riiiite, I would be fu***. Properly.

The solution is very obvious; encrypt your data before you move it onto the server. But how would one do that using a windows client and free software only? There are several ways to achieve that. You could choose to write a batch script, use 7zip or something to compress / password protect that data and copy it over to the other side.

Since I don’t really like batch scripting and prefer doing fancy stunts using bash, I choose cygwin, cron (running as NT service, @see /usr/share/doc/Cygwin/cron-4.1-7.README) and openssl to encrypt that data. So, here is the one-liner doing all the work:

tar cz MyImportantDataDirectory | openssl des3 -salt -pass pass:SECRET | ssh pulsar@router "cat &gt; /mnt/backups/documents-daily.tar.gz.des3"

Go crazy now! Use the week-number to create a series of backups instead of the daily snapshot, remove old backup sets etc. Once you have that script, schedule it using the cron (crontab –e) and watch your sensitive data being backed up automagically. /me likes!

Dream Machine

Here is a small application I wrote from pure boredom and curiosity.

What is it?

It is a pathetic attempt to simulate a dream machine. It is supposed to provoke hallucinations by stimulating the optical nerves with a specific frequency. That simulation can alter the brainwaves and make you see complex patterns of color behind your closed eyelids.
Did not work for me – might work for you.

Why?

I’ve read an article on this topic some time ago and got curious. I made this stupid application to give it a try.

I want more background on this!

Do you? Head over to http://en.wikipedia.org/wiki/Dreamachine

Download

right here

A word of warning

It might cause a epileptic seizure - so be careful if you have that kind of predisposition.

Skype crippling network performance

Another thing I've learned today: Whenever Skype runs in the "super-node" mode it will do some traffic shaping on your network.

While it does make sense for the limited DSL upstream one would have, it absolutely makes no sense to limit my 100 mbit link to the router down to ~90mbit. This would also cripple transfer from/to my NAS.

So, what can be done about that? You could try to setup some intelligent (desktop) firewall rules to prevent Skype doing NAT Traversal and becoming a Supernode. As we all know, Skype is VERY persistent when it comes to punching holes into your firewall. So this task might cost you some nerves and could potentially affect other applications you run on your desktop. So, what options do we else have? Apparently Skype does offer some hidden registry settings which will affect that behavior. Once you disabled the supernode feature using the registry snippet below your intranet network performance should return to its former glory

  1. Windows Registry Editor Version 5.00
  2. [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Skype]
  3. [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Skype\Phone]
  4. "DisableSupernode"=dword:00000001

Convert a RSS / Podcast Feed to a .pls Playlist

X-Mas time...
I just got my wife a nice WiFi Radio (yes, she does not give a sh** about this blog). She loves to listen to internet radio stations so it seemed like a cool gift. We'll know for sure in less than 4 days.

Anyway. I unwrapped it to make sure it works and to preinitialize it with some presets she likes. But wait! What about my presets? Yes, I love to listen to podcasts. While the device itself has some support for RSS feeds (browsing my genre, country etc.) - it won't allow adding a RSS feed to your favorites / bookmarks. Here it will only accept playlists.  

A minor inconvenience you can fix with some PHP and SimplePie. Here is a small script which will convert any arbitrary RSS Feed to a PLS ... well, playlist :)

  1. <?php
  2. require_once("simplepie.inc");
  3.  
  4. function getFeedItems($rss, $numberOfFeedItemsToFetch = 50)
  5. {
  6. $feed = new SimplePie($rss);
  7. $feed->init();
  8. $feed->handle_content_type();
  9. if ($feed->error()) die ($feed->error());
  10. return $feed->get_items(0,$numberOfFeedItemsToFetch);
  11. }
  12.  
  13. $url = urldecode($_GET["url"]);
  14. $numEntries= $_GET["numEntries"];
  15. if (!$numEntries) $numEntries=50;
  16. if (!$url) $url = "http://feeds.feedburner.com/cnet/buzzoutloud?tag=rtcol";
  17. $items = getFeedItems($url,$numEntries);
  18. $plsItems = array();
  19. foreach($items as $item)
  20. {
  21. if ($item->get_enclosure())
  22. {
  23. $plsEntry = array();
  24. $plsEntry["title"] = $item->get_title();
  25. $plsEntry["link"] = $item->get_enclosure()->link;
  26. $plsEntry["length"] = (int) $item->get_enclosure()->length;
  27. $plsItems[] = $plsEntry;
  28. }
  29. }
  30.  
  31. header('Content-type: audio/x-scpls; charset=utf-8');
  32. header('Content-Disposition: attachment; filename="playlist.pls"');
  33. ?>[playlist]
  34. NumberOfEntries=<?= count($plsItems) ?>
  35.  
  36. <?
  37. for ($i=0; $i<count($plsItems); $i++)
  38. {
  39. print("File".($i+1)."=".$plsItems[$i]["link"]."\n");
  40. print("Title".($i+1)."=".$plsItems[$i]["title"]."\n");
  41. if ($plsItems[$i]["length"] > 0) print("Length".($i+1)."=".$plsItems[$i]["length"]."\n");
  42. else print("Length".($i+1)."=-1\n");
  43. print("\n");
  44. }
  45. print("version=2");
  46. ?>

The usage is quite simple. Call the script like this:

http://myserver/the_script.php?url=[encoded rss url]&numEntries=[optional: max number of entries in the pls]

If you don't know how to encode a URL properly, try this:

  • open a new tab in firefox
  • enter
    javascript:document.write(escape("http://your.friggin.url/feed.xml"))
    into the address bar
  • copy & paste the result

If the Feed-URL does not contain any parameters (chars such as &, ? or =) you probably won't need to encode it. Won't hurt though!

You also might want to add a fake URL part (path info) if your client needs that .pls ending in the url. so the script-call would be like:

http://myserver/the_script.php/fake.pls?url=...&numEntries=...

Oh! And you will need a copy of SimplePie for the script to work. Grab it over here

download the script bundled with SimplePie

Ummm... WHAT!?

Webstart ErrorWebstart ErrorTranslates to "Entryscreen: Error rcv". Yes... I have NO IDEA.

Unexpected Consequences


Ooops! That was quite unexpected

Accessing Arrays in .NET/c# via Reflection

Yesterday I was implementing a generic serializer (for logging purposes). While there is a good number of XML serializers available for .NET - none of them was meant to be used for only the purpose of reading. That means, I would not need deserialization but only some nice human readable output.

Anyway, thats not the point here. What took me about an hour to figure out is how to handle arrays (of natives) via reflection. I kinda feel stupid, but let me show you what i tired:

  1. Object propertyValue = prop.GetValue(o, null);
  2. if (propertyValue != null &amp;&amp; propertyValue.GetType().IsArray)
  3. {
  4. //if you need the type, here is how we get it, it's not used
  5. //in this example.
  6. Type arrayType = propertyValue.GetType().GetElementType();
  7. object[] arr = propertyValue as object[];
  8. for (int i = 0; i &lt; arr.Length; i++)
  9. {
  10. // serialization logic goes here
  11. }
  12. }
  13. ...

While this might work perfectly for arrays of "real" objects such as string[] - it will fail when your array is composed of native objects such as long[]. The cast to object[] will get you a nice null reference. Yummy.

After that I've been looking for Array.ForEach() which was pretty interesting, but did not really help due to it's generic nature. The solution was much simpler in the end, it just did not cross my mind to cast the propertyValue to Array - sometimes .NET can be pretty mysterious in terms of Autoboxing. Here is how it should be done:

  1. Object propertyValue = prop.GetValue(o, null);
  2. if (propertyValue != null &amp;&amp; propertyValue.GetType().IsArray)
  3. {
  4. Array array = propertyValue as Array;
  5. foreach (var arrElement in array)
  6. {
  7. // serialization logic goes here
  8. }
  9. }
  10. ...

Straight forward, simple - makes me feel stupid.

TWiki Installation / Collaboration Software?

I've been looking into collaboration solutions for small teams recently. TWiki (.org) caught my attention so I decided to give it a try. Jeez! I am used to difficult installations (can you spell J2EE?), but what TWiki expects me to do is way beyond the "userfriendly" term.

You have to create/validate 3 .htaccess files, add pretty lengthy configuration files to your apache vhost config, beat the crap out of file permissions - all of this only to get confronted with a setup screen basically telling you to check every option once again since this is "what it guessed".

It is not about rocket science, no magic involved here either. But considering the time spent on the installation I had also to consider the time I will be spending on maintenance and security updates. Seems really like a nice piece of software, but given those facts? Got kicked out faster than it was installed.

Bummer.

Any recommendations on collaboration software? I've been eyeing on Clearspace and Confluence, but none of them offers a solution for VERY small teams for a reasonable price (preferably free). Oh, and I don't mix it up with groupware which is more appointment / mail centric.

Syndicate content