Popfly Virtual Earth Mashup on Moonlight

April 12th, 2008 by Daniele Muscetta
Popfly Virtual Earth Mashup on Moonlight

Installed moonlight on Ubuntu from source by following these instructions (there are some typo's but they are understandable and correctable).

All in all, even being still under heavy development, what Miguel de Icaza has achieved (with moonlight, just like with mono) is amazing.

After I posted the above picture on Flickr, John Montgomery was amazed to see PopFly (his creature) working on moonlight, and he linked to me from his blog.

Get-FlickrPhotos

January 14th, 2008 by Daniele Muscetta

A while ago, talking to some friends, I was mentioning how cool it was that Flickr provides APIs, so that you can always get your data out of it, if you want to. There are several downloader applications that I found on the Internet, but I have not yet chosen one that I completey like among the few that I've tried. So, inspired by Kosso's PHP script for enumerating your photos on Flickr, I thought I'd port it to Powershell and make my own version of it. Just for the fun of it. My Powershell script does not do everything that Kosso's one does: I don't build a web page showing description and comments. I suppose this is because the original script was made with PHP, which you usually run on a web server and outputting as HTML is the standard thing you would do in PHP. I just concentrated on the "download" thing, since mine it is a console script. You can think of mine as a "full backup" script. Full… well, at least of all your photos, if not of all the metadata. It should be trivial to extend anyway, also considering Powershell XML type accelerator really makes it extremely easy to parse the output of a REST API such as Flickr's (I would say even easier and more readable that PHP'simplexml). There is a ton of things that could be extended/improved in the script… including supporting proxy servers, accepting more parameters for things that are now hardcoded… and with a million other things. Even this way, though, I think that the script can be useful to show a number of techniques in Powershell. Or just to download your photos :-) So you can download the script from here: Get-FlickrPhotos.ps1

Welcome www.powershell.it!

January 4th, 2008 by Daniele Muscetta

I just read from Jeffrey Snover about this newly born Italian PowerShell community site.

I just created an account for myself on the site… as you know I like PowerShell, so even if I usually prefer writing stuff in english, I will try to hang out there and see how can I contribute to it.

After all, I am italian… :-)

.Net Framework CODE is going to be available!

October 4th, 2007 by Daniele Muscetta

I am amazed and excited to read that Microsoft has decided to release the source code of the .Net libraries.

Scott Guthrie writes:

"[…] One of the things my team has been working to enable has been the ability for .NET developers to download and browse the source code of the .NET Framework libraries, and to easily enable debugging support in them. […] VS 2008 will include support to automatically retrieve the appropriate .NET Framework source files on demand from Microsoft. This means that the source code for the ASP.NET GridView and BaseDataBoundControl classes above do not have to already be installed on the machine before we started the debugger. Instead, when we use F11 to step into their implementation VS can automatically download the source files from Microsoft and open it within the IDE. […]"

WOW. This is so cool, and a further step in the right direction.

Thanks to Alessandro for having picked this up, as I read it on his blog, and I thought it was an information worth spreading!!!

Open Source Projects and Microsoft

August 24th, 2007 by Daniele Muscetta

This CNet article about CodePlex has some VERY interesting points:

[…] Bayarsaikhan has posted the top 25 most active open-source projects on Microsoft's Codeplex site. Looking at the list, it looks like Microsoft developers spend their time doing much the same as the rest of the Java/other world: play games and make the Web world pretty with AJAX. You can see the top project interests below in the Codeplex tag cloud.

Codeplex is interesting to me for several reasons, but primarily because it demonstrates something that I've argued for many years now: open source on the Windows platform is a huge opportunity for Microsoft. It is something for the company to embrace, not despise.

And it does several things well (better than Sourceforge, in my opinion) […]

Facebook Mobile is not working for Italy

August 21st, 2007 by Daniele Muscetta

Facebook Mobile is not working for Italy

Facebook mobile is not working from mobile operators not in the US, I suppose.
I can't even log on to m.facebook.com with my WIndows Mobile SmartPhone.
I can't send status updates through SMS.

I can't even send them by mail, or I get the following back:

Facebook Mobile is not working for Italy

So, now, I am updating Twitter.
Twitter can be updated with an SMS even from Europe. Or it can be updated with a bot running GTalk. Very easy, can do it from everywhere.

I then wrote a small command line application (based on the same "hack" as the one described before) that runs every five minutes from the scheduler on my server and keeps the two in sync.

I wrote it in C# as a Console application because that's usually what I do when I want it to run it both on my windows machines and/or on my Linux server (with MONO). I already used this approach in the past and I found it to be successful. As long as you keep the application simple enough and check out the documentation for the implemented classes on mono, it runs without modification both on windows on the "real" .Net framework and on Mono on Linux. i just copy the executable and I am ready to go.
Not this time, though.
I am hitting what seems to be a bug in mono. I might be able to find a workaround, but I haven't had the time to dig in the issue yet.
I posted some info about this on this forum.

Windows Live ID Web Authentication 1.0 SDK !

August 16th, 2007 by Daniele Muscetta

Check this out:

Windows Live ID Team has published on the web the SDK that lets you liveID (or "passport")-enable your applications!

http://msdn2.microsoft.com/en-us/library/bb676633.aspx

There are even code samples in six different languages: C#, Java, PHP, Python, Ruby e Perl! You can download them from http://go.microsoft.com/fwlink/?LinkId=91761

Wow! Having time, it would be cool to write a WordPress plugin using Passport authentication to authenticate/identify users that want to comment… mumble mumble….. :-)

