## Solving [WordHero] October 10, 2012

I took pretty much a brute force attack at coming up with this app that solves [WordHero]. It is pretty efficient and takes longer to type in the letters of the puzzle than for it to solve it.

Here's how I went about it.

So, you get a puzzle with 16 (or so, as you can see with the Qu block) letters arranged in a 4x4 grid.  Obviously this is a dictionary brute force attack, in the most literal sense.

What I do is start at the top left block, finding words that start there, then when all options are exhausted, move onto the next block and find all words that start there, and so on until we've covered all blocks. I wrote this solution in Node.js. First, there is the LetterBox class:

```var LetterBox = function(letter, row, col){ this.letter = letter; this.row = row; this.col = col; this.used = false; } LetterBox.prototype.clone = function(){ var lb = new LetterBox(this.letter, this.row, this.col); return lb; } ```

The letter box can only be used once during a word solve. The next is the Board, which consists of LetterBoxes

```var Board = function(str){ this.originalString = str; this.makeBoard(str); this.letterBoxLookup = {}; var self = this; this.letterBoxes.forEach(function(lb){ self.letterBoxLookup[lb.row + "" + lb.col] = lb; }); this.rows = 4; this.cols = 4; }```

I implemented clone on both the Board and LetterBox classes.
The last piece is the BoardSolver class. We'll just look at two functions of it:
Solve:

```BoardSolver.prototype.solve = function(max){ for (var i = 0; i < this.board.rows; i++){ for (var j = 0; j < this.board.cols; j++){ var boardinstance = this.board.clone(); this.getWords("", i, j, boardinstance, this.dictionary); } } var list = []; for (var w in this.foundWords) list.push(w); return list; } ```

And getWords:

```BoardSolver.prototype.getWords = function(cur, row, col, boardinstance, dictlocal){ var letter = boardinstance.getLetter(row,col); if (letter == null || letter.used) return; var curlocal = cur + letter.letter; var potlocal = this.potential(curlocal, dictlocal); if (potlocal.length == 0) return; // no potentials down this path var wordlocal = curlocal.length > 2 ? this.matches(curlocal, potlocal) : []; var self = this; wordlocal.forEach(function(w){ if (!(w in self.foundWords)) self.foundWords[w] = w; }); letter.used = true; //var recurseClone = boardinstance.clone(); // n,s,e,w this.getWords(curlocal, row, col-1, boardinstance.clone(), potlocal); this.getWords(curlocal, row, col+1, boardinstance.clone(), potlocal); this.getWords(curlocal, row+1, col, boardinstance.clone(), potlocal); this.getWords(curlocal, row-1, col, boardinstance.clone(), potlocal); // diagonals this.getWords(curlocal, row-1, col-1, boardinstance.clone(), potlocal); this.getWords(curlocal, row+1, col+1, boardinstance.clone(), potlocal); this.getWords(curlocal, row+1, col-1, boardinstance.clone(), potlocal); this.getWords(curlocal, row-1, col+1, boardinstance.clone(), potlocal); } ```

So, while we're recursing, we'll get the current potential word (previous cur + this letter) and see if there are any potential words, words that start with the letters in curlocal. If there are no potential matches, stop recursion. If there are potential matches, keep going, also, store the current matched words at the current length (e.g. "break" is found on the way to finding "breaking")

To speed things up a bit, I only then search the potential list in the future attempts to narrow it down. Notice I'm passing the potlocal (potential local dictionary) into getWords on recursion.

To use the app currently, I just modify the string of characters. They are entered as follows (for example, for solving the puzzle attached in the screenshot)

[qu]aaevftmeimsckou

It will then store a file called

[qu]aaevftmeimsckou.txt.

Here's the results of it running that:

teams
omits
ammos
steam
stick
stave
smoke
vitae
smite
items
meats

My dictionary is lacking words, it only has 81,536...

One thing to point out. Since Javascript does everything by reference, I have to clone the board for each level of recursion since they will mark letters as used and then future recursions will see them as used.  The clone board method clones the letter boxes and then correctly marks the currently used letters as used in the clone. This makes it correct.

