Monday, December 15, 2014

Game Design Bundle - Hours of Training for only $8

Get Hours of Training in Unity and 3D Modeling for an Extremely Low Price


This is such a good deal I figured others may be interested in it.  Over at Slashdot Deals there is a 'name your own price' bundle for some pretty extensive game development courses.  The courses are hosted by Udemy.  If you want to learn about Unity or want to improve your artistic ability this may be the bundle for you - or a good gift for that developer you know.  Make sure to pay the average price (or above) to get the best deal by getting all four courses.  It's not really worth it unless you pay the extra to unlock all the courses.

https://deals.slashdot.org/sales/the-name-your-own-price-game-design-bundle

Get the Game Design Bundle on Slashdot Deals.

Why to the Courses


Professional Video Game Art School - This is the real meat of what I am interested in and if this is the only course I use in the group I will have easily gotten my money's worth.  This is a course on getting 3D fundamentals with 3DS Max.   These skills will be useful, not only for gaming, but to build 3D modeling skills which can be applied to other areas such as 3D printing.  Getting started with anything 3D is a real challenge.  For the eight dollars I paid for this package, this price is a steal and it is highly rated by people who have taken the course.  I'm in.

Unity3D Course - I've taken a lot of Unity tutorials, and most seem to cover the same old ground.  I'm not particularly excited about this course and the reviews haven't been good, but sometimes you can pick up new things that another instructor missed.  I'll probably spend some time going through the second half of this course.

Gamification Course - This class could be interesting and is geared towards taking an existing business (non-game) and making it more fun for the the users by adding game elements.  Not my primary focus, but could be useful on some other projects I am working on.

Photoshop Hand Painted Textures Course - I've always wondered how to be able to make great looking textures to apply to gaming models so I'm looking forward to taking this short class.


Tuesday, December 9, 2014

Get Licensed - Tips for preparing for the PE Exam in Computer Engineering

What is this NCEES exam and why would I want to take it?


The NCEES is a governing body that is allowed to license people and companies to practice engineering.  Any company with "Engineer" in the title needs to have a professional engineer (PE) or they may get sued by the professional engineering society for the state it is in.  The Principal and Practice exam is one requirement  prior to becoming licensed as an engineer.  This is an eight hour test that once you pass it, you are on your way to be licensed to officially perform the practice of engineering and run you own engineering company.  

People with a PE license are highly regarded in their field of expertise as it is no small feat to getting licensed.


My Tips


This applies to the Electrical and Computer : Computer Engineering exam, but the same methods and most books should work for the Software Exam.  Although the book list will need to be adjusted somewhat.

I spent many long hours studying for both this FE exam and then the PE exam, and now I have an engineering license to practice software engineering.  I wish I had some help along the way and someone to clue me in to what I needed to do.  Maybe my study methods can help you prepare for this exam.

To prepare for the PE test in October, I started studying five months in advance.  So, to take the test in October, I began studying in May a couple hours a night for most nights.  I figure I put about 300 hours of studying to get ready for this test.  Your needs may be different than mine as I wanted to make sure I did not have to take this eight hour test again.  Really, who wants to take this exam again.


Tips for passing the PE Exam


  1. Start studying five to six months in advance.
  2. Try for at least 300 hours of studying.
  3. Get to know your reference materials well.  Get everything you need early.  You will need to use them under stress and finding what you need quickly is key.  
  4. Use a calculator that you are allowed to take to the test.  Learn it well.  I used the Casio Fx-115ES.
  5. Spend the time to mark the Table of Contents, and where the Index is in all your books with sticky tabs.  You will be thankful later when you can just grab a book and start looking through the index quickly instead of fumbling for it. 
  6. Take all the sample tests you can until you feel comfortable with the material.



Here you can see the yellow tabs.  It is a good idea to mark the table of contents,
the start and end of the index for quick access.

The Books (Computer Engineering version)

