The Infinite Loop – Beginner's SEO, Beginner C# & JQuery Tutorials Problem. Problem Solved. Loop. – The life of a programmer

17Aug/110

Automatic Get/Set Visual C# 2010

One of my favorite features of c#. Automatic getters/setters!

Before, one would have to declare a variable.

private int _x;
And then write get/set methods:

public int X{
get{return _x;}
set{x=value;}
}

However, in VISUAL C# 2010 - you can now do the following:
public int X{get;set;} Which is the same as the code above!

Note: If you want to wrap any validation or anything around the get/set you will still need to write out the full get/set. However, for quick variables that require no extra work - the automatic get/set is a lifesaver! (or timesaver - if you're life is not in danger...whichever you prefer)

Filed under: C#, General No Comments
20Jun/110

C#/PHP Database Object Generator/Database Access Layer Generator

This is something i have been working on.
It is virtually a tool I use to generate c#/php classes based on a database schema.
The c#/SQL integration works well, however, I am still working to support the php/mysql generation.

It creates very simple base C# classes based on a database connection. The program includes Saving Generation profiles and reloading them at a later time. It has a recently loaded profiles list - and allows you to regenerate the DAO as many times as you like.

By using this C# Database Object Generator/Database Access Layer Creation Tool I can focus on my application development as opposed to my DAL (data access layer) development.

This piece of software is currently in beta - and I am the only beta tester! :)

If you would like the installer - you can send me an email and I can send you a copy.

Here are some screenshots and some example usage!


And example usage of the classes generated by the c# database object generator tool. Note - the class HeroBase was from the generation files.

public HeroBase GetHeroById(int id)
{

SqlConnection conn = serv.GetConnection();
try
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM hero WHERE hero_id="+id;
cmd.Connection = conn;
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
HeroBase h = HeroFromReaderRow(rdr);
if (h != null)
return h;
}
}
catch (Exception ex)
{
throw new Exception("Could not load Heros " + ex.Message);
}
finally
{
conn.Close();
}
return null;
}

public HeroBase HeroFromReaderRow(SqlDataReader rdr)
{
if (rdr == null)
return null;

HeroBase h = new HeroBase();
h.HeroId = Convert.ToInt32(rdr["hero_id"]);
h.HeroName = rdr["hero_name"].ToString();
h.HeroDescription = rdr["hero_description"].ToString();
h.HeroType = rdr["hero_type"].ToString();
h.ImageFile = rdr["image_file"].ToString();
h.ModelFile = rdr["model_file"].ToString();
h.BaseAutoAttackLow = Convert.ToInt32(rdr["base_auto_attack_low"]);
h.BaseAutoAttackHigh = Convert.ToInt32(rdr["base_auto_attack_high"]);
h.BaseMovementSpeed = Convert.ToInt32(rdr["base_movement_speed"]);
h.Premium = Convert.ToBoolean(rdr["premium"]);
h.Concentration = Convert.ToInt32(rdr["concentration"]);
h.ModelRotation = Convert.ToDouble(rdr["model_rotation"]);
h.ModelScale = Convert.ToDouble(rdr["model_scale"]);
h.Active = Convert.ToBoolean(rdr["active"]);
return h;

}

The reason the classes are affixed with the 'Base' word, is because this allows for the extension of these classes. HeroBase is the database version of the class - which includes base_hp, base_energy, base_movement_speed etc etc, however, an actual hero in a game will have much more than this (hp timers, energy/mana timers, current hp, current energy) - the naming of the classes allows for you to easily extend them.

For example:

public class Hero:HeroBase(){
public Hero():base(){
CurrentHP=MaxHP;
}
public int CurrentHP{get;set;}
}

I have classes created named service.
E.g HeroService - this service has necessary methods for loading heroes from the database. This service returns objects of the Hero/HeroBase type.

All in all - it saves me a ton of time and I am glad Ive written this tool. Please comment if you have any interest in it - as I would like to gauge interest before I invest more of my time into refining it. As it sits now - it is perfect for my side project development, however, if there is enough interest - I am more than willing to improve it :)

Filed under: General No Comments
20Jun/110

Beginner Game programming jobs in Toronto

Well, it seems to me that finding a game programming job in Toronto is going to be pretty hard.
I have used XNA and am currently working on a small c#/xna based engine for a game.
Currently I have the following, none of which are graphical (except for the heroes with a small chase camera):

Heroes (Health, HP regen, Energy Regen, Attacking Mechanisms, Defense Mechanisms)
Hero Abilities
Hero Stats
Creep Waves (CreepEngine class responsible for spawning waves and keeping track of wave timers etc)

