Mortgage Account Finances

I've come up with a brilliant idea. So I started the refinance process on my mortgage to bring down my monthly payments. I'm pretty happy with where they'll be for the next 30 years. But I've come up with a concept, at least, according to my outside influence, I've come up with it on my own, but it could be a concept already.

If I'm generally tight on finances, even with considering my mortgage payment is a lot less than it was, if I saved up in a dedicated account, enough for one mortgage payment, it would be like, after months of saving, it would be a huge release of pressure on the burden of paying mortgage that month.

If my mortgage payment is (fictitious amount here) $1200 a month, which includes all taxes and escrow, etc. Let's say I want that magical burden-lifting event to happen twice a year. I guess logically (although I came to the number in a different way) you'd multiply that mortgage by 2, to get $2400. Then divide that by 52 weeks in the year. I simply did $1200 / 26. You'd get 46.16, rounded up to the nearest penny.

$46.16 is the amount that you have to put away each week in order to have $1200 in a savings account after 6 months, that you can transfer over to your checking and use to pay your mortgage that month. Then it's like getting a cash injection. As a bonus you'd also have some extra cash in there due to interest accruing on that account over 6 months!

Obviously this isn't a long term savings plan. You'd be doing those as well on the side. I've got betterment for that. This would just be an extra account in my bank that I auto transfer $46.16 to every Friday (in my case). But I'm also transferring money to my investment accounts at the same time. It might be the reason I'm a little tight in finances, but in 6 months, that will be amazing to have that extra injection of cash!  :)  I don't do finance, just computers, so I don't know the terms for this type of financial strategy, but there probably is one.

Happy Saving!

Thread Safety in Node.js

Probably my last post about Node.js for a while. My original implementation of the webserver used page objects in the following way:

index.html -> /site/pages/index.js

Meaning that when index.html was requested, index.js was located and executed. A side effect of this, using the node.js construct "require", is that the js page will only be loaded once. Which was bad because I had my code structured in the following way:

//index.js: this.title = "My page title"; this.load = function(..., finishedCallback){ this.title = figureOutDynamicTitle(parameters); finishedCallback(); }

Granted, when someone went to index.html, there was a very small time that they might get the wrong title, in this example. But for things, like setting an array on the page to the value loaded from the database, or where you might have another case in the load function where the array doesn't get set at all, there's a very good chance that someone will see something that someone else was only supposed to see.

How I fixed this was to pass back the page object to the finishedCallback. The page object was declared, built and passed back all within the context of the load function, so it never has a chance to be wrong! This is how it looks now

//index.js this.load = function(..., finishedCallback){ var page = { title: figureOutDynamicTitle(parameters) }; finishedCallback({ page: page }); }

This works. And it's super fast still.

Borrow the good, discard the bad

In my many years of web development, I've come across a lot of good ways that platform authors did stuff, and a lot of bad ways. So I'm writing my version of a web platform on Node.js, and I decided to keep the good stuff, and get rid of what I didn't like. It wasn't easy but I'm pretty much finished by now.

As with most things I develop, I'll decide on an architecture that allows for changes to be made in a way that makes sense, but I'll start with what I want the code to look like. Yes. When I wrote my ORM, I started with the simple line,; (it turns out that's how you do it in MongoDB so I didn't have to write an ORM with Mongo :) When starting a web platform, I started out the same way.

I wanted to write:

<list value="${page.someListVariable}" var="item">
Details for ${}
<include value="/template/item-template.html" item="item" />

Obvious features here are code and presentation separation, SSIs, simple variable replacement with ${} syntax.

There aren't a lot of tags in my platform. There's an if, which you can use to decide whether to output something. There's an include, which you can pass variables from the main page so you can reuse it on many pages. This one takes an "item" object, which it will refer to in its own code with ${item}.

Recently I added a layout concept. So you can have your layout html in another file, and just put things into the page in the page's actual html. For instance, you might reach the file index.html, which would look like this:

<layout name="main">
<content name="left-column">
<include value="/template/navigation.html" />
<content name="main-column">
<include value="/template/home-content.html" />

