Sep 022017
 

by @WidowPage

Before I show you the curing process, we need to talk about salt and how it turns pork belly into bacon.  Curing doesn’t happen without salt.  If you look back into the history of bacon, humans all over the world were packing pork belly into salt to preserve the meat.  The Chinese and Europeans started curing meat as early as 1500 BC.  According to the Pork Board of America, Hernando de Soto’s herd of 13 pigs sparked early conflicts with Native Americans who developed a fondness for the taste of pork.  His herd eventually grew to 700 hogs, not including those that were eaten or ran away to breed and become ancestors of today’s feral hogs in the Southeast.

While I don’t know the exact process de Soto’s contemporaries used to cure bacon, they had to have used salt.  Today, everyone uses pink salt or Prague Powder or Curing Salt #1.  Some might confuse it with Himalayan salt.  Don’t do that.  These are 2 different substances.

Both could be called pink salt, but only use curing salt for bacon.

Most Himalayan salt comes from Pakistan which means it should really be called Pakistan salt, but that doesn’t quite have the mystery or cache of Himalayan salt.  Thanks marketing team!  It is purer than table salt, but it is the impurities that give it its pink color.  Some people claim it has special health benefits, but I just find it tasty on baked red potatoes.

Curing salt was trademarked back in 1925 as Prague Powder by Karl Max Seiffert.  He turned around and sold his patent to Griffith Laboratories in 1934.  Here’s the super cool thing about this…I am not from Chicago but I lived here for more than 20 years and love Chicago’s history.  Griffith Laboratories was started in Chicago in the 1900s by a father and son who assumed ownership of a pharmacy.  The son backed out of attending agricultural school at U of Illinois and went Northwestern to study pharmacology.  Once he graduated, he and his father changed their company direction to “bring science to the food industry”.  They initially focused on bread and baking, but in 1934, they bought Seiffert’s patent and began distributing it across the country.  Griffith Labs still exists today as Griffith Foods and their global headquarters are in Alsip, Illinois.  You can buy Prague Power directly from them OR order it off Amazon.

Curing Salt #1

My curing salt came from Williams Sonoma.  When you buy curing salt for bacon, make sure you get Curing Salt #1.  Curing Salt #2 is meant for cuts of meat that cure for longer periods of time.  Think pastrami or ham.

Curing salt is also known as pink salt.  Manufacturers dye it this color to distinguish it from table salt.  Curing salt should NOT be consumed or used like table salt.  It contains 6.25% sodium nitrite which is what prevents the growth of botulism or the other icky things that grow in meat over time.  We will apply this salt to the pork bellies but will rinse it off once it does its job.  Do not use curing salt for any other purpose.

Tired of salt?  Fret not. Tomorrow’s post will be all about combining curing salt with other seasonings and getting on with the bacon process.  Lots of cool pictures and much fun.

Sep 092016
 

A while back, I wrote about how SQL Prompt now includes execution warnings and how useful I think that feature is. It’s saved my bacon several times now, including just last week!

I’m now happy to announce that I’ve recorded a demo video of this feature for Redgate’s series of #SuperSQLTips for SQL Prompt. Be sure to check out my video, as well as the rest of the series – there’s some super-helpful stuff in there!

 

May 202016
 

Parenting is most definitely something that parents are constantly learning more about. Our son is 11 weeks old today, and while Michelle and I are by no means experts, we’ve learned a bunch in that time. We’ve also found some techie tools that have proved incredibly helpful these past few months, and I wanted to take a brief break from database speak to share them. Here they are, in no particular order:

Whoa – I’m 11 weeks old today!

Baby Tracker. This awesome app helps you keep track of your baby’s eating, sleeping, and diaper-ing. It’s incredibly simple to use, and never again will you have to wonder if your spouse changed them recently, or how much sleep they’ve gotten today compared to yesterday. It syncs between multiple devices, and creates some really nice visualizations of your data. It comes in free and “pro” versions ($5). The pro version has no advertisements and better charting and has been well worth the cost to us.

