Tigraine

Daniel Hoelbling-Inzko talks about programming

Don't bother with sharing a printer

HL-2140

If you've ever ran a home network before you may have noticed that installing and running a printer over the network usually works great and pretty seamless.

Except for those rare conditions where your printer drivers sucks, the host where you connect your printers is old and slow, and the fastest way to your printout is copying the doc to the host computer to print it locally.

I've complained about that before, but I didn't need too much printing lately so I forgot. Until today when I found the wonderful Brother HL-2150 N printer that costs just 130€ and sports its own NIC.
So instead of bothering with network share and stuff like that I just had to plug in the printer to the LAN and run the driver install locally at my machine.

Everything was up and running in about 30 seconds and I'm relieved of the ever daring "is this stupid computer up or not" question (The status LEDs on the host aren't connected).

If you need a cheap black and white network printer, I'd definitely suggest this one here.

Filed under personal

ASP.NET Wiki - An unpleasant experience

Last time (just before I went mad at Windows Live Writer), I posted some modified code from the ASP.NET Wiki that I thought isn't worth posting to the Wiki, while still being worth a post in this blog (it was out of scope for the Wiki article).

But what I also had to note that the Wiki System is far far away from perfect.
So let's get to the nitty gritty details at the example of the good article on HttpWebRequest.

