Category Archives: Learning

Earn More and Big Wins

Over the last few years I have been studying wealth.

What kind of people are rich? What do they believe? What do they do? What did they do?

Two Paths

There are basically two ways to start accumulating money. Earn more. Spend less.

Most people will try to spend less. That is not wrong, it is just difficult to do long term and has a limited effect. You can only reduce your expenses to zero. Zero expenses is pretty difficult, but for someone just starting out it might be possible for a time (i.e. living with parents).

Also, too many people go for small wins when reducing expenses. Cutting out entertainment, leisure, or that morning cup of coffee.

Earning more is tough. It usually requires sustained effort, increased responsibility, and often some creativity. Also, many methods of increasing your income require some financial investment. But the upside is basically unlimited.

Lets just go over a little example of the difference. If you earned $2500 per month and your expenses are $2000 per month, if you just want to decrease your expenses, the absolute most income you will get doing that, assuming you can get your expenses to zero, is $2500 per month.

Now if you want to increase your income, you can work to increase it to $5000 per month and now you have a net of $3500. And you can just keep increasing that number. It is up to you.

I recommend doing both at the same time if possible. But for expense reduction, focus on easy wins and focus on big wins (big easy wins are the best). An easy win would be canceling subscriptions that you don’t use. A big win is switching cell phone plans and cutting your cell phone bill by 60%, getting rid of car payments by selling a car that you owe on and getting one that is paid in full, moving to a less expensive apartment or smaller house, getting a roommate to share expenses with.

If you want more info on different ways to creatively get big wins on expense cutting, I recommend Ramit Seti’s blog I Will Teach You To Be Rich. His writing had a huge influence on me giving myself several thousand dollars worth of raises over the past couple years with big expense cutting wins. (i.e. I reduced my cell phone bill by $1200 per year)

Real Estate

Besides working harder on your job, there are a few different methods of earning more money. One of the big ones that I researched is through real estate.

Specifically, buy and hold real estate.

One of the keys to actual wealth is having your money work for you. Kevin O’Leary, one of the Sharks from the show Shark Tank, likes to say that he sends his little dollar bills out as soldiers to go get him more dollar bills. There is a word that describes this process, investment. Based on my research, buy and hold real estate is one of the best investments you can make. It is not easy, but it has good returns.

With buy and hold real estate you do not flip houses to try to make a quick buck. You find a house, condo, etc. in a decent neighborhood buy it and rent it out for 20-30 years, ideally with positive but possibly with neutral cashflow until it is paid off. Eventually you will want to move up to apartment complexes but probably best to start with houses. One of the most creative ways to start if you can is to buy a duplex and rent out the other side.

A few caveats about this.

First, it is good to have a property management company handling the renting so you don’t have to. From what I hear, a good company is hard to find.

Second to make the cashflow math work, you will most likely need to put a 20% down payment on the house. There are a lot of people out there selling courses on how to get started in real estate with no money down. I am not an expert on this but that method is high risk and getting leveraged like that can put you in an awkward situation.

Depending on where you live, that 20% can represent a large chunk of change. This may be a prohibitive factor for you and it has been for me.

Doing a Better Job and Getting a Better Job

Upgrade your skill set. Become more valuable. You are going to get paid what your worth. If you aren’t getting paid much it is probably because you aren’t very valuable to the marketplace.

One of the fastest ways to get an increase in pay after upgrading your skill set is to get a better job. Often companies are slow to give raises and promotions. But if you already have the skill set and another company is looking, you can often negotiate your way in at a higher starting salary.

Warning, responsibility comes before money and some things are worth more than an increase in salary. Make sure you calculate everything when considering a new position.

Anther method that a lot of people won’t use because of fear of rejection is ask for a raise. Go in prepared. Get industry numbers and comparisons and have information about why you should be paid more. If you discover through your research that you are getting paid a fair amount, you should look into how you can be more valuable.

Tomorrow I will talk about one of the other methods of earning more money, starting a business.

Keep getting wiser, stronger, and better.

