An experiment in finishing stuff

One area I’ve struggled with consistently as far back as I can remember has been finishing things. I’ve always been good at having good ideas, and–just as often–not carrying them out. IOW, really good at the R part of R&D, not so great at the D. This is something I’ve resolved to change about myself, and tomorrow (Friday) marks the end of four weeks of a focus on finishing things. Some stuff was important, a lot of it wasn’t. At work, I tried to finish the highest-value tasks, or things I’d promised others, and at home, I tried to finish the most important things, and the things that brought me happiness or satisifaction.

  • Finished two books, on my way to finishing a third
  • Finished 3 different long-term projects that I’d had on my back burner for months
  • Started and finished some high-value policy guidance, from development through socialization
  • A bunch of housekeeping on my Linode backend (more than six months overdue!)
  • My SO and I restructured our finances to better plan for the future
  • Got numerous things with external gating factors back on track

Anyway, this hasn’t been a month where I’ve worked harder. It’s been a month where I’ve worked smarter. I’ve never been an adherent of any particular productivity school, but I do borrow from several (GTD, kanban). Here are a couple of things I did:

  • Didn’t even try to start new things if I could avoid it; I simply added them and added them to my backlog
  • Eliminated some low-value stuff entirely (why do low-value stuff at all?)
  • Carved out calendar time in my day for next steps, immediately after completing pre-requisites. (This ensures adequate time, and a regular delivery cadence.)
  • I’ve always been an inbox zero kind of guy. That didn’t change, and it remained a producitivity (and happiness) multiplier.

It’s not all sunshine and daisies, however. Balancing the reactive, “operational” side of my job with the planful, inside-your-own-head development stuff that provides the real, long-term organizational value remains a challenge.

Here’s a good talk by Adam Savage–of Mythbusters fame–that really resonated with me. I feel like I’m good at (and regularly do) all the stuff, except for maybe the last three minutes. That I saw this video while working on finishing stuff was purely coincidental.

Sonder

The Dictionary of Obscure Sorrows:

n. the realization that each random passerby is living a life as vivid and complex as your own—populated with their own ambitions, friends, routines, worries and inherited craziness—an epic story that continues invisibly around you like an anthill sprawling deep underground, with elaborate passageways to thousands of other lives that you’ll never know existed, in which you might appear only once, as an extra sipping coffee in the background, as a blur of traffic passing on the highway, as a lighted window at dusk.

How to determine how large a mortgage you can afford using Excel

Note: this is applicable to fixed rate mortgages.

Mortgage brokers typically use your gross monthly income to calculate the amount they’re willing to lend you. Frankly, this is a very bad way of calculating what you can actually afford. It is more useful to know what you can reasonably afford each month before you go house shopping.

If you’ve got a monthly payment in mind that you’re comfortable making, you can use a present value calculation to come up with the amount you can afford to finance. In Excel, this is very easy with the pv function:

=pv(interest rate, number of payments, payment, montly payment)

  • Interest rate: If annual percentage rate (APR) is 3.5%, this number will be 3.5%/12 = (0.035/12).
  • Number of payments: 12 months * 30 years = 360
  • Payment: What you’re comfortable paying on a mortgage each month.

Suppose:

  • You’re willing to spend $1,750 a month on a house
  • APR: 3.5%
  • Term: 30 years

=pv((0.035/12), 360, 1750)

You can afford to finance: $389,716.22

When determining what you can afford each month, don’t forget the following:

  • House insurance
  • Mortgage insurance (PMI)
  • House taxes, typically calculated as some amount per thousand dollars of assessed house value
  • Homeowners’ fees, if applicable

These are things that many renters don’t need to pay, and thus forget to think about when buying their first home.

Slow carb: week 2

This past Saturday marked my second cheat day on the slow carb diet. This will be a much shorter post, with the addition of Recipes section.