Eye-Fi Mobi Pro WiFi SD Card. I’ve wanted one of these for a while, and wish I had bought it sooner because it’s really been useful. Admittedly, most of the photos we take of our son (and in general) are on our phones, but for the times I need a real camera, getting those photos off of it has always been a (relative) chore involving removing the SD card, sticking it in a reader, and copying files to my computer. Getting photos off my phone is trivial by comparison; I just use Dropbox‘s camera upload feature. Eye-Fi makes getting photos from my camera to my computer just as easy. For an added bonus, it can also transfer photos to my phone, so they can be shared right away if I’m not at home.

Google Photos. Years ago, I was a huge fan of Picasa and Picasa Web Albums. Then the whole Google+ Photos thing really turned me off. Last year, Google unveiled the new Google Photos, and I’ve been a fan ever since. It’s extremely easy to use, and while I hope they add a few more features, it does an excellent job of letting you store photos from all your devices in one place in the cloud. You can also create albums to share with others very quickly, thus keeping those rabid grandparents happy.

Foscam FI9821P IP Camera. Audio baby monitors are no longer good enough, now we need video ones. There’s no shortage of options in this space, but rather than go the baby monitor route I decided to just buy a real web camera and stick that in junior’s room. Not only was it cheaper, it’s easy to watch/control from our phones and I’m sure I’ll find a use for it once we no longer need to watch our son sleep. I also bought a PoE adapter so it can be powered by my network – no power cord necessary!

Anker Astro E5 USB Battery. If you attend PASS Summit or any other conference, you probably know these things are pretty much indispensable anyplace where you need to charge a mobile device and can’t be tied to a power outlet. The ability to charge our phones anywhere has proven very valuable since our son was born, and we’ve been using this almost daily. It’s not just for conferences anymore!

Remember The Milk. I’ve been using this app to keep track of my to-do list for years. Now that I have less time to do things, maintaining a list of what needs to be done has become even more helpful. There’s tons of apps out there for task lists; I’ve tried several others just to see what they’re like, and RTM is still my favorite by far.

So these are our favorite tools. If any new parents out there are reading this, hopefully you’ll find them helpful too! And don’t worry, next week I’ll be back to posting things more database-centric.

May 102016
 

I’ve loved using Redgate’s tools ever since I discovered what they were, and now that I’m a Friend of Redgate it’s even more fun because I get to give feedback to their developers and hear all about what’s coming out in new releases! Recently, Redgate announced SQL Prompt 7.2, with a bunch of new features and improvements. My personal favorite of all these is execution warnings.

Databases (and computers in general) have this pesky habit of always doing exactly what we tell them to do, instead of doing what we really meant to tell them to do. Have you ever been burned by running a query without the WHERE clause? Perhaps you ended up updating or deleting ALL the rows in a table instead of just a few? A common way to reduce the risk of this is to run those commands inside a transaction, and if you see an abnormally high number of rows affected, it’s simple to rollback. This works great, until you’re in a hurry and forget to run BEGIN TRAN, greatly upping the chances of disaster. Now in SQL Prompt 7.2 you have an added layer of protection – the tool is watching your queries and can warn you! Check it out in action:

If I try to update my table of important data and don’t specify a WHERE clause, I’ll see the following:

The same happens for deletes:

And I think it’s great that I have the option of checking the box and not showing that warning again, but I definitely won’t be doing that.

A lot of times it’s the little things that really make a difference, and I think these warnings are a simple and unobtrusive way to make sure you really meant to run what you typed.

Feb 262015
 

Whether you are working in T-SQL, Oracle, MySQL, C#, or Java, the range of possible values for a signed (positive or negative) 32-bit integer is from -2^{31} or (-2,147,483,648) to (2^{31})-1 or (2,147,483,647). The fact that it’s so consistent across so many different platforms (and also against plenty of others I didn’t list) means there has to be more to it than just the preference of some developers somewhere, right? Exactly right.