Unreal Journey

This year I will be teaching myself about Unreal Engine and how to work with it. This is one of many goals for the year but an important one.

There was more than one project that I came across last year that I would have loved to be able to contribute or work with but every single one of them was using the Unreal Engine and my current experience with it is zilch.

Often we miss opportunity because we are not prepared for it. I certainly did.

I will be perfectly honest. This feels like a pretty big challenge I have given myself. I don’t even know where to begin right now other than with the tutorial videos on the Unreal Engine website.

But begin I will. And this time next year I may have even create a small game or 2 to show off my new skills.

What skills will you have this time next year that you didn’t before?

Keep getting wiser, stronger, and better.

A Simple Guide to Installing OpenCart Manually on BlueHost

I recently had to install the appropriately named open source shopping cart OpenCart on a BlueHost shared web host account and figured it would be good to record the basic steps here in case I need to do it again or if someone else comes along and needs to do the same thing.

Note: All of these actions were performed from a Windows machine.

Part 1: Get OpenCart to the Server

This is pretty straightforward. You need to download the zip file of the latest version of OpenCart from the official website.

You should then create a private key through the cpanel interface to make connecting to your server easier. This is done by visiting the SSH Access section and managing keys. After you create a new key, authorize it and download a ppk format version to use with Putty and WinSCP.

Using a program called WinSCP (that is Windows Secure Copy), you copy the zip file to your server’s file system using the SFTP protocol.
In the Advanced Menu under SSH – Authentication, you can choose your key file for authentication.

Once you have the OpenCart zip file copied over to the server, you will need to SSH into it. A common tool for this on Windows is Putty. However if you are a little computer savy, since Windows 10 you have the option of installing a Bash shell such as you would use in a Linux environment and directly running the ssh command from there.

For now, I will assume you are using Putty.

Run Putty and put your server URL or IP address into the hostname box. In the list of options on the left, expand SSH and select Auth. This will allow you to choose your key file for authentication just like WinSCP. I would recommend saving this session for future use.

If you created your key with a password, which you should do, you will need to enter your username (provided by your webhost) and your key password.
Now you are in.

Navigate to the folder with the zipped OpenCart file and unzip it. This is as simple as running `unzip nameofopencartfile.zip`.

This will create a folder called “upload” and you need to copy all of the files in that folder to your public_html folder or the subfolder related to your url in the public_html folder.
`copy -r upload/* public_html/url_folder/`

Part 2: Setup

Now that we have all of the files on the server. We need to prepare a couple of things before we finish the installation.

First, we need to setup a database and user for OpenCart. Back in your cpanel interface, go to the MySQL database setup and create a new database for this installation. Then create a new database user and give it full privileges on the new database.

In your browser, visit your website URL and you should now see an OpenCart install screen at step 1 with a license agreement.

Accept the license agreement and move to the next step. You may need to rename a couple of config files in the OpenCart directory on your server at this point from config-something.php to config.php, one in the main folder and one in the admin folder.

Next you will input the database information you previously created. And finally you will create an admin user that will be used to manage the site.

That is the basic setup for an OpenCart install.

There may be a popup warning when you first visit the admin page to move the storage folder to a different location outside of public_html. It seems like the site will create a new folder for you automatically, but you may have to manually remove the original folder.

Keep getting wiser, stronger, and better.

Books I Read in 2017

This may or may not be a complete list as I did not keep perfect track of my reading last year but I will definitely highlight some of my favorites and add to the list as I remember them.

This is mostly in order of the ones I remembered strongly and that had an impact on me.

How to Fail at Almost Everything and Still Win Big – Scott Adams

Not only is this book an entertaining read, it contains solid practical advice as well. Scott Adams breaks down some of his personal beliefs and habits that have led to his success. The main theme being, your goal should actually be to build systems that will guarantee success over and over rather than some end result (like a million dollars). He has an interesting point that often you can combine enough skills you are just OK at to make a powerful skill stack, in his example writing, drawing, humor, and knowledge of the corporate world.