To get the booklist, I started with the exam specifications from NCEES and made sure the books I selected covered most of those topics.  If you are taking the software only exam, you will not find as much use for the Electronics Engineers' Handbook.
  1. The Computer Science and Engineering Handbook, Tucker - This book was the best single resource for the test, it is a hefty beast, though.
  2. Electronics Engineers' Handbook, Christiansen - This book also was a great resource for the test.  It's big, but covers a lot of ground.
  3. Operating Systems: Internals and Design Principle, William Stallings  
  4. The Camara Books - Some people don't like his books.  I didn't either at first, but it turned out they were actually useful for me - especially the sample problems:
    1. Electrical Engineering Practice Problems for the Power, Electrical/Electronics, and Computer PE Exams, Camara
    2. Electrical Engineering Quick Reference for the Power, Electrical and Electronics, and Computer PE Exams - This one is expensive and not as good as the Electronic or Computer Science Engineering Handbook.
    3. Electrical Engineering Sample Examinations for the Power, Electrical and Electronics, and Computer PE Exams - The sample problems are a must.  You should be able to solve these using just your reference materials.
  5. PE Electrical and Computer: Computer Engineering Practice Exam - The sample test from NCEES.
  6. Guide to the Software Engineering Body of Knowledge (SWEBOK) - Absolutely necessary.  I used the 2004 version and this book was quite handy for the project management details.  A newer version is available.
  7. Schaum's Outlines - I got these books but didn't really need them for the test. Your mileage may vary.  If you need to target specific holes in your knowledge, they may be a good resource.
    1. Schaum's Outline of Digital Principles
    2. Schaum's Outline of Computer Architecture
    3. Schaum's Outline of Software Engineering
    4. Schaum's Outline of Operating Systems
  8. Microelectronic Circuit Design, Jaeger
  9. Introduction to Computer Engineering: Hardware and Software Design, Booth
  10. Microelectronics (Mcgraw Hill Series in Electrical and Computer Engineering), Jacob Millman


Good luck!

If this list does help you, please consider clicking on +1, post a LOL cat photo, or whatever.

Friday, November 28, 2014

Migrating from PHP 5.3 to PHP 5.4 or 5.5 - Watch Out For a Dangerous iconv Bug

If you are using iconv to filter out invalid characters for strings and you migrate to PHP 5.5, you may experience the nasty bug that bit me.


Currently I am converting all my web data from a nice UTF-8 format to ISO-8859-1 (otherwise known as ISO Latin-1) for use for inserting into PDF reports using the fantastic FPDF library.

The code looks something like this:
$clean = @iconv("UTF-8", "ISO-8859-1//IGNORE//TRANSLIT", $text);

I used the error suppression here so no errors get output to the screen when an invalid character needs to be stripped.  If the error displays on the screen, then it interrupts the creation of the PDF file and the user does not get a file.  Not so great, right?

Here is the error that is returned when the error is not suppressed:
Notice: iconv(): Detected an illegal character in input string in {...}

I had been using the //IGNORE directive to direct the function to ignore characters that have errors in them.   I also use //TRANSLIT so that if a character doesn't match exactly to the specific character set, the closest approximation is used.



$text = "Equipment List – Projéct [2014-Nov-28]";
$clean = @iconv("UTF-8", "ISO-8859-1//IGNORE//TRANSLIT", $text);
print_ln($clean);



It may be hard to see, but the first dash '
–' is an em dash and is actually a different character and longer than the '-' en dash (or minus symbol).  Also, I placed a 'e' on project just for good measure.  That doesn't have a representation in the ISO-8859-1 character set according to iconv.

In my PHP version 5.3.29 (with iconv library version 2.17) I get the output:
Equipment List - Proj�ct [2014-Nov-28]

However in PHP version 5.5.19 (also with iconv library version 2.17) with the same code, I get no output at all.


Temporary Solution


So how to correct for that behavior?  Well, I'm not quite sure what's going on in the code for iconv, but I found that if I remove the //IGNORE directive and just leave //TRANSLIT then I am ok.

$text = "Equipment List – Projéct [2014-Nov-28]";
$clean = @iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text);
print_ln($clean);
Output:
Equipment List - Proj�ct [2014-Nov-28]

That's what I wanted, so we should be good for now.  At least until I can examine the iconv source code from GNU Libc and see what is going on.


Update:

After reviewing the source code to the PHP implementation of iconv (from PHP 5.3 iconv to PHP 5.4 iconv) I think the culprit lies in how PHP is calling the iconv library, not the iconv library itself.  There is a line that calls the PHP return value after a check for errors and handles it differently in the later version (line 2390 of PHP5.4+.iconv.c).
    if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
        RETVAL_STRINGL(out_buffer, out_len, 0);
    } else {
        if (out_buffer != NULL) {
            efree(out_buffer);
        }
        RETURN_FALSE;
    }