Java Server Faces used a two way data binding mechanism which was really helpful. But then you need controls, like input[type=text] or whatever. My pages will not have two way data binding, but you can use plain html. Which I like better. (However, those controls were very simple to swap due to the generous use of interfaces by Java, and their documentation pretty much mandating their use. e.g. using ValueHolder in Java instead of TextBox, and if you were to make it a "select" or input[type=hidden], your Java code would not have to change, which is one thing I absolutely hate about ASP.NET).

I borrow nothing from PHP.

ASP.NET pretty much does nothing that I like, other than it's easy to keep track of what code gets run when you go to /default.aspx. The code in /default.aspx.cs and whatever Page class that inherits, or master page that it's on. In Java Server Faces you're scrounging through xml files to see which session bean got named "mybean".

My platform is similar to ASP.NET in that for /index.html there's a /site/pages/index.js (have I mentioned that it's built on node.js), that can optionally exist, and can have 1-2 functions implemented in it, which are "load" and "handlePost", if your page is so inclined to handle posts. Another option is to have this file exist, implement neither load nor handlePost, and just have properties in it. It's up to youme.

Here's a sample sitemap page for generating a Google Sitemap xml file:


<!--?xml version="1.0" encoding="UTF-8"?-->

<urlset xmlns="">
<jsn:foreach value="${page.entries}" var="entry">

I use the jsn prefix, which just stands for (now, anyway) Javascript Node. I wasn't creative. I guess I can call it "Jason's Site N..." I can't think of an N.

And the javascript:

var date = require("dates"), common = require("../common");

this.entries = [];