Down to the bits

Any data your computer deals with, be it numbers, text, music or videos, all end up in binary at one point or another. Binary means values are in “base 2”, where each digit represents a power of 2, and the possible values for that digit are 0 or 1. A digit capable of storing only the values 0 and 1 is typically referred to as a bit, which is short for “binary digit”. This is in stark contrast to the decimal or “base 10” number system commonly used, where each digit represents a power of 10 and the possible values for that digit are 0 to 9. To show how values are calculated in different number systems, here is the value 37 in both binary and decimal:

(click to enlarge)

I realize that’s an extremely brief example, but if you want to learn more about binary numbers, there are tons of great resources online.

But what about negative values? Negative numbers can be represented a bunch of different ways. Sometimes it’s done with the minus sign

-150

or with parentheses

(150)

but those are all formats, or different ways of expressing a value. A format can be changed without altering the value itself.

How do you really represent that a value is negative? Since binary consists only of bits storing the values 0 and 1, what if the first bit of a binary number served not as a value, but to show whether it was positive or negative? A “1” in the left-most bit would effectively mean the value is negative, and a “0” would mean it is positive. Losing a bit to storing positive or negative would effectively cut the number of values you could store in half (since you are losing a power of two), but it would be awfully handy. There’s a little bit more to this method than that, but it’s known as…

Two’s Complement

Two’s Complement is a great way to express signed numbers in binary, for reasons we will see shortly.

Expressing a negative value via two’s complement is a rather simple process. Start with the binary expression of the positive value you want to negate. Next, flip all the bits so all the 0’s become 1’s, and all the 1’s become 0’s. If we were to stop here, this would be the one’s complement of the value. To get the two’s complement, we add 1 to the one’s complement. Here’s an example for the number 19:

010011  (19, unsigned, with leading 0 added)
101100  (bits flipped)
101101  (add 1. This is -19 in two's complement)

We now have the two’s complement of 19, which has the value -19.

Why did we have to add one? Let’s say we’re in a five-bit environment and want to find the two’s complement of zero (which would be negative zero). The number zero is represented as 00000 in this case. If we flip each bit, we now have 11111, and by adding one to that we now need a sixth bit so we can arrive at 100000. Since we’re still working in a five-bit environment, we ignore the leftmost bit, bringing us back to 00000, which represents both zero and negative zero. Having a single value for positive and negative zero is a key advantage that two’s complement has over ones’ complement.

An even larger advantage of two’s complement is that addition, subtraction, and multiplication work exactly the same as if all values were positive. You can even use the carry method to do this (like you were probably taught in school, but your kids most likely won’t learn thanks to common core in the US.) As a demonstration, let’s add 24 to the -19 value we just computed. The result should be 5.

(click to enlarge)

And indeed it is! If you’re paying close attention you will notice that I truncated the result to 6 bits and ignored the left-most carry. Restricting the result to the same number of significant bits you are adding is a requirement to arrive at a correct answer.

This is really neat, but it still doesn’t answer our original question about the possible range of values. Let’s look at the values you can create with 3 bits.

Three bits allow 8 or 2^3 values to be stored, and in the case of unsigned numbers, those values are from 0 to 7.  The two’s complement values of those same bit arrangements gives a range of -4 to 3.

Thinking of it in powers of 2, three bits in two’s complement allows us to store values from -(2^2) to (2^2)-1. Both the exponents are 2 instead of 3 because a bit is being used to determine whether the value is positive or negative. If we showed 2 as one less than three, the value range would look like:

-(2^{(3-1)}) to 2^{(3-1)}-1

So for n bits, two’s complement lets you express values ranging from -(2^{(n-1)}) to 2^{(n-1)}-1. This is exactly why for a 32-bit integer, the range is -(2^{31}) to 2^{31}-1.

And there you have it. Two’s complement is the reason why basically any signed data types have the range that they do.