You are currently browsing the category archive for the ‘programming’ category.

Npm link, wait, what!? Yeah npm link, a way to test npm packages as you develop them. This is a little something I learned last week and need to write it down so I remember how to do it.

I was working on the THAT Conference api and needed to add a custom GraphQL scalar for a ‘Slug’. In this particular case I am working with member slugs, though the Slug scalar will be utilized for any of our slug needs.

The package project, that-api, will contain the new Slug scalar located locally at ~/tc/that-api.

The api project, that-api-members, will be using the new scalar located locally at ~/tc/that-api-members.

After a bunch of hacking, etc. its was time to test the npm package in the api project. Here are the steps. This assumes that both packages pass tests, build and run. Both these projects use Babel and output to a folder named __build__. Package name is @thatconference/api

Starting with that-api

$ cd ~/tc/that-api
$ npm run validate
$ npm run build
$ cd __build__
$ npm link
$ cd ..
$ npm run dev

Now at the api project that-api-members

$ cd ~/tc/that-api-members
$ npm run validate
$ npm link @thatconference/api
$ npm run validate
$ npm run start:watch

At this point the that-api-members project is running using the linked that-api package, not the one downloaded into its node_modules folder.

So to undo this. I am not 100% sure this is correct, but it seems to work.

Unlink the the package from that-api-members.

$ ^c
$ cd ~/tc/that-api-members
$ npm unlink @thatconference/api
$ npm i @thatconference/api

Stop the running code and unlink to remove the link from npm which removes it from global location `{prefix}/lib/node_modules/<package>`

$ ^c
$ cd ~/tc/that-api/
$ npm unlink
$ cd ..

When you unlink a package it removes it from packages.json, so we need to then add it back. This is why we removed the global link first so we could install and get the package, not the link.

A Few Notes

  • If you use a node version manager like nodenv, both the application and package need to run the same version or the application will not be able to locate the link.
  • Using the command npm --link=true may show linked location in your node_modules.

oct 2020: instruction fixes

It seems after every MacOS update these days I get this reoccurring issue about not being able to build GYP in a node project. I got tired of looking up the references to fix it and am consolidating them here for future reference.
Note: October 2020 update at the bottom (x-code 12).

The Error

The error that is thrown (or close to it is):

gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (/usr/local/Cellar/[email protected]/10.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:191:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.3.0
gyp ER

The Fix

XCode CLTools is require for this to work. I don’t know the details, only what has corrected this for me in the past.

Check if installed:
/usr/sbin/pkgutil --packages | grep CLTools

Nothing will be returned if they are not present. If they are, ¯\_(ツ)_/¯, more research I guess.

Install XCode cli only (may need to use sudo:
xcode-select --install

If you received the error, “xcode-select: error: command line tools are already installed, use “Software Update” to install updates” you will need to remove the xtools first. Per the documentation you do that by:
sudo rm -rf /Library/Developer/CommandLineTools

Run the install again, and all should install as expected (may need to use sudo).
xcode-select --install

Once the install is complete recheck if CLTools are present:
/usr/sbin/pkgutil --packages | grep CLTools

You should received a response something like:

That’s it, try your build again.

October 2020 Update Note:

I still run into this issue after most updates. It happened again after the macOS 10.15.7 update. Though this time when running the install (sudo xcode-select --install) a message popped up that the software could not be found on the server. After some Duck Duck Googling I found the X-Code CLI Tools download. After installing this I was back in action and able to build again.


The 12 factor app, guidelines to build applications which are scalable, flexible and simply great.

I. Codebase

One codebase tracked in revision control, many deploys

II. Dependencies

Explicitly declare and isolate dependencies

III. Config

Store config in the environment

IV. Backing services

Treat backing services as attached resources

V. Build, release, run

Strictly separate build and run stages

VI. Processes

Execute the app as one or more stateless processes

VII. Port binding

Export services via port binding

VIII. Concurrency

Scale out via the process model

IX. Disposability

Maximize robustness with fast startup and graceful shutdown

X. Dev/prod parity

Keep development, staging, and production as similar as possible

XI. Logs

Treat logs as event streams

XII. Admin processes

Run admin/management tasks as one-off processes

A tall high-five to the employees at Double Fine.  That cool indie game company out of San Francisco headed up by the legendary Tim Schafer.  Why? do you ask. Well let me tell you.  


My eldest son just finished the sixth grade where he was in the gifted program.  This year his teacher decided to try the Genius Hour program in her classroom.   Genius hour is a movement that allows students to explore their own passions and encourages creativity in the classroom.  It provides students a choice in what they learn during a set period of time during school. The teacher planed to have a few Genius Hours throughout the year.  The first two Genius hours the students may pick any subject that they don’t already know about.  The third Genius hour the students needed to pick a future career.  After the students learn about their subject they put together a report and short presentation to explain what they learned, etc. to the rest of the class.

Genius Hour Logo

For his first Genius Hour he chose ink as a subject to learn about.  He never really said why, “just because I was interested in it”, he would say.  Okay, cool.  He sure has brought up some interesting ink facts over the last few months I must admit.  I never did see his presentation, but I believe he received a perfect score.

His second Genius Hour was on building games in Unity3d.  He went through one of their tutorials to build a top-down space shooter game.  This was followed by a presentation of what he did and what he learned. One conclusion of his project he discovered he prefers is creating content and story-lines over hacking on code.

Space shooter imageIt’s his third Genius hour, future career, that I am writing about here.  The teacher had the students research the chosen career and interview someone in that field. My son chose, “Senior Developer at an Indie Game Company.”  As a programmer myself, this sounded interesting.  And who wouldn’t want to create games for a living? I know I would love to! It seems natural that he would pick game development of some type. Since he was very young, at least three, he would make up games all the time to play with people.  His Grandmother Debbie played these games with him the most.  She would say they are really creative, though, of course, skewed for him to win.  😉  He has continued to create games with parents, friends, neighborhood kids, etc. and they are much more fair now (so we think… j/k).

As time went on an his deadline came closer I kept asking him how things are going.  He usually responded that he was researching about the job but had not found anyone to interview.   I thought he may be able to interview me, though honestly I am, at best, an aspiring game developer.  I thought of a few friends at work, but they didn’t fit well either.  Until one day I thought of Double Fine. Oh that would be perfect!

I first heard of Double Fine through their Kickstarter, “Double Fine Adventure“.  I have always loved Tim DoubleFine logoSchafer’s games and the fact he wanted to raise money to build one without the bureaucracy and bullshit of production companies. I’m all for it, sign me up!  On top of that they planned on filming the making of the game and provide that movie to backers.  When I saw this, I had to have a copy of the movie. Mostly because I hoped it could give an inside view for my son on what goes in to these computer games he loves to play and design.

So my next question was, how to contact them?  I started with the basics, the about/contact page on their website.  I found a general email address and started crafting an email.  It was a horribly written email, I have no idea what I was smoking at the time. My wife still loves to rib me about my appalling use of the English language.  Though this didn’t matter.  I sent the email on Friday, April 25th at 17:32 Central Time.  I didn’t expect to here back from anyone until the following week.  By 18:02 that same day I received a response which started out with:

“I’ve forwarded your e-mail to the whole company and there are already a few that are more than happy to oblige. You should be getting a separate e-mail from one soon.”

What!? Are you kidding me? That is freak’n awesome!  I really didn’t think anyone would really be interested.  I was flat out wrong.  A few seconds later I received an email From Ben Burbank, a senior developer at Double Fine.  Him and another showed interest and agreed to an interview.  After a while there where a few more who were interested as well.  At this point I was kind of hoping to hear form Tim himself, though I knew that was a pretty tall order.  The overall response from the company’s employees was so warm.  They expressed so much interest in helping.  It was refreshing very appreciated.

I had my son plan out the time and interview with Ben and others.  He needs to learn these things, I got him the contact, he can run with it.  Which he did pretty well.

The day of the interview Ben and others spent close to one and one-half hours on Skype with my son.  That was so completely awesome.  I am so happy I reached out to Double Fine, the results turned out better than I had hoped.

My son finished his interview, wrote up his paper and completed his presentation all on time.  He “winged” the presentation, which I wasn’t too happy about.  Though he needs to learn in his own way.  His score reflected his input.

It is now a couple of weeks into Summer break and he has not stopped creating.  He put together a mod pack for Minecraft to design some mini games around. And just today, designed some floor game using dice and army men which he said he really liked the outcome of and plans on writing up rules/instructions.

Needless to say, but I will anyway, I am so proud of my son.

I have real simple advice for him, “Never stop being awesome.” Everything else will fall in to place.


To the great people of Double Fine:

Thank you so much for taking time out of your day, your life, to give a little of yourself for the benefit of my son. I really appreciate you. And hey, you never know, maybe one day he may be the Senior Developer in an Indie Game Company at your company.  🙂

If you are every in the Chicago area, give me a call, I’ll buy you a drink.


I love computer games.  I have been playing them since I was able to use a computer.  I can’t say I am an avid gamer, I really don’t have the time for that, but I sure enjoy playing them.


One game I play often, and usually with my sons, is Minecraft.  A sandbox adventure game which we have found very fun.  We have spent countless hours building different things, going on adventures and PvP fighting.

On a cold night in November I started digging in to MinecraftForge.  A modding system for Minecraft.  In short time my oldest son and I created two ‘Mods’ for Minecraft: Stonecraft and GrackMod.

I really enjoyed manipulating the game play.  I found it very satisfying to interact with items we added to the game.  Play with rules we developed.  It was just cool.

A month or so prior to this a friend of mine introduced me to Unity3d.  A game development environment which allows you to release 2D and 3D games to many different platforms. And you can do all your scripting in C#!  JavaScript I believe is the other scripting language available.


Acting on the bug which bit me writing the Minecraft mods I downloaded Unity3d and started playing around.  Quickly I figured out this stuff is pretty complex, there is simply a lot to it.  Off to the tutorials!

The first tutorial I found was a top-down shooter game called, Space Shooter.  You fly a simple spaceship and shoot asteroids flying toward you.  It’s a basic 3d game which covers many of the very basics of building a game in Unity3d. My version can be found here.

Of course I couldn’t leave the tutorial as is.  Once built I added a high score, increasing difficulty with more asteroids and faster asteroids.  The overall experience was good and I want more!

Since I can’t draw for shit, and am not very creative with design tools, I plan to stick to the 2d world of gaming.  Modeling 3d objects just scares me.  So you may ask, where do you plan to get content?  Well, two main sources, first, is my son who is a better artist than he realizes and second I will end up buying available content.  I have found some decent stuff already (links needed) and I assume I can find someone to create some stuff form me.

Next on the list is to build a tower defense game.  I found at least one tutorial to build one.  It’s not 2d but  I am hoping it will provide more depth into maintaining more cloned prefabs, controlling their paths and player’s placing items.  Hey, who doesn’t like tower defense games?

See one of my ultimate goals is to build a SimTower type game.  A game I really enjoyed in the past, which doesn’t work on most new hardware (though I do still run it in an XP VM on my Win8.1 box!).  Can I improve on the game?  I have no idea, but I am going to build my version and see how it goes.  I don’t plan to get caught up in cloning the old game, I just want to take it a step (feature) at a time and see where it goes.  I think it will be a lot of really-frustrating fun to build.  The whole reason I build things in the first place.  What fun would it be if it was simple?  It would be boring and be lame.


I’ll update progress as I continue tutorials and build new stuff.  I plan to keep all of it available in GitHub so others may use it for examples or whatever.

All my main development machines are now running Visual Studio 2012.  I have a few new projects in VS2012 and have begun updating my old projects to it as well.  I ran into an annoying issue today that I need to post.

My Blog by Email site was built using VS2010 and ASP.NET MVC 3.  My new machine, which I am working on right now, is running Windows 8 and VS2012.  Recently a new user started using the site and discovered a few bugs I needed to get fixed.  I cloned the repo from Bitbucket and opened the solution in VS2012.

My first tip-off that there was an issue is when the Migration Report displayed 7 errors all on the _bin_deployableAssemblies\ folder.

BlogByEmail\_bin_deployableAssemblies\Microsoft.Web.Infrastructure.dll: Failed to backup file as C:\vsp2k12\BlogByEmail\Backup\BlogByEmail\_bin_deployableAssemblies\Microsoft.Web.Infrastructure.dll 
BlogByEmail\_bin_deployableAssemblies\System.Web.WebPages.Razor.dll: Failed to backup file as C:\vsp2k12\BlogByEmail\Backup\BlogByEmail\_bin_deployableAssemblies\System.Web.WebPages.Razor.dll  (... Plus 5 more files)

My second is when I went to run the project and the build failed for the same 7 files.

If you recall the _bin_deployeableAssemblies folder is used to aid in bin deploying MVC 3 applications to [shared] hosts which don’t have ASP.NET MVC 3 loaded.  You can read more about it here [].

It turns out this isn’t required in VS2012 as I found here :

Starting with MVC 3 Tools Update we are now using Nuget package references, which means that your project is automatically bin-deployable. Since the tooling gesture is no longer necessary it was removed from VS 11.

The fix here is really simple.  Remove the files and _bin_deployableAssemblies folder from your project.  Everything should compile just fine.

Now the one part I have not figured out is where or how we get the files that used to be in _bin_deployableAssemblies.  I don’t see them in the bin folder as I assumed they would be.  I will need to do some test deployments at my host, Arvixe (I think they didn’t have MVC 3 loaded).  Add a comment below if you h ave some knowledge around this.

I ran into a styling issue last night and it is driving me nuts.  I have found a work-around, but I want to see if I can figure out how to do this way.

I have a span tag which I am using for a button.  This button calls a JavaScript function to test blog posting settings.  I am using a span because it was easy enough to style.


#VerifyBlogClick {
border:1px solid gray;
padding:2px 5px 2px 5px;
margin:0 0 0 13px;
border-radius: 2px;
#VerifyBlogClick:hover {
.verifierRunning {


<span id="VerifyBlogClick" onclick="javascript:verifyBlog_click()" title="Tries to send an unpublished test post to your blog">Verify Blog</span>



// ... stuff


Basically what I have here is a span styled like a button.  When the button is clicked I add the class .verifierRunning to the span tag using jquery. This class changes border-right to 20px and defines a background image (a loading image).

The problem that I am running into is that any properties defined in the id selector are not overridden by the class.  It seems that id’s always have a higher precedence than a class.  I can’t believe that there isn’t a way around this, though I have not been able to find anything on the web which will work.

My work-around this is to change VerifyBlogClick to a class.  I don’t mind doing this, I would just like to find out a way to do this the other way.

I just took the long silly way around to return a json result to  a page.  I kept trying to send a json string back as just that, a string and it just wouldn’t work.  Whenever JavaScript received the string it didn’t know what to do with it, except treat it as a string of course.  I banged my head against this one for too many hours.  Though my persistence payed off.

As the night got later (I think it’s 03:00 about now) I decided to figure out how others are returning json object from ASP.NET MVC.  It isn’t as simple as it should be, but not too difficult.  The biggest issue, as with much in MVC land is the huge lack of documentation.  So looking up something like JsonResult, yields a pretty useless help page.  So more time had to go into discovering on how to actually use this cool new result type.

It turns out you can set up and action with a return type of JsonResult (it’s usually ActionResult) and have that action return a json object.  I am not even going to pretend I can do this from other objects like (from James Newton-King).  I am using this to return a model as json which populates my form with on-demand instructions.  This library rocks, but I digress.

The basic structure I used is a dictionary object

public JsonResult MyAction()
  Dictionary<string, string> dict = new Dictionary<string, string>();
  dict.Add("keya", "valuea");
  dict.Add("keyb", "valueb");
  return Json(dict);

That’s pretty much it in a nutshell.  Json() is a new web helper in MVC3.  You can find it at System.Web.Helpers.

I saw one example where you can build an object on the fly, but I couldn’t get it to work.  It basically looks like this:

return Json(new {keya = valuea, keyb = valueb};

The dictionary generic works for now.  If you know of a better way, please let me know.

While working on Blog by Email ( I came across the necessity to create my own HTML helper class.  For those who don’t know helper classes “…reduce the amount of tedious typing of HTML tags that you must perform to create a standard HTML page.”

The registration request form on the site was getting hit pretty hard by spam bots and I was getting tired of cleaning up the mess, so I decided to add a captcha.

ReCaptcha is what I decided on and started down the rabbit hole.  First of all there was only ASP.NET examples.  Since I was writing this in ASP.NET MVC, I wanted to use a more, “MVC” approach to it.  I came across an post on named Using ReCaptcha with Asp.Net MVC.  The post covered exactly everything I need, what it was missing is details around its steps, specifically Step 5 – Create a Html Helper to build and render the Captcha control. It shows the current code and nothing else:

public static string GenerateCaptcha( this HtmlHelper helper )
  var captchaControl = new Recaptcha.RecaptchaControl
      ID = "recaptcha",
      Theme = "blackglass",
      PublicKey = -- Put Public Key Here --,
      PrivateKey = -- Put Private Key Here --
  var htmlWriter = new HtmlTextWriter( new StringWriter() );
  return htmlWriter.InnerWriter.ToString();

My first thought, is cool, I can just add an HTML helper to the view to generate the captcha, this is a good approach.

First stumble, that is a method, that needs to go into a class–what class should it go in to?

No problem, I’ll just look up creating helper methods.  That was an easy search which rendered an ASP.Net site page, Creating Custom HTML Helpers.  Great, now I have my examples.  I matched it to an extension method; okay, I get that, I have used those before.  I learned the syntax and added it to my site.

It doesn’t come up in Inteli-sense.  What can it be.  I changed all kinds of things around, from renaming the class, to changing the method name.  I was wondering if it followed some naming scheme like controllers and models do.  I don’t recall it needing to.

I decided to browse though the comments, see if anyone else ran into this.  And there is was, someone named, ianchadwick mentioned a way to make the namespace global in the web.config.  Well, damn, that is it, the view doesn’t know about my namespace BlogByEmail.Helpers.  I added @using BlogByEmail.Helpers; to the top of the page, and everything fell into place.

To use the helper in the view simply use @Html.Raw(Html.GenerateCaptcha())

Html.Raw is needed to keep MVC from HTML Encoding the output.

Damn I feel dumb sometimes.  …back to my code!

For some time now I have wanted to post to a blog from an email account.  Some blog engines these days have this functionality, like WordPress and TypePad.  Some through plug-ins and some built in.  I have used the WordPress plug-in on a test installation, and it works pretty well.  Though WordPress is probably my most preferred blogging engine, most of the time when I am installing blogs, it’s on a Microsoft stack and I am not big on running PHP on Windows.  On the Windows stack I really like using Blogengine.NET.  I find it to be a very capable blogging engine.  The only problem is, at least to date, I have not found a plug-in for it to post by email.  What it does support though is XML-RPC.

With the Help of the XML-RPC.NET library and a few hours away from the family, I through together a rough blog posting application.

I added in OpenPop.NET, a popmail client library I have used in the past, and now have a way to collect emails.  Now all I needed to do is tie them all together.

The outcome is Blog by Email (  An online service for setting up email accounts to post to blogging engines.  Besides looking like crap (I am using the generic MVC layout), it is functioning well. I am hoping my buddy will give me a hand coming up with a real design for the site.

The biggest challenge to setup posting to a blog is finguring out what XML-RPC entry point is, and what the blogging engine uses for the Blog Id.  The blog id is often the name of the blog, but I found in MovableType it uses the actual integer value assigned to that blog.  Bit of a pain to get that value.  A cool aspect of MovableType is that it generates a password to use for posting via XML-RPC.  A nice security feature.

Speaking of security, to protect the users entered credentials I am encrypting both usernames and passwords in the database.  Also, each user is given a unique key pair when the sign up with the service.  Little steps to make it harder to get this information in case someone does hack the application.


If you need to post to your blog from a POPMAIL email address, give Blog by Email a try.  The service is free (at least until it grows to the point where it needs a bigger web server).

While the site is getting off the ground and I get the code stable, registration is closed.  There is a form request an account.  I am looking for people to help test the system, so if you are interested please let me know.


Twitter Updates

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: