by Mwwhited
10. June 2009 22:06
After running across a "code golf" question this afternoon on stack overFlow I answered with a short answer...
using (var inFs = File.OpenText(args[0]))
using (var outfs = File.AppendText(args[1]))
{
outfs.Write("<table border="0">");
while (!inFs.EndOfStream)
outfs.Write("<tbody><tr><td>" + string.Join("</td><td>", inFs.ReadLine().Split(',')) + "</td></tr>");
...
[More]
by Mwwhited
9. June 2009 01:06
Okay... those guys over at MSR (Microsoft Research) as just INSANE. Photosynth is too cool. Here is a synth of a scupture I own. Dragon Egg Savannah Clipper ... Enjoy, Matt
by Mwwhited
7. June 2009 12:06
One of the problems with RESTful services is not having a description language to allow for easy enumeration of services. This extension method allows for service classes to be described in an XML format that is easy to understand.
public static XElement GetWebGetServices(this object input)
{
return new XElement("services",
from method in input.GetType().GetMethods()
let webInvoke = method.GetCustomAttributes(typeof(Web...
[More]
by Mwwhited
7. June 2009 11:06
Not being able to serialize Anonymous Types with the build in XmlSerializer was kind of a bummer for me, so I created this set of extension methods. Another feature I added at recursion detection based on the .GetHasCode() to prevent recursive object graphs from causing stack overflows. It's ugly... but it works... I was going for a proof of concept so I'm happy for now. -Enjoy, Matt
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Lin...
[More]
by Mwwhited
7. June 2009 05:06
Not sure why Microsoft didn't include a ActionResult that supported XML but here you go. This version will directly support XNode, XmlNode, Data Contracts, and then try to use the standard XmlSerializer. Enjoy...
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using WhitedUS.Common;
namespace WhitedUS.Web.Mvc
{
public class ...
[More]
by Mwwhited
16. May 2009 10:05
Now that my project is complete for the Dare to Dream Different Challenge for Microsoft .Net Micro Framework, I am going to move on to another new technology. I started to play with Oslo a few weeks back and totally fell in love with MGrammar. Next stop... to use MGrammar with Reflection.Emit to build a simple .Net Compiler http://msdn.microsoft.com/en-us/library/dd129870.aspx
by Mwwhited
29. April 2009 02:04
One of the features that are "lost" in C# from C/C++ is the ability for switch cases to "fall though". This feature may be explicitly added back to your code simple by using a "goto" pointed to a particular case. Another way to implement this would be to use unsafe code and use pointers instead of array indexers.
public static void DuffsDevice(T[] from, T[] to)
{
int count = from.Length;
int position = 0;
switch ( count % 8 )
...
[More]
by Mwwhited
29. April 2009 00:04
Okay... calculating PI can be crazy enough. But to do it in BF... that's just insane. The guy that wrote this deserves a gold star and a metal. http://dl.getdropbox.com/u/35146/PI16.txt
by Mwwhited
23. April 2009 00:04
Here is a simple Telnet server implmented using C#. This is a very simple introduction to Socket, TCPListener, and Network Streams.
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TcpListener listener = new TcpListener(23);
listener.Start();
while (true)
...
[More]
by Mwwhited
20. April 2009 23:04
@ECHO OFF IF "%1"=="D" GOTO debugIt IF "%1"=="d" GOTO debugIt IF "%1"=="debug" GOTO debugIt IF "%1"=="B" GOTO buildIt IF "%1"=="b" GOTO buildIt IF "%1"=="build" GOTO buildIt REM IF "%1"=="A" GOTO doneWithIt IF NOT "%1"=="" GOTO :errorCmd boottest.cmd mypc.vmc GOTO doneWithIt :buildIt echo Build DistroWorld.proj ms...
[More]