Win Bigly – Scott Adams

To give you a sense of how good this book was, I got it for Christmas and finished it in less than a week. Win Bigly is a dive into persuasion, primarily the persuasion used during the recent election. If you are still scratching your head as to how someone so socially unpopular became elected president, this is definitely worth a read. It will arm you with a new perspective about the way people act.

The ONE Thing – Gary Keller

If you have more than one priority, then you have no priorities. The ONE Thing gives a simple but powerful question to help determine what that priority should be. The question is “What is the ONE thing that by doing it, make everything else easier or unnecessary?” When you answer this, you have your very next action to take. Then ask the question again. You may be thinking, “Why do you need a whole book about that sentence? Seems pretty straightforward.” I might agree but I read the book and it contains a lot of other valuable information to go along with this powerful principle to help you answer that question. It also provides 7 different areas of life in which to apply the question. If you only read one book this year, I can recommend it be the ONE Thing.

Sell or Be Sold – Grant Cardone

While it is definitely directed toward salespeople and the sales profession, this book has a great foundation in a positive and empowering life philosophy. Grant’s theory is that just about everything is sales and we are always selling, so why not be good at it. Whether you are selling yourself to your boss for a promotion, to a new company to hire you, looking for a spouse, or actually selling a product to a customer, the principles and ideas in this book will help you get there.

The Complete Software Developer’s Career Guide – John Sonmez

If you are a software developer, are in school for anything related to software, or even considering going into any computer related field, you should read this book. Stuffed with valuable advice and information about basically everything you need to know when getting into software development. The title says it all. Might recommend this on on kindle though as it is incredibly thick (796 pages). Could also recommend the audio version that John narrates himself.

Fiction

I always enjoy a good story and as someone who is aspiring to be a great game designer, I think a good fiction base is essential for world building in games. If you are looking to become a game designer, make sure to include some good stories in your reading to help you become a better story teller.

The Tawny Man Trilogy – Robin Hobb

I was introduced to Robin Hobb’s books by a friend several years ago and enjoyed them immensely. So when I spotted the first 2 books of this trilogy on the shelf at my local goodwill I grabbed them to see if they were any good. Turns out they were and I bought the final part of the trilogy on Amazon to finish it up. This set ties up the story began in the Farseer Trilogy also by Robin Hobb. If you are looking for a fun little fantasy adventure, look no further.

The Silmarillion – J. R. R. Tolkien

To be perfectly honest, my bookmark is only halfway through this one. It is a tough read. For perspective there is a 40 page list of names at the back for reference. But for world building, it is an excellent source as Tolkien draws on the mythology of countless cultures to piece together the creation of Middle Earth and the beloved realm of Lord of the Rings.

The Year’s Best Science Fiction – Seventeenth Annual Collection

I found an anthology of curated science fiction at a Goodwill a few years ago and really enjoyed the odd and entertaining short stories in it. I found another one last year and picked it up as well. Ton of good stories in it.

Again this is not a complete list of everything I read but definitely some of the better stuff, and any of them would make a great read. There are at least 5 books sitting nearby with bookmarks partially the way through them that I will ideally finish this year.

Keep getting wiser, stronger, and better.

2017 Year in Review

One of the most valuable things you can do at the end or beginning of a year is to review the previous year to see how you did. This is also a valuable activity at the end of a day, or a week, or a month. Take a little time and review

Writing

This past year I did a lot less public writing, but picked up journaling. And I couldn’t recommend it more. For the first part of the year I was very consistent about journaling every day and ended up with 250 pages of journal entries at the end of the year.

Journaling is helpful for capturing valuable ideas that you find to help solidify your understanding and memory of them. It also helps to record commitments, plans, and challenges that you have faced and overcome.

Reading

My reading amount was down but I did read quite a few books with some very powerful ideas. I may do a review later this month of some of my favorites and at least try to list out the books I read. Particularly enjoyed a couple of books from Scott Adams.

Coding

