Thursday, December 12, 2013

Part 1: From nothing middle-class chump (Worth by 2003: < -$13,000)

I am going to be a millionaire and I'm going to tell you how I'm doing that even though my current net worth is -$115,443.00.

TL;DR I learned horrible money management as a kid, blew all my advantages as a young adult, except getting my degree in Computer Science, and until recently was a typical hyper consumer that racked up more than $100,000 in debt.

Why I became a in-debt middle-class chump (Net worth: $200)

I grew up poor in Minneota; the son of a single father.  That pretty much summarizes my entire relationship with money (at least mentally) up until I joined the Army in 2001.  To elaborate a bit that means that I would go with my dad once a week on a bus from downtown Minneapolis to some grocery store miles away to buy food with food-stamps then make the 1+ hour journey back home.  Free lunches at school. Occasional trips to the food shelter.

We were poor for mainly one reason my father was a non-functioning alcoholic and would relapse almost like clockwork ever six months. And when my dad had a job he would promise me very nice allowances (I remember at one time being promised a $20/week allowance), but then only receiving the two installments.  This also allowed us to get very nice tax rebates every year.  This tainted my relationship with money horribly.  Money came in then you spent it as fast as you could on the things you needed/wanted then you barely scraped by the rest of the time.

What's sad is looking back I seemed to have the traits of a saver.  I opened a savings account with $10.00 when I was in kindergarten because I liked the idea (my teacher or my father may have put the idea there). Then a few years later my uncle asked to borrow money from me and I gauged that he was high risk (seriously, I thought about it and decided there was a good chance he wouldn't pay me back and raised the interest rate on him) and I'd just learned about interest, so I charge him 10% interest per week (I picked a number I could actually calculate easily) on the $10 or $20 I had and loaned to him. These events were few and far between, especially as I got older. My more common modus operandi was to ask/beg for some money once or twice a month then immediately go spend it at the damaged goods warehouse store down the street or go to a movie. I very rarely had money; usually I was out and just demanded a toy and that was how I got stuff (I was a brat; mainly because it worked).

The biggest thing I had going for me after this childhood was that I've always been a planner and I knew money management was important (Thank you high school economics!) . When I was 12 and 13 I saved my money up and bought myself a refurbished TI-85 calculator and a copy Borland Turbo C++ even though I had never programmed anything more complicated than a text adventure game in BASIC at the time, because I knew without a doubt I was going to be a "programmer" and I was going to learn a lot of math even though I was on the fast track to becoming a high school drop out with my 1.9 GPA (my only A's were in electronics and wood-shop) my freshman year of high school, due to issues at home. I can think 1, 2, 5 years out and know where I want to be then decide all the steps that I need to take to get there (even if my plans were derailed by being a spendthrift or unfocused).  Eventually I decided to leave my dad a move in with my mom, who had just moved to England from Japan at the time. I spent the rest of high school being an geek and learning how to play the game of school.

The makings of a winner? (Net worth: $2,500)

