Archive for the ‘Mono/.Net’ Category

LugRadio

Monday, October 15th, 2007
LugRadio

I spent half an hour tonight finding a AAA battery to resurrect my ancient 512 MB SanDisk SDMX1 MP3 player, so I could listen to LugRadio while washing dishes.

I’ve never listened before, but after seeing Jono Bacon listed as the #1 Linux blog I decided to give it a chance. There was a great interview with one of my geek heroes Miguel de Icaza. He always seems to be surrounded by controversy even though his decisions are very pragmatic and always end up being exceedingly beneficial to the open source community.

I actually didn’t listen to the whole episode (stopped on the bit about the streaming media server). This American Life remains the only non-musical audio production thats able to keep my attention for a full hour.

LugRadio definitely isn’t geared soley for the hardcore open source geek. Casual open source users should feel right at home as well.

There’s plenty of swearing, so you may not want to listen to it at work without headphones.

SharpOS Says Hello

Sunday, April 8th, 2007

SharpOS is an ambitious project to create a fully managed operating system using Mono/.Net. I tried working on the project until I realized that just knowing C# doesn’t mean you can help create an operating system written in C#.

Now it seems the project has achieved an important milestone: Hello World. Check out the screenshot and download a virtual machine image.

Update:  I downloaded and ran Revision 86 of disk.img in QEMU.  Below are my screenshots…

Grub Boot ScreenSharpOS Saying Hello

Debian Etch Released

Sunday, April 8th, 2007

It appears Debian GNU/Linux 4.0, codenamed Etch, (quite a mouthful) has been released as the latest stable version of Debian.

Go download it using BitTorrent to be cool. ;)

Tip #1:  You do not have to download all of the CDs, just get one and Debian’s installer will download the rest.)

I’m a happy and loyal Debian user and strongly encourage any Linux power users to try out Etch. Ubuntu is still my recommendation for users who want things to “Just Work.” However, I highly recommend Debian for any kind of server (file, print, application, database, web, e-mail).

Tip #2: Check out Debian Multimedia for all of your proprietary codec needs!

Mini-Review

I’ve been using Etch (and Sid) for a while now, so its tough to do a real review from a “normal” end user’s perspective.

Some highlights:

  • Developer’s should be happy as PHP, Python, Mono, MySQL, and PostgreSQL are all fairly up-to-date and extremely easy to install.
  • Gnome is stable and speedy.
  • The graphical installer brings Debian out of the 1990s and offers tons of features.
  • As usual, Debian’s package repository is huge. Forget vendor-supplied RPMs or custom installers, if its not in Debian’s repository (or Debian Multimedia), you probably don’t need it. ;)

Some downsides:

  • Relatively ancient version of the standard C library (2.3.6) means poor compatibility with 3rd party binaries (which Debian has always hated anyway).
  • Gnome is 2 stable versions behind in Debian (2.14 vs. 2.18). This is very frustrating as Gnome constantly produces nice incremental improvements.
  • Debian just isn’t as easy to use by default as Ubuntu. Debian needs to install and integrate some of the more cutting edge desktop apps like Beagle, Tomboy, Deskbar, and Ubuntu’s nicer package management interfaces.
  • Secure APT is a great feature, but the error messages it can produce are going to scare the pants off of new users. More effort needs to be made to integrate all of the various places user’s encounter public key crypto. Right now its very schizophrenic and confusing: GPG errors are too common, and command line magic that even confuses me is necessary to add new repositories.
  • Not related to the release, Debian’s support system is a confusing jumble of web interfaces, mailing lists, IRC channels, and an excellent wiki (that I rarely remember to use). Hopefully this is something a new Debian DPL will address.

Handy .Net Service Template

Thursday, February 15th, 2007

I love .Net Services. Its a handy way to create background processes, and they work beautifully in both Windows and Linux (thanks to Mono!).

However, every time I create one I find myself writing a lot of the same code with minor variations:

  • OnStart: start a worker thread, make it sure it didn’t die, exit
  • OnStop: try to stop the worker thread nicely, wait, abort it, exit

