mostlylucid

November 2004 Entries

Another great HttpModule - free upload module...

Just a quick one - free module for uploading items to ASP.NET, with source code. This is like the holy grail, efficient uploading! (Link is to the guy's blog - he says he'll post news there..)

Realy nice Regular expression based HttpModule URL Rewriter

Fabrice Marguerie has extended and (IMHO) improved Fritz Onions HttpModule for URL Redirection - basically Fabrice has added the ability to define regular expressions (ala .TEXT) for the redirection. Oh, and the source code implementation is pretty nice too - worth a look if you're just interested in HttpModules!

Downtime later tonight

I'll have to take down my server for a couple of hours later tonight (16/11/2004) - it will return with a new hard drive (current one is doing a passable impression of a slightly confused dolphin)

UPDATE: All done, oh, and I can recommend Powerquest v2I Server Edition (now  Symantec LiveState™ Recovery Advanced Server)  - one click and it copies a whole drive on to another one...

Essential tool to fix those hard to find ASP.NET problems...

Filemon is a tool which does one simple yet essential thing - shows you what files are accessed by what, when in windows. The most difficult ASP.NET bugs in my experience are to do with permissions / paths, the only way to get to the bottom of these issues is this tool. So, if you have a wierd bug which doesn't make any sense to you when running an ASP.NET app, fire it up and watch for problems.

So should I just work on .TEXT 0.95?

I have a ton of modifications I want to do to the source of my blog to make it more closely suit my needs (comment spam removal, POP3 entry submission along with some search & perf enhancements, improving layout for Firefox etc...)) - but I've been holding off, waiting for Community Server :: Blogs before spending any amount of time on this stuff - but there seems to be no sign of this being released and no recent updates on when this will change.It does look really cool though!
Hmm...still in two minds, dues to the way .TEXT is currently structured, loosely coupled plug-ins are fairly straightforward to do...but there's been a lot said about how radical the changes to the blogging engine will be in the next version...hmm...

Konfabulator Rules!

I have to admit, I was sceptical about yet another desktop widget type thing but man, Konfabulator is just brilliant! The user experience right from install right through to using the widgets, memory footprint etc is just perfect. This also shows a problem with bits like the Longhorn sidebar and my current favourite, DesktopSidebar, namely, the stuff is all in one place...anyway, I plan to use this for a while, let you know how I get on - but I really encourage you to try it out!
This is how my desktop currently looks (oh, the background is from DeviantArt )

 

I'm not dead, promise here's a little code snippet to prove it!

I've been incredibly busy at work lately and I really will get back to this blog soon. Anyway, came across this little bit of code whilst combing through an old backup, it basically lets you make a file of any size with any name (file contains totally random, non-compressible data) - I used it for testing uploading functions - oh, it's a winforms app before I forget :-):

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.IO;

using System.Security.Cryptography;

 

namespace DummyFileMaker

{

    /// <summary>

    /// Summary description for Form1.

    /// </summary>

    public class Form1 : System.Windows.Forms.Form

    {

        private System.Windows.Forms.TextBox FileSize;

        private System.Windows.Forms.Button MakeFileButton;

        private System.Windows.Forms.TextBox FilePath;

        private System.Windows.Forms.Label label1;

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.Container components = null;

 

        public Form1()

        {

            //

            // Required for Windows Form Designer support

            //

            InitializeComponent();

 

            //

            // TODO: Add any constructor code after InitializeComponent call

            //

        }

 

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        protected override void Dispose( bool disposing )

        {

            if( disposing )

            {

                if (components != null)

                {

                    components.Dispose();

                }

            }

            base.Dispose( disposing );

        }

 

        #region Windows Form Designer generated code

        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            this.FileSize = new System.Windows.Forms.TextBox();

            this.MakeFileButton = new System.Windows.Forms.Button();

            this.FilePath = new System.Windows.Forms.TextBox();

            this.label1 = new System.Windows.Forms.Label();

            this.SuspendLayout();

            //

            // FileSize

            //

            this.FileSize.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