Recipes
This week we decided we wanted to eat more savory foods, as the diet can be quite bland. We tried spaghetti squash with home made marinara and turkey meatballs with almond flour. It was OK… the squash wasn’t cooked enough, and the marinara recipe we used wasn’t very good, either (it was essentially tomatoes with onions, and not much “sauce” ugh). Next time we’d bake the squash longer, and use a better marinara recipe.

We also made chili with black beans, kidney beans, and garbanzo beans (chickpeas). We added WAY more veggies: mushrooms, broccoli, red peppers, and we also threw in one ear of raw corn cut off the cob. (Yes, we “cheated”, if you could call < 1/8 of an ear of corn per serving “cheating”.)

It was amazing. So. Bloody. Good. Best food we’ve eaten since being on the diet.

Quantitative

  • Weight: 222.5 (down ~1lb)
  • Waist: 40″ (no change)
  • Hips: 40″ (no change)

I spent first 3 days after my cheat day above my weigh-in weight. I suspect I may have weighed in at the perfect time: just evacuated everything, slightly dehydrated, didn’t eat much the day before. (All of these things were unintentional.)

Qualitative

  • Energy levels are still higher and smoother than what I’ve been used to (more on that below)
  • Weight loss was much less than the first week. I believe my assertion that most of the weight was water weight in the first 3 days was incorrect, and that I continued to shed water weight for most of the week.
  • I’m really at a “new normal” now as far as preparing food, making lunches, eating food, etc is concerned. It’s easy to say no to most foods, and I cook without thinking.
  • My allergies seem to be gone. (Weird!) I don’t breathe heavily, nor have I been congested. This doesn’t seem connected to the air quality, so I don’t have any idea why this is true.

The most illustrative thing, though, is the bike ride I went on. I hadn’t been on a bike in a month, and I decided to go on one about 2 hours after lunch. Up until that point, I’d had breakfast (two eggs, lentils, half a thick sausage patty) and lunch (cereal-bowl-sized bowl of chili with melted cheddar). I knew I’d be hungry by the end, so I brought some carrots with me to eat when I was done.

About halfway through, I got hungry. In the past, this would have meant I would have hit the wall, unable to bike with any appreciable energy. I did not have this problem. I had no problem sustaining 18-20mph, and when I turned back, I was sustaining 20-22mph, despite being hungry. In fact, these are the fastest speeds I have ever sustained on this course… even though I hadn’t been on a bike in a month, and my weight loss wasn’t much as a percentage of my starting weight.

It was very strange to have my energy levels largely decoupled from my hunger. Similarly, my leg strength was the limiting factor, not my cardiovascular system. This hasn’t been the case since I was in high school, so this is A Very Good Thing.

Slow carb week 1 foods

I’ve been asked what I ate during week 1. The answer: pretty boring stuff, mostly. I actually took pictures of most of the food I was eating to send to Laurel, because she was planning on doing the diet, but was away in Israel when I started.

The trick is to cook more than one serving at a time, even for things like cooked vegetables. I don’t like frozen veggies, so I generally buy fresh and make 2-4 servings at a time because it saves time and energy. Hooray for dishwashers.

Things cooked in bulk:

  • Lentils: one package tends to last me about a week. I like them a little softer, so I boil them for close to 30 minutes.
  • Bacon: one package of center cut bacon at a time. I save the bacon rendering for later. Haven’t used it for anything yet.

Breakfast tends to be the same thing every day:

  • Lentils (often fried in some oil; the texture is nicer)
  • 3 scrambled eggs, Gordon Ramsay style
  • 3 strips of bacon (microwave them for 20 seconds, and they taste like they’re right out of the pan!)
  • 1 serving (8oz) of V8 juice. This was my savior at the beginning, as it the thing with the “loudest” flavor, and until I adjusted to the subtleties of the other things I was eating, it was the most interesting thing on a daily basis
  • 2 cups coffee with 1 tablespoon of cream per cup

