Merry Christmas Karla

Hopefully when you’re parched and need something tasty to drink this helps you hit the spot. I want to give you a big juicy hug and kiss.

Love Scott

Leave a comment

Merry Christmas Mom

Mom, I hope you enjoy this book. I read it this summer when looking for a good fun world to dive into. I think you’ll like some of the strong female characters and appreciate a very unique approach to story telling.

Oh Dad, if you’re reading this – you’ve chosen incorrectly. Try again.

Leave a comment

Merry Christmas Dad!

I loved this book, I finished it only a few days ago. This was my rowing book – the audible version at least. James Reece is a Dirk Pitt like character that I think you’ll really like. Oh and Mom, if you’re reading this, you’ve chosen poorly. Try again.

Leave a comment

Merry Christmas Karly

Karly we the kitties: Max, Ni Ni, and Freyja did the work for this. Boy was lazy and just laid on couch. We insisted though and wanted you to have something to open on Christmas Morning. We Love You! You tell us we are pretty and never say mean things to us.

Love you Baby!

Leave a comment

The World’s Most Over Engineered BBQ Thermometer

So let me tell you a story.  Our story starts on Christmas morning, 2018.  I was hosting, my family had spent the night at my house christmas eve.  Being foodies we were beyond excited for the succulent 8lb prime grade prime rib that we would be cooking that day, outside on the large big green egg on my deck.  

We had an amazing Christmas with presents galore.  The grill was at the perfect temperature, the $160 cut of prime grade beef was prepped and it was time to cook.  It all went without a hitch as I loaded the grill up and placed the dual temperature probes – one in the meat one on the grill itself.  We waited, and waited. After about five hours it seemed like it should be done but the thermometer i was using at the time insisted no that it was not done.  So we waited and waited longer. Finally being very curious why it was taking so long I grabbed another instant read thermometer and checked it myself. At 120F we were going to remove it from the grill and let it gradually come up to a perfect rare doneness.  

When I plunged the thermometer into the roast I was horrified to see it was already at 142f.  It was overcooked by 22 degrees. My thermometer probe had failed and could not be trusted any more.  Something had to be done before next christmas.

But what to do?  As I stood in shock from the tragedy that had befallen us a plan suddenly became clear.  

There is only one thing to do.  Only one course of action that would be possible.  Build a Mult-Tenant Kubernetes Based BBQ Thermometer in Golang.  

Why had I not seen the need for this before?  By capturing more than one probe’s worth of data for each data source (two for grill, two for meat) then one could not fail without leaving detectable evidence of the failure.  Also, by tracking historical data and combining it with ambient weather conditions if both probes did fail you could compare past cooks with historical ones and against historical weather conditions to tell when the time was getting abnormally long for a cook.  

That was just the start though, eventually I would be able to build in AI to detect an event hours before it happened by comparing the temperature curve with historical data.  Gradient descent might be a simple way to do it.  

It needed to be run in Kubernetes because I would need the scalability of being able to go out to five thousand nodes.  We take our bbq very seriously.  

In the coming months I would build the thermometer.  Its not done yet, the code is all here to be reviewed but there is more work to be done.  I have gained a lot of insights by looking at the temperature curve of a cook. Specifically for the rather long cooks – Boston Butt or Brisket.  By graphically analyzing the temperature curve I’m able to spot the stall and to see that sometimes it happens sooner than the 160f that its supposed to.  Accurately detecting this can cut hours off of a cook.  

I’m actively working on this all the time.  The project is hosted in github:  https://github.com/ssargent/bbq  and uses Kubernetes, Golang, ReactJS, Redis, Postgres, Typescript and Javascript.  If you’d like to know more come check out the page on github.

, , ,

Leave a comment

Tensorflow Error Cannot Find cudnn64_6.dll

I’m trying to dabble in Deep Learning – cause that’s a simple topic you can just dip your toes in right?  Ok well maybe I’m overly optimistic.  But I did run into an error this evening that threw me for a loop.  I’m sure I’ll see this error in a few months on my other machine and be baffled.  On that day I’ll google and hopefully find this post.

The Error:

Traceback (most recent call last):
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\platform\self_check.py", line 87, in preload_check
 ctypes.WinDLL(build_info.cudnn_dll_name)
 File "C:\Program Files\Python 3.5\lib\ctypes\__init__.py", line 347, in __init__
 self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File ".\helloworld\world.py", line 4, in <module>
 import tensorflow as tf
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
 from tensorflow.python import *
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
 from tensorflow.python import pywrap_tensorflow
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
 self_check.preload_check()
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\platform\self_check.py", line 97, in preload_check
 % (build_info.cudnn_dll_name, build_info.cudnn_version_number))
