Out-Blog!

November 24th, 2006 by Daniele Muscetta

[Edited again 25th November - Jachym gave me some suggestions and insights on the use of parameters, and I slightly changed/fixed the original code I had posted yesterday. There are still some more things that could be improved, of course, but I'll leave them to the future, next time I'll have time fot it (who knows when that will be?)]

This one is a post regarding my first test writing a cmdlet for PowerShell. After a few days since having change my blog's title to "$daniele.rant | Out-Blog" (where Out-Blog was a fantasy cmdlet name, and the title just meant to mimick PowerShell syntax in a funny way), I stumbled across this wonderful blog post: http://blog.boschin.it/archive/2006/09/21/4375.aspx that describes how to use the assemblies of "Windows Live Writer". Then I saw the light: I could actually implement an "Out-Blog" cmdlet. I am not sure what this could be useful for… but I thought it was funny to experiment with. I followed the HOW TO information on this other blog post to guide me through the coding: http://www.proudlyserving.com/archives/2005/10/lets_all_write_1.html

The result is the code that follows. you see is pretty much Boschin's code wrapped into a cmdlet class. Nothing fancy. Just a test. I thought someone might find it interesting. It is provided "AS IS", mainly for educational purpose (MINE, only mine…. I'm the one whose education is being improved, not you :-))

 

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Management.Automation;

using WindowsLive.Writer.BlogClient.Clients;

using WindowsLive.Writer.BlogClient;

using WindowsLive.Writer.CoreServices;

using WindowsLive.Writer.CoreServices.Settings;

using WindowsLive.Writer.Extensibility.BlogClient;

using Microsoft.Win32;

 

 

namespace LiveWriterCmdlet

{

[Cmdlet("out", "blog", SupportsShouldProcess=true)]

 

public sealed class OutBlogCmdlet : Cmdlet

{

[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string Title

{

get { return _title; }

set { _title = value; }

}

private string _title;

 

[Parameter(Position=1,Mandatory=true,ValueFromPipeline=true,ValueFromPipelineByPropertyName=true)]

[ValidateNotNullOrEmpty]

public string Text

{

get { return _text; }

set { _text = value; }

}

private string _text;

 

[Parameter(Position = 2, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string BlogApiEndPoint

{

get { return _blogapiendpoint; }

set { _blogapiendpoint = value; }

}

private string _blogapiendpoint;

 

[Parameter(Position = 3, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string UserName

{

get { return _username; }

set { _username = value; }

}

private string _username;

 

[Parameter(Position = 4, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string Password

{

get { return _password; }

set { _password = value; }

}

private string _password;

 

 

[Parameter(Position = 6, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string ProxyAddress

{

get { return _proxyaddress; }

set { _proxyaddress = value; }

}

private string _proxyaddress;

 

[Parameter(Position = 7, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public int ProxyPort

{

get { return _proxyport; }

set { _proxyport = value; }

}

private int _proxyport;

 

[Parameter(Position = 8, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

public string ProxyUserName

{

get { return _proxyusername; }

set { _proxyusername = value; }

}

private string _proxyusername;

 

[Parameter(Position = 9, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

public string ProxyPassword

{

get { return _proxypassword; }

set { _proxypassword = value; }

}

private string _proxypassword;

 

[Parameter(Position = 10, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

public SwitchParameter Published

{

get { return _published; }

set { _published = value; }

}

private bool _published;

 

 

 

 

protected override void BeginProcessing()

{

base.BeginProcessing();

 

 

ApplicationEnvironment.Initialize();

if ((ProxyAddress != null) | (ProxyAddress != ""))

{

WebProxySettings.ProxyEnabled = true;

WebProxySettings.Hostname = ProxyAddress;

WebProxySettings.Port = ProxyPort;

WebProxySettings.Username = ProxyUserName;

WebProxySettings.Password = ProxyPassword;

 

}

else

{

WebProxySettings.ProxyEnabled = false;

}

 

}

 

 

 

 

protected override void ProcessRecord()

{

if (ShouldProcess(Text))

{

ISettingsPersister persister = new RegistrySettingsPersister(Registry.CurrentUser, @"Software\Windows Live Writer");

IBlogCredentials credentials = new BlogCredentials(new SettingsPersisterHelper(persister));

IBlogCredentialsAccessor credentialsAccessor = new BlogCredentialsAccessor("dummy-value", credentials);

 

credentials.Username = UserName;

credentials.Password = Password;

 

MovableTypeClient client = new MovableTypeClient(new Uri(BlogApiEndPoint), credentialsAccessor, PostFormatOptions.Unknown);

 

 

BlogPost MyPost = new BlogPost();

MyPost.Title = Title;

MyPost.Contents = Text;

client.NewPost("dummy-value", MyPost, Published);

 

WriteVerbose("Posted Successfully.");

 

}

 

}

 

}

}

Test Post from PowerShell !

November 24th, 2006 by Daniele Muscetta

This is a sample Post from Powershell, posted thorugh my Out-Blog sample cmdlet !! It's probably useless for most people, but is Fun!

Upgraded to Wordpress 2

November 20th, 2006 by Daniele Muscetta

It was a snap. I thought it would be much worse. My bad. It was very easy.
As soon as I have some more time I need to try with another blog I manage - now that one has several plugins and several hacks I did to the code myself and it might result trickier…. let's see. Maybe I am worrying for nothing (it would not be unusual).

I am a “generous experiencer”… according to PersonalDNA

November 20th, 2006 by Daniele Muscetta

The personality test at PersonalDNA says I am a "generous experiencer".

I don't believe that tests can totally be accurate, but there are some elements which are indeed correct.
Give it a try.

Email talk on Port25

November 20th, 2006 by Daniele Muscetta

Interesting interview to Eric Allman on Port25.
He talks of the future of email, of SenderID, of sendmail… of openness and interoperation.
Very interesting.
With the change in licensing of SenderID, let's how quick this gets picked up by Wietse Venema

This server now running on XEN

November 17th, 2006 by Daniele Muscetta

The fine guys that host this machine at rimuhosting.com have upgraded their systems. So now this machine (you knew it was a Virtal Machine, didn't you?) is not running on UML anymore but on XEN. Everything seems to work fine, actually better than before.
Great people at that hosting.

Rome Calendar 2007

November 11th, 2006 by Daniele Muscetta
Rome Calendar 2007

Rome Calendar 2007, uploaded by Daniele Muscetta on Flickr.

I've used these photos to publish a calendar that you can get here: www.lulu.com/content/512186

Ok, I won't get rich from it, but I thought it was funny.


Support Independent publishing: buy this calendar on Lulu.

More on Specialization

November 5th, 2006 by Daniele Muscetta

"[...] A generalizing specialist is more than just a generalist. A generalist is a jack-of-all-trades but a master of none, whereas a generalizing specialist is a jack-of-all-trades and master of a few. Big difference.

Too much specialization is a pitfall of its own. Have you ever worked on projects where you had "the database guy", "the testing guy", "the web guy", and so forth [...]" - Jeff Atwood

I love this. It "clicks" and "sounds" a lot similar to my "Superior Dedication" tagline. Or at least, to what I mean with it. BTW, Have you noticed that I changed it to a nicer, stronger, les polite one lately ? You didn't ? Well, it used to be touting "Superior Dedication - You notice the difference"; but I just grew even more pissed off at certain claims and a while ago I decided to change it to "Superior Dedication - Specialization is Bullshit". Which has pretty much the same meaning, it just smells stronger.

The previous post I quotes gets crowned by a very nice first comment, attributed to Konrad Lorenz:

"[...] Every man gets a narrower and narrower field of knowledge in which he must be an expert in order to compete with other people. The specialist knows more and more about less and less and finally knows everything about nothing. [...]"

It is nice to see that you are not the only one thinking out of certain schemes. Especially on sundays. It makes you ready for tomorrow, when you'll have to go to work again… when you will be with the customer, and what REALLY counts is not specialization, but dedication, passion and intuition :-)

Microsoft-Novell deal

November 5th, 2006 by Daniele Muscetta

[aka: Linux is less Free and more O$$ every day]

News of this Microsoft-Novell deal are all over the web.

I'd like to comment by cross-posting: this post in particular hides a pearl of wisdom:

"[...] But what does this mean to the end user?  Probably not very much. 

SLED aficionados will continue to praise Novell while espousing the virtues of free Linux – pretending all the while that Novell is not just as anxious to turn a profit on enterprise versions of their Linux products as Microsoft is to push its Windows wares. 

Others in the Linux camp will criticize Novell as a 'turncoat' to the Linux movement — never mind that everyone pushing their own Linux distribution is desperately trying to make money off of the open source software movement [...]"

But this is something you could see a long time ago. I even fell in the trap at the beginning when I started looking at Novell's move in the Linux and Open Source market…. but they did not fool me for long . In the second article I wrote:

"[...] There are people who might not like this. I even understand it. An I am not referring to Microsoft. I am referring to people who love and advocate free software. This behavior does not look fair. It looks like the competition to Microsoft is trying to use all possible weapons to regain market, using (and abusing) open source software they did not create in the first place. This might be true, but to those who might not agree, being idealistic about linux… I have to say that unfortunately the dream of 'complete freedom' of software has already vanished. Haven't you noticed it already ? It would be great, in theory, but talking of IT is rather obviously talking of a market, rather than of just a hobby. And a market is where companies play. After all, RedHat is charging money for its up2date, while WindowsUpdate is still for free… …you might say that other distributions don't charge people for the updates… but for how long is it really going to last? Companies have stepped in, and they are going to stay. I am not trying in any way to defend their position. I am just making an analysis of this phenomenon. [...]"

And that was already three years ago.

Still you get people insisting on free software, and how companies should use it to stop paying Microsoft. Yeah, right. And to start paying IBM or Novell. They'll always pay someone anyway.

I stepped out of the dream and started working at Microsoft when I realized this.

I also still use FREE-OSS (like Debian or Gentoo Linux Distros) for myself. But companies can't really depend on those. Their mentality requires them to pay someone to do things. And this is not that terrible. It actually keeps the market going and it gives me a job after all. Why should I despise it ?

It's a shame that people don't see things in advance, they sometimes are even hard to figure them out when they are already old. Some other people instead do look around and see things when they are preparing to happen. They are probably those that keep their eye open. Even if not directly related to open source, Roberdan wrote this concept in Italian here:

"[...] ma perchè dicono che ho una visione? perchè sembra che io sappia esattamente come andranno le cose, che veda quello che accadrà tra 1 mese, tra 1 anno o tra 10 anni. Chiaramente dal punto di vista tecnologico, ma anche organizzativo. Avrò quindi poteri soprannaturali?? Sarò un fenomeno paranormale come Alberto Sordi? (e quindi riuscirò a monetizzare questa facoltà mettendomi a fare il santone? :-)….o SEMPLICEMENTE…

Semplicemente ho gli occhi aperti? una bocca e due orecchie per cui ascolto il doppio di quanto parlo? Un istinto non ancora represso e ingabbiato nei meandri della moderna società del lavoro? Secondo me si.

Volete essere dei visionari? Aprite gli occhi, non fermatevi a guardare la goccia che cade dal vostro naso, non arrendetevi all'evidenza. Scavate. Se non capite fate domande. Se avete dubbi confrontatevi, SE VOLETE CAMBIARE QUALCOSA CAMBIATELO [...]"

It's a shame it is not written in English, but - hey, he was probably referring to an Italian audience. I love Italy, but Italian readers should really move their asses and learn english. He probably thinks different so he addresses them in writing in Italian… as of me, I just don't care anymore (I have probably never done) about those little italians who can't read english. Those who can't read my posts in english are probably also the same people that need to be spoon-fed and told everything, those who can't figure it out themselves. And when they can't figure it out themselves, that usually also means they take themselves too seriously… so why bother ?