In the original 5.3 version it just returned what was found (line 2330 of PHP5.3.iconv.c)

    if (out_buffer != NULL) {
        RETVAL_STRINGL(out_buffer, out_len, 0);
    } else {
        RETURN_FALSE;
    }

It looks like that extra check (bolded above) is causing any failure to return FALSE which will give you an empty string ''.

Tuesday, November 18, 2014

What are static bindings in PHP - Using self:: versus static::

[1] Why an abstract horse?  See below.

What are static bindings?

Static bindings are functions or variables that can be called on a class that don't need an object created to use them first.  For example, you don't need to use the new operator to call a static method or access a static variable.  These methods exist the first time the class is loaded by the php process and are accessed using the '::' accessor.

How and when to use late static binding in PHP

Late static bindings should be used anytime you are likely to want to redefine or override static objects in children class.  In those cases you will use the static keyword which is a signal to php to check the child class for the appropriate overridden function or variable before it goes up the chain in checking the parent classes.

If you are sure the static function in the base class isn't going to change, or you don't want it to change, then you should consider using the self keyword to access the item.

<?php

abstract class booger {
    abstract function b();
    public static function a() { echo("base class function<br />"); }
    public function c() { self::a();}
    public function d() { static::a();}
}

class goober extends booger{
    public function b() { echo("extended class function<br />"); }
    public static function a() { echo("late static binding<br />"); }
}

$goob = new goober();
$goob::a();
$goob->b();
$goob->c();
$goob->d(); //this is the line that actually uses the late static binding
goober::a();

?>


OUTPUT:

late static binding
extended class function
base class function
late static binding
late static binding



The first line $goob::a() is just a regular overridden function call and does not use the static keyword for the access.  Similarly, $goob->b() is regular method call to a function that was required to be created because of the abstract keyword.

$goob->c() makes use of the self keyword.  This means that the whichever class the keyword is found in is the one that is searched for the requested method.  That is why it shows the output from the base class function.
 

$goob->d() makes use of the static keyword which shows how although the same function a() is called, that since the static keyword was used php knows to check not the base class but the calling class first for the requested function.  That was the desired behavior we were looking for in this case.

Summary

Generally, in most cases static will be the correct keyword to use since the programmer often expects the class to prefer to use the functions in the children classes over those in the parent class.  There are exceptions in situations where self is more appropriate such as when you don't ever plan on calling a particular function from a child class and only the parent class.

Some Gotchas

Please note incorrect order or positioning of the classes in your code can affect the interpreter and can cause a Fatal error:
Class 'YourClass' not found 

This can happen when there are multiple levels of abstraction and the base classes are out of order in the source code.  

For example:
 
<?php

abstract class horse extends animal {
    public function get_breed() { return "Jersey"; }
}

class cart extends horse {
    public function get_breed() { return "Wood"; }
}
 
abstract class animal {
    public abstract function get_breed();
}

$cart = new cart();
print($cart->get_breed());
?>

this outputs:
Wood

 
However, if you put the cart before the abstract horse (literally):
 
<?php
//same code, just in a different order
class cart extends horse {
    public function get_breed() { return "Wood"; }
}

abstract class horse extends animal {
    public function get_breed() { return "Jersey"; }
}
 
abstract class animal {
    public abstract function get_breed();
}

$cart = new cart();
print($cart->get_breed());

?>

this throws an error:
Fatal error: Class 'horse' not found
So, when using multiple levels of abstraction, be careful of the positioning of the classes within the source code - and don't put the cart before the abstract horse.

[1] The abstract horse image was provided by pptbackgroundstemplates.

Tuesday, September 16, 2014

Four Pitfalls of PHP's Comparison Operators: When to Use == Versus ===

Tips for choosing between '==' (equals or loose comparison) and '===' (identical) operators in php.


Equals or == for loose comparisons.
Identical or === for exact matches.

When choosing the correct operator you want to use in PHP you will want to consider whether you want PHP to try different ways to match your data or if a more strict or exact match is needed. If your data is from a secure location or already validated you may not need the strict identical === operator, but if your data is from an outside source (HTTP GET/POST or user entered) you may want to be more precise depending on the situation. Below are some example cases to keep in mind, starting with a look at the equals == operator.


