Air Fryer Naan Bread

One of my life changing purchases that I made during this COVID era is an air fryer. I honestly got it because I wanted to reduce the number of grocery store trips I was making. I was a huge salad eater but unfortunately leafy greens and bag mixes don’t last that long in the fridge. I knew at the time that air fryers were awesome for cooking sweet potatoes but that is literally the tip of the iceberg.

I use my air fryer almost everyday, sometimes twice. It is fantastic for quickly cooking tougher veggies and roots while at the same time giving them a great crisping. I’m a huge fan of the instant pot too because of its speed but the air fryer is even faster and has almost no clean up. Frankly, both are fast. Case in point though, if you like having roasted veggies in a flash, you got to get an air fryer.

Now here is where things get really fun. You can make naan bread in the air fryer. Ya… that’s right… and from scratch too. I posted my recipe on cookpad. It’s no secret that I love baking and messing with dough and pastry. Air frying naan bread however… that is just mad science. Honestly, it is quite practical to do even in an apartment setting. Normally, you would use a cast iron pan to fry them up but when you use an air fryer instead, you don’t make any smoke; none at all. You just get hot and delicious naan!

New longest distance – 15.8 miles

Well, my marathon training is still progressing even with the number of COVID cases in Washington spiking again. It actually isn’t that bad running outside at this time of year. There aren’t too many other runners or walkers out there. I am using my hiking buffs as my running mask which I rarely need to use since I can easily keep 8 feet or more away from anyone I happen to bump into.

Today I hit a new high of 15.8 miles. I am also one week away from the half way point in my training schedule. With these distances, I need to make sure I’m used to having snacks during my runs. The last time I really got this serious about running, I tried gels and they were just awful both in flavor and in how they agreed with my stomach. I used chews but they are pretty expensive and you always end up wasting some. So I did a bit of research and discovered that raisins and dried cherries are pretty good options which is awesome for me because I love eating them too. I’ve done 3 runs with them now and today I even added in a few dark chocolate discs all of which I had no problems with. I do a lot of baking so I always have dried fruit and chocolate discs kicking around but more importantly, not only are these much healthy options, they are way cheaper too.

So if you are working into runs where you need snacks, don’t feel compelled to buy those over the counter running snacks. You might have just what you need in your own pantry to do your own DIY ones.

Bonkers Post Election Day Run

Hi all. It’s been a few since I posted. Work has been absolutely nuts with the pandemic. It’s been busy but a really good busy where each day the things I do I know have an impact. As weird as the social distancing and lockdown have been, there is a wonderful sense of reward in having those honest days of work.

In addition to working all the time, I’ve also been focusing on my running. I have official started training for a marathon and I am now on week 7 of an 18 week schedule. Today I did a 7.9 mile run at a 7:57 pace which is a personal best for me; it was a crazy one given it is November and raining. I don’t have an actual race on the schedule yet but I am hopeful for one early in 2021 once we all get vaccinated.

Sub 50 10k

Well, it has been a long time since I’ve broken 50 minutes with my 10ks but today was the day. I think the last time I did it was about 6 or 7 years ago. This morning, I really shattered it going sub 49.

Without a doubt, Noom has had a huge impact on my life. It’s been about 10 months since I’ve started following their green/yellow/red approach to tracking what I eat. I’ve managed to lose and keep off about 40 lbs. Just shedding that weight dramatically improved my running. Recently though, I started mixing in interval runs about once a week. This post from Running Faster is a good one for routines. I don’t quite know why I decided to do them again. It was probably a combination of things but I think it was primarily that I am feeling more confident about my running and I have a smart watch where I can program in the intervals. Anyhow, I’ve been hovering around the 50 minute mark for a while trying to work my way towards breaking it and I guess it was a plateau. I literally knocked a minute off my time this morning.

Imperfect Foods: One Weird Sweet Potato

I’ve been getting my groceries delivered to me weekly now for about a month using Imperfect Foods. I love these guys. The service, aside from being very convenient, has a mission of helping the environment by focusing on selling meat and produce that cosmetically doesn’t meet the bar for grocery stores. Unsurprisingly, there is a lot of food that doesn’t look perfect but what is surprising is that it typically doesn’t get sold. This is where Imperfect Foods comes in. Instead of letting that food go to waste, they make it available in their delivery service and at a great price. I am now saving money on my groceries every week and they are delivered to my front door, basically for free when you think about it.

