A coders playground.

Archive for the ‘General’ Category


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.WindowWidth - 1;
            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.

AutoCompleter Tutorial - jQuery(Ajax)/PHP/MySQL

Sep 19, 2007 Author: Jamie | Filed under: CSS, Dev, General, Javascript, PHP, SQL

AutoCompleter Tutorial

As always, links to a demo and ZIP at the bottom, Enjoy!

I thought i would write this tutorial because most of the auto completer applications i have seen just dump the code into a zip and tell you how to use it rather than how and why it works, knowing about this enables you to customise it a lot more (this has been demonstrated with the other apps i have written here)!


(more…)

Miss Teen South Carolina’s Parents!

Sep 7, 2007 Author: Jamie | Filed under: General

Ha, they must be the happiest couple in the world!

MySQL Calendar - V1.2: Multilingual

Aug 24, 2007 Author: Jamie | Filed under: General

After popular demand i have added the ability to change the month names into other languages..

Here is how it is done!

Inside ‘rpc.php’ (line 45) there is an Array with month names in English…

Just change the month names to your language - keep them in the same order or it’ll make you look pretty stupid!

The download links have all been changed to the new version!

Calendar Demo

Calendar ZIP

Jamie.

My First AT&T iPhone Bill Came in a Box With 300 Pages

Aug 13, 2007 Author: Jamie | Filed under: General

I finally got my first bill from AT&T in a cardboard box containing 300 pages of it. Apparently, they give you a detail transaction of every text message sent and received. Completely unnecessary.

read more | digg story

How to learn HTML - Visual way [Pictures]

Aug 10, 2007 Author: Jamie | Filed under: General

The funniest and easiest way to learn HTML

read more | digg story

Calendar with Event Manager v1.1

Jul 23, 2007 Author: Jamie | Filed under: General

Hi everyone!

Thank you for all the comments for v1.0 of the calendar.

I have just released v1.1 which adds the missing ‘delete event’ button so everyone can administer them easily.

Here are the links :)

Calendar Demo

Calendar ZIP

Jamie.

If Architects Had To Work Like Web Designers

Jun 27, 2007 Author: Jamie | Filed under: General

Dear Mr. Architect: Please design and build me a house. I am not quite sure of what I need, so you should use your discretion. My house should have somewhere between two and forty-five bedrooms. Just make sure the plans are such that the bedrooms can be easily added or deleted…

read more | digg story

MySQL Calendar

Jun 27, 2007 Author: Jamie | Filed under: CSS, Code, Dev, General, Javascript, PHP

VERSION 1.1 RELEASED!

Changes: Added (by popular demand) Event deletion!
Ok… I have finally got this script working!

I have not done it like a tutorial because it is just too big, so here are a load of screen shots, There is a link to a fully functional demo and zip at the bottom!

A little setup information:

1. Copy the entire calendar into whatever directory you want.

2. Create your database and import the ‘databaseSQL.sql’ file into it, this will create the default data for running it.

3. Alter the ‘databaseConnection.php’ file to show your connection details.That should be it..

NOTE:By default the username and password are both ‘admin‘ (without the quotes), i suggest you change your password in the control panel.

If you have any problems i will be happy to help, just post your query as a comment to this page.

Screen Shots

Default View

(more…)

!! Holidays !!

May 31, 2007 Author: Jamie | Filed under: General

Hi Everyone!

Im heading on holiday for a couple of weeks, so any scripts i have still to complete ie: the database version of the calendar will be pushed back to when I return!

Bye!
Jamie.

Flickr PhotoStream

  • n502521777_179244_4230
  • n502521777_179243_3953
  • n502521777_179242_3670
  • n502521777_179241_3413
  • n502521777_179240_3111
  • n502521777_179239_2875

Categories


Archives


Links


Statistics

View blog authority

Meta

Advertising


2Big2Send.com