Sep 19
PDT (PHP Development Tools) in Eclipse
icon1 Mikkel Meyer Andersen | icon4 September 19, 2007 at 15:33 (UTC) | icon3 No Comments »
icon3

I've actually never used Eclipse before. I've had it installed, but never used it in a production. Not until today at least. I've heard a lot of good things about Eclipse, so when I  read that a new PHP-development plug-in for Eclipse was released, I simply had to try it.

Having used it for just a couple of hours I'm still impressed and smiling! I'm really surprised - well, I think it's both because I had no expectations at all and because it's actually a good product!

I installed it in Eclipse by performing these steps:

  1.  Install Eclipse
  2. Open it
  3. Help -> Software Updates -> Find and Install...
  4. "Search for new features..."
  5. New Remote Site with http://update.phpeclipse.net/update/nightly as URL
  6. Finish and install all the PDT-components
  7. Restart Eclipse
  8. Window -> Open Perspective -> Other
  9. Select PHP

As far as I remember that was all! Nice and easy!

Now the next step ought to be to find out whether C-development in Eclipse is as enjoying as well :-)

Jul 4
Not null or not null or...
icon1 Mikkel Meyer Andersen | icon4 July 4, 2007 at 22:13 (UTC) | icon3 No Comments »
icon3

Excuse me for publishing such a shot post (it's now the last one, so please don't feel too annoyed), but this little nice thing in C# can be nice to know:

1
2
3
string a = null;
string b = "hello";
string c = a ?? b; // c equals "hello"

In other words, it returns the first argument that is not null.

May 5
Thread safe queue
icon1 Mikkel Meyer Andersen | icon4 May 5, 2007 at 18:21 (UTC) | icon3 No Comments »
icon3

It's often quite nice to have a blocking queue (thread safe queue) - how many times haven't you used the producer/consumer-pattern? Because we're lazy we make one class we can use every time (long live recycling) instead of making that blocking mechanism implicit in out program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Threading;
using System.Collections.Generic;
 
namespace Scienco
{
    class ThreadSafeQueue<T> 
        where T : class
    {
        private Queue<T> mQueue; 
        private Semaphore mSemaphore;
 
        public ThreadSafeQueue()
        {
            mQueue = new Queue<T>();
            mSemaphore = new Semaphore(0, int.MaxValue);
        }
 
        public void Enqueue(T element)
        {
            if (element == null)
            {
                throw new ArgumentNullException();
            }
 
            lock (this.mQueue) 
            {
                this.mQueue.Enqueue(element);
            }
 
            this.mSemaphore.Release();
        }
 
        public T Dequeue()
        {
            this.mSemaphore.WaitOne();
 
            lock (this.mQueue)
            {
                if (this.mQueue.Count > 0)
                {
                    return this.mQueue.Dequeue();
                }
 
                else
                {
                    return null;
                }
            }
        }
    }
}

You probably don't like my coding-style in some way ({, mQueue or whatever) - please feel free to follow whatever guidelines rocking your world.

Next Entries »