Lunches and dinners are generally a meat with a legume and vegetables–often 2 or more. Sometimes cooked, sometimes raw. If you need rubs for your meats, I recommend Penzeys market (online or retail).

Meats:

  • Steak spiced with a rub or seasoning
  • Chicken spiced with a rub
  • Boneless pork chops spiced with a rub
  • Breadless cheeseburger, using aged swiss cheese, and often topped with salsa
  • Tuna (usually wrapped in lettuce like a lettuce+tuna roll)
  • Chicken sausage (grilled or broiled)

Sides:

  • Black beans or lentils
  • Raw cucumbers and carrots
  • Nathan’s dill pickles

Vegetables:

  • Asparagus (sauteed in olive oil with spices, or steamed)
  • Green beans (steam a bunch, and eat them over the next 2-3 days)

Other dishes I make regularly or would make again:

  • Spaghetti squash + slow carb tomato sauce + turkey meatballs, and shredded parmesan on top. Surprisingly good. Make the turkey meatballs with almond meal instead of breadcrumbs.
  • Two slices of Thin n trim chicken from the deli with a slice of aged swiss in between. Brown it up in a pan (no oil needed!), which melts the cheese. Top with salsa, and eat with a knife and fork like a thick slice of ham.
  • Lentils mixed with salsa.

Things I’d like to try:

  • Grilled kabobs with meat and veggies
  • A cooked black bean salad/stir fry thing with meat and veggies and beans
  • A stir fry over lentils or beans.

I eat the same things over and over again, which is what most people do (and certainly what I did before the diet). The only real difference is that I’ve changed the things that I repeat.

Slow carb: week 1

Last Saturday, I sat down in the morning, and planned out my strategy for eating for the weekend. I knew I’d essentially be by myself, so if I was going to be miserable, I wouldn’t be bothering anyone. Ideally I need to lose about 40lbs; I’m at 230lbs now and 190lbs would put me at about 5lbs more than my high school weight.

My initial goals for the weekend experiment were modest:

  • Eating entirely slow carb, where the biggest change was replacing starches with beans and lentils
  • Seeing how I would feel during my first two days: how bad would the transition be?
  • Putting together some slow carb meals to see if they were palatable

Knowing that I’d be doing at least a full month of it at some point, I figured I would just stick with the diet if:

  • The transition was miserable, but I got through it in the two days (why repeat it?)
  • I was satisfied with the meals I’d created

This is how I approached the experiment:

  • I didn’t treat “Tim’s word” as received wisdom, which is fairly unusual in the slow carb world where explanations are often prefaced with “Well, Tim says…” whenever a newbie asks a question.
    • I haven’t read 4 Hour Body (and probably won’t)
    • I skipped the supplements; “toxins being released” and “flushing the body” and other pseudosciency hand-waving is nothing but woo and appeals to magical thinking
    • When in doubt, I looked at the glycemic index of the food before eating
    • I deferred to Gary Taubes more often than Tim Ferriss, as Gary’s work is incredibly well sourced
    • I followed the diet pretty strictly, though I did add a slice of aged swiss cheese to make breadless cheeseburgers and tuna melts
  • I ate any time I felt hungry
  • I did not count calories
  • I deferred to sustainability if I was particularly unhappy with something (adding in cheese, for example)
  • I didn’t exercise any more than usual

To make it easy, I planned out all of my meals for the next two days, and made enough inputs to more than last for that time. (I batch cooked all of my legumes, because cooking them is time consuming and generally sucky.) I also bought a bunch of vegetables to have as snacks, as most of my normal snack foods aren’t allowed.

Yesterday (Saturday) was my cheat day. Now for the results…

Quantitative

  • Down 7lbs (230 -> 223)
  • Two inches off my waist (42″ -> 40″)
  • I spent about $40 on food this week, way less than normal

