Friday, April 18, 2014

Util Regex functions for Javascript

Just a bunch on quick 1 liner validation functions I wrote a bit back that keep making themselves useful. Thought I'd share.
Because everybody needs some validation sometimes and because more specifically I needed these today and I had this snippet in the queue.
And also because everybody needs somebody sometimes is stuck in my head.

Feel free to play with these in jsfiddle.

Wednesday, March 19, 2014

Advice for those just starting out in Software Development

So this is a question that a friend asked me in an email. I though it was worth sharing.

Hey, how are you? I hope everything is going well for you. Im writing for advice or suggestions. I started taking classes for programming. I was wondering if there is anything languages I should really focused on or any reading material you suggest?

Okay here goes....

Rule of Thumb

It depends on what you want to do. However the key thing is to remember when starting out is Depth over Width. With that I mean learn one (or more than likely two) programming language well and its concepts will transfer to other languages. When starting out it is better to just learn how to do one very well that it is to know a little bit of a lot of different programming languages. After you have a pretty solid understanding of the core fundamentals of a language, its inclinations for certain architecture decision, design patterns, data structures, and general methods of code reuse etc..... So in short you can "think" in that language pretty well.

Talkin' Bout Some Relations... Database relations that is.

To add to this, early in your career you will more than likely need to know something about relational database management system. Those bad boys are used to store the data that you would be playing with and unless you are building tools for other developer (even sometimes then) you are going to have to have a fair bit of knowledge about how to preform Creation, Removal, Updating and Deletion queries using a special type of programming language. More than likely this will be a dialect of Sql short for Structured Query Language. As to which SQL there is some debate but I'm of the opinion that MySql or Microsoft Sql would server you well in the beginning as this is what I have seen most commonly in the wild (and are freely available).(this can vary by location so if you have your heart set on a particular location I'd do some research by looking at the job sites and querying for sql or database and see what shows up )In any case you should know something about relational databases.

Major Areas of Specialization

Web of Lies

In some cases just learning one language deeply is not practical. This is especially true for web development. Noting that IMO the additional web languages you work with aren't all that hard in comparison to learning other programming languages. Speaking in overly broad terms and possibly making a number of generalizations I'd say that if you are aiming to be a web developer (even just starting out) I'd expect you to know the following.


  • You should be able to stub out a basic html page with a header, body, form, a couple of input elements
  • Stub out a table
  • Uses for a div
  • Uses for a span
  • Uses for an anchor tag


You should be able to use a class, id and element selector. Create a even layout for a page just with a style sheet and little to no inline css or element attributes on your html.


  • You should know what the DOM is and be able to access DOM elements by id and name,
  • Some jQuery because its so common
  • JSON, What it is and how is it used
  • Ajax what it is and how to use it.

Javascript - bonus

  • Object Extensions
  • the difference between "==" and "===" when talking about comparison,
  • what closures are and what the are good for
  • Prototypical Inheritance
  • General OOP concepts and Design Patterns and how to apply them in javascript. I.E. how do I make a method or property private.
  • What Underscore.js is
  • Common pitfalls in javascript
  • Some basic knowledge about SPA applications. What they are, when to use them, what are some libraries in the wild.
  • General code organization, possibly using tools like require.js

There are a ton of places to go learn these skills if you don't already know them. Additionally you will want to have a good grasp of a server side language like php, java, c#, ruby, python or even node.js (special case)

Other Areas of Application Development

Often Desktop applications are written in a language like C#, vb6, vb.NET, Java, c++ or some other language with a SQL database back end. Not as many as there were in the late 90's due to the growing popularity of the web but are still around.