I did not do much game programming at all in 2017. A little at the beginning of the year working on a Monkey-X tutorial and I spent a small amount of time looking into Unreal Engine.
However I did begin working with a small startup in addition to my day job. This has taken over most of my programming time outside of work as it is in a technology stack that I previously did not have a large amount of experience with.

Things are going well and I expect to be using it as the topic of a lot of my writing in 2018.

Video

Document, preferably with video. One of the lessons I am taking from Gary Vaynerchuk. One of the most interesting things you can do for content creation is document what you are going though.

I did a few videos this past year, not to document what I was doing necessarily but to document my mindset before I get to a higher level of success. To me it will make more sense if I am going to help someone else become successful to point to the documentation of my time before I was to teach them how.

I plan on doing more videos this year in addition to my writing. Not all will be published immediately.

Plans for 2018

I have come up with several challenges for myself in 2018, especially to start out the year, such as writing every day for the first 30 days.

Looking forward to a great year.

Keep getting wiser, stronger, and better.

Testing ASP.NET with Sessions and HttpContext

In my last post I advocated strongly for writing tests for any project that you inherit that does not have them.

As I begin to build a test suite for the code I am now responsible for, I am going to be writing about challenges I run into writing tests in a framework with which I am not heavily experienced.

Mocks Are Your Friend

When writing tests, it is important to isolate the code that you are testing to make sure that only it is being tested. You usually want to test specific behavior from a specific scenario.

One of the ways you can do this is by mocking or faking the responses from any other parts of the code that it calls.

The framework that I have decided to use for this is called Moq and makes it pretty easy to create a small stand in object that fakes the response you want.

Using these I was able to isolate problem areas in the test to determine the resources I needed to get the code to operate correctly.

HttpContext in Your Test

The project I am working on is an ASP.NET application. The way it was designed relies on redirects, the HttpContext.Current, and Sessions. This means that testing things can get tricky.

I was trying to Mock out the responses I needed for my test and made good headway doing so. But after doing a bunch of research along with trial and error, the best place I found to create the HttpContext for the test is in the TestInitialize portion of the test.


        [TestInitialize]
        public void TestInit()
           {
            var request = new HttpRequest("", "http://localhost", "");
            var response = new HttpResponse(new StringWriter());
            var testHttpContext = new HttpContext(request, response);
            HttpContext.Current = testHttpContext;
           }

Their are many cases where you would just want to make a simple Mock of the HttpContext and whatever you were trying to get out of it in the function, but the function I was testing used so many aspects of it that it just made sense to create one in the test initialization.

Session in Your Test

The main problem I ran into was with Session. Every use of Session in the code I was testing gave an error of “Object reference set to Null.” Additionally their did not seem to be a good way to Mock it out. It is not created by default in a new HttpContext, so putting that in the TestInitialize section did not work.

After doing a lot of digging, I finally found a way to add a new Session to the HttpContext. You have to create a HttpSessionStateContainer and then use the SessionStateUtility to add it to your HttpContext object in the TestInitialize code.


var sessionContainer = new HttpSessionStateContainer("id", new SessionStateItemCollection(),
                                            new HttpStaticObjectsCollection(), 10, true,
                                            HttpCookieMode.AutoDetect,
                                            SessionStateMode.InProc, false);
SessionStateUtility.AddHttpSessionStateToContext(testHttpContext, sessionContainer);

If you are tearing your hair out trying to figure out how searching for things like “C# asp.net test set httpcontext” or “C# asp.net test mock session”, then hopefully this helps you.

Happy Testing

Inheriting a Large Project with No Tests

Recently I have begun working part time for a small startup that has had a base version of their software already created by a company that used an overseas team. The codebase is large and in a language and framework that I have not worked in recently and uses features that I had not previously heard of.

On top of that their are large blocks of commented code, hardcoded values for things that need to be in a config file, and not one test.

As a professional software developer, when you are creating a large project for the company you work for, for a client or even for yourself, you absolutely should write test. Many people would even say you should write the tests first (TDD).