Interoperability. Wow.

More info at the Live ID starting Page: http://dev.live.com/blogs/liveid/archive/2006/05/18/8.aspx

Why do developers tend to forget about people behind proxy servers ?

August 13th, 2007 by Daniele Muscetta

I know this is a very common issue.

I keep finding way too many software that claim to interact with Web 2.0 sites or services, and connect here or there…. still forgetting one basic simple rule, that is: letting people use a proxy.

Most programmers for some reasons just assume that since they are directly connected to the internet, everybody is. Which isn't always the case. Most companies have proxies and will only let you out to port 80 – by using their proxy.

…which in turn is one of the reasons why most applications now "talk" and tunnel whatever application protocol on top of HTTP… still a lot of softwares simply "forget" or don't care proving a simple checkbox "use proxy", which will translate in two or three extra lines of code… three lines which I personally usually include in my projects, when I am not even a *developer*!! (but that might explain why I *think* of it… I come from a security and networking background :-))

I thought of writing this post after having read this post by Saqib Ullah.

Anyway. I keep finding this thing over and over again. Both in simple, hobbyist, sample and/or in complex, big, expensive enterprise software. Last time I got pissed off about a piece of code missing this feature was some days ago when testing http://www.codeplex.com/FacebookToolkit. The previous time was during Windows Vista beta-testing (I had found a similar issue in beta2, and had it fixed for RC1.)

Actually, I am being polite saying it is "missing a feature". To be honest I think missing this "feature" would have to be considered a bug: every piece of software using HTTP *should* include the possibility to pass thorugh proxy (also, don't forget about  AUTHENTICATED proxies), or the purpose of using HTTP in the first place is defeated!!

Developers!!! You have to remember people ARE behind proxies !!!!!

Facebook StateTray

August 3rd, 2007 by Daniele Muscetta

Facebook StateTray

Facebook StateTray, uploaded by Daniele Muscetta on Flickr.

This is a Screenshot of the small application I first described in my previous blog post.

It is a simple Windows Form that lets you change your status on Facebook without having to browse to the site. It does not rely on Facebook's API (as they won't let you change your status, at least to date) but is really uses a hack on the Facebook mobile pages. It is based on PHP code posted by Christian Flickinger, ported to C# (.Net 2.0) by me.

When you pull down the form you get to see the settings:

Facebook State Tray

Those can be stored in an XML file, that gets loaded automatically every time the program starts.
Beware that password ARE displayed and stored in clear text.

The idea so far is that you run it on your PC and you just keep it resized so it does not show the "dangerous" bits.
You can keep it minimized on the tray in windows, pop it up when you need to update your status, write your new status and click "change" – it will freeze for a couple of seconds while updates your status, since it uses synchronous calls – then you can minimize it again.

UPDATED –  September 1st 2007: I have been asked by Facebook to pull down the source code from the Net, as it violates their terms of service (I had not realized that). Apologies to all.

Facebook API and WinForm experiment

August 2nd, 2007 by Daniele Muscetta

While testing with the Facebook API, I started creating a WinForm using the Facebook Toolkit.

What I had in mind was a simple program that would run on my PC, maybe minimized in the system tray, that would let me update my status in a click, thorugh the day, without having to log on to the website. Most of the day I am busy working, and I don't really have time to go surf and check Facebook… but I like the possibility for people to hear how I am doing. Changing the status would keep them up to date, and would keep my profile current.

As I figured out afterwards, their API does not yet let you change your status yet.

There are other people asking for this possibility… but then I went further searching on the Internet, and I found this blog: http://www.nexdot.net/blog/2007/04/20/updating-facebook-status-using-php/

I just hacked together a small WinForm written in C# that reimplements this idea.