Last week I got this especially odd looking sweet potato. It kind of looks like a heart. It just looked weird though. Nothing else was wrong with it. I cooked it up in a hash with spinach. Yum!

jolt: JSON Transforms Simplified

Every now and then it comes up that a REST API you are working with is a little inconsistent with the JSON that it returns. Sometimes a property you want is an array when it has multiple values but an object when there is only one. It’s annoying when you encounter these APIs and it happens more often than you think. Jolt is a package that handles JSON transformations really well and is perfect for this exact situation.

What I especially like about it is that it separates JSON transformation logic into separate files that can be read in at runtime. That allows it to be more configuration driven as oppose to being in your code. Here are a few examples that you can play with to get a feeling for things.

Step 1: Include jolt as a dependency

Create a new starter project using Gradle as your dependency manager. Add jolt as a dependency.

compile group: 'com.bazaarvoice.jolt', name: 'jolt-complete', version: '0.1.1'

Step 2: Get a JSON string to transform

Add this JSON to your src/main/resources folder as a file named jolt-me.js. We are going to use it as the target for our jolt transformations.

{
    "hello": "world",
    "I'm an array": [
        {
            "object": 1
        }
    ]
}

The following snippet will read that JSON file and covert it into a String instance.

Scanner scanner = new Scanner(ClassLoader.getSystemResourceAsStream("jolt-me.js"));
StringBuilder inputJSON = new StringBuilder();
while(scanner.hasNextLine()) {
    inputJSON.append(scanner.nextLine() + "\n");
}
scanner.close();

Step 3: Create a transformation JSON

All jolt transformations are executed using an instance of Chainr. To create an instance, you feed it JSON that defines the transformations that you want it to perform. Jolt provides several types of transformations out of the box. The two I find the most usefully are Shift and Cardinality.

Step 3.1: Shift transform

Shift transformations are for moving properties around and renaming them. Hence why it is called shift. Here is a simple example below. Safe it in a file named shift-spec.js in your src/main/resources folder:

[
    {
        "operation": "shift",
        "spec": {
            "hello": "blue",
            "*": "&"
        }
    }
]

The following snippet loads and runs the shift transformation.

Chainr chainr = Chainr.fromSpec(JsonUtils.jsonToList(ClassLoader.getSystemResourceAsStream("shift-spec.js")));
System.out.println(JsonUtils.toPrettyJsonString(
        chainr.transform(JsonUtils.jsonToObject(inputJSON.toString()))
    )
);

That results in the following output:

{
  "blue" : "world",
  "I'm an array" : [ {
    "object" : 1
  } ]
}

Step 3.2: Cardinality transform

This transformation is by far my favorite. The cardinality transform is specifically for dealing with JSON properties that are sometimes arrays and sometimes objects. In other words, the API you are working with is not consistent in how it returns data. I don’t know why this happens so often but I suspect developers of those APIs are trying to make things easier by considering the context in which their end points are getting called. However, it really has the opposite effect especially when you are trying to deserialize that JSON into a POJO.

Create the file cardinality-spec.js in src/main/resources with the contents below.

[
    {
        "operation": "cardinality",
        "spec": {
            "I'm an array": "ONE"
        }
    }
]

As with the previous step, you use a Chainr instance to execute the transformation. For example:

Chainr chainr = Chainr.fromSpec(JsonUtils.jsonToList(ClassLoader.getSystemResourceAsStream("cardinality-spec.js")));
System.out.println(JsonUtils.toPrettyJsonString(
        chainr.transform(JsonUtils.jsonToObject(inputJSON.toString()))
    )
);

That gives the following output. Notice that I'm an array is not an array anymore. It’s an object.

{
  "hello" : "world",
  "I'm an array" : {
    "object" : 1
  }
}

Step 3.3 Chaining transforms

What is really cool is that you can chain transforms together. So let’s combine the previous two transforms into a single JS file called chain-spec.js in your src/main/resources folder. The contents should be the following:

[
    {
        "operation": "cardinality",
        "spec": {
            "I'm an array": "ONE"
        }
    },
    {
        "operation": "shift",
        "spec": {
            "hello": "blue",
            "*": "&"
        }
    }
]

This familiar Chainr snippet will execute it.

Chainr chainr = Chainr.fromSpec(JsonUtils.jsonToList(ClassLoader.getSystemResourceAsStream("chain-spec.js")));
System.out.println(JsonUtils.toPrettyJsonString(
         chainr.transform(JsonUtils.jsonToObject(inputJSON.toString()))
    )
);

That gives you the following. As you can see, both the shift and cardinality transforms were performed on our JSON data.

{
  "blue" : "world",
  "I'm an array" : {
    "object" : 1
  }
}

Closing Thoughts

Jolt is pretty convenient as an off the shelf utility for quickly doing some JSON transformations. The implementation of its JsonUtils is a little clunky and it is annoying how it doesn’t support generics so explicit casting has to be done. Regardless, that is pretty minimal pain compared to having to do these transformations using POJOs.

Whole Wheat Biscotti

I’m having a lot of success baking with whole wheat flour these days. In fact, I am rather thrilled that I haven’t needed to make any sacrifices transitioning from regular white flour. Working with nut flours is still giving me some odd results though. I recently made cookies with almond flour and… well… it was like eating ground almonds pressed together. I suppose that should make sense.

Anyhow, here’s my recipe for whole wheat biscotti. Perfect with a hot coffee and not super bad for you. Toss in chopped dried fruit that you have on hand to give it some flavor and texture. When you make it, don’t get discouraged by how sticky the dough is. Remember that you are going to twice bake this cookie. Hence… Biscotti 🙂

Discord YAGPDB Custom Role Commands

A few of my friends asked me recently if I could help them with the Discord bot, YAGPDB, that they use to help organize server roles for people that they play games with. I do love chat bots so I opted to throw some code their way.

Specifically, what they were asking for were two commands for assigning and removing a given role to a list of users. The documentation for YAGPDB isn’t the greatest and their code samples use a function that they developed, userArg, which limits you to 5 calls per custom command execution; not ideal for bulk assignments. Below are the custom commands that I created which do not use userArg so they aren’t restricted to this limit. I got around it by simply parsing out the user id.

Give Role

This custom command gives the specified role to all listed users. When I deployed it to YAGPDB, I called it give-role which is why I refer to it as such in the usage instructions I wrote.

{{ if (gt (len .CmdArgs) 1) }}
	{{ $role := (reReplace ">" (slice (index $.CmdArgs 0) 3) "") }}
	{{ range $x := seq 1 (len .CmdArgs) }}
		{{ $userId := (reReplace ">" (slice (index $.CmdArgs $x) 3) "") }}
		{{ giveRoleID $userId $role }}
	{{ end }}
{{ $role }} given
{{ else }}
Usage: give-role \@role \@user1 \@user2 ...
{{ end }}

Take Role

This custom command removes the specified role from all listed users. Like the give role command, I called this one take-role when I deployed it.

{{ if (gt (len .CmdArgs) 1) }}
	{{ $role := (reReplace ">" (slice (index $.CmdArgs 0) 3) "") }}
	{{ range $x := seq 1 (len .CmdArgs) }}
		{{ $userId := (reReplace ">" (slice (index $.CmdArgs $x) 3) "") }}
		{{ takeRoleID $userId $role }}
	{{ end }}
{{ $role }} taken
{{ else }}
Usage: take-role \@role \@user1 \@user2 ...
{{ end }}

Closing thoughts

I love how vibrant the Discord bot community is and how it is helping people spend more time gaming and less time doing administrating and coordinating. I was a little surprised that these commands were not already built into YAGPDB since bulk role management is a pretty common task. I hope others find these custom commands as useful as my friends do.

Noom Friendly Whole Wheat Sweet Potato Muffins

Veggie cake is quickly becoming one of my favorite things to bake. You can make something low cal and healthy that also satisfies that cake craving. Sweet potato followed by carrot are my veggies of choice. Sweet potato I find has a natural sweetness to it just like carrot but it is softer and easier to work with. Zucchini in general is popular but I don’t really get it. It is super wet and doesn’t have much flavor. It is kind of just all filler. Check out my recipe for sweet potato muffins. You can whip a batch up in a flash especially if you bake your potato using a microwave.

My Favorite Quick Bread: Irish Soda Bread

I have to say that by far, my favorite quick bread is Irish soda bread. It is something that you can whip up as soon as you wake up in the morning and have with a coffee for breakfast. It takes less than 10 minutes to make the dough which doesn’t need to prove. 35 minutes in the oven and your done. It is honestly one of my favorite ways to start the weekend.

Here’s my recipe for it on Cookpad. There are very few ingredients that go into soda bread. Buttermilk is quite critical though as its acidity in combination with the baking soda is what causes the bread to rise in the oven. I like adding in some sort of dried fruit or berry. Soda bread is generally pretty dense so having something that provides a strong flavor makes it more interesting.