A coders playground.

Archive for November, 2007


Don’t Give Up on Vista

Nov 21, 2007 Author: Jamie | Filed under: Apple, Humor

Saw this on the top if digg.com

Dont you just love the way Apple pokes at fun at Microsoft!

CSSEdit – funny!

Nov 14, 2007 Author: Jamie | Filed under: CSS, General, Humor

Some of you may not know, but CSS Edit is a Mac only CSS Editor from Mac Rabbit

Anyways – if you have a look at the new Icon (hi-res for OS X Leopard) it reveals a funny comment!

Look at the bottom left corner if you dont understand!

Matrix Code in C#

Nov 9, 2007 Author: Jamie | Filed under: General

Hi,

I found some code earlier which creates a Matrix Code style display in the Command Prompt, pretty cool if you are into that sorta thing.

Thanks goes out to Nifke over at http://blogs.ict-blue.be/nifke/2007/11/09/teh-m7tr1x/

Anyways, i copied the code into Visual Studio creating a Console Application and it didnt work, so i tweaked it a little:

Here is the updated code:

using System;

namespace m7tr1x
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "tH3 M7tr1x 3ff3";
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WindowLeft = Console.WindowTop = 0;
            Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
            Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

#if readkey
            Console.WriteLine("H1T 7NY K3Y T0 C0NT1NU3 =/");
            Console.ReadKey();
#endif

            Console.CursorVisible = false;
            int width, height;
            int[] y;
            int[] l;
            Initialize(out width, out height, out y, out l);
            int ms;

            while (true)
            {
                DateTime t1 = DateTime.Now;
                MatrixStep(width, height, y, l);
                ms = 10(int)((TimeSpan)(DateTime.Now – t1)).TotalMilliseconds;

                if (ms > 0)
                    System.Threading.Thread.Sleep(ms);

                if (Console.KeyAvailable)
                    if (Console.ReadKey().Key == ConsoleKey.F5)
                        Initialize(out width, out height, out y, out l);
            }
        }

static bool thistime = false;

private static void MatrixStep(int width, int height, int[] y, int[] l)
        {
            int x;
            thistime = !thistime;

            for (x = 0; x < width; ++x)
            {
                if (x % 11 == 10)
                {
                    if (!thistime)
                        continue;

                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.SetCursorPosition(x, inBoxY(y[x]2(l[x] / 40 * 2), height));
                    Console.Write(R);
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                Console.SetCursorPosition(x, y[x]);
                Console.Write(R);
                y[x] = inBoxY(y[x] + 1, height);
                Console.SetCursorPosition(x, inBoxY(y[x] – l[x], height));
                Console.Write(‘ ‘);
            }
        }

private static void Initialize(out int width, out int height, out int[] y, out int[] l)
        {
            int h1;
            int h2 = (h1 = (height = Console.WindowHeight) / 2) / 2;
            width = Console.WindowWidth1;
            y = new int[width];
            l = new int[width];
            int x;
            Console.Clear();
            for (x = 0; x < width; ++x)
            {
                y[x] = r.Next(height);
                l[x] = r.Next(h2 * ((x % 11 != 10) ? 2 : 1), h1 * ((x % 11 != 10) ? 2 : 1));
            }
        }

static Random r = new Random();

        static char R
        {
            get
            {
                int t = r.Next(10);
                if (t <= 2)
                    return (char)(‘0′ + r.Next(10));
                else if (t <= 4)
                    return (char)(‘a’ + r.Next(27));
                else if (t <= 6)
                    return (char)(‘A’ + r.Next(27));
                else
                    return (char)(r.Next(32, 255));
            }
        }

public static int inBoxY(int n, int height)
        {
            n = n % height;
            if (n < 0)
                return n + height;
            else
                return n;
        }
    }
}

Enjoy!

Screenshot :)

Here is a link to the app.

MatrixCode.exe

Jamie McConnell and/or Nodstrum.com cannot be held responsible for any dataloss or corruption from running this program. The source code provided is exactly what was compiled.

Categories


Archives


Links


Statistics

View blog authority

Meta

Advertising