Facebook StateTray

I indeed would like to thank Christian for the idea, and my friend and colleague Pierluigi for his precious help with the regular expressions :-)

At the moment it has terrible things such as hardcoded passwords in it, but as soon as I will have time to polish the code a bit, I will post it.

One more thing I would like to do with it is turning it from a standalone application into a Live Messenger Add-In, so that it synchronizes my messenger status with the one of Facebook. When I will have time for that.

IronPython and Visual Studio Shell

June 8th, 2007 by Daniele Muscetta

I read on the IronPython Mailing List about this cool integration with Visual Studio Shell! Also, further in the same thread, you can find out that the current CTP of ASP.NET (ASP.NET Futures) also includes ironPython integration. Look at this:

IronPython running in VS Shell

This blog in C#

May 30th, 2007 by Daniele Muscetta

I have been busy trying to write a new frontend for this blog that uses .Net. I already blogged about it here. In the last couple of weeks I have been adding stuff – permalinks using mod_rewrite, I finally show the comments properly, I have added categories and category archives (as in http://www.muscetta.net/dotnet/tag/coding). There is even an RSS Feed.

The layout is still crap, but I sort of like it being so light weight, so that is not on my priority list so far. Moreover, I am a crap designer.

Before that, tough, I still have to add important functionalities like the possibility to POST comments (which needs a new CAPTCHA, etc, so it will take me a while), and I am having issues with text encoding (it does not show the accented characters properly, yet).

But I am having fun doing it.

[Edit of December 2009 – I killed the above experiment. I had fun doing it, but there is not time for all, it needs a lot of work to keep it running/update it with every wordpress update, and mod_mono is wasting too many resources on the server.]

Death by right-click -> Delete ? Nope. PowerShell.

May 30th, 2007 by Daniele Muscetta

So at one stage I was testing the RSS reader capabilities of Outlook 2007, and I imported an OPML file with roughly 500 feeds! Of course I was NOT interested in reading ALL of them, and it was causing quite a bit of work to do on my machine to fetch them all and sync the content in my mailbox…

So I figured out it was possible to remove the subscription (from the Tools menu -> Account Settings -> RSS Feeds) but the folders were left there. Now, I didn't want to have those 500 folders in my mailbox, and I did not even want to die by right-clicking, pressing "delete", confirming…. all of this 500 times! No way.

So I wrote this little PowerShell script, I guess it *might* be helpful to someone at one stage, who knows ?

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Interop.Outlook')
$oApp = New-Object -COM 'Outlook.Application'
$rss = $oApp.GetNamespace("MAPI").GetDefaultFolder("olFolderRssFeeds")
forach ($folder in $rss.Folders)
{
$folder.Delete()
}

Please note that if you don't have the Office Interop Assemblies installed on your machine, you can't use the first line. As a result, you will have to change the third line hardcoding the number that represents the RSSFeeds folder, so it would become:

$rss = $oApp.GetNamespace("MAPI").GetDefaultFolder(25)

Note: I found out (later, of course) that there is a much more general post on this subject (that is, automating Outlook through PowerShell): http://www.leeholmes.com/blog/GettingThingsDoneOutlookTaskAutomationWithPowerShell.aspx

WordPress.Net

May 1st, 2007 by Daniele Muscetta

WordPress.Net

WordPress.Net, uploaded by Daniele Muscetta on Flickr.

It has been quite a while that I wanted to experiment a bit more with ASP.Net but I don't have a windows machine on the internet. Not one that performs enough anyway. My server runs linux. I have had mono running on it for a while, but its support was not complete with the old release of Debian, so part of my mono and mod_mono installation were a custom compile and they were breaking from time to time, each time some library got updated. So I did run a "Hello World" page with it, but nothing more, because it was a bit of a mess to mantain and, moreover, because I had not yet figured out how to have it connect with mysql instead than with MS SQL Server.
Also, I did not have any real project or idea to implement in my mind.

Now that I have upgraded to Debian Etch, mono support seems to be much more out-of-the-box and stable on this release. I also got an idea of what to do with it, so I finally gave it a try.

As a starter, I am trying to re-publish my blog, historically running at www.muscetta.com, on my other muscetta.NET domain (it makes sense to use a .NET domain, right?). But this is not a new site, it is a republish of the same content, but done using C# – just pointing at the same wordpress' mysql database. Connection to MySQL is done with MySql.Data (the ADO.Net driver for MySQL).

I still need to implement a lot of things/features, such as comment posting (you can only read them now), some layout/styling/framing to make it look nicer, some sidebar/blogroll, feeds, and a many other things. I am not aiming at a complete rewrite (for example I won't do an administrative interface or a webservice so far), but just a republish/frontend to the visitors.
I don't know when I will have time to continue writing it, but all in all I am glad it works so far, and I had fun doing it.

Writing ASP.Net for mono on linux in the absence of Frontpage server extentions and WebDAV and the remote debugger is proving slightly more challenging than just dragging and dropping controls in Visual Studio and let it do a lot of work with you. You have to write the code, upload it, and see if it works. No debugging, no intellisense. Just the hard old way of trial and error, which makes development slower, but you learn a hell of a lot more that way. Of course you need to keep the MSDN library handly :-)

[Edit of December 2009 – I killed the above experiment. I had fun doing it, but there is not time for all, it needs a lot of work to keep it running/update it with every wordpress update, and mod_mono is wasting too many resources on the server.]

MOM 2005 Alerts to RSS feed

March 22nd, 2007 by Daniele Muscetta

I am an RSS Addict, you know that.So I wanted an RSS Feed to show MOM Alerts. I have been thinking of it for a while, last year (or was it the year before?).
It seemed like a logical thing to me: alerts are created (and can be resolved – that is, expire), generally get sorted by the date and the time when they have been created, the look pretty much like a list. Also, many people like to receive mail notification when new alerts are generated.
So, if the alert can be sent to you (push), you could also get to it(pull).
Pretty much the same deal with receiving a mail or reading a newsgroup, or syndicating a feed.

At the time I looked around but it seemed like no one had something like this already done.
So I wrote a very simple RSS feed generator for MOM Alerts.
I did it quite an amount of time ago, just as an exercise.
Then, after a while, I figured out that the MOM 2005 Resource Kit had been updated to include such a utility!

Wow, I thought, they finally added what I have been thinking for a while. Might it be because I mentioned it on an private Mailing list ? Maybe. Maybe not. Who cares. Of course, if it is included in the resource kit it must be way cooler than the one I made, I though.
I really thought something along these lines, but never actually had the time to try it out.
I think I just sort of assumed it must have been cooler than the one I made, since it was part of an official package, while I am not a developer. So I basically forgot about the one I wrote, dismissing it as being crap without looking too much into it anymore.
Until today.
Today I actually tried to use the alert to RSS tool included in the resource kit, because a customer asked if there was any other way to get notified, other than receiving notification or using the console (or the console notifier).
So I looked at the resource kit's Alert-to-RSS Utility.
My experience with it:
1) it is provided in source code form – which is ok if it was ALSO provided as source. Instead it is ONLY provided as source, and most admins don't have Visual Studio installed or don't know how to compile from the command line;
2) Even when they wanted to compile it, it includes a bug which makes it impossible to compile – solution in this newsgroup discussion;
3) if you don't want to mess about with code since you are using a resource Kit tool (as opposed to something present in the SDK) you can even get it already compiled by someone from somewhere on the net, but that choice is about trust.

