Wednesday, March 10, 2010

Quick Console App to Ping a Server

This is based mostly off of something in the Microsoft documentation. It's just a quick hack to let me know when a remote server comes back up.

static void Main(string[] args)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
//PingReply reply = pingSender.Send(args[0], timeout, buffer, options);
PingReply reply = pingSender.Send("server.domain.com", timeout, buffer, options);
for (; ; )
{
if (reply.Status == IPStatus.Success)
{
Console.WriteLine("Address: {0}", reply.Address.ToString());
for (int i = 0; i < 5; i++) Console.WriteLine("\a");
// Or System.Media.SystemSounds.Beep.Play();
// Or Console.Beep();
break;
}
else
{
Console.WriteLine("Failed " + System.DateTime.Now);
Thread.Sleep(30000);
}
}
Console.ReadKey();
}

Thursday, February 25, 2010

Center the Effing Div

.image {
margin-left: auto;
margin-right: auto;
width: 415px; /* fix the width while we're at it */
text-align: center; /* and we'll center the caption as well */
}

Thursday, October 8, 2009

Backup / Export Your Google Site

Judging from this thread, the inability to easily backup/export a Google Site has been a problem for awhile. Thankfully there's a tool on Google Code you can use to grab a local copy. The tool is pretty simple, but the documentation is not entirely clear. Here's what I did for my simple site, which is private:
  • Host: sites.google.com
  • Domain: [leave blank]
  • Webspace: [the last part of domain name path; if the domain name is http://sites.google.com/site/mysite123, this value would be just mysite123]
  • Import/Export Revisions: [I left this unchecked]
  • Username: [my Google account, with @gmail.com at the end]
  • Password: [the obvious]
  • Choose Target Directory: [the obvious]
Here's Google's blog post that talks about the issue a bit more.

Sunday, September 27, 2009

MVC Storefront Collected Links

There are videos and posts out there about the MVC Storefront sample application for ASP.NET MVC 1.0, but they're scattered around a bit.

This list will mix the original posts from Rob Conery's blog, Weke Road, and the ASP.NET MVC video collection and some Rob's related posts.

  1. ASP.NET MVC: Introducing The MVC Storefront Series [video]
  2. ASP.NET MVC: MVC Storefront, Part 2 – Repository Pattern [video]
  3. ASP.NET MVC: MVC Storefront, Part 3 – Pipes and Filters [video]
  4. ASP.NET MVC: MVC Storefront, Part 4 – Linq To Sql Spike [video]
  5. ASP.NET MVC: MVC Storefront, Part 5 – Globalization [video]
  6. MVC Storefront, Part 6: Catalog Completion and Initial UI [video]
  7. MVC Storefront, Part 7: Helpers and Routing [video]
  8. MVC Storefront, Part 8: Testing Controllers, Iteration 1 [video]
  9. MVC Storefront, Part 9: The Shopping Cart [video]
  10. MVC Storefront, Part 10: Shopping Cart Refactoring and Membership [video]
    MVC Storefront: Brainbender Intermission
    MVC Storefront: Intermission’s Over, Made Some Changes
  11. MVC Storefront, Part 11: Hooking Up The Shopping Cart And Components [video]
  12. MVC Storefront, Part 12: Mocking [video]
  13. MVC Storefront: Dependency Injection [video]
  14. MVC Storefront Part 14: Ajax With Shawn Burke [video]
    ASP.NET MVC: Script Registration Helper
    ASP.NET MVC: List Helper Extension Method
  15. MVC Storefront, Part 15: Code Review With Ayende [video]
  16. MVC Storefront Part 16: Membership Redo With OpenID [video]
  17. MVC Storefront Part 17: Checkout With Jeff Atwood [video]
    ASP.NET MVC: Avoiding Tag Soup
    Lazy Loading With The LazyList
  18. MVC Storefront Part 18: Creating An Experience [video]
  19. MVC Storefront Part 19: Processing Orders With Windows Workflow [video]
  20. MVC Storefront Part 19a: Windows Workflow Followup
    [video]
  21. MVC Storefront Part 20: Logging [video]
  22. MVC Storefront Part 21: Order Manager and Personalization [video]
  23. MVC Storefront Part 22: Restructuring, Rerouting, and PayPal [video]
  24. ASP.NET MVC Storefront Part 23: WebForms and Dynamic Data [no video]
    MVC Storefront Preview 1 Available
  25. (Episode 24 was cut)
  26. MVC Storefront Part 25: Getting Started With Domain-Driven Design [video]
  27. MVC Storefront Part 26: Finis [video]

The source code is out on Codeplex.

Friday, July 31, 2009

Unique Attribute Values Across Multiple Documents using XQuery

It's a little slow, but here's one way to get a list of all the unique attribute values across multiple XML documents using XQuery.


let $raw-values :=
for $book in collection("abc")/(gbook|set)[@type='oeb']
return
element { "book" }
{
for $value in distinct-values($book//node()/@class)
return element { "class" } { $value }
}
for $item in distinct-values($raw-values//class)
order by $item
return element { "uniques" } { $item }