Qualitative

  • I got a headache the first day, but 800mg ibuprofen cleared it up
  • I felt a little light headed and dizzy on the first day; this may’ve been psychosomatic.
  • Day 2 was substantially better, and I didn’t need to approach my routine in a “defensive” fashion; I just went about my life as normal
  • It was going so well by the end of day 2, I decided to just roll with it indefinitely
  • I was pissing like a racehorse for the first couple of days (most of the weight loss occurred after this period, oddly enough)
  • I could not wait for my cheat day for the first 3 days. This urge disappeared almost completely by day 5, and when I added in aged swiss cheese and made a breadless cheeseburger, the results were even better
  • I stopped getting hungry after 2-3 days. (Not that I don’t get hungry, but if you were to graph hunger over time, it’d look like a slow wave with no sharp spikes. Except on cheat day(!).
  • I did not get tired in the afternoons the way I normally do. This happened around day 3; I didn’t notice until day 6. Even trying to take a nap was useless; I couldn’t stay asleep for more than 15 minutes.
  • My energy was quite high this whole week, even after playing frisbee. Normally I’m depleted afterwards, but not this week.

Cheat day
My cheat day was not nearly as excellent as I thought it imagined it would be during the first few days. By the end, I was anxious to get back to the slow carb eating. My energy was lower; I had severe hunger spikes.

The strangest thing I noticed?

Unhealthy food is very loud. The tastes are overpowering, and there isn’t much subtlety. It’s like a food version of the loudness war: there’s not a lot of dynamic range in processed foods. Even “boring” foods like honey bunches of oats are incredibly sweet. The foods I ended up enjoying the most were fruits, and apple pie. I ate 1/4 of a 12″ pie for dinner last night, and I have no regrets for having done so.

I also thoroughly enjoyed the small Hawaiian pizza I ordered, and my normal grape fizzies (grape juice + seltzer). On my next cheat day, I will probably eat a buttload of fruit: strawberries, blueberries, pineapples, apples, and apple pie. Maybe another pizza. That’s about it.

How does this compare to counting calories?
I dieted the “normal” way back in 2010, for about 3 months; eating balanced meals, maintaining a calorie deficit of at least 500 under maintenance load every day except one cheat day per week. I lost 3lbs during that time. On the slow carb diet, I never felt hungry or deprived–which is more than I can say for my experience in 2010.

There’s an argument to be made that my weight loss is purely do to with releasing water weight by depleting the glycogen stores in my liver–which theoretically happens whenever you restrict caloric intake. That said, I did not lose any water weight when I was counting calories, and most of my weight loss occurred after the first three days.

Open questions
How sustainable is this? I don’t know. I don’t have an end game right now, and I’m just going with it. I’ve spent a little bit of time thinking about “What comes after”, and I think a longer-term diet plan might look less slow carb and a little more paleo. One thing it won’t be is full of white carbs like it has been; I feel so much better eating this way. My breathing isn’t labored, I don’t get tired during the day, and generally have more energy. As a random aside: I wrote a fair bit of code this week, and it’s the best code I’ve ever written, and my thinking has felt clearer, but it could be placebo.

I’ve also been toying with the idea of going ketogenic, just to see what it’s like (but I probably won’t).

How-to: Use Mercurial with EditPlus

I use EditPlus for most of my non-Visual Studio development. I’ve recently begun extending its functionality to use it as a “lite” PHP IDE by invoking php.exe from the commandline and capturing the output. I’ve also begun using Mercurial as my version control system of choice, and wondered if it would be possible to invoke hg from within EditPlus.

Turns out you can, and it’s quite easy. I find it best to configure Mercurial with an existing set of tools. I’m doing a lot of PHP right now, so that’s where I’ve stuck it.

  1. Add Mercurial to your PATH Environment variable using the method I outlined in this post.
  2. In EditPlus, configure your user tools: Tools > Configure User Tools
  3. Add Tool > Program
    Add tool
  4. Fill out the field as displayed, making modifications to suit your preferences:
    EditPlus Mercurial preferences

Details

  • "$(FileDir)" is the EditPlus variable indicating the directory that your current source file resides in. I have it enclosed in quotes, because sometimes directories or filenames have spaces in them.
  • -v indicates that I prefer verbose output. By default, mercurial will only display output if there has been an error, but I prefer to see success messages as well.
  • -m indicates a commit message.
  • "$(Prompt)" tells EditPlus to display a dialog that I can type in. This is where I put my commit message. I have it enclosed in quotes so I don’t have to worry about spaces breaking the commit message. You may need to escape more exotic characters; I have not tested it.

Caution

This method commits the working directory that your source file is in. This may or may not make sense, depending on the directory structure of your project. If you are concerned about the integrity of your atomic commits, it might make sense to configure your arguments differently, or to commit using the commandline or TortoiseHg.

Here’s the output as I see it in my editor:
EditPlus mercurial output capture

Here is a log of the commit messages as viewed with TortoiseHg:
EditPlus TortoiseHg log file viewer

Java solution to Project Euler Problem 48

Problem 48:

The series, 1^1 + 2^2 + 3^3 + … + 10^10 = 10405071317.

Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + … + 1000^1000.

Running time: 125 ms

Assessment: Again, very easy and fast using arbitrary-precision arithmetic. Like one of my other solutions, I didn’t limit the output to just the last ten digits in the series, but you could easily tack that on.

import java.math.BigInteger;
 
public class Problem048
{
	public static void main(String[] args)
	{
		long begin = System.currentTimeMillis();
		BigInteger sum = BigInteger.ZERO;
		BigInteger temp = BigInteger.ONE;
		BigInteger GrandTotal = BigInteger.ZERO;
 
		for (int i = 1; i <= 1000; i++)
		{
			sum = temp.pow(i);
			temp = temp.add(BigInteger.ONE);
			GrandTotal = GrandTotal.add(sum);
		}
 
		long end = System.currentTimeMillis();
 
		System.out.println(GrandTotal);
		System.out.println(end-begin + "ms");
	}
}

Java solution to Project Euler Problem 36

Problem 36:

The Fibonacci sequence is defined by the recurrence relation:

Fn = F(n-1) + F(n-2), where F1 = 1 and F2 = 1.

Hence the first 12 terms will be:

  • F1 = 1
  • F2 = 1
  • F3 = 2
  • F4 = 3
  • F5 = 5
  • F6 = 8
  • F7 = 13
  • F8 = 21
  • F9 = 34
  • F10 = 55
  • F11 = 89
  • F12 = 144

The 12th term, F12, is the first term to contain three digits.

What is the first term in the Fibonacci sequence to contain 1000 digits?

Running time:

  • Checking for a palindrome in Base 10 first: 500ms
  • Checking for a binary palindrome first: 650ms

Assessment: This problem isn’t super interesting. What I did find interesting was that changing the order of the isPalindrome() comparison resulted in a significant difference in execution times. This makes sense because there are more binary palindromes than Base 10 palindromes. For no particular reason, I expected the compiler to optimize that section so the difference wouldn’t be as stark.

I commented out the slower method so you can play with it if my explanation is unclear.

public class Problem036
{
	private static boolean isPalindrome(String s)
	{
		String s2 = new StringBuffer(s).reverse().toString();
		if (s.equals(s2))
			return true;
		else
			return false;
	}
 
	public static void main(String[] args)
	{
		long begin = System.currentTimeMillis();
 
		long Sum = 0; 
		for (int i = 0; i < 1000000; i++)
		{
			if ( isPalindrome(Integer.toString(i)) && isPalindrome(Integer.toBinaryString(i)) )
				Sum += i;
			/*if (isPalindrome(Integer.toBinaryString(i)) && isPalindrome(Integer.toString(i)))
				Sum += i;*/
		}
		System.out.println(Sum);
 
		long end = System.currentTimeMillis();
		System.out.println(end-begin + "ms");
	}
}