So what do you do when you inherit a large, legacy project that has zero tests?

Step One: Get a Build Working

Code is really difficult to test if the code doesn’t work or you don’t know how it should work. First you need to make sure you have a build that runs. If it doesn’t run, time to debug and get it running. It helps if you have someone who knows how it should be working so that even if it does not work properly, you can make it.

Step Two: Begin to Eat the Elephant

How do you eat an Elephant? One bite at a time.

Pick a small piece of the code and write a test for it. For the first test, try for a simple piece of code that does not rely on a bunch of things being mocked out (learned this the hard way).

Step Three: Take Another Bite

Repeat step 2 until you have reasonably good test coverage of the project. This does not necessarily mean 100% test coverage.

Bonus

If the code is particularly troublesome to get working, it is actually a good idea to write tests for sections of the code that do not work properly as you go through step 1. When something does not work, write a test that will pass when it does work and then fix the code.

Most importantly, remember to be a professional and write tests.

The ONE Thing Book Review

I heard several people discussing a book called The ONE Thing with very positive things to say about it. It was recently available for free through one of the many benefits you get through Amazon Prime, called Prime Reading although it does not appear to be any longer, and I took the opportunity to read it. I am so very glad that I did.

The basic principle is simple. Have one thing that is your focus, your priority. Work on it everyday. This is the key to success.

It is all centered around asking something like this:
What is one thing I can do, that if I do it, would make everything else easier or unnecessary?

The author identified these 7 areas of your life to ask that question about. The order is important.

  1. Spiritual Life
  2. Physical Health
  3. Personal Life
  4. Key Relationships
  5. Job
  6. Business
  7. Finances

It is important that the answer to the question be both big and specific. If it is not big, it won’t change much and won’t actually make other things easier or unnecessary. If it is not specific, you won’t know what your next step is.

The process that is setup is to take this guiding question and look at five years in the future at where you want to be. Then ask what needs to be done in the next year to reach that goal. Ask the same question about six months, three months, one month, this week, and finish by asking what you need to do today.

Then do it.

Strong recommendation on reading this book and asking yourself this question. You may be surprised at your own answer.

Xamarin Forms: ListView with SQLite

Previously we stored our entry in a SQLite database. Now we want to be able to look at a list of the things we previously saved.

ListView

When you want to display a list of objects, your best option is most likely the aptly named ListView. The ListView binds to a dataset and then displays each item according to a template in a scrollable list.

This is exactly what we want to use to view our saved properties for the cashflow calculator.

Getting the Data

There are several ways to get the data out of the SQLite database and into the ListView. Two of the most common ways are returning the result to a List or creating a CursorAdapter.

I chose to use the List method as it is simple and worked well with how I have set up the database calls to be asynchronous.

A New Page

We need to create a SavedProperties Page and set up our ListView there.

In the XAML file, we need to create our ListView and our template for each item. For now I just want to display the property name and its value.


<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SimpleCashflowCalculator.SavedPropertiesPage">
    <ListView x:Name="saved_properties_list">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout Orientation="Horizontal" 
                        HorizontalOptions="FillAndExpand"
                        Margin="20, 10, 20, 0" >
                        <Label Text="{Binding Name}" HorizontalOptions="StartAndExpand" />
                        <Label Text="{Binding Value}" />
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</ContentPage>

This creates a ListView called saved_properties_list and gives it an item template with 2 text labels. It is now expecting a Name field and a Value field for whatever objects are bound to this ListView.

Setting the ItemSource

The way to actually tell the ListView which dataset to use is by setting its ItemSource. We want to refresh this view every time we switch to it so that it always has the latest data. To do that we are going to set the ItemSource in the OnAppearing event.


        protected override async void OnAppearing()
        {
            base.OnAppearing();
            saved_properties_list.ItemsSource = await SimpleCashflowCalculatorPage.Database.GetPropertiesAsync();
        }

This is a parent class method so we override it and then call what is often called the super method or the parent method before adding our changes.

From the previous post we added this method to our Database class.