ImportError: Could not find 'cudnn64_6.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 6 from this URL: https://developer.nvidia.com/cudnn
D:\source\github.com\ssargent\ml\tensorflow\src [develop +1 ~0 -0 !]> python .\helloworld\world.py
Traceback (most recent call last):
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\platform\self_check.py", line 87, in preload_check
 ctypes.WinDLL(build_info.cudnn_dll_name)
 File "C:\Program Files\Python 3.5\lib\ctypes\__init__.py", line 347, in __init__
 self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File ".\helloworld\world.py", line 4, in <module>
 import tensorflow as tf
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
 from tensorflow.python import *
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
 from tensorflow.python import pywrap_tensorflow
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
 self_check.preload_check()
 File "C:\Program Files\Python 3.5\lib\site-packages\tensorflow\python\platform\self_check.py", line 97, in preload_check
 % (build_info.cudnn_dll_name, build_info.cudnn_version_number))
ImportError: Could not find 'cudnn64_6.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 6 from this URL: https://developer.nvidia.com/cudnn

In my case, I had run a simple hello world program using Tensorflow but found it ran slow.  I believe this is because I’m using the GPU version and its a hello world, if its not doing any real work then its likely faster to use the CPU.  However I figured an update may speed it up.  So after the update I ran the program again and got this error…  Oh shoot…

Well I should have read the message more clearly – this is clearly a #ScottFail.  I searched for cudnn64_6.dll but couldn’t find it.  I had cudnn64_5.dll but not the _6 version.  Googling was suprisingly unhelpful for this.

In my case here’s what this is saying: You have CUDNN 5.1 but you need CUDNN 6.0 – Go download that and try again.  After doing that I got this:

 python .\helloworld\world.py
b'Hello, Tensorflow'

It works!  So don’t be like me and be confused – or be like me an see this blog post.

Leave a comment

The specified cast from a materialized ‘System.Int64’ type to the ‘System.Int32’ type is not valid

I ran into a sql related .net error today.  If you read the title of the post you’ve probably guessed what it is.  If not here’s the error:

The specified cast from a materialized ‘System.Int64’ type to the ‘System.Int32’ type is not valid.

Google was marginally helpful, but if you’re like me when you google an error you’re hoping for that post that says:  If you see ABC, then you have done XYZ, do 123 to fix the error.  In this case the error is saying there’s a datatype problem.  Something about a Long and an Int.  My app only has ints.  No longs in the schema at all.  This specific error came out of an entity framework method, so I couldn’t easily pinpoint it to a given column.  98% of my app is pure entity framework, mostly code-first (though I do write out transactional schema patches to update the database in a scripted manner.)  There is one stored procedure in the app, and this stored proc I had just changed to add some new features specifically paging from the sproc.

In this case, the sproc looked like this:

Reports_MyReport SomeGuidID

it returned data of the report, field1,field2, field3 etc..

My change was to add paging directly to the sproc, reduce the amount of data leaving the box as this report was going to get hit a lot.

Reports_MyReport SomeGuid, PageNumber, PageSize

it returns data like RowNumber, Field1, Field2, Field3, TotalRows

I tested out the changes, they worked great, no nulls where they weren’t expected.

Upon running the new sproc through my app, i got the error listed above.  It turned out that my sproc, which had code like this:

select RowNumber, Field1, Field2, Field3, @totalRows as TotalRows  ….

was the culprit.  @totalRows was being interpeted as a int64, as that was comming from an @@ROWCOUNT function.  I know i’ll never have more than int32 rows in that table, so for me switching by casting to Int32 solved the problem:

select RowNumber, Field1, Field2, Field3, cast(@totalRows as int) as TotalRows  ….

Problem solved, error gone!

Hopefully by the time I have completely forgotten about this, and make the exact same mistake again – in six months – this post will be living in the googles.  Hopefully this helps someone else as well.

 

Scott

 

, , ,

1 Comment

Maximum call stack size exceeded when using Modals and AngularJS

Saw a really wierd error today, as you can guess from the title of the post it has to do with Maximum Call stack size exceeded, modals and AngularJS.   First a bit about the app.  I’m currently building a table of data, its basically a status report, so the url might be http://mysite.com/#/report/myreport  which would show you the list of data.  However I’m also building a detail page that will use a modal popup when you double click on a given row of the report.   I wanted this to be addressable so it would have its own url.  So basically i’ve got my angularjs route setup with an optional rowid parameter.

Request this:  http://mysite.com/#/report/myreport and you see the report show up.

Request this: http://mysite.com/#/report/myreport/32 and you see the report in the background with a modal overlay showing the details of row 32.

You can close the modal, view other records, the url changes as you do so.  All in all, its a pretty simple angularjs app.  No new concepts for me, I’ve used modal before, controllers etc all of it.  However, today when i wired up my code to load the modal when the page first loads, I saw an evil error in chrome:

Uncaught RangeError: Maximum call stack size exceeded.  jQuery.event.special.focus.trigger…. tons of jquery calls ….

Only in chrome, FIrefox acted a bit wierd, and IE well IE i’ll save for another day.  I tried googling it, all the results pointed to a recursive loop, but i had no recursive code.  Google was actually pretty unhelpful for this error.  I backed out all my changes for the instant modal popup functionality, and instead just wrote a log entry to the console.

The error didn’t appear, the log entry did appear, twice.  Somehow my controller was loading and running twice.  Googling that was helpful, I found this:  http://stackoverflow.com/questions/15535336/combating-angularjs-executing-controller-twice

It turned out I was doing the exact same thing.  I had no idea you were not supposed to register the controller at the top of the page if you were using routing.  Removing that single html attribute solved the dual log entry problem.  I then re-enabled my instant modal on load code, and that all worked without error as well.  Somehow with the controller loading twice and my code running at startup caused some wierd stack overflow.

Once it was loading only once the problem went away.  So here’s another post for google, I’m sure I’ll make this mistake again sometime,  probably in about three months or so.  Hopefully then I’ll google it and find my own blog post.

Leave a comment

Bundling AngularJS

There’s lots of posts out there on how to correctly bundle angularjs with any of the popular bundling tools.  I happen to use MVC’s built in bundling.  It works for me now, though I am looking at using less and gruntjs for some additional functionality.  Here’s a recent problem that I solved.  

I would see an error that looked something like this: 

Module Error
error in component $injector
Failed to instantiate module myApp due to:
Error: [$injector:unpr] http://errors.angularjs.org/undefined/$injector/unpr?p0=n
at Error ()
at http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:130753
at http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:143147
at i (http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:141792)
at Object.r [as invoke] (http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:141964)
at http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:141398
at Array.forEach (native)
at r (http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:131065)
at p (http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:141201)
at sf (http://myapp.mysite.com/bundles/app?v=xmkhVlgjOx7Eo5ltsK1SZpAavJM1dB6-bg-ujblqCgc1:1:143261

I was pretty confused as to what was going on, I’d properly configured all of my controllers so they used an array like [‘$http’, ‘$q’, …] for injection.  What was going on.  

It turned it out it was one simple error.  In my app.js which handles the routing, I had code looking like this:

myApp .config(function ($routeProvider) {
$routeProvider.

That turned out to be the issue.  Once i refactored it to look like this:

myApp.config([“$routeProvider”, function ($routeProvider) {
$routeProvider.

It then bundled nicely and no javascript errors.  I should have noticed immediately when it said a module error, but I didn’t.  Hopefully this post gets into google and helps someone else.

 

, , , ,

Leave a comment

Cleaning Up with MSpec

I use MSpec for testing my code.  I love the behavior driven approach, for me it just makes sense.  I love how if my boss asks where are we with component XYZ, I can just run all my tests and give him the output.  It shows what’s working and what’s not.  Further more, we can say or make a rule that software doesn’t have a feature until there’s an mspec test saying that it does.

I was recently working with mspec doing integration tests – these I usually do to make sure my DAL and my database are structurally compatible – and I kept getting database constraint errors when I reran tests.  It didn’t make a lot of sense as I had a cleanup section in my code and I wasn’t seeing any errors.

It turns out, that if an exception is thrown in the cleanup section you’ll never hear about it.  At least for me, it doesn’t bubble up.  Once I put a breakpoint on the first line of the cleanup I figured it out.  Previously I was thinking it wasn’t even hitting my cleanup code.  It was hitting the cleanup section however, only there was an error in that section.  Hopefully this gets into the googles and helps someone.

using Machine.Specifications;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace My.Project.Integration.Tests
{
    public class when_creating_a_mything_record
    {
        protected static IMyThingService MyThingService { get; set; }

		protected static MyThing MyThing { get; set; }
		protected static MyThing SavedMyThing { get; set; }

		Establish context = () =>
        {
            MyThing = new MyThing() {
				Name = "thing",
				Description = "thing one"
			};
			MyThingService = ServiceLocator.Instance.Locate<IMyThingService>();
        };

        Because of = () => Exception = Catch.Exception(() =>
        {
            SavedMyThing = MyThingService.Insert(MyThing);
        });

        It should_not_have_thrown_an_exception = () => Exception.ShouldBeNull();
        It should_have_an_id_that_does_not_match_guid_empty = () => SavedMyThing.ID.ShouldNotEqual(Guid.Empty);

        Cleanup after = () =>
        {
           // If this does not appear to get called. put a breakpoint here.  You may have an exception.
           MyThingService.Delete(SavedMyThing);
        };
    }
}

Leave a comment