1. Zero, false, empty strings, empty arrays, null are 'loosely' equal in PHP


Below are some base cases to keep in mind. The equals operator uses type juggling, and 0 can become false or an empty string.

Comparisons to Zero
0 == ""                => True
"0" == false           => True
"0" == 0               => True
0 == false             => True

2. Watch out for string comparisons to 0 in PHP


Perhaps the strangest one is that any string with an equals comparison to 0 (as an integer) is True. If you always are expecting to compare both sides with a string, you should strongly consider using the identical operator '==='. Perhaps the strangest one is that any string with an equals comparison to 0.

String Comparisons 
"str" == 0 => True (This one is definitely weird) 
"str" == 1 => False 
"str" == "0" => False 
"strA" == "strB" => False

3. Type juggling converts strings to numbers and vice-versa

When using the equals operator, the strings are converted to a numeric value when the string comparison match fails.

Numeric Comparisons
3 == 4                 => False
"3" == 3.0             => True
1 == "1"               => True

4. Blank strings are 'loosely' evaluated null

This example shows that you need to be careful if there is a potential for blank strings to be passed along as data. Also, you may have expected that the string zero "0" would loosely evaluate to null since "0" loosely evaluated to false, but that is not the case.


Null Usage
"" == null             => True
1 == null              => False
null == null           => True
null == 0              => True
null == "0"            => False
null == false          => True

The Identical Operator removes the loose evaluations


The identical operator is great whenever you expect both sides of the comparison to have the same type and it will help keep you out of trouble. In this case, it helps remove the guesswork from the comparison and your output is more likely to match what you expect.
 
Comparisons to Zero
0 === ""               => False
"0" === false          => False
"0" === 0              => False
0 === false            => False

String Comparisons
"str" === 0            => False
"str" === 1            => False
"str" === "0"          => False
"strA" === "strB"      => False

Numeric Comparisons
3 === 4                => False
"3" === 3.0            => False
1 === "1"              => False

Null Usage
"" === null            => False
1 === null             => False
null === null          => True
null === 0             => False
null === "0"           => False


null === false         => False

The Code


The PHP documentation for the comparison operators can be found here, and the chart that displays what the value of the comparisons should be is here.
Here is the sample code that generated the tests above:
 



Echo "Comparisons to Zero<br />";
eval_string('0 == ""');
eval_string('"0" == false');
eval_string('"0" == 0');
eval_string('0 == false');
echo "<br />String Comparisons<br />";
eval_string('"str" == 0');
eval_string('"str" == 1');
eval_string('"str" == "0"');
eval_string('"strA" == "strB"');
echo "<br />Numeric Comparisons<br />";
eval_string('3 == 4');
eval_string('"3" == 3.0');
eval_string('1 == "1"');
echo "<br />Null Usage<br />";
eval_string('"" == null');
eval_string('1 == null');
eval_string('null == null');
eval_string('null == 0');
eval_string('null == "0"');
eval_string('null == false');

echo ("<br />Now Check as the === operator which removes type juggling:<br />");
Echo "Comparisons to Zero<br />";
eval_string('0 === ""');
eval_string('"0" === false');
eval_string('"0" === 0');
eval_string('0 === false');
echo "<br />String Comparisons<br />";
eval_string('"str" === 0');
eval_string('"str" === 1');
eval_string('"str" === "0"');
eval_string('"strA" === "strB"');
echo "<br />Numeric Comparisons<br />";
eval_string('3 === 4');
eval_string('"3" === 3.0');
eval_string('1 === "1"');
echo "<br />Null Usage<br />";
eval_string('"" === null');
eval_string('1 === null');
eval_string('null === null');
eval_string('null === 0');
eval_string('null === "0"');
eval_string('null === false');
function eval_string($str) { $disp_str = str_pad($str,20," "); echo "$disp_str \t\t=> ".get_boolean_output(eval("return {$str};"))."<br />"; } function get_boolean_output($val) { if ($val == false) return "False"; else return "True"; }

Thursday, September 4, 2014

The Not So Sweet! Saga of King.com's Trademark Trolling

Five Reasons Not to Play Candy Crush Saga


