Code Example

I was doing some thinking the last month or so about how I didnt appreciate the tools and freedoms that Half-Life 2 provided me with. Something about working in CPP made my abilites as a coder quite free and open. I felt so much more challenged and thus motivated to push through and achieve things that were seemingly impossible. 

This last week we had a challenge, write an application that uses as few variables as possible in MASM Assembly that is able to calculate the day of the week that we were born, and as such, allow us to calculate the day of the week that any date provided is. 

Below you will find my solution…

Continue reading “Code Example”

Code Example #6 – UT3 Logging Essentials

Below is the library that my team and I use for our UT3 Development. Please feel free to enjoy as well.

All you have to do is include the uci file

`include ({PackageName}/Classes/LibraryMessage.uci)

LibraryMessage.uci

// Macros for easy calling of Library_Message functions.

`define GetObjectMethodPrefix() self $ "." $ GetFuncName() $ ": "

`define ClientMessage(message) class'LibraryMessage'.static.ClientMessage(self, `message)
`define DebugMessage(message) class'LibraryMessage'.static.DebugMessage(self, `GetObjectMethodPrefix() $ `message)
`define LogMessage(message) class'LibraryMessage'.static.LogMessage(`GetObjectMethodPrefix() $ `message)

Continue reading “Code Example #6 – UT3 Logging Essentials”

Code Example #4 – MSSQL Tests

This week I am working on extending an application that takes advantage of the MSSQL servers that proliferate my company. I am writing a number of changes, altering, creating and dropping tables, and unfortunately – the scripts have to be executed a number of times. This poses a simple challenge. I don’t want to be executing SQL that has already been executed on a previous run, so I have had to get creative in my queries in order to avoid this overlap. Below are a few of the tests that I am using.

Does a table exist?
Does a table not exist?
Does a stored procedure exist?
Does a table have a field already?

This week I am working on extending an application that takes advantage of the MSSQL servers that proliferate my company. I am writing a number of changes, altering, creating and dropping tables, and unfortunately – the scripts have to be executed a number of times. This poses a simple challenge. I don’t want to be executing SQL that has already been executed on a previous run, so I have had to get creative in my queries in order to avoid this overlap. Below are a few of the tests that I am using.

Continue reading “Code Example #4 – MSSQL Tests”

Code Example #2 – Super Cool Alignment Classes!


Todays code example is really more of a fluke. I have always found myself trying to write interchangable and easily updatable html and found that since i moved to CSS that is more of a challenge. Instead of trying to write different classes that would handle everything you need and trying to make them very specific you can break things down into simpler forms.

.align-center
{
   text-align: center;
}
.align-left
{
   text-align: left;
}
.align-right
{
   text-align: right;
}

and you use them as follows:

Code Example #1 – Per File Execution Testing

In my projects i often come across or up with cute pieces of code that i think may be interesting to others. Instead of hoarding i will be posting them (possibly in sub pieces) so you can take part in the fun.

Todays Fragment: Per File Execution Testing

You can use this piece of code to test the file being executed and perform unit testing or output debug information as necessary. It can also, as is being used here, be used to redirect the user away from executing this page.

if ($_SERVER['SCRIPT_FILENAME'] == __FILE__)
{
    header('Location: http://gneupaste.gneu.org/');
    exit;
}

I dont think the exit is entirely necessary, but it may be dependent upon the server’s configuration.

Bad Code

I have some serious issues with what I am about to say, but please bear with me.

Development is as much an art, as much a science, as much a skilled and science driven thing, as air is fun to breathe. Sometimes I get energetic about being able to expand my rib cage and feel the cool air flowing through into my lungs, helping me expand them more, and I continue expanding until I cannot quite expand them any more and I sit. I stretch out my rib cage, allowing my muscles to wonder when they are going to receive their oxygen and close my eyes. It is a lot like holding my breath, only I am not intending to turn blue.

Continue reading “Bad Code”