The file uses a library I wrote for node.js to easily read / write files. You can download my [WordHero] solver here. You can fill in the missing fshelp methods with standard node file IO methods.

Enjoy!!

## New Band That I Love September 12, 2012

I've discussed previously on this site my different phases of music. They usually revolve around bands or styles of music. I'm in a new phase right now. It's "no phase". I'm scouring the web looking for new music.

But I've found a new band that is worth my time and deserves my fanaticism.  The Head and the Heart.  They are pretty awesome. Be sure to watch their videos on youtube. I like all of their songs. Some of my absolute favorites, if I had to choose, are:

- Heaven Go Easy On Me
- Cats and Dogs
- Ghosts
- Honey Come Home
- Lost in My Mind

I like them all though...

## The computer of the next 6 years August 27, 2012

I bought a new "main" computer today.  It will replace two old "main" computers.  I got an MSI GE60. This is significant.

My previous main laptop was a MacBook Pro which I purchased in November 2006. It lasted a long time, but it doesn't like heat and I'm moving on. It was Core 2 Duo, 2.2 ghz or something, 2 gb of ram. I had all manner of drives connected to it, so it quit being a laptop and was permanently a desktop.

My gaming machine was also Core 2 Duo, 2 GB ram, ran XP and all my games, with its Nvidia 260 GTS I think.

One laptop to replace two machines. The GE60 is Intel Core i7 Quad Core, 2.3 GHz, can boost to 3.3 GHz. It comes with 6GB of RAM upgradeable to 16. I can order that off of newegg right now for \$90. It has an NVidia GTX 650M or however you designate that. It comes with 2GB of video memory.

1080p resolution, USB 3 and USB 2, so all my old stuff will still work, and I can still have access to my data. 7200 RPM Hard drive, but I bought a 256 GB SSD to swap in.

Back in 2006, the technology wasn't that great. You couldn't really get a laptop comparable to a MacBook Pro. Or I might not have trusted the quality of other laptops. The parts were much better in the MBP. Today, though, and for \$1000 roughly, you can get an all powerful machine that can run that old MBP virtually! I shall be doing that.

And if I want to do gaming, it's there too. I can run the latest games on that thing, at high settings. Awesome.

## Model View Controller Pattern - Brainstorm August 23, 2012

I wanted to implement an MVC solution in my Node.js webserver. Let me describe my webserver first...

I don't typically know the names of everything I create, even if I copy the concept from another technology. But here's what it has:

Server side tags (foreach, if/else, include, combine, layout, placeholder)
Page content rendering inline through \${ style } syntax. For instance \${page.title}
Servlet style "handle get" and "handle post" interface.
URL Rewriting (e.g. /item/12345/name-of-item will load (but not redirect to) /item?itemID=12345&itemKey=name-of-item
Content caching via the "If-Modified-Since" and "Date" headers
JS and CSS combining
GZIP compression on anything
Multipart and urlencoded form handling
Sessions, to store current user, etc (very extremely low very low overhead :)
Built in mobile site redirect (detect mobile and redirect to m.HOSTNAME.com)
Content sharing between full site and mobile.  So it will use the same content unless otherwise specified.  Keeps content/functionality duplication to a minimum
Application scope. Want to keep track of all the users currently online?  Simple. Cache a list from the database that will never be updated? That's a good spot for that.
HTML templates (layouts).  So you can code your overall structure once, and have pages put different pieces in "placeholders" in the layout.
.NET Style "code behind"... They aren't really, like I said in the 2nd point, they are more like Java servlets. But the front end would be /index.html and it would automatically load up /index.js and call "load" on it, unless it's a POST, then it'll call "handlePost".  I like taking the best bits from technologies with which I am familiar.

This all works amazingly well, especially considering I wrote every piece except for the stuff node.js provided, and the multipart form parser.  So I wanted to do an MVC as I've said.  One other aspect of my webserver is content handlers. For binary files, there's a binary handler, with mime types. "JSN" is my "Jason's Server in Node" files, which are HTML with those JS "code-behind/servlet" files. I could add an "MVC" handler with it's own extension, or a setting "useMVC" that gets checked when the server loads up content. If this setting is set, load up the MVC handler instead.

Model:  This part is already taken care of, as mongoDB provides an excellent data store.
View These are already implemented in JSN/HTML files.
Controller: This is the part that's tricky.  I'm thinking something like this:

function Controller(modelType){

}

HIGH LEVEL OVERVIEW (I'm getting tired)....  So a resource at /pianos/12345/view    will say "Load up the pianos controller, give me the one with ID 12345, and show it to me." Typically MVC's main distinct characteristic is the URLs.  /pianos/jason/search  will search pianos with "jason".  The actions will be defined as methods on the Controller, each customizeable of course. The controller will point the server to the correct view, passing the model along. For updates, it'll be /pianos/12345/update.  Also, typically, MVC uses REST style requests, which means to delete a piano, you would use the DELETE HTTP method, on the URL /pianos/12345/

I am too tired for this right now, hopefully I can make sense of this post in the morning.

## JsViews and JsRender Use Case... August 23, 2012

I came across JsRender a few weeks ago, looking for an updated javascript template rendering system. I was in need for a side-project at work (yes, we have side projects sometimes, although honestly, I did most of it at home).  The basic gist of this side project is this: we have many clients, with many servers that we have to maintain, and each of those has different passwords. This would replace an Excel spreadsheet that sits on a shared drive, that when a password changes, we have to go in and update it, and it might be locked because someone else is viewing it.

The technological philosophy behind the creation of this application is this:  Users can log in, add clients, environments, credentials at will. The updates are seen almost immediately to other users logged in, through ajax polling. And an extensive history is kept so we can keep track of who updated what, and what it was before. Passwords are encrypted and viewable upon request.

Some definitions... environments are like, production, staging, dev. Credentials can be username / password for remote desktop access, database, the CMS admin, FTP, etc.

Also listed for each client is their subversion URL if they have one, the version of the development environment to use, which database and version, and what CMS and version they are using, if any.\

Here is a picture of it:

So here, the client is Delphic Sage (for our website, etc), none of these pieces of data are real.  There are four environments.

Data structure is as follows:

Client: Active, Name, Host (Rackspace, Self hosted, etc), Software list, comments, Environment list, History list
Software: version, DB reference to software (type (cms, devenv, database), name, versions list)
Environment: type (free text, usually production, staging, dev), url, credentials list

The whole thing is really cool. Maybe I'll put up a sample of it somewhere, but our app will be run internally of course.  I'll post another screenshot when the styles have been updated! The data structure I created in MongoDB is pretty much literally what you see on screen, and it taught me a lot about MongoDB. I also wrote a lot of helper methods to shorten the code a lot when dealing with MongoDB. The back end is my Node.js web server (what is running this website).  I can't think of anything else to add at the moment, so that means it might go into production very soon.

I'll make follow up posts with some code.

## A Cool, Dark Room August 20, 2012

Walking into a bedroom late at night, with the lights out and the air conditioning going, always reminds me of growing up on Shadeland. I would go into the bedroom on the far side of the house, there would be no light, with the loud drone of an 80s era air conditioning window unit blaring away, with 3-5 Connell brothers, on any given night, lying around the room in various places, in various states of sleep. I'm almost conditioned to turn on a light real quick... not long enough to wake anyone and get cursed at, but long enough to mark my path through the room without steppin on any heads.

Ahh those are good memories :)

## Currently Known As... July 13, 2012

Talking in work today... I'm going to change my name from "Jason" to "The Programmer Currently Known as Jason"

## Hi Poop June 27, 2012

Sometimes I'll be picking up Beaker's poop when a neighbor waves at me or drives by. I'm going to make a more conscious effort to not wave a bag filled with poop at them.

## Change June 12, 2012

I like change.  Over the past month I've changed a lot of my life around, just to keep me on my toes. Here are a few things:

1.  Previously not a father, now a father.
2.  New car!  I bought a 2011 Hyundai Elantra Touring to replace my 2002 Monte Carlo SS.
3.  New checking account.  I've gone through the effort to move my banking to a new bank, which will probably result in more money for me in the long run, with less fees and just overall a better banking experience.
4.  Selling my house. I could use a change in the amount of mortgages I'm paying, or helping to pay, a month.
5.  New shoes!  I've gone with the laceless shoes from DC. I also have sneakers but these are very comfortable.
6.  I will be getting all of my t-shirts in the future from threadless.com
7.  Within the year I've changed hosts for my website.
8.  Galaxy S II phone in May also. Much needed upgrade.

It's good. That might be it for a while, I don't know what else I can change for now!

## Same Sex Marriage May 10, 2012

With President Obama declaring today that he has decided to support same sex marriage, it prompted me to finally get my thoughts on the subject down on paper... err, internet.

Basically I see it this way.  The United States of America was founded with the separation of Church and State as one of its principles. Marriage has been defined using a religious and classical social view; between a man and a woman. It was with a generous heart that married couples get any benefits, be it tax breaks or other benefits. Think about it. This was to help out families with single incomes, historically, and to my best guess. Having only one income with children, tax help and other benefits made this financially feasible. The economy has shifted, however. Cost of living has gone way up, and one income hasn't really been enough to raise a family. Now both parents have to work. So in the classical sense, these families with two incomes are now cheating the system!  In some sort of twisted logic. They are still getting the tax benefits of being married, but they have two incomes so they really don't need it anymore.

In this sense, with the classical definition of marriage according to the US tax law, marriage has already changed.  Leave alone any religious definition of marriage at this point, mind you. Religion and the classical social definition lead to the US Laws defining marriage as a union between one man and one woman. Religion pretty much condemns homosexuality, according to some interpretations.  Religion also condemns eating certain foods during certain times. However, with the separation of Church and State, marriage can be defined in its own, new, context. A Federal context. Religions and their followers are free to keep marriage between a man and a woman, and same sex couples would probably opt to not get married in a religious ceremony, due to the condemnation and overall unchanging view of their lifestyle. While through the government, anyone could marry anyone else.

To really buy into this argument, you have to respect what the founders of this country were trying to accomplish with the separation of Church and State.

This is also pretty easy to imagine when thought about it this way: In this country we have the freedom of religion. I could found a religion tomorrow and be free to practice it, as long as I'm not breaking any federal or state laws.  For instance, ritual sacrifice of douchebags would land me in the slammer.  With as many religions as there are already, we could have this discussion without making up one. For a quick example, let's look at the interpretation of Sunday being the day of rest and worship for Catholics. I use Catholicism because I am Catholic. If the federal government were to enforce this as a law, it would be illegal to work on Sunday, and it would be illegal for any company to be open on Sunday. While a lot of us have normal 9-5, Monday through Friday jobs (those of us that are lucky enough to have jobs), places that we depend on, specifically government agencies like the police and fire departments, are staffed 24/7. Not to mention hospitals.  According to classical Catholic definition, this is an abomination. Maybe slightly exaggerated, but imagine this was just as important as the concept of marriage between a man and a woman. Pick anything else that shows up in the bible or other religious texts and apply it to today. The world has changed. So if a religion were to allow same sex marriage, right now it would be a crime to perform this ceremony, or it would not be recognized by federal and state laws. This due to the classical definition of marriage according to classical religions and their ancient ways.

In a similar light, would we need to make laws for every religion's specific laws. Mormons, according to my limited exposure, don't drink alcohol. The government tried that... I guess what I'm getting at, is there are differences between religious laws and government laws. Yes, it's illegal to murder according to federal laws and religious laws. However, according to federal laws, you could be defending your property and kill an intruder, and go free from prison, but are you condemned to hell in this situation? Are religious laws that specific? Does religion condemn drunk driving? Of course not, since at the inception of most religions, driving wasn't a thing, unless you count chariots. So, would you follow religion as closely on these situations as you do on marriage?

I could get more philosophical about it... what is marriage anyway?  I am a married man and in no way look down on marriage. It's a commitment. (I'm not going to talk about the divorce rate, but it is worth a quick mention!) What made people decide that there should be a ceremony that joins a man and a woman for life? There are animals that share one partner for the rest of their lives when they find each other, so since we are highly evolved, it would make sense that humans would come to this conclusion. But that's just staying with the same person for the rest of your life. Marriage seals the deal in a religious and social sense. To record keepers, it's just a piece of paper, less tax returns, kids sometimes...