Candy Crush Saga by King.com is the type of game that you love to hate. Maybe it's the constant spamming of Facebook messages from your friends inviting you to play it, but no... This is a story that began with the success of King's popular Facebook game Candy Crush Saga that turned mobile and a desire to protect the company that turns into greed.  Candy Crush Saga now generates millions of dollars per day for King.  Yes, around three to four million per day according to their 2013 IPO registration.  King has produced a highly polished, but wholly unoriginal game that makes the bulk of their wealth.  While credit should be given to King for the marketing success of their Candy Crush Saga game, the trademark abuse and opposition to small independent game developers is completely unnecessary.


Reason #1 - The CandySwipe Saga

Early color matching games - Snood, CandySwipe, and Bejeweled

Before there was Candy Crush Saga there were other colorful matching games. Does anyone remember Snood in the 90's or Bejeweled?  In 2010 Albert Ransom (a small independent developer) released and trademarked CandySwipe, a matching game.  Years later Candy Crush Saga was released on Facebook in April of 2012.  With the rising popularity of Candy Crush in 2013, people began to confuse CandySwipe and Candy Crush, so much so that the Candyswipe game began received negative complaints in the app store for being a Candy Crush clone, when in reality it was the Candy Crush game that appeared to be a clone, although with more polish than CandySwipe.  This caused Albert Ransom to file a complaint against the Candy Crush Saga trademark in which he tried to protect his own brand due to many graphic similarities between the two games.


Reason #2 - The Money Solution

Riccardo Zacconi - King.com

King was able to purchase a bankrupt company to get the European trademark for Candy, and a game in January of 2013 called Candy Crusher which was originally released on Blackberry all the way back in 2009.  These two purchases seemed to both solidify King's ownership of their brand name and prevent any prior art complaints from Ransom's CandySwipe.  Flush with cash from their 2013 popularity the company seemed to be able to fight any legal battle to protect their flagship game.



Reason #3 - All Your Trademarks Are Belong to Us


Trademarks are used for legal protection of company brands.  Let's say you want to sell a product that has a distinct brand name that no one else is allowed to use.  For example: if I open a store and want to sell hamburgers I could call it McDonald's Burgers.  If someone else tries to use a name too similar to attempt to confuse people such as MacDonald's Burgers, then that is trademark infringement.

When King started to gain popularity they trademarked some words related to the titles of their games like 'Candy Crush' and 'Candy Crush Saga'.

It makes sense for King to trademark the titles of their games so that people can't clone their product and claim it as their own.  When a trademark is registered the category of usage needs to be declared.  For example: A company like Time Inc, the producer of Time magazine can trademark the word 'Time' (TM# 86043259).  Their trademark covers things like entertainment services - magazines, journals, websites, and publications. How many of categories did they need to cover to protect their all important magazine brand? 14.  This means you could create a cleaning product called Time (if you really wanted to) but not an entertainment website.

What doesn't make sense are the categories covered by King's trademarks.  The Candy Crush Saga originally covers 37 different uses including: computer games, clothing, classes, fire extinguishers, scientific, nautical, & various other uses.  So, King plans on releasing Candy Crush branded fire extinguishers, really?

