A coders playground.

Archive for the ‘General’ Category


This will mess with your head!

Jul 21, 2008 Author: Jamie | Filed under: General

Ever had a good look at the FedEx Logo?? I guarantee you won’t see it the same again after mousing over the logo below.

Put your mouse over the logo below.

FedEx Logo

See the Arrow?? Now enjoy haveing your eyes always trying to focus on it in the future.

Sorry :)

Jamie.

Shorthand PHP IF/ELSE Statements = much shorter code!

Feb 14, 2008 Author: Jamie | Filed under: Code, General, PHP

You may or may not have heard of shorthand if/else statements, but they do exist, and trust me they make things SO much more ordered in your code when used in the right way.

This is the Shorthand version - below this, if you cannot work it out for yourself is a nice description.

    // Will print out ‘i am male’ if $myGender is ‘male’ and vice-versa.
    echo ($myGender == ‘male’ ? ‘i am male’ : ‘I am female’);

Description of how this actually works
We all (i would hope) know the normal way of writing if/else statements (here is a recap just incase)

$myVar = true;
if($myVar) {
    echo ‘My Var is TRUE!’;
} else {
    echo ‘My Var is FALSE’;
}

That sort of statement is great for in the body of your code, but when want a dynamic selector within your HTML code, it gets very messy.

EG:

if($myGender == ‘male’) {
    // Gender is MALE.
    $maleOpt = ’selected’;
    $femaleOpt = ;
} else {
    // Gender is FEMALE.
    $maleOpt = ;
    $femaleOpt = ’selected’;
}
<select name="gender"><
option value="female" <?= $femaleOpt; ?>>Female</option>
<option value="male" <?= $maleOpt; ?>>Male</option>
</select>
 

Now - that is alot to write and will make your HTML form look a total mess, this is where the shorthand comes in. It allows us to write the same thing inline

Look:

<select name="gender">
<option value="female" <?= ($myGender == ‘female’ ? ’selected’ : ”); ?>>Female</option>
<option value="male" <?= ($myGender == ‘male’ ? ’selected’ : ”); ?>>Male</option>
</select>
 

As you can see - there is a huge difference in the amount of code - and if Wordpress formatted it nicely - it would look loads better!

And the all important Explanation!

// This will echo selected to the screen if $myGender is male.
echo ($myGender = ‘male’ ? ‘ selected’ : );
 

So - $myGender is the variable we are checking, in this case we are checking to see if $myGender == ‘male’

The questionmark (?) seperates the ‘answers’.

The first ‘answer’ is what is set/displayed when the query is true, the second is if the query is false.

This is the equilivent to :

if($myGender == ‘male’) {
    echo ’selected’;
} else {
    echo ;
}

Hope that helps some of you out!

Halo 2 - High ALtitude Object

Jan 28, 2008 Author: Jamie | Filed under: General

The Halo 2 (High ALtitude Object) Project is an amazing read: http://www.natrium42.com/halo/flight2/

My project launched a payload with GPS, camera, sensors and communications to an altitude of 30km. I obtained most parts ready years ago, but only recently had time to finish it.
High altitude ballooning is an emerging hobby, since price of GPS and communications equipment has gotten quite low. It is an excellent hobby for people fascinated by space flight and telerobotics and has many learning aspects — from systems design to electronics design to software engineering. There is also an exciting risk factor, namely, that you could lose your precious electronics if something malfunctions. In this project, many of my interest and knowledge areas came together. Also, I have verified that the Earth is indeed round and that space is black.
 

2Big2Send - Nearing Full Beta - Need Users Now :)

Jan 22, 2008 Author: Jamie | Filed under: 2Big2Send, General

Hi Everyone,

Thank you for coming along to Nodstrum, I am taking this opportunity to invite you all to signup to my new Web App 2Big2Send.

Our service allows you to send large files to anybody with an email address without clogging up their inbox or risking waiting for the file to send then have it bounce back, never a nice thing!

The system allows you to see the upload progress and will notify you when you file has been collected.

During this Beta period we are offering you the following:

  • 100MB 250Mb Storage
  • 10 Downloads per file
  • Unlimited sends per month
  • File expire after 5 days
  • File delivery/collection notification
  • Desktop Client (Coming very soon)
  • Preview most uploaded images

We will most likely up the storage so you are able to send and store much larger files during this period, this depends on the number of users who signup - the more users, the more space you will get.

So! if you are interested, head over to http://2Big2Send.com and signup!

Thanks!

University = Finished, Done & Dusted!

Jan 21, 2008 Author: Jamie | Filed under: General, University

Today i finally finished University at Oxford Brookes!

Somehow i came out with a 2:1 (Upper Second Class Honours) in Computer Science! I cannot convey how much of a cloud it is off my head!!

It also proves that you can do a dissertation in 2 months get a B+ in it and come out on top :)

Job Posting: Webmaster for charity.

Jan 9, 2008 Author: Jamie | Filed under: General, Portfolio

Hi everyone,
I have been the webmaster/ developer for the Northern Irish charity MT4Uth for 3 years but I now have a full time job and therfore do not have enough time to dedicate to the website.

The website is coded in PHP/ HTML with a MySQL backed database.

There is a custom CMS on the main website - nothing difficult, your typical page editing/news script.

There is a custom portal which utilizes the Prototype/Scriptaculolous Javascript libraries.

The website needs less than an a few hours per month as it is in a very useable state.

The all important URL is: http://www.mt4uth.com

If you are interested in this freelace job or would like more information, please post a comment below and I will asset your queries as best as possible.

Jamie.

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.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!

Flickr PhotoStream

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

Categories


Archives


Links


Statistics

  • 4 Users Online
View blog authority

Meta

Advertising


2Big2Send.com

Recent Comments