Entries from April 1, 2007 - April 30, 2007

Saturday
Apr282007

CommunityServer sucks?

I think I'm about to give up.

I've spend the last 2 weeks of my life fighting with CommunityServer, and as far as I can determine, this is a product that is NOT designed for other developers.

Lack of documentation.  Lack of up-to-date examples or explanation of the layout of the SDK means that a typical developer spends weeks and weeks in the dark about where things are.

Forums are completely useless - with questions and answers relating to older versions that doesn't apply.

If you are after a good Blog/Forum/CMS software, look elsewhere.
Tuesday
Apr242007

Posting with Windows Live Writer (beta)

So far so good, I like the very clean looking interface. 

It also makes posting pictures a lot easier (at least for me).

Here's a sketch of a evil warlock in tier 6 gear spamming ggcoil.

Technorati tags: ,

Tuesday
Apr172007

AJAX, Tooltip, World of Warcraft (WoW)

Spend a whole day trying to work around a simple issue.
I give myself one html page.  No server side code.
Write a javascript/css based approach to pull data from either Thottbot or Allakhazam and return the data, then render it as a popup.

The AJAX isn't hard, nor is the pop-up page, the problem lies in the "no server side code".

Both IE and FireFox don't like to make XMLHttpRequest cross-domain.  That is, it doesn't like being hosted on a http://localhost/test.html or even file host file:///test.html, making a request to thottbot.com.
On IE, you get a security question pop'up everytime you try to make such a call.  If the user clicks "OK", he'd be let through.
On FireFox, it's automatically denied unless you try to obtain UniversalBrowserRead privilege.  Extremely difficult and potentially a security loophole.

The solution seems bleak.

Use AJAX to query the origin server - without making a cross-domain call.  But use the server to make the 'translation' - possibly caching as well.

Monday
Apr162007

Be serious with the Lord

I got quite a bit out of brother Ron's memorial service. Although there was a strong sense of loss, I am extremely glad he has finished his course and ran his race. Now he can finally rest in the Lord and pray for the Lord's coming and our overcoming.
  • be a proper person
  • have a living that can match our desire to be useful
  • turn to my spirit quickly
  • don't missing the gatherings
Wednesday
Apr112007

Generics, Casting and Anonymous Delegates and the Where clause

I have a situation where the code looks like:

( ( TextBox ) ( _someParentControl.FindControl( "_childControlId" ) ) ).Text = "SomeText";
( ( TextBox ) ( _someParentControl.FindControl( "_childControlId" ) ) ).Enabled = someBool;

repeat about 10 times with different child control type, parent controls, child Ids, and properties.
obviously, there's a similarity and refactoring was in order.

private static void ExecuteOnControl<T>( WebControl parent, string id, Action<T> action) where T : WebControl
{
    T control = parent.FindControl( id ) as T;
    if (control != null && action != null)
    {
        action( control );
    }
}


The where clause is important because you can't cast "As" within the function without having some limits on the generc T.

Which allowed me to shrink the example down to:
ExecuteOnControl<TextBox>(_parentControl, "_childControlId", delegate(TextBox tb) { tb.Text = "someText"; });

This can be further simplified since the delegate can be declared once and used later.
Action<TextBox> tbDel = delegate(TextBox tb) { tb.Text = "someText"; };
ExecuteOnControl<TextBox>(_parentControl, "_childControlId1", tbDel);
ExecuteOnControl<TextBox>(_parentControl, "_childControlId2", tbDel);


One can argue here that the new code isn't really that much more readable though, but it was good hacking
Tuesday
Apr102007

10 April 2007

Write a GreeseMonkey filter for the new wow forums.

  1. kill list
  2. space
  3. hide signature
  4. work-safe
Wednesday
Apr042007

I'll see you again, brother Ron.

A small tribute to brother Ron Topsom.

On Monday (April 2th 2007) afternoon, I lost a brother and a friend.  Ron Topsom was someone that looked after me as I went through a troubled university life (I was always a good kid, but my life went upside down due to events outside of my control).  He made sure that I at least keep turning to the Lord Jesus as well as fellowshipped with me concerning many practical things regarding my personal living with Christ, my studies as a christian, and even working as a single-working believer to be a testimony at work.