In many historical instances, religion was tightly integrated with law. Philosophy, the beginning of law, was very much integrated with mystical concepts. Nearly every civilization used their religious beliefs as the foundation of their federal law system. However, our founders made it clear, our laws should be separated.

In conclusion, we should really stick to this separation of Church and State since it works well in other situations. We should allow federal laws to evolve away from their religious underpinnings if society deems necessary. I'm confident that in the future, this will end like other discrimination attempts. I'm confident in the process, and the history of America's evolution beyond (arguable...) social discrimination gives me hope.

## Genevieve Naomi Connell May 1, 2012

I wanted to get this all down before "today" turned into "yesterday", and "yesterday" turns into "last year", etc.

Today, your Mom and I welcomed you into the world, beautiful baby girl! You were born by Cesarean Section at 13:14 on April 30th, 2012, weighing 8 lbs 8 oz, and 19.5 inches long.

Where to begin. I suppose Wednesday.

## Wednesday

This was the day before your due date. We had an appointment at the Dr's office. I will butcher the spellings, but we met with Dr. Heinzel. He and Dr. Laveran are really nice and very good doctors.  He measured your Mom and there was absolutely nothing going on. Dr. Heinzel set the cutoff point. If nothing happened by Sunday night, they were going to induce labor that night, and it could take a day or two for you to be born. This was due to the fact that your Mom had a bit of extra amniotic fluid in her sac, which you didn't mind at all!  It's warm and sound proof from the high pitched squeal of Beaker barking at horses on TV. We apologize for any spoiled naps caused by this same crazy dog, by the way. We can't control it!