Anyway, one way or another, after it is finally set up…. surprise surprise!!!
It does NOT show a LIST of alerts (as I was expecting).
It shows a summary of how many alerts you have. basically it is an RSS feed made of a single item, and this single item tells you how many alerts you have. What is one supposed to do with such a SUMMARY? IMHO, it is useless the way it is. It is even worse than one of those feed that only contains the excerpt of the article, rather than the full article.
Knowing that I have 7 critical errors and 5 warning without actually knowing ANYTHING of them is pointless.
It might be useful for a manager, but not for a sysadmin, at least.

So I thought my version, even if coded crap, might be useful to someone because it gives you a list of alerts (those that are not resolved) and each one of them tells you the description of the alert, the machine tat generated it, and includes links to the actual alert in the web console, so you can click, go there, and start troubleshooting from within your aggregator!
My code does this. Anyway, since I am a crap coder, since I wrote it in only fifteen minutes more than a year ago, and since I don't have time to fix it and make it nicer… it has several issues, and could be improved in a million ways, in particular for the following aspects:

  1. is currently depends on the SDK Database views – it could use the MOM Server API's or the webservice instead;
  2. it uses SQL Security to connect to the DB – by default MOM does not allow this – it is suggested for the SQL instance hosting "OnePoint" to only use Windows Integrated Authentication.. so to make my code work you have to switch back to Mixed mode, and create a login in SQL that has permission to read the database. This is due to the fact that I've coded this in five minutes and I don't know how to use delegation – if I was able to use delegation, I would… so that the end user accessing IIS would be the one connecting to the DB. If anybody wants to teach me how to do this, I will be most grateful.
  3. it could accept parameters as URL variables, so to filter out only events for a specific machine, or a specific resolution state, etc etc
  4. At present it uses RSS.Net to generate the feed. It could made independent from it, but I don't really see why, and I quite like that library.