In the last few years he has been ill, but it was always good to see him strengthened by the Lord and keep going on.  Sadly, he went to be with the Lord on last Monday.

I miss him already.  I wish I had more time for more fellowship.  It's such a shame, I never have enough time for everything I wanted to do.  I pray when it's my time to go to be with the Lord, I won't have the regret that I have right now.

Thank you Lord for such a pattern of a proper christian.
Monday
Apr022007

2 April 2007

Determination.
I'm determined to get my unit of work completely finished by today and hand it in for review.  It is a very big unit and I don't know when the review will come back.  But it's dragged on for quite a while and needs a suitable conclusion.
My poor wife will probably see me very late tonight.
Monday
Apr022007

Get it and Do something with it.

I wrote a much better version of the Get & Do that I'm happy with.  Here's the code below.



// Using this:

private void Form1_Load(object sender, EventArgs e)

{

    new Get<Control>(this.button1, this.button2, this.button3, this.button4)

        .Do(delegate(Control c) { c.Enabled = false; return c; })

        .Do(delegate(Control c) { c.BackColor = Color.Red; return c; });



    new Get<Control>(this.Controls)

        .Do(delegate(Control c) { c.Visible = false; return c; });

}



// The Get class below.

using System.Collections;

using System.Collections.Generic;

namespace GetAndDo
{
    /// <summary>
    /// Get something we want
    /// </summary>
    /// <typeparam name="T"></typeparam>
    class Get<T>
    {
        public List<T> objects;

        /// <summary>
        /// Create a Get wrapper around something we want
        /// </summary>
        /// <param name="getObjs">param array of stuff</param>
        /// <remarks>
        /// Try to design the constructor to be functional and readable.
        /// </remarks>
        public Get(params object[] getObjs)
        {
            objects = new List<T>();
            foreach (object obj in getObjs)
            {
                if (obj is IEnumerable<T>)
                {
                    objects.AddRange((IEnumerable<T>)obj);
                    continue;
                }
                if (obj is IEnumerable)
                {
                    foreach (object obj1 in (IEnumerable)obj)
                    {
                        if (obj1 is T)
                        {
                            objects.Add((T)obj1);
                        }
                    }
                }
                if (obj is T)
                {
                    objects.Add((T)obj);
                }
            }
        }

        /// <summary>
        /// Signature of a delegate for any actions
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>
        /// null - filter from result set (filter-operation)
        /// true - include obj in result set
        /// T - include new object in result set (map-operation)
        /// IEnumerable - useful for nesting deep
        /// </returns>
        public delegate object Action(T obj);

        /// <summary>
        /// Run delegate on each element in the current Get wrapper
        /// </summary>
        /// <param name="action">delegate to run</param>
        /// <returns>
        /// New Get wrapper - does not modify original wrapper.
        /// This allows chaining of delegates
        /// </returns>
        public Get<T> Do(Action action)
        {
            List<T> newObjects = new List<T>();
            for (int i = 0; i < objects.Count; i++)
            {
                object result = action(objects[i]);
                if (result == null)
                {
                    continue;
                }
                if (result is T)
                {
                    newObjects.Add((T)result);
                    continue;
                }
                if (result is IEnumerable<T>)
                {
                    newObjects.AddRange((IEnumerable<T>)result);
                }
                if (result is IEnumerable)
                {
                    foreach (object obj1 in (IEnumerable)result)
                    {
                        if (obj1 is T)
                        {
                            objects.Add((T)obj1);
                        }
                    }
                }
                if (true.Equals(result))
                {
                    newObjects.Add(objects[i]);
                    continue;
                }
            }
            return new Get<T>(newObjects.ToArray());
        }
    }
}



Monday
Apr022007

Using ForEach and Anonymous Delegates.

//a piece of testing code, I think there's plenty more work to do.
private void Form1_Load(object sender, EventArgs e)
{
new List<Control>(new Control[] { this.button1, this.button2, this.button3, this.button4 }).ForEach(delegate(Control c) { c.Enabled = false; });
}