and am currently working on a few mechanics - like stealing gold etc.
I guess Im just doing this to kill time and practice coding a game engine, but hopefully it gets to a point where it could be useful to someone.

It seems breaking into the game programming industry will be harder than I thought - teachers in college often discouraged me from it - saying it was a hard industry with tight deadlines etc etc...but what can be more fun than MAKING GAMES?!

:) There will be a point in time where I know that programming business apps will no longer do it for me - and thats when I want to switch over to game programming. Call it a midlife crisis (at 22 years old) - but I am passionate about it! It seems that most video game companies already want a ton of experience in the game industry - how can someone get that experience if no one in the industry will hire?

Its nuts.
3years with an advanced college diploma - and its not enough.
Everyone wants a bachelors degree in comp sci - because having the money to pay your way through university and being in debt is somehow a sign that your dedicated. I will continue working on my little demo - it wont be easy and it will take a while but, I will get there.

Is anyone in the same situation as me?
Does anyone feel helpless with this whole video game industry?

Its such a big industry - I don't even know where to start (Sure, I can go to a game programming school for $15,000/yr) - but life isnt a crystal staircase and I have bills to pay).

Any tips, inside knowledge etc, is highly appreciated - [b]comment if you'd like please!!! :) [/b]

Filed under: General No Comments
25Nov/100

HostGator 2010 Black Friday Sale Special 50-80% off hosting!

Discounted hosting has never been better!
As a hostgator affiliate I get emails and notices about their specials. And this one blew my mind.

One day only 50-80% off!!

Now - let me be perfectly frank - I am an affiliate and do make commissions off referrals - but come on 80% off hosting for 3 years? Thats awesome any way you slice it. (horizontal, vertical, or diagonal). But, even if I didn't make any commission referring - i would still HIGHLY recommend them. Their live support chat always gets 10 ratings from me across the board!

Here is an excerpt from my affiliate email (we're obviously refers to hostgator) :) :

We're offering 50% OFF EVERYTHING From 12:00AM CST – 5AM CST (11am EST - 4am EST)

We're offering 80% OFF EVERYTHING From 5AM – 9AM CST (4am EST - 9am EST) WHILE SUPPLIES LAST (first come, first receive; so definitely don't miss out!)

From 9AM – 11:59PM CST (8am-10:59pm) OR after 80% OFF accounts have sold out, we will continue to offer 50% OFF EVERYTHING

This applies to ALL Accounts and ALL Term Lengths. So you're visitors and friends will have the opportunity to receive up to 80% off of up to 3 years worth of Hosting! That would come out to $35.64 for 3 FULL YEARS!

And - The links you have all been waiting for:
(Feel free to use hostgator.com if you do not want me to get commission on your referral)





ENJOY!!!! :)
Theyve treated me really well - and they will treat you just as well.

29May/1013

Paging in PHP – PHP Paging Tutorial

PHP Paging & Automatic Pagination Tutorial - Paging made easy

I have written a php paging tutorial before. Admittedly, it wasn't the greatest. I don't think I was as clear as I wanted to be. SO I'm trying again. :) At the end of this tutorial, there is a file named php-automatic-pagination.php.txt
Please download it! It will help you understand the following.

Here is what we will be making..nice, simple pagers! (Dont worry about the Image #x text, thats really not part of the tutorial)
PHP Automatic Pagination/Simple PHP Paging Tutorial

Paging in php and automatic pagination is something every coder has to deal with when coding in php. I mean, you COULD show all results on 1 page and skip the php paging, but paging is necessary to reduce bandwidth and organize content. Paging is very easy to do and I will walk you through it step by step.

PHP automatic paging comes with a few questions:
Paging 1 : Page Size - How many results would you like to display per page?
Paging 2 : How can we bring back proper results in mysql?
Paging 3 : How can we print a pager that will help show the next items.

Decide on your page size - 10, 15, 25, 50, 100. It really depends on what you would like to do. For this tutorial I will use 15.

//we want 15 results per page

$pgsize=15;

//if there is a p variable in the query string e.g: page.php?p=5 we will get this value, else we will use 1 (page 1)

$pg=(is_numeric($_GET["p"]) ? $_GET["p"] : 1);

//lets determine where we would like to get results from
//if $pg is 1, this calculation results in 0 (we want to start from the first record in the database)
//if $pg is 2, this calculation will result in 1*15..which means we will start at the 15th index of the database (row 16)

$start=($pg-1)*$pgsize;

//let us query the database for our results
//you will notice LIMIT and $start and $pgsize.
//On page 1, this query will be SELECT * FROM image_table LIMIT 0,15 - this means return 15 rows starting at row-index 0 (row 1)
//On page 2, this query will be SELECT * FROM image_table LIMIT 15, 15 - this means we will return 15 rows starting at row-index 15 (row 16)
//On page 3, this query will be SELECT * FROM image_table LIMIT 30,15 - this means we will return 15 rows starting at row-index 30 (row 31)
GET IT?!?!?!

$imgs=mysql_query("SELECT * FROM image_table LIMIT $start, $pgsize");

//we will also need the total number of records in our table
//notice there is no limit? we want to know how many records are in the entire table!
//we can use COUNT(*), COUNT(1), or COUNT(fieldname), they will all return the same result

$img_total=mysql_query("SELECT COUNT(1) FROM image_table");

//mysql_query returns a resource id, we can use this to get the row it has returned

$img_total=mysql_fetch_row($img_total);

//the count will be the first field in this row

$img_total=$img_total[0];

//lets determine how many pages we will need
//WRONG!, this will cut off results..why?
//say we have 31 images, and our page size is 15. 31/15= ~2.x...We need to round this result up!

$max_pages=$img_total / $pgsize;

//use this line instead

$max_pages=ceil($img_total/$pgsize);

Once we have all this information, we can use a handy little function I have written named printPager. This function will print out a neat little pager. It uses a helper function named add_querystring_var which was from Added Bytes here:
http://www.addedbytes.com/code/querystring-functions/

Copy/paste this function into your page or into one of your includes:
This will print out your awesome little pager! :)

PHP Automatic Pagination Function

function printPager($max_pages,$pg){
print '<div class="clear"></div>';
print '<ul class="pager">';
$i=1;
if($pg!=1){
$url=$_SERVER["SCRIPT_NAME"];
$url.=add_querystring_var("?".$_SERVER["QUERY_STRING"], "p", $pg-1);
print '<li class="prev"><a href="'.$url.'"><<</a></li>';
}

while($i<=$max_pages){
$url=$_SERVER["SCRIPT_NAME"];
$url.=add_querystring_var("?".$_SERVER["QUERY_STRING"], "p", $i);

if($pg==$i){
print '<li class="current">';
print '<span>'.$i.'</span>';
print "</li>";
}else{
print "<li>";
print '<a href="'.$url.'">'.$i.'</a>';
print "</li>";
}

$i++;
}

if($pg!=$max_pages){
$url=$_SERVER["SCRIPT_NAME"];
$url.=add_querystring_var("?".$_SERVER["QUERY_STRING"], "p", $pg+1);
print '<li class="next"><a href="'.$url.'">>></a>';
}
print '</ul>';
print '<div class="clear"></div>';
}

function add_querystring_var($url, $key, $value) { $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); $url = substr($url, 0, -1); if (strpos($url, '?') === false) { return ($url . '?' . $key . '=' . $value); } else { return ($url . '&' . $key . '=' . $value); } }

Print Pager is called like so:

PHP Pager Styles

We can style this pager using the following:
/*pagers*/

div.clear{clear:both;}
/spacing between numbers and sizes
ul.pager li {
float:left;
margin-right:5px;
font-size:8pt;
padding: 2px 5px 2px 5px;
}

//link color
ul.pager li a{
color:red;
}

//link hover style
ul.pager li a:hover{
text-decoration:underline;
color:red;
}

//current page styling
ul.pager li.current span{
color:red;
}

//previous and next stylings
ul.pager li.prev, ul.pager li.next{

}

Download this tutorials script! It will help you understand. Right click: php-automatic-pagination-tutorial.php and click Save as. Then get rid of the .txt extension and name it php if you would like to run it. You will need to setup a database table to use for the tutorial. It can have an id field and another field.

If you enjoyed this post please leave a comment! I like reading and responding to all my readers!
Thanks


Use HostGator 2010 Coupon Code: 994offhgpackage for $9.94 off your first month!
(First month will cost $0.01)

24May/100

HostGator Discount Code 2010 – Cheap Web Hosting

By far one of the best hosting companies I have had the experience of being a customer of is HostGator. Their prices are extremely affordable and their customer support is SUPERB. I have never had a web hosting company with the technical expertise and patience of the live support chat. They always answer questions and help configure servers. I have had live support chat agents sit there patiently and wait for me to re-test my site after their changes.

Our programming company uses HostGator to host all of our sites - they have shared web hosting, reseller accounts, and others.
They offer UNLIMITED disk space hosting (250,000 files maximum ...100,000 if you intend to use the auto-backup feature) and
UNLIMITED bandwidth and are just the best hosting company i have ever had the pleasure of working with.

Use one of these HostGator 2010 coupon codes to receive $9.94 off your first month!

HostGator Discount Coupons/Promo Codes:

HostGator 2010 coupon/promo code 1: 994offhgpackage
HostGator 2010 coupon/promo code 2: 2010hostgatorcoupon
HostGator 2010 coupon/promo code 3: hostgatorcoupon2010
With the "BABY" plan for 1 month this means you pay $0.01 for 1 month hosting!

22May/100

ING Direct Orange Key 2010

Using this ING Direct 2010 orange key: 17190811S1 you and I will receive a $25 each when you deposit a minimum of $100 to start your account!

Who doesn't like free money? :) Enjoy

21May/103

Hide Google Custom Search Engine (CSE) Textbox

There doesn't seem to be any articles on this, so I will try to save you time by letting you know. Using firebug, we can inspect the textbox element to see it is a form with the class .gsc-search-box.

To hide the search box simply add this to your css:

.gsc-search-box {
display:none;
}

24Apr/102

How To Remove Viruses and Spyware Manually

Remove Viruses and Spyware Manually

Viruses,spyware, malware - whatever you want to call it, these things wreak havoc on your computer. Browser hijacks, file deletion, disabling ctrl+alt+delete are just a few things that some of these baddies can do. However, there are some tools to help you remove viruses and spyware manually.

Preventing Viruses and Spyware

Prevention is the best medicine. I'm sure you've heard something like that before but its true. Knowing about how to prevent spyware goes a long way. There are many programs that offer virus+spyware/malware protection and they will monitor your computer for changes to  your registry and files. I recommend the following programs for spyware/malware protection and scans.

Spyware Search & Destroy (Spybot S&D)

Ad-aware SE (Free for personal use)

Malware Bytes

Steps To Remove Viruses and Spyware Manually

  1. Download and Update 1 of the above software (or all 3! [recommended])
  2. Perform scans - Use the above programs to perform viruses, spyware, and adware scans. This is usually the initial step in removal as it will remove most of the spyware/adware/malware on your computer.  I recommend using safe mode to do these scans. In safe mode, your computer does not load extra applications and drivers, only the bare minimum need to run  your operating system, so these programs will have an easier time removing/deleting files from these viruses. There are different ways to get into Windows Safe Mode. On my computer, I turn off the power and turn the computer on. I keep hitting the F5 key until i get a prompt asking how I want to boot. I select safe mode and let it load. On your computer it may be a different F  key...like F7.
  3. Check your startup using  msconfig - Now that we have run scans and have done an initial clean on our computer. We can check our startup. Hit Start, then Run and type msconfig. Hit OK. Click the Startup tab, and look through the list. For the most part, anything here can really be unchecked. Try to look at the file path and the name of the checked items, this will usually give you a hint of what is what. Example: Logitech Quickcam Driver -> This is probably your camera driver, dont disable it. Once you go through the list and uncheck unwated items, click apply. Restart when you are prompted to. After restarting, click Do Not Show This Message Again and click OK.
  4. HijackThis! - Download Hijack This Hijack This is a program that will scan your computer and show information about changes that have been made to it. Download and install hijack this and run a scan and produce a log. You can copy and paste your log into this site: http://hjt.networktechs.com/ and it will guide you onto what to remove (To remove items, place checks next to them and click Fix Selected Issues) .  Also, there are many forums which will let you paste a HJT log and other kind users will help you analyze it. Alternatively, you can post your HJT log in the comments below and I will try to assist you with it.
  5. CC Cleaner  - Download CC Cleaner CC Cleaner will help remove temporary browser files, cookies, recycle bin, some program cache info. It is a good idea to run this program every once in a while just to help free up some space and keep your programs running in top shape.
  6. Reformat (Last Resort/First Resort) - A lot of viruses and spyware can be removed with the above steps, however, sometimes you get very pesky viruses and programs.  If you think the malware/adware/virus will be extremely difficult to remove, or if it is extremely malicious (i.e rootkit viruses that attach to windows files) sometimes the BEST option is to reformat and reinstall windows. This is the ONLY way to ensure your computer is COMPLETELY free of spyware. The programs listed above often do the trick. Sometimes you will do Steps 1-5 and then decide to reformat anyways because they couldn't completely remove the infection. Sometimes when I get extremely pesky infections, I reformat as my first resort. A backup, reformat and reinstall of all my programs takes me less than 4hours. Sometimes, virus removal and infection cleaning takes more than this.



Hope this guide helps you remove viruses and spyware infections. I often get paid to clean and remove spyware, adware, and viruses, however, I don't mind sharing how I do it. Most people just cant be bothered with it, but, if you can take the time to do the steps above, you will have a cleaner, faster, better, smoother running computer.
Comment if this helped you!
Paste your HJT logs if you need assistance.