Sunday was also the unselfish call for Dr. Heinzel, since he would like to be there to deliver you, but he wasn't in until Tuesday. He wanted to get the process started earlier, giving the pleasure of delivering the most beautiful baby in the world to his colleague, Dr. Laveran. What a guy!

The Flyers had just beaten the Pittsburgh Penguins on the previous Sunday to advance to the second round of the 2012 NHL Playoffs, which were set to begin that same Sunday we were going to the hospital.  This was fine, since the game started at 3pm and we weren't due in the hospital until 8. You will come to learn that Daddy loves his Flyers hockey! Mommy had taken off of work that week, her leave started on the Friday before, and she needed a week of doing nothing.

## Saturday

After a long week of work for Daddy, I wanted to surprise Mommy with some flowers and another little gift that, as of this writing, I hadn't given to her yet.  I had taken Beaker for a walk that morning, and we hung out with Mommy in the bed. I wanted to go get Dunkin Donuts before I went shopping, but before that I decided to take Beaker for another walk. This would prove to be a bad move.  Taking Beaker for his second walk, we went up a street where a big dog lived behind a weak gate. This time the owner wasn't there to tell the dog "NO!". It busted through that gate like Black Friday shoppers at a Walmart!  I picked up Beaker and tried to fend off the dog, but he got a pretty good hold of Beaker. I dropped to my knees, bloodying them in the process, and was reaching into this dog's giant-teethed-germ-filled-mouth, trying to get Beaker out. I ended up with some bloody fingers. I nearly passed out from the shock I just went through! You might witness my wooziness or fainting first hand if you ever get injured!!

Your grandpop, and the cop that we called, suggested that I go to the emergency room to get my hands checked out. I really didn't want to! I had to go shopping for your Mom's flowers and surprise gift!  I fought this like a kid not wanting to eat vegetables. I had other plans with a 4pm deadline, and it was 1 o'clock!

## Sunday