Not content to just have a trademark for the name of their products, 'Candy Crush' and 'Candy Crush Saga', but King has applied for trademarks for the individual words appearing in their games Saga (TM# 85482736, 86242335), Candy (TM# 85842584), Sweet! (TM# 86138537) and even Keyword (TM# 86191982).

How can King claim the trademark to use common words such as Saga, Keyword, and Candy?  Sure, the word saga appears in many of their games and candy in their most popular game.  King was able to purchase the European Union trademark for Candy in February of 2013 and then use that purchase to bolster support for their request for the US trademark for the word Candy.  King received approval for the US trademark for use of the word Candy in 2014.


Reason #4 - The Banner Saga


Around the same time that Candy Crush Saga was released on Facebook, an independent developer named Stoic had successfully funded their game 'The Banner Saga' on the popular funding platform Kickstarter.  



Candy Crush Saga           
Banner Saga
Graphics:
Candy Land Style


Viking Themed
Gameplay:
Puzzler

Role Playing Game

Story: Minimal Epic Story - based on player choices

This game has nothing in common with Candy Crush and is a truly original game, but in December of 2013 King filed a trademark complaint against Stoic apparently only because the game had the word 'saga' in the title.

What is a saga?  From Merriam-Webster, a saga is a long complicated story with many events.  Think of the story of Lord of the Rings or the Harry Potter series. The Banner Saga game has a long and complicated story based on player choices and is, in other words, a saga.


Reason #5 - Not So Sweet! 

Sweet! from CandySwipe

The most egregious trademark abuse by King is perhaps the one for the word 'Sweet!'.  King applied for a trademark of the word 'Sweet!' in December of 2013.  Looking at the scope of the trademark reveals that it covers too many things to list: from Malt Beer, Lithographic Stones to Cobblers' wax and Make-Up.  These are just some of the 2191 categories of items covered.  They can't realistically expect to be involved with the distribution and business of producing all these types of goods.  So, if a baker makes a pie that has 'Sweet!' somewhere on the label they can get sued for infringement by a software company?

On the same day the trademark for Candy was approved, King notified indie developer Benny Hsu that his game 'All Candy Casino Slots - Jewels Craze Connect: Big Blast Mania Land' was infringing on their candy trademark.  Similar to The Banner Saga, this game has nothing in common with Candy Crush Saga except that it features a word in common in its long title.  Granted in this case, Hsu may have been trying to capitalize on popularity of certain keywords to get an edge in a crowded app store.

Popular opinion in the gaming industry began to stir with antipathy for King. Game Jams were held by game developers to create games that featured candy. King posted an open letter on their website attempting to explain that they were just protecting their brand but failed to demystify the greedy breadth of the trademarks they were seeking (Sweet! - 2191 categories of use, Candy - 106 uses, Saga - 112 uses, Keyword - 305 uses).  The letter satisfied no one, and unable to save face the company abandoned the Candy trademark just 40 days after having it approved.


Epilogue


The CandySwipe issue was finally resolved between King and Ransom in April of 2014 when Ransom removed his complaint against the Candy Crush Saga trademark after reaching an understanding with King.  They decided that both games could coexist on the app store.

In August of 2014 after eight months of objection to The Banner Saga, King finally removed their opposition to the usage of saga in the title.  The game is now published on Steam.

Benny Hsu renamed his game to 'All Sugar Casino Slots - Jewels Craze Connect: Big Blast Mania Land' removing the word Candy from the title.

King still owns the European trademark for the word Candy and is awaiting approval for the expanded usage of their trademark for: Keyword, Saga, and Sweet!  In fact, if they receive final approval of the extremely broad scope they are requesting, it is likely the title of this blog post could be opposed by King.

Update

Candy Crush berry fruit snacks

So, just two days after posting this article I get home to find my wife had purchased some new fruity snacks to munch on.  I was quite shocked to find these sitting innocently on the kitchen table.

Wednesday, July 9, 2014

RHM picks for classes to take at the Amazon Summit NY

Right Handed Monkey is going to be at the New York Amazon Summit 7.10.2014!

I'm very excited to spend this time getting to know more about the Amazon platform and meet other startups and entrepreneurs in the area.  Let's do this, people.  Leave a comment if you're interested in meeting up at one of the social events.

My picks for the Amazon Summit 2014:


1. Deploy, Manage, and Scale Your Apps with OpsWorks and Elastic Beanstalk


Why: I picked this class because I want to learn about scaling my current system and what tools are available to make it grow.  Plus I want to make sure when I am programming a site that I do it in a way that is compatible with scaling (ie. Beanstalk.).

2. Scaling on AWS for the First 10 Million Users


Why: This is a given.  Everyone wants to know how to scale up their software so it can support as many users as possible.

3. Updating Security Operations for the Cloud, presented by Trend Micro


Why: Originally I considered 'Managing an Enterprise Class Hybrid Architecture', but the truth is I'm not managing mega-sized legacy infrastructures and won't be anytime soon.  My sites are lean and have simple needs, but may have to scale fast.  Plus my sites get lots of weird hits and spam from places like Russia and China.  Some extra security won't be that bad of an investment.

4. Building Mobile Apps on AWS


Why: Because, you had me at mobile.

5. AWS Summit Social and AWS Activate - Networking & Social Event for Startups


Why: Get to meet at greet the brains behind the organization.  

Hope to see you there!