The Tiobe index is one kind of indicator for the popularity of programming languages
(does not necessarily reflect the industry as a whole but you can't go too bad from learning one or two of the languages on the list)

Mobile development
Mobile development is mainly done with Java ( for Android) or Objective-C (for IPhone) but can also be done with web knowledge to some extent and work on both (

Easy to Hard

I listed some languages in order of easiest to most difficult from my experience,This is highly speculative and just my opinion.

  1. HTML CSS (go hand and hand)
  2. SQL
  3. PHP Python Ruby  (about the same level of difficulty)
  4. C#  Java (about the same) 
  5. Vb.NET  
  6. C
  7. C++
#3-#5 are beyond debatable.
#2  is easy to learn the basics but has more than a fair bit of depth

In any case whatever you decide I'd recommend a few spots

For FAQs
For learning online

For lots of free books


  • Asking Questions Online
    For actually asking questions your best bet might be a chat room like an IRC I don't suggest starting out asking stuff at a place like stackoverflow just because they aren't really that friendly to newbies* and its kind of hard to find places that are. Maybe user groups on facebook or google plus might be better but those are kind of hit and miss as well.....

    *note* Stackoverflow is an awesome resource, just not the greatest place to start out asking questions. That being said if you
    are going to ask about something on SO I'd recommend you look at this on Stackoverflow and this article from Jon Skeet, the record holder for most rep on so

    Remember Remember.....

    Okay so thats a lot to process... but it should be a good start. Biggest thing to remember again is to pick one language and area and stick with it until it becomes easy.... Which takes a considerable amount of time.Also don't just read about the field or language actually make stuff, not big stuff but small simple things..... really small simple things and finish those small simple things and share them so others can critique.

    Best of luck to you in programming....
    Its hard but rewarding both financially and mentally and at times spiritually.

    Tuesday, November 5, 2013

    Respawning a Player in a Relatively Safe Spot in C#

    My rudimentary (kinda brute force-ish) way of re-spawning the player in a spot away from enemies and thus my fix for instant-death-spawning.This is something from  my bacon jam 6 entry for fixing a major bug after the contest. It does not account for things like falling enemies but, it should do the trick in a pinch.


    So performance wise I'm pretty sure Linq isn't great for xna with respect to garbage collection and number of instructions but, baring that Im going to ignore it for now seeing as premature opt being the route of all evil  or whatever..


    Link to code

    Sunday, October 27, 2013

    Bacon Jam 6 Entry: Slay The Rainbow

    Slay The Rainbow

    Ello all, Just posting all the links for my Bacon Game Jam 6 entry. I will follow up with a post mortem a bit later. (I.O.U.)


    About my Entry 


    Slay The Rainbow:Ninja vs Rainbow?
    You fight a legion of rainbow monsters armed with nothing but a sword and your ninja agility.
    20 seconds to clear the level.
    Times running out..... What are you still reading for?????

    Technology used

    C#, xna, (hak'd together a mod of the starter kit)


    Xbox Gamepad

    Move -joystick or directional pad 
    Attack - X 
    Jump - A

    move- arrow keys, 
    Left - left arrow key ,a 
    Right - right arrow, d, 
    Jump- space bar, w 
    Attack - f

    How to play my game. 

    ***Installation Note Read me first**  this needs to be installed before before running the exe. To install just download and double click.

    If you are running some form of windows go ahead and download and extract The executables from the link. If you have a problem please let me know. Thanks.

    Wednesday, October 23, 2013

    Open sourced a bunch of projects, Maybe you see something you like.

    Come and get it. 

        So I decided to go ahead and open source a bunch of my old code (and actually added licences too,OMG!). Feel free to look and comment. It is all under the WTFPL licence. I will add readmes to the pages to make them more readable at some point. So the first couple are a couple of stabs at the same thing but with different toolsets. In retrospect it kinda makes me feel a little sad.


    Best Of Craigslist (Android)


    Languages: Java, javascript,html

    So the Best of Craigslist is a section of Craigslist, dedicated to the weirdest (and lolz-iest ) parts of Craigslist. (Not particularly child friendly or work safe).

    I was so sure for some reason that people would love this sort of thing. But with the cease and desists and others with the same idea making nil I used it as a means to learn new stuff more than anything. I'm pretty sure I have an old mono version and wp7 somewhere in all my scrap code as well.


    Wallpaper Changer (Windows)

    Description: A somewhat put together wpf wallpaper manager, (playlist scheduled) changer and downloader (at least from 4chan's w anyway)

    Comments:A better wallpaper changer that a previous attempt in vbscript. At the time I was deep into learning xaml (wpf, wp7) and wanted to put together something cool looking for the desktop.

    Because there aren't a lot of good wallpaper changers out there that match the functionality of the built in mac os one.


    Clear Wifi (Android)


    Language: c# (xamarin)

    A quick and tiny app used to delete wifi hotspots from android phones.

    I did this in response to a Hak5 wifi pineapple tool and later a blogpost by Scott Hanselman.
    Took less than a day easily. I later was working on putting together a whitelist for this in a native java version somewhere.....(since the size limit on the C# wouldn't let me do much more)


    YQL Client (Win 8 Store)


    Language: c#, xaml

    A windows 8 Store app that would act as a yql client that you could take with you sync you favs and history and render the results in html(xml) or json.

    I really started this at a Win 8 Camp in Columbia SC and placed in 3rd-5th(tied 3 way I guess)
    and polished it up a bit.


    Give Camp Columbia ( Mvc 2 )


    Language:c#, razor, html, css

    A fork of the give camp starter site .

    I wanted to get my mvc skills up and telerik was allowing folks to use their stuff for charity at the time. (not sure what the current rulling is on that.....) I put this together for hosting a give camp which never came to fruition due to logistics, time and money costs.


    Angel 2d v3.1 Rube Loader for json to box2d import (windows)


    Language:c++, lua

    An importer I tweaked from the rube site. Converts json to box2d objects.

    Specifically, I was tailoring it to work with Angel 2d as I liked the Game Engine. It works but does not tie into the angel2d engine. Also I'm sure I didn't use best practices for "cross platform" implementation. I.E. back vs forward slash, #pragma once etc...

    Tuesday, October 22, 2013

    About Javascript Immutable Objects and Prince

    By default when creating an object is used with the object literal notation such that...

    It creates a ref type object (Musician) that is mutable.

    What that means is that its state can be changed.
    In otherwords...
    if I take that Person named Prince and change his stage name

    We will still only have one Musician object in memory that has a StageName of "Prince".
    However that is to say the members are not mutable. All the stage names set are immutable which in contrasts means that
    their state can never be changed.

    But, Terrance. It looks like they values are changing for Stagename and you said the is only one musician so doesn't that mean you either shouldn't be able to change the value of stage name or that all the stage names are somewhere?

    Well I'm glad you asked that. The value located at Musician.StageName  isn't actually changing behind the scenes. It stays in the same place in memory. What is actually changing is the thing that Musician.StageName is pointing to. That is to say that somewhere in memory there is still a  "Jamie Starr", "Christopher", "Alexander Nevermind" and a "Joey Coco". We just can no longer access them directly. This holds true until javascript 's garbage collector deallocates that particular portion of memory and after which we can truly say that they are gone.

    So with that all immutability really means is that the data stored at a location or "address" will not change. This does not mean that the state of our current object will not change. In our case it means that the Musician is directing all who access the Stage Name to refer to him as what he is currently pointing to. This also means that there is a potential for a lot of memory to be used when dealing with a large number of strings or a large number of literal assignments.

    To apply the behavior you expected (as far as immutability is concerned) there is a neat function that is partially supported referred to as Object.freeze() that will make an object Immutable.

    See it in action here. *note that this will potentially throw a TypeError when using Strict Mode

    While we might remember,for a time, all the different stage
    names he has given himself over the years,
    if nothing else he will always simply be Prince... lol

    Tuesday, October 15, 2013

    My Javascript Fundamentals class is on Youtube

    Hello all,

    I finally had the courage to put this presentation on youtube after months of fretting about it.
    Please give me your feedback but, not too rough my ego bruises pretty easily.

    Thank You

    • Thanks to Todd Lewis the executive director at Itology @ Innovista.
    • Thanks to my nieces, Erin and Shan for supporting me and recording. 
    • Thanks to Robert G. Lewis @ for editing 
    • Thanks to all the guys in my IT department and everyone else for showing up.

    And as an additional bonus, here are the slides so you to can follow along. I tried to make them as interactive as possible so feel free to hop in.