When I graduated from high school I had earned probably less than $1,000 in my life and most of that in the last few months leading up to graduation by working at a grocery store. However while I worked at that Kroger in Duluth, Georgia I was excited because I put part of my wages into the employee stock program.  I loved looking at my pay-stubs and seeing that small number of stocks increase...however slowly (I knew stocks were the way to make money because you buy them for one price and they go up to another and that was about it, high school economics didn't go very deep into the material, but I loved the idea of compounding). But the number grew very slowly with such a low paying job and the stock price was just as slow, so I quickly got frustrated because I just resigned myself to accept it.

After graduation my next move was back to Minnesota to work in a plastic factory for a year. I had an uncle and some other relatives that worked at Juno, so I got a job there making decent money, I think at the time it was $10.00 an hour for entry level work.  I took the weekend shift and worked three 12-hour days Friday, Saturday, and Sunday and was paid for 40-hours; plus, I got four days off a week and two weeks of vacation a year. It was a very good job to me at the time and living with my grandma I had regular spending money for the first time. I even managed to save around $2,500 in that year for college, but that was as far as my money management went. Pay yourself first (I think I was around 10%, because isn't that what you're 'supposed to' save as an adult?) , then spend everything else. I was happy and thought I was doing well. And thinking back it was the last year I was debt free.

My first big mistake (Net worth: < -$10,000 student loans and < -$3,000 credit card debt)

That was the last time I was so care-free. The following fall I started college at the University of Minnesota. I followed all the instructions and filed my FAFSA, I qualified as an independent student and immediately got loans for as much as I could. Plus, I received around $10,000 from my mom and step-dad for tuition. I lived in the dorms and got a single-room ate in the cafeteria and enjoyed some spending cash on my dining card every semester. I lived and studied then at some point during my first year I started feeling a pressure from being in debt. My mom started talking about how expensive college was and that when I graduated I'd better be prepared to pay it all back and help my half-sister through college. "What? Really?", I thought to myself, "You expect me to pay you back and on top of that 'help' pay for Nicole's school?" That just didn't sit right with me. I had also gotten a couple of credit cards during the year and bought a 19" lcd monitor, one of the really early ones in 2001 for around $2,000. By the end of the year I'd gotten a new job on the systems team in the computer science department, but that was barely more than minimum wage,

I started looking into the Army Reserves as a linguist since I was triple majoring in Computer Science, Math and Japanese and ended the year by enlisting in the Air Force two days before 9/11. That summer I also borrow around $500 from an exchange student friend of mine to cover my credit card bills (I think  and never paid him back (That's the only debt I've ever skipped out on. I kept a record of it for the next five years, but eventually it was lost. I knew he wasn't hurting for money at all, but I still feel bad about it to this day.)

Thursday, April 28, 2011

Creating a plugin interface in Java in only 16 lines of code

I have been working on refactoring a java graphics package for the graphics program at EWU and noticed that it was adding tabs to a JPanel, so I figured that it could put all the tabs in a package then scan the directory for appropriate classes and load them dynamically. Voila instant plugin architecture.

It turned out to be pretty simple using Java's ClassLoader interface. The only complication was that my tabs had parameters in their initialization functions, so I needed to create a super class(MasterPanel) that held that functionality and call that instead of casting the class as a JPanel, since I don't know what the panel names might be in the future.

//Get the path of the package relative to the project directory
String packageName = "";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 
String path = "./" + packageName.replace('.', '/');
//Check all the files in the package directory for Panel.class files
//If there are any add them to this panel as tabs 
File dir = new File(path); 
File[] files = dir.listFiles(); 
for(File curFile : files) 
  if(curFile.getName().endsWith("Panel.class") && !curFile.getName().endsWith("MasterPanel.class"))
    String curPanel = curFile.getName(); 
    int index = curPanel.indexOf('.'); 
    curPanel = curPanel.substring(0, index); 
    Class<MasterPanel> loadPanel = (Class<MasterPanel>) Class.forName(packageName + "." + curPanel); 
    Constructor<MasterPanel> constructPanel = loadPanel.getConstructor(new Class[]{Scene.class}); 
    MasterPanel newPanel = constructPanel.newInstance(new Object[]{theScene}); 
    if (newPanel != null) 
      tabPane.addTab(, newPanel); 

Thursday, April 21, 2011

Time to bite the bullet.

I've been interested in making my own website for quite a while, but being so public I always felt shy about putting my first attempts up.  Also, I never felt I had anything interesting to put on a web site.

But I decided to go ahead with it.  And I'm starting with Linode as my hosting service, since they have a suite of wonder tutorials that will guide me though all the steps I need to get going.

What finally pushed me over the edge to build one was Nai over at pragmaticstartup)). This guy is starting from ground zero and letting people know about his successes and failures. So, why can't I do the same? Of course my first website will suck, but that's where everyone starts.

I guess I've just let my pride in knowing what I'm doing get in the way of trying new things.

Stupid solarmist, get over yourself or you'll never grow.

Saturday, December 4, 2010

Graphics fundamentals - the why of "4-D" (homogenous) coordinates

(Note: This is not meant to be a comprehensive list of the why's of homogenous coordinates, just some of the bigger ones)

Apparently computer graphics is a bit of a black art when it comes to why things are represented the way they are, even if you "know" basic linear algebra.

This is a response to by way of

In this article the only prerequisite is knowing matrix multiplication is not commutative(i.e. order matters in multiplication of matrices) and how to multiply and add matrices.

If you've never been exposed to OpenGL or D3D you might assume everything is done with 3x3 matrices, but you'd be wrong.  Actually, everything is done in homogenous ("4-D") coordinates.  Now why the hell would you use "4-D" coordinate when you're going to be projecting 3-D objects onto a 2-D screen?  Well, it simplifies the math, that's why.

Suppose you have a line segment (from pt A=(1,1,1) to B=(0,0,0)) in space and you want to stretch it along the y-axis and move it out one unit from the origin on the x-axis. Well, using normal 3-D coordinates you'd need your scaling/stretching matrix (S) and your translation vector (T)

Translation is pretty straight forward just add how much you want to move it on each axis (negative for moving it closer to the origin, positive for further away).

T = (1, 0, 0)

The basic scaling matrix looks like this

  [stretches x 0 0]
S=[0 stretches y 0]
  [0 0 stretches z]

We'll stretch it along y by double, so we just make the second term 2 and the rest 1.

  [1 0 0]
S=[0 2 0]
  [0 0 1]

Then you apply it to your points (A and B).

(First stretch then move)
New A = SA + T and
New B = SB + T

Well, what's wrong with that? It seems simple enough. And it is until you realize that most graphics objects are going to be significantly more than two points and you need to apply those transformations (and usually many more) to each point in the same order (because remember multiplication is not commutative for matrices).

Now how can we make this process more fool proof? Well, if we had a way to represent all our transformations as a single object that would make it much easier to not make mistakes. And hey, while we're at it let's only have to worry about one type of object, matrices, for those transformations (rather than matrices and vectors/points).  It turns out that the 4x4 matrix space takes care of both of these problems for us. And for free it throws in elimination of an operation, addition. Yup, now we can do all of our transformations as matrix multiplication only.

Going back to our last example if we add another coordinate we have points that looks like P = (x,y,z,w). Now we're going to set w to 1, so terms don't disappear on us as we move our points around. This makes our original points A=(1,1,1,1) and B=(0,0,0,1).

First, in 4x4 space we have to notice that the identity matrix is

   [1 0 0 0]
I= [0 1 0 0]
   [0 0 1 0]
   [0 0 0 1]

The 1 in the bottom row is important to keep things consistant just like having w = 1. As I'll show in a couple of steps.

This makes scaling matrices look like

  [Sx 0  0  0]
S=[0  Sy 0  0]
  [0  0  Sz 0]
  [0  0  0 Sw]

For the most part we'll never scale w because it is just there as a place holder.

Moving our S from 3x3 to 4x4 we get

  [1 0 0 0]
S=[0 2 0 0]
  [0 0 1 0]
  [0 0 0 1]

Now let's put our T in 4x4 as a matrix this time

  [1 0 0 Tx]
T=[0 1 0 Ty]
  [0 0 1 Tz]
  [0 0 0 Tw]

Why are we doing it like this? Well we need to notice that if we multiply a matrix and a point (x1,y1,z1,w1) in 4d we get

[1(x1) + Tx(w1)]   [1 0 0 Tx][x1]
[1(y1) + Ty(w1)] = [0 1 0 Ty][y1]
[1(z1) + Tz(w1)]   [0 0 1 Tz][z1]
[Tw(w1)]           [0 0 0 Tw][w1]

This is almost what we want. Except that w1 is in the way.  Ah, that's why we set w=1. If we do that everything works out right.

Now we can do our formulas again, but this time we need to combine matrices before apply it to the point

New A = (T+S)A and
New B = (T+S)B

I thought you said we could eliminate addition I hear you crying. We can! IF you set Sw = 1 and Tw = 1

[1 0 0 Tx]   [Sx 0  0  0]   [1 0 0 Tx]   [Sx 0  0  0]
[0 1 0 Ty] * [0  Sy 0  0] = [0 1 0 Ty] + [0  Sy 0  0]
[0 0 1 Tz]   [0  0  Sz 0]   [0 0 1 Tz]   [0  0  Sz 0]
[0 0 0  1]   [0  0  0  1]   [0 0 0  1]   [0  0  0  1]

That gives us a single matrix that we can work with now

         [Sx 0  0  Tx]
TS = T*S=[0  Sy 0  Ty]
         [0  0  Sz Tz]
         [0  0  0   1]

Now we can take this TS matrix and apply (multiply) it to each point, rather than having to apply a formula to each point. This saves us coding and it also saves cycles (by only combining our transforms once, rather than each time we apply it to a point).

New A = (TS)A and
New B = (TS)B

Be careful with this example though, even though it doesn't matter what order we did the operation this time that's not true once you start rotating things in space, then it very much matters what order you build your transformation matrix in.

If you want to learn more about this subject let me know and I'll start posting about some more of the fundamentals.  Or you can go to check out this course on fundamental math used for graphics ( He keeps the linear algebra as simple as possible. For a more in-depth explination see chapter 4 of Essential Mathematics for Games and Interactive Applications, Second Edition: A Programmer's Guide (A great book, all the math you need for graphics and games, but in general WAAAY more than you need for most projects and it's pretty formal so you better remember your sophomore/junior level linear algebra. Overall, it makes a great reference though). 

Tuesday, November 23, 2010

Let down by the system?

I read this presentation the other day and was struck by how much it sounded like advice I've heard for computer science students.  Go do something real, anything! Go work on an open source project. Start your own. Work through OCW material, something that other people haven't done. And although it has that self-help guru slimy feeling to it, it does a decent job on delivering what it promises.

View more presentations from Charlie Hoehn.

I was treated like Charlie when I was in college. I was told over and over just get through school and you'll have an amazing job waiting for you at the end of it all.

Having my computer science degree in hand I can tell you that's not exactly true. While it is an enormously marketable degree and I've never had trouble finding a job, they weren't exactly stimulating or enriching jobs(in any sense of the word) and they actively drained my passion for technology, but I thought that was what a fresh grad was SUPPOSED to do.

Building on Charlie's thoughts I think the problem is two fold. And it isn't a problem with college per se, but more the attitude about college.

First, the education system and people's thoughts about it are stuck in the past when getting a degree wasn't something you were expected to do. It was something people did to get ahead, somewhat like getting a master's degree or MBA today (this won't be true tomorrow though; considering the rate we're cranking out MBA's and other advanced degrees). It made you stand out in the crowd of other people.  Sure maybe there were 50 applicants for a job in the 80's, but only five of them had degrees. Unfortunately this idea is still lingering and people in college the idea they are entitled to a job upon graduating.

Well, that idea is total crap. It's never been the degree they cared about. They just wanted some way of weeding through all the weak resumes down to a number that was manageable. People aren't good at making choices based on a large numbers of options. Think The Paradox of Choice. They want a handful of decent options to consider.

This leads to the second problem. The idea of doing a job search the way they teach you in high school and college (by finding job postings, sending out 1,000 resumes and praying for an interview) is completely useless, especially for new graduates! Like Charlie talks you're competing with all the people that have been in your field for more than a decade, all the people overseas that will do anything to get to the states, and all your peers. Good luck standing out in that crowd.  The other method they tell you to use is networking talk to everyone and I'm not sure about you, but I've never met anyone outside of sales that's ever actually been successful with that approach until they started developing skills and a reputation for people to talk about. "Oh, Josh? Yeah, I know him... He's that guy I went to college with. I think works for a computer company now or something." or "Hey, you should come work for my company they're awesome we make software that counts beans! (and they give me a hiring bonus for every sucker I bring in)." Most people don't get their dream jobs like that.

If you want to stand out and get your dream job then you can't follow everyone else and just try and do it better than they did. In the past I've tried to follow the culture and read Slashdot or Arstechnica and while entertaining, it hasn't let me forward. I could read twice as much Slashdot or write four times as many merge sort algorithms in the languages of the day, but that wouldn't put me ahead of the game. If you think the heart of the tech industry is facebook then let me tell you, you're way behind behind the time. Yes, facebook's a great company and they do cool shit, but they're no longer "it". And if you start with your goal of aiming to get into facebook then you're just like the 10,000 other CS grads this year that want that nice big cushy salary they offer.

What I've found has helped me most in finding jobs I'd actually want to do is to plug into the community that's on the bleeding edge of your field (not academia, of course) and follow it.   For me, right now, that's Hacker News.  If they recommend a book to each other, then read it and try to figure out why they recommended it. If they think a program is awesome, spend time with it and figure out how they made it like that (ideally read the code if it's open source). Be pick a technology or language that's brand new or no one uses and learn it just for the experience. Once you plug it you'll start feeling the ebb and flow of different topics and what's hot or not and once you learn more and more you'll be able to start picking them out yourself. Once you're on the pulse of the industry you start seeing potential jobs everywhere you look.

I'm not sure I stayed on topic here, but I think I said what I was trying to. Conventional wisdom is wrong and you need to stay at least one step ahead of everyone else if you really want to do great things. Who know, by the time you read this all this information may be out of date, but the ideas are sound no matter when it is. If tomorrow everyone has Ph.D.'s (and that may very well turn out true the way the academic system is churning them out in the US) then just having a Ph.D. won't mean anything to anyone. And all the smart people will have found twelve new ways of standing out.