Depending on how “nice” you want to be to your worker thread, you can come up with some pretty crazy code to deal with your worker thread (volatile class variables, wait loops, etc.).

I’ve created a basic template for new .Net Services:

ServiceTemplate (2007-02-15)

It was inspired by a service I wrote to read a firewall log file into a database:

Lumberjack (2007-02-15)

The template doesn’t contain any complex worker thread stopping code. Lumberjack uses a mess of methods to try and nicely stop the worker. I’m not sure what Lumberjack does is really any more useful than just using Abort(), but I didn’t want to leave a database connection open.

Both zips contain MonoDevelop solution files, although Main.cs is the only important file in both of them.

The other highlight of both the template and Lumberjack is the SmartLog() method which logs to syslog in Linux and the Event Log in Windows. Although you probably have to comment out the syslog reference to build the source in Windows.

I’m sure I’ll update and keep using this code in the future… I need to find some way to manage my mini-projects and code snippets… any ideas?

Lost in a Sea of Web Frameworks

Wednesday, February 7th, 2007

AdvertisementIf you aren’t going to do your own web page design then going online to a place like Edezines.com to find a web site design firm can be a good idea. You’ll want to set yourself up as a web site with a design worth re-visiting, so web design can be rather important for keeping a site afloat.

So I’ve been trying to learn Python and have successfully written a couple small scripts. For the couple of small web sites/services I’ve written, I used CherryPy mostly because I know someone who is active in the CherryPy community.Coming from PHP and ASP.NET, Python’s offerings of web frameworks are a bit confusing. Here is my impression of the general landscape of the 3 platforms:

  • PHP - A language which survived without widely adopted frameworks for many years. While many frameworks are gaining popularity, most major PHP applications are their own framework.
    Examples: Drupal (a CMS) and Horde (a framework and suite of web applications)
  • ASP.NET - The web framework bundled with Microsoft’s monolithic .NET platform. Supports multiple languages and even implementations (go Mono!). A few alternative web frameworks exist for .NET (Castle Project), but it seems much more popular to just build components on top of ASP.NET.
  • Python - While I’m still learning a lot about Python, it seems Python has a wide variety of frameworks which range from a complete web application stack including database and kitchen sink (Zope) to just a widgets toolkit (ToscaWidgets) or just an HTTP/object-dispatching framework (CherryPy).

Then there are the various Javascript/DHTML/AJAX client side frameworks which can replace the interface portions of the above platforms and frameworks. It seems to me these UI frameworks have caused PHP-sans-a-framework to remain popular because the server-side code becomes a simple data broker for the complex UI widgets.

Python is obviously a bit different than PHP and ASP.NET. While using a framework seems the norm (unlike constantly rolling your own in PHP), there’s no 1-framework-to-rule-them-all like ASP.NET.

Luckily my web applications have been very simple, so CherryPy by itself has worked fine. I may even go the hackish route of just using a Javascript UI framework to keep my Python code simple. I’ve been trying to learn a little more about TurboGears and ToscaWidgets as well, but so far I haven’t needed a full framework.

cssh: C# Shell

Wednesday, December 20th, 2006

The other day I found myself writing a shell script in PHP because I refuse to learn bash’s archaic syntax.  I’m actually a lot happier with PHP as a shell scripting language than a web application language.  However, I’ve always wanted a scripting language with the power of Mono/.NET.

So yesterday I quickly threw together cssh: C# Shell.  You can’t use it as a real shell like bash, but it does allow you to write quick little C# programs that can be run like a script.

Basically the shebang (#!) tells your shell to run your script via cssh.  cssh then strips out the shebang line, prepends a Class and a Method declaration, appends a return 0; as well as a couple closing brackets (}), and executes it in memory using Microsoft.CSharp namespace and Reflection.

In all it took about 60 lines of code to write.  You can download a zip file with the source and a binary if you’re interested.  It should compile and execute just fine under both Mono and Windows/.NET, although Windows lacks shebang script support.

While this was an interesting exercise, I’m not sure its worth pursuing.  C# isn’t a scripting language, so to make it really useful you’d want to make some language modifications.  I think I’m going to take a look at boo or python instead of continuing to develop cssh.  Although I do love my semicolons…