Sunday was game time!  The Flyers started their series against the New Jersey Devils.  Your Uncle Billy and Aunt Mara (Aunt and Uncle MOFAS) came over with your "boyfriend" Ryan, and his big sister Rayann. We watched the Flyers knowing we would be going to the hospital that night. Of course, the game went into overtime, and we didn't have time for overtime!!  I ran out at the intermission between the third period and overtime to get some last minute supplies, like Pop Tarts. Hearing the radio, a goal was scored by Danny Briere on my way back, but it was called off. I ran into the house, but in the time it took to go from my car to the house, Briere had scored an official goal, and the Flyers had won!  Oh well!  A game winning goal is something I can miss, Sunday night and Monday were not something I would ever miss.

Sunday night we were getting a little hungry, and decided to go to Casey's for dinner. We finally left the house around 7:15 PM, after getting absolutely everything we own packed up!  Just kidding, we just packed what we need, which for me didn't include extra underwear, although your Mom insists she packed it!!  Haha. I checked that bag twice, but didn't see it. I wouldn't say that they definitely weren't there, but I didn't see them :)  Casey's that night was terribly understaffed, and we ended up getting to the hospital at around 8:25, 25 minutes late.

At around 9 or 10 on Sunday night, the nurses had given Mommy her first dose of medicine that's supposed to speed up this whole process. At 2am they checked her again and gave her another dose. It seemed to be going well. At 5:15 am, her "water" broke, making for a very wet bed! Our nurse, Erin, was very excited for us. She was very nice. The medicine was working!!

## Monday

A new nurse was on the shift. Ruth. The shift change is an experience that you wish you don't have to go through when you have an excellent nurse. You just wish you could have the same nurse forever!

Ruth had asked us what we think we're having... "Boy".  "Boy".  "Boy too". We were all pretty convinced, as much convinced as you can be with zero evidence. It's pretty much academic! Ruth said "I think Girl."  "What an idiot", I thought.

In the morning, another medicine was started that would hopefully move the process along further.  More Drs and nurses checked, medicine doses were upped, more checks and larger doses; Mommy was not progressing.  You were sitting high above where you needed to be, however still head down like you were supposed to be. Dr. Laveran gave us our options at around 11:30 or 12pm, the exact time to me is now fuzzy. We could sit around for another two hours and see if you had dropped lower in Mommy's belly to see if you would come out without surgery, or we could do the Cesarean Section. The Dr. was not impressed with the likelihood of a birth without surgery. After some emotional exchange, Mommy and Daddy opted for the surgery.

This all moved so fast! There were a set of twins being born in the Operating Room (OR) in the meantime, which means we would have to wait. Your Dad was a total wreck. Your Mommy was emotional, but knew what had to be done. This was in no way an emergency, but we would have the operating room in no time! After Mommy signed a few forms, she was whisked away in her bed. The nurse had dropped off scrubs, a hat, booties and a mask, all for me. I put them on, and was pacing back and forth, just very very nervous. Will I faint? Mess up somehow? Afterall, I have no idea what I'm doing. The lack of food I had that morning would have guaranteed a faint, so I wolfed down a bagel that your Grandmom Bullwinkle brought me that morning. After what seemed like an eternity, it was my turn to join your Mom in the operating room.

Oh my goodness!!!  A precious little girl. Our precious little girl!!

A nurse had called over to me, "Dad, can you come over here for a sec?"  I, having never been called "Dad" before, ignored her completely. "Dad. Jason." OH ME! I told her, "Sorry, I'm not yet used to being called that", it being the first time.

Love Always,

## Transformation April 26, 2012

My transformation to a coffee based life-form is almost complete, as I accidentally inhaled coffee and didn't cough it up all over the place

## In Honor April 13, 2012

In honor of your tattoo of my face on your back, I got a tattoo of your back on my face.

## Some conversations should be shared April 2, 2012

Jason: apparently philly made "distracted pedestrian lanes" on some sidewalks, did you see any? it was an april fools thing, but will be around all week
Jason: so like, people could walk and text in them
Jason: pretty clever i thought
Mark: i did not notice them.
Mark: then again, i'm too busy looking at my phone.
Jason: haha
Mark: j/k.  usually i'm too busy looking for walking lanes around distracted pedestrians.

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006
2005