The code is just an ASP.Net page and its codebehind, no need to compile, but of course you need to change a couple of lines to match your webconsole address.
Also, you need to get RSS.NET and copy its library (RSS.Net.dll) in the /bin subfolder of the website directory where you place the RSSFeed generator page. I see that I wrote this with version 0.86, but any version should do, really.

Here is what it will look like:

AlertToRSS

And here's the code of the page (two files):

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

Default.aspx.cs

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using Rss;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string webconsoleaddress = "http://192.168.0.222:1272/AlertDetail.aspx?v=a&sid=" // must change to match your address

// Inizializza il Feed
RssChannel rssChannel = new RssChannel();
rssChannel.Title = "MOM Alerts"
rssChannel.PubDate = DateTime.Now;
rssChannel.Link = new Uri("http://192.168.0.222:1272/rss/"); // must change to match your address
rssChannel.LastBuildDate = DateTime.Now;
rssChannel.Description = "Contains the latest Alerts"

// query – you might want to change the severity
string mySelectQuery = "SELECT ComputerName, Name, Severity, TimeRaised, RepeatCount, GUID FROM dbo.SDKAlertView WHERE Severity > 10 AND ResolutionState < 255"

// SQL Connection – must change SQL server, user name and password
SqlConnection conn = new SqlConnection("Data Source=192.168.0.222;Initial Catalog=OnePoint;User ID=rss;Password=rss");
SqlDataReader rdr = null;

try
{
conn.Open();
SqlCommand cmd = new SqlCommand(mySelectQuery, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
RssItem rssItem = new RssItem();
string titleField = rdr[1].ToString();
rssItem.Title = titleField;
string url = webconsoleaddress + rdr[5];
rssItem.Link = new Uri(url.ToString());
string description = "<![CDATA[ <p><a xhref=\"" + rssItem.Link + "\">" + rdr[1] + " </a></p><br>" + "<br>Computer: " + rdr[0] + "<br>Repeat Count: " + rdr[4] + "<BR>Original ALert Time: " + rdr[3];
rssItem.Description = description;
rssChannel.Items.Add(rssItem);
}

// Finalizza il feed
RssFeed rssFeed = new RssFeed();
rssFeed.Channels.Add(rssChannel);
Response.ContentType = "text/xml"
Response.ExpiresAbsolute = DateTime.MinValue;
rssFeed.Write(Response.OutputStream);
}
finally
{
if (rdr != null)
{
rdr.Close();
}

if (conn != null)
{
conn.Close();
}
}
}
}

Phrogram – Kids Programming Language

February 25th, 2007 by Daniele Muscetta

It was since the old times of LOGO that I did not see an effort to bring kids closer to computer programming. This is what makes Phrogram (previously called KPL – kids' Programming Language) unique today. On the KPL site you can also read that "KPL isn't just for kids any more". This means it has evolved and it is now as complete as a programming language as one of the many other you can choose among to create your full-blown applications and games.

Anyhow, this means that people might choose it because it is easy and straightforward to build up complex programs (especially games), but it also still primarly is a very attractive tool to teach the youngest generations how does programming work.

I learned the very basics of programming… in BASIC ,in fact, on my first Commodore64. What does a kid try to do ? Write a game. I also did. It was painful back then when you had to use instructions such as PEEK and POKE to "draw" the bitmaps making up your sprites and let them move by moving those bits around… at the elementary school it wasn't exactly crystal clear to me why did it work, and how. I actually had my issues with much simpler stuff, like figuring out what on earth a multi-dimensional array was, and stuff like that. LOGO simplified all of that, as you finally could just draw on your computer by moving the Turte simply asking her to move back, forward, right, left, and so on…

Of course twenty years have passed, CPU capacity has massively improved, object oriented programming has become mainstream….. so that now, with KPL/Phrogram you can write a real Arcade videogame that uses DirectX 3D graphics with just a bunch of lines of code! This absolutely ROCKS!

Out-Flickr!!

January 10th, 2007 by Daniele Muscetta

This is soooo cool! An "Out-Flickr" script for PowerShell:

http://abhishek225.spaces.live.com/blog/cns!13469C7B7CE6E911!285.entry

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.");

 

}

 

}

 

}

}

Thoughts, Blogs, and Ruby with .Net

June 9th, 2006 by Daniele Muscetta

For those who have not seen it yet, Mischa Kroon has a nice blog post about interoperability between Ruby and the .Net framework.

It provides several links and things to think about. If you are into .Net, or Ruby, or both, or simply interested about how things can interoperate, give it a read.