this.load = function(site, query, finishedCallback){
var self = this;
var now = new Date(;
var yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var yesterdayFormat = date.formatDate("YYYY-MM-dd", yesterday);
common.populateCities(site.db, function(states){
for (var i = 0; i < states.length; i++){
var entry = {
loc: "http://" + site.hostUrl + "/metro/" + city.state.toLowerCase() + "/" + city.key,
lastmod: yesterdayFormat,
changefreq: "daily",
priority: "1"
finishedCallback({contentType: "text/xml"});

My finishedCallback function can take more parameters, say for handling a JSON request, I could add {contentType: "text/plain", content: JSON.stringify(obj)}.

That's about all there is to it! It's pretty easy to work with so far :) My site will launch soon!

MongoDB and Node.js

I am starting a joint venture with my very good friend, where I am doing the coding, and I decided that I will be doing it in Node.js with a MongoDB backend. I was thinking about why these two technologies, and how I would explain my choices to another techy. I think I have my explanation figured out...

First and foremost, Javascript. I have come to love everything about it! For my side projects, I used to use Java, and wrote a pretty decent web middle tier and rolled my own ORM also. You are witnessing it in action by reading this post. I could make an object like "Book", add properties to it, give them properties in an XML file (a series of them, if you know how Java web apps work ;), and my ORM would create the table, foreign keys, etc. It was particularly magical in how it handled foreign keys and loading referenced objects in one SQL query, knowing which type of join to apply and everything. However, this was all a daunting task, made even more so by the fact that Java allows abstraction to the Nth degree. If I could remember that code, I would be very much more specific on how it worked, but I had an object for connecting to the database, an object in another project for building SQL because I thought I could abstract that out and rewrite it if I had to, and swap in SQL building engines. That was the main cause of pain, I would think "If I just wanted to swap in another X, it would be easy." I initially made plans to have it either go to SQL or XML or JSON, whatever you wanted, and you would just swap in an engine in the config file. It was heavily reflection based :)

So, I've been writing Javascript a lot. Only lately, but before discovering Node.js, have I come to realize its power... anonymous methods and objects, JSON, Functions as first class citizens. Of course there are the libraries, like jQuery, and Google APIs, like maps for instance. There's the shear fact that you don't have to think ahead about every possibility for an object before creating it. Like, my Book object would have an author, title, etc. If later I wanted to add the ISBN or something, in Java I would have to update any IReadable interfaces (well, considering that you could read a cereal box that would undoubtedly NOT have an ISBN, this example is falling apart, but you know what I'm talking about :P ), then update the Book class, update the list to enable searching by an ISBN, etc. Tons of stuff. Javascript:

var Book = function(opt) { for (var i in opt) { this[i] = opt[i]; } }

Imagine I start calling it with
var book = new Book({title: "Brainiac", author: "Ken Jennings", ISBN: "some string of numbers});

I can now just get the ISBN in other places by calling "book.ISBN".


I've grown weary of writing server side code in Java and C#. ASP.NET is a CF with its control design, JSF was a CF with its configs and my ginormous web framework that is almost 6 years old now, and I never tried updating past JSF 1.1, so I don't know if it's gotten any better. But Java web development was nuts, you always needed 34 external libraries, most of which came from Apache's Jakarta project (which is awesome though), intimate knowledge of how to set up Tomcat or your favorite application server, you had to know how to write servlets and JSPs, JSTL, JSTL configs, and to read a Catalina.out file. I'm sure I'm forgetting something worth hours of learning...

Node.js is simple. Create a server, attach a listener to the request method. It's so barebones, that requesting anything will not work at all on the server you just created. I researched some libraries for web app development, and I decided, F it, I'm not falling in that trap again. I've dealt with enough code in my life, I could write one. One that takes my favorite things from the frameworks I know, and works on that. It is nearly done...


MongoDB is clearly the only choice for me on Node.js. JSON documents. That should about clear it up, if you were still wondering. If still... imagine we need an ISBN on a book. There's no updating 14 stored procedures that perform CRUD ops on Book to now also include ISBN. No alter table statements... There's simply, Book has ISBN now...{title: "Brainiac", author: "Ken Jennings", ISBN: "some number"});

There'll be other books without ISBN, but that's simple... if (book.ISBN != null) (or simply if (book.ISBN) of course). So you think of the basic stuff you need to get off the ground running, and you run. You can run, and you can run fast and recklessly, because if you think of something to add, you put it in. There's very minimal pain, or slowing down, in change.

Node and MongoDB are built for scaling, but I'm not too concerned about that at the moment. Then why, you ask, am I using them? Simply because I do not know them! Although it is 10% for the learning factor, 90% for the cool factor. If it's not cool and I don't know it, then I won't go out of my way to learn it. You might ask, if you're trying to make something awesome, why don't you do it in what you know first, then convert it once you start making money? I'd rather do it in something awesome. Knowing these technologies will be more valuable to me than selling the site to Google for a billion dollars! Ok, that's not true. But if it hits that point, and I didn't do it in Node + MongoDB, then I would not have learned them, and I would not have much reason to NOW, being a billionaire, would I? :P

Oh yeah, Happy Birthday to me today :)

The Best Diet Ever

Not. For the past 3 months I've been on somewhat of a diet, but for the past 3 weeks, I really started pursuing "thinness". My goal is to be at 170, or lose 30 pounds, by the time I reach the age of 30. I think it can be done, and I've put a lot of money into making sure I can do it. First I bought a blender. The BlendTec Total Blender. It was expensive but it really works like all those videos of that guy blending iPhones say it works. I bought a digital scale. I bought a lot of fruits which I'll do every two or so weeks. And I bought a lot of granola, which will get me through the morning and will be half of my dinner every day. So far I've seen a steady decrease in my weight on my new scale. Here's my plan:

Eat not a lot of calories a day. A granola bar, a salad for lunch, a granola bar and a small dinner every day. Those granola bars are 150 calories and they fill me up for a good four hours.

Work out a few times a day. Since I still smoke (another part of my weight loss plan), I can't do 30 or 40 pushup or pullup sets every two hours. In fact, I can still only do about 4 pullups in one set! I'm getting a lot stronger though. 10 pushups right now is my max. Take the dog for a brisk walk and do 10 pushups right afterwards. Then watch tv for a bit, go upstairs and do my normal amount of pullups.

From Thursday of last week up til Monday morning, I was losing a pound a day! Then Labor Day happened and I gained 2 pounds! I had a hamburger, a hot dog, some corn, and lots of chips and salsa with cream cheese. But after a short nap (it was the most I've eaten in 3 weeks, I was tired!), I did 10 pushups. Then got my hair cut.

If you want to try this diet out, it's open source! Eat a Kashi GoLean bar with coffee, half and half, and sugar (I won't make any sacrifices regarding coffee!). This is also delicious since coffee and chocolate are brilliant together. For lunch get a small chicken Caesar salad (don't skimp! Dressing, cheese, bread crumbs). For dinner, have a turkey sandwich on one slice of 12 grain bread cut in half and another Kashi. Basically, I could give a flying f%#@ what food tastes like, or how varied my meals are. Really, I don't care. They're just something to get us through the day, not part of the day.

Workout schedule: When I wake up, I do my pullups and get a shower and go to work. At work, run up stairs and walk briskly to go pick up your salad. Usually I get a diet iced tea with lunch. When I get home from work I spread out the workout like I mentioned above. Walk in the door, pullups. Rest for 20-30, pushups. Before bed I do 10 upbeat pushups and my regular pullups (I try not to mention more than once how many of these I can do right now :) It's embarrassing), although I might do less because I just did 10 exhausting pushups. And of course take the dog for a brisk walk. It's good to get a fast dog.

That's it! Before I really started this, I was at 210 in mid June before Jamaica. Thursday when I got the scale I weighed in at 198. Monday morning I was at 193.5. Then I gained 2 pounds at the barbecue! Oh well, as long as I stick to the workout.

The real method behind my madness is to not have to work out too briskly and let my lack of previous binge eating (I would never eat between meals or eat fast food or anything really junky, but I would eat a lot...) replaced by very light but satisfying eating lose the pounds for me. It's really a mix of the two. Since I smoke I wouldn't have the breath right now to work out enough to lose the weight if I kept on my normal eating habits. That's really all I have been trying to say :) Enjoy.

And so my photography hobby begins...

While in Jamaica, I noticed how much fun Mike and Jared were having with their DSLR cameras, and I wanted to get in on the action. I will be keeping a log here for just that purpose, and uploading the photos I take to Flickr and displaying them here with the details of the photo. I've been reading up on some things, but also bought a book to help me out. I got a Nikon D40 with the default load-out, an 8GB memory card, a bag for it, and the book which is on exposure. I'll probably read around the web as well and maybe try out some trial versions of professional photo software like Aperture from Apple or Lightroom from Adobe. Jared uses Lightroom, Mike uses iPhoto which is a basic photo application. Aperture is cheaper than Lightroom but only available on a Mac which is perfect since I use one :) But I'll try them out. It should be fun. I've been into photography for a while but never really fed my interests.

I did have a camera in 4th or 5th grade, though. A really old one. I went to Notre Dame and took a photo of the gold dome they have and it turned out really good, like a post card. They also had these giant sand dunes that I took a few pictures of. We had the big red van back then. That was fun.

So I'm giving it another whirl. We'll see how it turns out. Hopefully better than my drawing experiment a year or so ago :)

I have an affinity for science

This has been apparent since I started learning about science, besides biology. I'm up the latest I've been up for the past month or so. It's 2 AM. Bear with me.

I was always also pretty good at math. No genius, but kind of quick to catch on. This was displayed in first grade when I was moved from the B class to the A class in Math. I was 6. This also was evident when instead of learning long division the way the teachers would teach it, I taught myself a way to do it without writing even a quarter as much as the teacher's method. I taught this to a kid in the class who was having problem doing it, and he got in trouble because he didn't "do all the math". But it gave right answers. I never got in trouble.

Then after about 8 years of video games (Nintendo and Sega Genesis mainly), by the time I was 14, I knew that I wanted to make video games, but didn't know what to learn to be able to do that. In the meantime, I was still in first track math, getting 95s or so without trying much, acing Geometry and Trig, doing good in calculus. When I was a junior, I had to start thinking about college, and had no idea what I wanted to do besides make video games, which I hadn't researched at all.

So, instead, I was doing good in chemistry and generally enjoying it, so in my Junior year, I wanted to be a chemist. The next year, I learned physics, was really good at it, and highly enjoyed it. Although, I was only in 2nd track physics. So I wanted to be a physicist. Either of these two would have been a disaster, I think, compared to what I did end up taking.

In college, still looking to fill that gaping void, I took a few physics classes, including astronomy. Today, I still can't get enough physics. With the advent of the internet, and podcasts, I listen to all things physics and astronomy, including Astronomy Cast. But not only podcasts. Audiobooks are like 4 hours long. I have 18.7 hours worth, including three Stephen Hawking books, and one by the Dalai Lama, which is called "The Universe in a Single Atom", which is just a history of his studies and learnings from various minds in theoretical physics.

The only things is I'm not smart enough to come up with my own theories or even begin to understand some of the more complex theories out there. There's not math in those books, though, just theories or almost proven theories, but no math to back them up. Which is fine, I'd be completely lost since I haven't had a math course in years. The way they explain it is good. The current Astronomy Cast is "What shape is the Universe?" I just get so completely lost thinking about it. You might be able to come up with any shape as long as you can come up with a bit of evidence to prove it. I can say, "When you step away from the universe and look at it, it spells 'Jason'".

And talking about 11 parallel universes. A universe that is always expanding. And every object in space, every other galaxy we see is moving away from us, but we're not in the center. There is no center. And is it finite?

The big bang. How when the universe "started", it started as a point with a trillion trillion trillion trillion trillion grams per square centimeter or whatever. My one theory is this... I imagine multiple big bangs in the past, but each time, the universe collapsed on itself. So there's no way to know just how old the universe is because each time it started over. Time started over. Einstein, move over :)

If you think about that, multiple big bangs, but this universe is always expanding now... it means that in the past big bangs there was more mass in the universe that gravity made it eventually come back together. After billions and billions of years. But what happened to that mass that now it's expanding with no collapse in sight? I don't know that there's no collapse in sight, though. If the acceleration of the expansion of the universe is slowing down, then it will collapse again. Of course I don't know that this isn't already a theory since I don't read or listen enough, and anything that Hawking doesn't discuss has since been ignored. But I'll take credit for it :)

Just wrapping my head around those ideas; the infiniteness of the universe, the shape, the center. How instead of Newton's theory of gravity where objects PULL other objects to them, instead there's wells created in space. How nothing in space travels in a straight line, not even light, since it gets warped by these divots in space created by mass. It might keep me up later thinking about it, but I wouldn't venture to call myself even an amateur theoretical physicist, maybe not even a hobbyist, I just want to understand. But Astronomy Cast says some of it is the most difficult ideas to understand. Well, I love a challenge.

Rocking It "Flat Style"

Means I went after work to the Flat Rock Saloon with my coworkers. I tried to sell the motto to the bouncer :D He liked it.

Development Underway on Ubuntu!

I've added a new feature this weekend. It would have only taken me about a half hour, but I encountered some major problems on the way. In my ORM system which I call "Dumb", table aliases were previously generated a stupid way. If a table referenced another table, and the two tables were possibly at the long end of a list of joins, it would generate table aliases something like this:


which would be joined from a table with an alias something like this:


This seemed to have worked well for a while amazingly. However, when I tried to build my latest addition, I ran into problems because my User table was being referenced towards the tail end of two different branches in the so-called "join hierarchy". Through much trials and tribulations, I eventually ended up creating a class called "JoinHierarchy" so I could get consistent and unique table aliases. I created a thing called "NewsPicture" which basically links a News item (what you're reading) to a Picture. There's also a "NewsDownload" so I can list downloads as well. Here's what NewsPicture and its join hierarchy looks like:

NewsPicture [PictureId, NewsId, Sequence (for ordering)]
PictureId -> Picture -> PictureAlbum -> User -> Bio
NewsId -> News -> User -> Bio

So as you can see, User and Bio were being joined twice but under the same alias, so MySQL has a problem with that, as well as any database management system out there. Now, each object that can potentially be saved to the database has its own join hierarchy that you can just call up whenever you need a table alias or to get all the joined fields or join statements (including left joins if something could potentially allow null). Take a look at the images and downloads below!! I'll just throw in some random ones this time.

Going strong after three days

It's actually five days with a slight lapse (one smoke) three days ago...

Part of the trick to quitting smoking is that you need to disassociate stuff that you used to smoke a lot while doing. For me it's most things besides going to church or sleeping. Disassociation takes a lot of doing everything that you smoked during, doing it more often and longer than you did when you smoked, and doing it without smoking. The first of the disassociation process for me was video games.

This weekend Beaner and I played the Wii pretty much all weekend. It was indeed another "Wiikend". Tanks on Wii Play is awesome. We pretty much played three games on Wii Play the whole time, which were Tanks, Shooting Gallery, and the one where you have to find Miis. I'm not sure what it's called. Bean made a Mii, too, which looks a lot like him.

Besides the Wii, I played a lot of STALKER, Rainbow Six Vegas, Company of Heroes, and Sid Meier's Railroads! The latter game was played the most because I bumped up the difficulty from where I'm used to playing, and I bumped up the graphics to 1280x1024 with anti-aliasing on. It looked f@%#@$ing beautiful. It's a slow paced game where smoking would be easiest. You're not always doing something with the keyboard and mouse. You'll set up a route and wait until you're able to make enough money off of it to set up more routes. It's a good financial strategy game. Lots of time to sit back and smoke, which is what made it all the more worthwhile to play it a lot.

Did I mention that my new computer is a goddamn beast?! I think it actually runs cooler than my liquid cooled PC. And I'm telling you, Company of Heroes never looked so good. I have it maxed, but the thing that makes the biggest difference is having the effects maxed. So when my rifle guys are shooting their Browning Automatic Rifles, they kick up dust next to the German soldiers they are shooting at. Or when I drop a howitzer artillery strike on an enemy base, the dirt, concrete, and dudes that it hits all go flying. And I'm so damn good. Zatko and I played a multiplayer game at about 12:30 am Sunday on Seine River Docks. It was him, me and a hard computer vs. an expert, a hard, and a normal computer. Zatko was backed into his corner sucking his thumb, while I was trying to make forward progress the whole time. :) It was a brutal match, but I finally broke through the computer's defenses across from me, and eventually made my way through to the other computers. All without smoking. The only bad thing about online multiplayer is that you can't tell which computer is which. Meaning, I would love to know if I had at least the hard computer across from me. Zatko and I were split with the hard computer between us, and the hard computer wasn't doing anything. So he had a good opponent across from him. I know the CPU player across from me was getting help from someone, so it's not like I couldn't take out a medium. The expert was definitely helping. Anyway, after an hour and twelve minutes, the match was over and we emerged victorious.

Rainbow Six Vegas is a fun game, and it also looks terrific. I had started it on the old computer, but decided that I wanted to go through it from the beginning when I got the new computer up. Well worth it. The combat in it is fun. First person, or even third person, shooters haven't really innovated in terms of combat. I can name a handful... FEAR, Max Payne (1 & 2), Brothers in Arms, and Rainbow Six Vegas.

In FEAR, it was just incredible. I have to install that again. Running up to a dude in slow motion and bashing him across the face with your gun could never be equaled in any game. Or throwing a proximity mine then switching to slo-mo and watching it jump up and explode at eye level with enemy. In Max Payne, again with slow motion, diving and watching all the bullets fly was great. Max Payne 2 introduced a more interactive environment with physics, which became apparent from the start when you shot a dude into a tray full of medical supplies in the hospital and watched it all fly all over the place in slow motion. Brothers in Arms had a less interactive environment than both of those games, and no slow motion, but still it was very innovative. You couldn't kill a guy unless you suppressed and flanked. You could sometimes score a lucky shot, but you had to use the situational awareness (pause and view from above the battlefield) to find the best place to suppress from and the quickest path to flank. Each map was like a puzzle. The third one in that series is sure to be a blast, with a more interactive environment (built on Unreal Engine 3, with destroyable buildings and the like).

I just noticed I'm missing some movies. Sometimes my movies will make their way downstairs. I like to watch them on my MacBook Pro, so the best ones are usually in my bedroom. But sometimes my brothers will take them downstairs where they'll pile up until I collect them. Tonight I collected about 30 of them and brought them back upstairs. That's like half of my collection. But I know that I'm missing some, like Minority Report. I should really keep a better catalog... but once I buy a house, it'll be easier to keep track, since I also have some movies in Jeff's room, like Hitchhiker's Guide to the Galaxy. I'll collect them tomorrow. I'll probably end up buying Delicious Library... if there's a way to export it to some format that can be put onto a website easily. That would be a great use of a webservice... send an image with a barcode and get back the details of whatever it is you scanned. Or just a website with an exportable format where you upload images of the barcode (or ISBN for books) and it adds it to your library. The new applications will not be run on my computer, which is what Google has figured out. There's no need for anything but computational intensive applications, or just stuff that you can't do on the web, to be running on my computer. Figure it out, already, stupid internet. I'm out.