public Task> GetPropertiesAsync()
{
    return database.Table().ToListAsync();
}

We use this to set the ItemSource of the ListView to be all of our Properties in the database.

The next thing we want to add is a click event listener so that when a ListView Item is clicked, it will go to the edit page for that Property and pass its database ID to allow it to be edited.

First Monkey-X Game: Images and Theme

Games in general can get by with just basic shapes like squares, circles and triangles if the gameplay is good enough.

But we don’t want to just get by, so we are going to add images to our game that have a theme.

If you recall from earlier in the series, our theme is being underwater in a submarine fighting various kinds of biological and mechanical enemies.

We Need Art

The first thing we need is art.

There are a variety of ways to acquire game art. You can make your own, hire someone to draw you custom art, buy some already created art assets, or use some free art from a site like opengameart.org

Personally I like to draw and make little art assets. There are a lot of free tools that you can use and the images you make don’t have to be great, especially not for your first game.

What Will We Draw?

Let’s start by making a list of the objects in our game that we want to have art for.

  1. The Player
  2. 3 or more Enemy types
  3. 1 or more Bosses
  4. 1 or more Projectiles
  5. 1 or more Power Ups

For now we are going to start with the Player, some Enemies, some Projectiles, and a Boss. We will save the power ups and other images for later.

What Style Will We Use

One of the important things about your art is that is has a consistent style. Most of the time you don’t want to be mixing some 8 bit pixel art with cartoonish drawing style art.

You also want a style that lends itself to the theme and setting of your game. For example, you probably don’t want a cartoony and silly style for a horror game.

If you want you can pick a different style but for this I chose a simple flat basic shape style.

Adding the Images to the Game

Pack it Up

One of the ways to make your images more efficient for your game is to pack it into something called a sprite sheet. There is a free tool that will help with this called Texture Packer that works with FantomEngine.

You simply bring in the set of images that you want to turn into a sprite sheet and it puts them all together and allows you to export them into a single image. It then lets you save a file that describes that image so your game knows how to grab each one.

Fantom Engine only knows how to read the LibGDX and Sparrow data file formats for sprite sheets so make sure you pick one of those in the Texture Packer output file settings.

The Player

Let’s just start with the player and a single image and animation.

I created a simple set of 3 images to represent the player’s submarine. The only difference being the propeller so when we animate it, it will look like the propeller is spinning.

We are going to put it into our games ‘.data’ folder so we can load it later.

Loading the Images and Animation

Now that we have created an image, we need to load it into the game and associate it with the player.

What we are doing here is loading the image into memory, then creating an Animation object to replace our regular box that we had before. The Animation needs an image, it needs to know where in the image the animation starts, how big each frame is, and how many frames there are.

Everything else about the Fantom object remains the same so collision, movement, and everything else still works but now we have an animated little submarine instead of a box.

Using a Sprite Sheet

Now that we have a single image and animation working, we will see how to use a full sprite sheet.

I created an image for 3 different enemies, 2 different projectiles, the player, and a boss.

We then put all of the images into Texture Packer and publish the sprite sheet and the atlas mapping file. Remember to use the LibGDX or Sparrow formats for the atlas mapping file. Then we are going to put both into our games ‘.data’ folder.

Let’s start adding our new sprite atlas to the game and by getting our player’s animation from the new combined sprite sheet.

As you can see, this is not all that different from using an individual image for the animation, but it saves our game time and resources.

Fewer Enemy Types

Previously, we had all sorts of randomly sized enemies flying around the screen. Now since we have images or animations for 3 enemies, we will limit our enemy characters to being 1 of the 3 that we have images for. This is going to be a major overhaul of our enemy generator function.

First we need to pick our next enemy type at random. Then we will build the animation or regular image from our sprite sheet based on which enemy type it is.

Projectiles

The final 2 things that need to use our sprite atlas currently our the projectiles and the Boss.
Let’s start with projectiles.

And the Boss

Last but not least the Boss.

Now just by adding some images our game has a little underwater theme going on.