Click the edit button and get a standard (really nothing special) WYSYWIG editor that completely hides the markup from you.
Maybe somebody sees this as a good thing (editing MediaWiki isn't that great after all due to WikiText), but I think WYSIWYG is absolutely lame!

Let's get to the source. To get this look

image

The HTML code looks like this:

<div style="border: 1px dotted rgb(204, 204, 204); padding: 5px; background: rgb(239, 239, 239) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;">
<p style="margin: 0px;"><span style="color: blue;">If</span> <span style="color: blue;">Not</span> (IsPostBack) <span style="color: blue;">Then</span></p>

<p style="margin: 0px;">    <span style="color: blue;">Try</span></p>

<p style="margin: 0px;">        <span style="color: blue;">Dim</span> fr <span style="color: blue;">As</span> System.Net.HttpWebRequest</p>

<p style="margin: 0px;">        <span style="color: blue;">Dim</span> targetURI <span style="color: blue;">As</span> <span style="color: blue;">New</span> Uri(<span style="color: rgb(163, 21, 21);">"http://weblogs.asp.net/farazshahkhan"</span>)</p> </div>

I hope this has just raised some eyebrows, it sure did when I saw it first. Hell that's the way Microsoft wants us to post code??

After all, ASP.NET is about code. It's about ASP.NET, so there will be code everywhere. And we're supposed to somehow (still don't know how) do the syntax highlighting manually, copy everything to the HTML surface in the shitty WYSYWIG editor and then let others come in and edit this crap?

Oh my god, man.. Wiki is all about editing, not about posting in the first place. If I want to write a new story on something I'd go off and post it to this blog.
But to edit just one line of code, you'd have to copy the whole code sample into some kind of IDE, edit it, export it in HTML, repost it to the Wiki's HTML view.

No way anyone would ever go through this hassle just to increase the readability of some sample. I mean, if I'm in for a 20 minute edit job just because I think the variable int x should be named double y_, I'd never even think about editing.

So, concluding: Sorry Microsoft, but try harder next time.
Posting Code to a Wiki about code should be as seamless as possible, and not providing the tools to do so is a shame!


There is a "Format option" called "Source code" in the WYSYWIG, but it doesn't do a damn thing, so we see people posting their code from Word (like in the CSVExport article), do some other weird stuff (look above!).

Get your act together Microsoft, create a <code> block that will get syntax-highlighted at the server or something like that. But don't depend on your users to put even more effort into their contributions!

Filed under internet

Exporting Data to CVS in ASP.NET

So, today I tried the ASP.NET Wiki that's currently in Beta and thought, best way to do so is to expand an article. I'll blog about my Wiki experience later, but for now I'd like to share my code on this one.

I started out with the Wiki Article Export to CSV file (revision 3) and thought on how to improve it.

As you may have noticed, the topic at hand is so simple, it doesn't really need improving, except for the main flaw where you have to specify all column headers in code.

My take on this was to use the DataBinder API from the System.Web.UI namespace and remove the whole HttpContext.Current stuff to an instance variable so it's easier to test the stuff and you can put it into a class library (if you want that).

Let's assume I have a list of type Person I want to write to CSV

public class Person
{
    public String Name
    { get; set; }
    public String Family
    { get; set; }
    public int Age
    { get; set; }
    public decimal Salary
    { get; set; }
}

Now here's the CVSExporter class that you just need to pass 3 things: Your List<Person>, your HttpContext.Current and a List<String> that specifies what columns you want printed out (eg. Name, Family).

public class CSVExporter
{
    public static void WriteToCSV(List<Object> dataList, HttpContext httpContext, List<String> columnNames)
    {
        InitializeHeaders(httpContext);

        WriteColumnNames(httpContext, columnNames);                  foreach (Object data in dataList)         {             WriteData(data, httpContext, columnNames);         }                  httpContext.Response.End(); //Everything has to end..     }

    private static void InitializeHeaders(HttpContext httpContext)     {         string attachment = "attachment; filename=PersonList.csv";         httpContext.Response.Clear();         httpContext.Response.ClearHeaders();         httpContext.Response.ClearContent();         httpContext.Response.AddHeader("content-disposition", attachment);         httpContext.Response.ContentType = "text/csv";         httpContext.Response.AddHeader("Pragma", "public");     }

    private static void WriteData(Object data, HttpContext httpContext, List<String> columnNames)     {         StringBuilder stringBuilder = new StringBuilder();         foreach (String column in columnNames)         {             AddComma(                 System.Web.UI.DataBinder.Eval(data, column).ToString(),                 stringBuilder);         }         httpContext.Response.Write(stringBuilder.ToString());         httpContext.Response.Write(Environment.NewLine);     }

    private static void AddComma(string value, StringBuilder stringBuilder)     {         stringBuilder.AppendFormat("{0}, ", value.Replace(',', ' '));     }

    private static void WriteColumnNames(HttpContext httpContext, List<String> columnNames)     {         StringBuilder stringBuilder = new StringBuilder();         foreach (String column in columnNames)         {             stringBuilder.AppendFormat("{0}, ", column);         }         httpContext.Response.Write(stringBuilder.ToString());         httpContext.Response.Write(Environment.NewLine);     }

}

So that's it for now. I guess there is still room for improvement, and if you need performance you should go with the original solution, DataBinder.Eval does some type-casting internally so it won't run at lightning speeds, but you get the idea of what can be done with the DataBinder control :).

And now I'm off to writing a Windows Live Writer Plugin that will allow me to paste longer code without jumping through loops like a madman (I posted the code in my Wordpress admin-gui because doing it from wlv simply didn't work!)

Filed under net, programmierung

Post Code with Dignity

After finally getting really really fed up with Windows Live Writer about the way it tries to tidy up your HTML code I decided that I need to do something about it.

So I did, writing a Live Writer plugin is very easy and straight forward, so I did a plugin that will take your clipboard, replace typical things like < > through &lt; &gt; and replace every 2 spaces through 2 &nbsp;.
So make sure you are using a even number of spaces for source indentation in your IDE.

The plugin is far away from perfect, and I think I'll make it a bit more configurable tomorrow. I also think I'll put it up on Google code and maybe release it to the Windows Live Gallery.

They key? Windows Live Writer fucks up your markup no matter what you do. So I simply departet from posting pure text as a ContentSource, yet the plugin is treating HTML as a SmartContentSource that will appear as a block inside Windows Live Writer, saving it from it's catastrophic markup-killing html-tidy algorithm.

Update: I already released the source at CodePlex and you can get the most up to date binary from there:

CodePlex Project Page: http://www.codeplex.com/wlwPostCode

Installation:
Simply put the dll into your Live\Writer\Plugins directory and start WLV!
It will now show up in your Insert-List as Insert Code..

Btw: The Plugin assumes you are using the same syntax highlighting script as I do and will put your code into a <pre> tag.

Filed under net, programmierung

Am I an island?

Due to the fact that most of university of klagenfurt's curriculum is biased towards Java sometimes makes it hard for a .NET developer to be able to go up to someone and say: "Hey, look what I did yesterday".
Either you just ran into one of those guys who just managed to get the last proprietary driver off his debian-unstable laptop and will chase you down some hallway by even saying the word Microsoft near his ears.
Or you will meet some insensible guy who's not into the study at all but decided that doing computer science after high-school is the right thing because he used to be playing computer a lot (people around here often use their studies as an excuse for not wanting to do real work).
Or there is that honest guy who just focuses on his studies and therefore is stuck in a world of Java :).

So, sometimes I read all those blogs out there from overseas about communities, ALT.NET, open spaces conferences and stuff, and start to feel a little lonely around here in carinthia.
I mean, there are plenty of people I really love to talk about tech, I even sometimes try bend my mind around to talk to some of the hardcore Linux guys around here. But there is nobody to whom I can talk about what I am up to lately (in .NET), nobody who is actually working with .NET (besides me) that I can call up to ask for advice on ... let's say WPF.

So today I decided to throw the words usergroup and Klagenfurt at my Google and I somehow ended up at ineta.org, short for International .NET Association.
After doing their usergroup search for Austria I found out that there ought to be two groups here around Klagenfurt university. Both of which seem to have disbanded (websites down etc).
Now what really struck me was that even the back of beyond (namely Vorarlberg) has a .NET user group, while Vienna and Graz having plenty of them.
Didn't they tell me when I signed up for my study that Klagenfurt is one of the major universities when it comes to computer science?
And now I'd like to know, if Klagenfurt is that good, why we can't have a .NET user group.

So is there an audience for a .NET user group in Klagenfurt? Or do I need to pony up the 60 euros per month for a bus ride and go to Graz if I want to meet like-minded people?
So it boils down to the initial question: Am I an .NET island?

Filed under net, personal

Setting up Cruise Control .NET

logo