                | System.Windows.Forms.AnchorStyles.Left)));

            this.FileSize.Location = new System.Drawing.Point(16, 8);

            this.FileSize.Name = "FileSize";

            this.FileSize.TabIndex = 0;

            this.FileSize.Text = "10";

            //

            // MakeFileButton

            //

            this.MakeFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

                | System.Windows.Forms.AnchorStyles.Right)));

            this.MakeFileButton.Location = new System.Drawing.Point(160, 40);

            this.MakeFileButton.Name = "MakeFileButton";

            this.MakeFileButton.TabIndex = 1;

            this.MakeFileButton.Text = "make file";

            this.MakeFileButton.Click += new System.EventHandler(this.MakeFileButton_Click);

            //

            // FilePath

            //

            this.FilePath.Location = new System.Drawing.Point(16, 40);

            this.FilePath.Name = "FilePath";

            this.FilePath.TabIndex = 2;

            this.FilePath.Text = "c:\\dummyfile.gif";

            //

            // label1

            //

            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));

            this.label1.Location = new System.Drawing.Point(144, 8);

            this.label1.Name = "label1";

            this.label1.Size = new System.Drawing.Size(128, 23);

            this.label1.TabIndex = 3;

            //

            // Form1

            //

            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

            this.ClientSize = new System.Drawing.Size(292, 69);

            this.Controls.Add(this.label1);

            this.Controls.Add(this.FilePath);

            this.Controls.Add(this.MakeFileButton);

            this.Controls.Add(this.FileSize);

            this.MaximumSize = new System.Drawing.Size(300, 96);

            this.MinimumSize = new System.Drawing.Size(300, 96);

            this.Name = "Form1";

            this.Text = "Form1";

            this.ResumeLayout(false);

 

        }

        #endregion

 

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        [STAThread]

        static void Main()

        {

            Application.Run(new Form1());

        }

 

        private void MakeFileButton_Click(object sender, System.EventArgs e)

        {

            label1.Text = "Creating file: " + FilePath.Text;

            using(FileStream fle = new FileStream(FilePath.Text,FileMode.Create,FileAccess.Write,FileShare.None,4096,false))

            {

                double numBytes = Convert.ToDouble(FileSize.Text) * (1024 * 1024);

                byte[] bytArr = new byte[(int)numBytes];

                RNGCryptoServiceProvider rng = new  RNGCryptoServiceProvider();

                rng.GetBytes(bytArr);

                fle.Write(bytArr,0,bytArr.Length);

                fle.Close();

            }

            label1.Text = "File Created";

        }

    }

}

Testing out Colin Coller's new CopySourceAsHtml release...

Looks like the definitive method for formatting source for blogs has been made! The new version adds a whole lot of stuff (from Colin's blog):

  • You can turn word wrapping on and off. If "wrap words" is checked, lines are rendered in <p> blocks. Otherwise, lines are rendered in <pre> blocks. Check this if your blog layout isn't wide enough for your code.
  • You can strip line breaks from the generated HTML. Handy if your blog software converts newlines automatically.
  • You can add additional RSS rules to the file, line, and block styles. Use this to add borders, scroll bars, etc. to your code.
  • You can embed styles or use a stylesheet. If "embed styles" is checked, tags have style attributes. If "embed styles" is unchecked, tags have class attributes, and the generated HTML includes a style block.
  • You can change which menu items are added to the context menus from within the add-in.
  • The generated HTML is copied to the clipboard in text and CF_HTML formats.
  • The code is cleaner and more modular, and the object model should make it easy to add new features in future versions.
  • There's an "About" tab with the version, copyright, license, my contact information, and my Amazon.com wish list (just kidding :).

Also added is using the defined colouring from VS.NET for the colouring (not Resharper coluring though - but I suspect Resharper uses some sort of hack for this anyway...)

Anyway, an example of what this awesome tool can output is below (just a simple object serialization routine):

using System.IO;

using System.Text;

using System.Xml.Serialization;

 

namespace Notifier

{

    /// <summary>

    /// Summary description for Deserializer.

    /// </summary>

    public class Deserializer

    {

        public static string Serialize(Template theTemplate)

        {

            XmlSerializer xSer = new XmlSerializer(typeof(Template));

            MemoryStream writer = new MemoryStream();

                xSer.Serialize(writer,theTemplate);

                string outStr =  ASCIIEncoding.ASCII.GetString(writer.ToArray());

                writer.Close();

                return outStr;

        }

 

        public static Template DeSerialize(string serializedTemplate)

        {

            XmlSerializer xSer = new XmlSerializer(typeof(Template));

            byte[] bytArr = ASCIIEncoding.ASCII.GetBytes(serializedTemplate);

            using(MemoryStream stream= new MemoryStream(bytArr))

            {

                return xSer.Deserialize(stream) as Template;

            }

        }

    }

}