Wow, what a day! After starting a new project today (I'll discuss that in another post) I decided that it is time to get serious with source control and continous integration. This time I thought I'd skip the java stuff and pass on JetBrains Teamcity, and instead went for the SourceControl.NET by ThoughtWorks that I heard of on Hanselminutes.

First things first: I am totally stunned of how great this has turned out. If you don't have a CI server yet, go get yourself one immediately. Even if you are programming by yourself, having someone run the build process and all unit tests for you never hurts and will save you time in the long run. Set-up of CruiseControl and the whole stuff was quite time-consuming (meaning 3 hours), but doing it on another project now really is a piece of cake, once you're done it feels quite natural.

So, to get started you should set up Subversion by simply installing VisualSVN, the server is running in less than 30 seconds, your users and repositories are in place after a mere minute. I can't think of any easier way to install Subversion, kudos to the VisualSVN team!

Now, this isn't quite standard, but really helps: Create a file called svn.bat in your C:\WINDOWS\system32\ folder with the following content:

@echo off
"C:\Programme\VisualSVN Server\bin\svn.exe" %*
Cool huh? Now you've got svn in your %PATH% without having to edit the variable itself. This will save you some time on the CCnet configuration.

The next thing was to install the newest CCnet version, and here I suggest you get the latest and hottest stuff directly from the svn. I ran into some troubles with some msbuild reports in version 1.3. Updating to 1.4 worked wonders.

Now that everything is set up (you can now access the WebDashboard through the http://<yourserver>/ccnet/ url), you need to get the whole thing configured. (The only painful thing in this installation).

A good starting point is the documentation that explains almost everything.

I won't go through everything in the ccnet.config file, just some things I want to point out:

  • Make sure to either run the latest CCnet build or use the doc that came with your binaries. New not used settings will stop the server from running.
  • While testing your build process go ahead and try to run the same commands from a shell. Especially with msbuild it took some time to sort out the quirks :)
  • Don't forget to blindly incorporate the whole list of <publishers>. I can't think of a scenario where I don't want almost all of those running, and if you skip some (like xmllogger and statistics) you will get some broken links on your dashboard.
  • VisualSVN sets up a https server. CCnet runs svn with the --non-interactive switch, so it will quietly break due to a unsigned SSL certificate. To bypass this simply run a svn list <repo> from a shell and accept the certificate permanently. And make sure the CCnet service is running under your login credentials, svn stores the certificate setting per user.
So, enough wisdom from my part on CCnet. I really had a blast in setting it up, and I can only recommend it. After the break I've postet my ccnet.config if you want to have a look.

<cruisecontrol>
      <project name="Valet">
        <workingDirectory>valet/WorkingDirectory</workingDirectory>
        <artifactDirectory>valet/ArtifactDirectory</artifactDirectory>
        <webURL>http://plato/ccnet/server/local/project/Valet/ViewProjectReport.aspx</webURL>
        <modificationDelaySeconds>10</modificationDelaySeconds>
        <sourcecontrol type="svn">
            <trunkUrl>https://plato:8443/svn/valet/trunk/</trunkUrl>
            <username>ccnet</username>
            <password>xEs6S-uW</password>
            <autoGetSource>true</autoGetSource>
            <!--<tagOnSuccess>true</tagOnSuccess>-->
        </sourcecontrol>
        <state type="state" />
        <labeller type="defaultlabeller">
            <prefix>Valet-alpha-0.</prefix>
            <incrementOnFailure>false</incrementOnFailure>
        </labeller>
        <triggers>
          <intervalTrigger name="continuous" seconds="30" />
        </triggers>
        <tasks>
            <msbuild>
              <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
              <projectFile>Valet.sln</projectFile>
              <buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
              <targets>Build</targets>
              <timeout>900</timeout>
              <logger>C:\Programme\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
            </msbuild>
            <nunit path="C:\Programme\NUnit 2.4.7\bin\nunit-console.exe">
                <assemblies>
                  <assembly>C:\Programme\CruiseControl.NET\server\valet\WorkingDirectory\ValetServerTest\bin\Debug\ValetServerTest.dll</assembly>
                </assemblies>
            </nunit>
        </tasks>
        <publishers>
          <xmllogger />
          <statistics />
          <modificationHistory  onlyLogWhenChangesFound="true" />
          <rss/>
          <modificationWriter />
        </publishers>
    </project>
</cruisecontrol>
Man, I hate my blog theme. I need to get this thing wider sometimes soon!

Filed under net, programmierung

Major site rehaul

wordpress

After doing yesterday's post on CruiseControl.NET it bit me that I really really needed a new theme for my blog. Posting sourcecode on a constrained surface doesn't really work, and after seeing the XML posted yesterday I decided I need to do something about it.

So I went to themes.wordpress.net and found the theme you are currently looking at. It's nothing really special, but I like the clean look and it has no fixed width. The theme came with no widget support so I followed this handy guide and hacked them into the theme myself. It really isn't that hard after all, although I found this php-html mix quite disturbing.

After being done with the new design, I decided that source is horribly unreadable, and I'm not really happy with my previous solution of doing screenshots (not indexable, not copyable). So I found this really cool JavaScript library by Alex Gorbatchev called SyntaxHighlighter that highlights <pre> tags and adds some very nice formatting to your code.
Here's an example:

static class Program
  
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }


And while being at it I also updated to the most current version of WordPress. So if you encounter any oddities (especially with the feed), please tell me about it so I can fix it.

Oh and by the way, while being at it I installed iWPhone so that any user who visits http://tigraine.at with an iPhone or iPod touch will get a stripped down site without too much clutter that's been optimized for the iPhone resolution. Images get removed from the front-page but everything still looks cool. :)

Filed under site-news

Disabling del.icio.us on the feed?

delicious I have been using feedburner for a pretty long time now, and one thing I thought is particularly handy is that you can let it incorporate your del.icio.us bookmarks into the feed as daily updates.
This removed the necessity of doing a blog post every week that boils down to a link-collection of the most interesting stuff I read across the web that week.

So the main thing is that due to the great Firefox3 Addon for del.icio.us I started to use del.icio.us more and more as a bookmark tool, so that I am "polluting" my feed with sometimes unnecessary stuff that you may or may not be interested in. This has led to the fact that sometimes there are 3-4 link flares from del.icio.us in between 2 of my blog posts.

So this is one question to my dear feed-subscribers: Should I remove my del.icio.us link splicer from my feed?

Ps: By the way, if you are using del.icio.us too and want to add me to your network feel free to do so through my profile, oh, and if you aren't already subscribed to the feed. You can find it easily to the right or through this link.

Filed under internet, personal

My Photography business

Projects

dynamic css for .NET

Archives

more