Seeking Inner Peace

You’re in a plane. There has been an accident and suddenly you and a loved one can’t breathe. The oxygen masks drop down in front of both of your faces. What was it that the flight attendant said? Oh! Put my own oxygen mask on first. Now you can help your loved one with a clear mind.

That’s one example where having a clear mind is a great foundation that supports you and those around you. Even when people sometimes do things that seem unwise, unhelpful, and potentially manipulative, you can choose to respond in a skillful way as opposed to reacting and then later regretting. In other words, what I do with relationships and stormy situations is that I first support my inner stability then I interact or choose to not interact as seems wise.

Recently, I got this concept from Andy Puddicombe of Headspace: There’s a storm outside and you’re inside a house looking at the storm outside through the window. If you can stabilize yourself internally, the violent storm of humanity that normally swallows you up is on the other side of the window.

So, that sounds good. Let’s seek peace within ourselves and have a foundation of balance with which to interact with others.

Seek Inner Peace:

How to do that? How to have inner peace and be balanced?

Some suggest jogging, watching a movie, or some other external activity. These can be great suggestions for some people some of the time. However, Andy of Headspace shares a good point in one of his meditation recordings: you don’t always have the opportunity to jog, but you always have your breath. Meditation is always available.

Mindful Meditation

So, is practicing meditation complex? It doesn’t have to be. Meditation can be as straight forward as focusing on your breath. See the 9 steps listed here under the section titled “Meditation Instructions” in How to Meditate. You don’t even need anything special and trying it out alone is certainly doable.

As briefly covered in “When and Why Did I Start Meditating?“, I was driven decades ago by my quest for excellence in all things including the mind. I meditated alone for years. However, having guidance with meditation can make a huge difference, save you from some confusion down the road, and enrich your meditation journey.

Luckily, there are resources out there. Two iPhone apps I use are the Meditation for Fidgety Skeptics by 10% Happier and Headspace. I also listen to the 10% Happier with Dan Harris podcast which is excellent. As covered in Meditating on Meditation Mobile Apps, I suggest starting with the iPhone app Meditation for Skeptics by 10% Happier if you can. Otherwise, I see that you can access the 10% Happier course material on the web. Alternatively, Headspace supports iPhone, Android and desktop.

Back to Basics

Beyond learning meditation, living in inner peace is also based on eating well, sleeping long enough, and exercise. None of this has to be perfect, but it has to be good enough most of the time.

If you value having a balanced mind, support it through meditation, and cover all the basics of healthy living, you will land on the spectrum of inner peace that has been explored for thousands of years. I wish you peace and hope you enjoy the adventure!

Adding Swift Initializers Through Extensions

While watching the Stack Views with Enums by objc.io, I learned an interesting little tidbit. You can add a convenience constructor aka convenience initializer by extending a class. The benefit of doing such is that you don’t have to subclass the class. In hindsight, the availability of that feature seems obvious. The Swift reference even has a section called “Initializers”. However, this ability may be news to others as well.

Similar to what they show at 7:45 in the video, one can write the following:

Next, you can call this new init like any other initializer:

I highly recommend you watch the entire Stack Views with Enums video. Enjoy!

RxSwift and Squishing the Pyramid of Doom

Say, you just learned RxSwift and all about subscribeNext. You have a series of Harry Potter related service calls to make and they affect each other. Let’s also say they all return the same type of Observable<Person>. So, you start to call these services one after another using subscribeNext.

The indention of calls is known as the Pyramid of Doom. This is a case of not using all of the power that RxSwift offers. If we inject flatMapLatest into the mix instead of all subscribeNext calls, we get the following:

Not only is the flatMapLatest approach easier to read, but one can see easily where the addDisposableTo(disposeBag) should be added at the end to manage the memory.

This concept is also covered in the RxSwift Tips document. Enjoy all that RxSwift has to offer!

Meow Mix Mantra

In my life, one of the meditation related challenges has been helping my son meditate. More specifically, helping him make meditation part of his daily routine.

We came up with the Mindful Minecraft Meditation plan together. That worked great for awhile. We’ve meditated together. He understands and has felt the benefits.

We’re even still making discoveries together. Here’s one. When he was really wound up last time, hugging him and having him focus on our slow and steady breathing helped him feel calm. It’s a technique similar to focusing on a stuffed animal as described in the video in Meditation Yields a Better Brain. In regards to focus and happiness, he has discovered a Meow Mix Mantra.

Coming at you with a disco ball and cats dancing, this remix of the old Meow Mix commercial is funny and hypnotic. With its cat theme, up-beat music, and occasional lasers coming from a cat’s eyes, the Meow Mix song [10 hours] YouTube video is something he has really latched on to.  Unless you suffer from photosensitive epilepsy, you will want to play it to fully understand [warning: lots of flashing and scene changes]:

As a family, we agreed to not play it at the dinner table. However, that brings up a challenge that has not been figured out quite yet with any of his meditative practices, schedule.

Due to school and what not, kids schedules are pretty full. When not using his small allotment of iPad time, he prefers to play with toys over meditating.

I feel certain that if we used something that provided tangible feedback such as the “brain sensing headband” called Muse, the idea of meditating would be even more attractive. With the cost being in the triple digits, that’s not a gamble we want to take though.

After a family discussion, our kid decided to not meditate at this time. That of course is fine. It is a decision that many adults make. Was it because he felt something else was threatened on the schedule though?

Regardless, he is sold on the Meow Mix Mantra and it’s good enough for him meow (now). May you find your happiness too.

“Good” Meditation Growth Then Tears Flowed

I have been using the iPhone app Meditation for Skeptics by 10% Happier for some time now. As said in earlier posts like 10% Happier App is Growing, the app has answered questions I’ve had for a long time, brought different perspectives to my meditation practice, and has given me insightful conversations with real-live meditation coaches.

Recently, something special happened.

After finishing a 20 minute meditation, I did the last two sessions of the 10% Happier app with Sharon Salzburg. I’ve done them before, but decided to revisit them.

After I completed the two sessions, I felt an urge to tell Sharon she did a good job. I thought: Why not? She earned it! It would also exercise my kindness mental muscle. So, I started writing a quick Twitter tweet saying she did “good” and then changed it to “great”. Great is better than good, right?

Sharon Salzberg. As you have heard many times I'm sure, you did great with your role in the 10% happier app.

Great Job Tweet

Why in the world did the word “good” still feel like higher praise than “great”? What’s going on? Then, the answer hit me. So, I shared my moment of “ah ha!”

This just helped me realize that when a grandfather told me "I did good" he meant it on two levels. Good for others too.

Why Grandpa Said “Good”

Time to share what I truly felt. She did well and it was a wonderful gift for all.

So, you did good.

Sharon Did Good Tweet

Boom! Feelings of gratitude, missing grandpa, and love washed through me. Tears flowed. It wasn’t sadness, but just “wow!” What to do?

Fortunately, I knew what to do. In my experience and from what I have learned from others on this path, it’s best to let the feelings flow through you. Let the tears stream down the face and to breathe deep. If such an experience is new to you, you may feel silly when it hits you. However, take comfort in that this is all normal and healthy.

This is a natural breakthrough. Sometimes such experiences can be interpreted as unsettling, embarrassing, or even scary.

I suggest comparing these experiences with those experienced with meditation. One obvious source is the 10% Happier app made by Dan Harris and others. Other local sources may serve you as well. Good luck on your journey and be well!

Swizzle Swift Class Methods

While writing some test Swift code, I ran into a situation where I wanted the implementation of a class method swapped out with some fake code. Basically, I wanted to swap out SomeClass‘s saveSomeThings class method with a fake one.

Inspired by NSHipster’s Swift & the Objective-C Runtime article, I came up with some concise code that does what I want. Focusing on only what shows the concept, we have the following example SomeClass:

The saveSomeThings method implementation is what we want to swap out with some fake code for testing purposes. How, you might ask? First, ensure the method has the dynamic keyword as discussed in this Stack Overflow post. Next, we grab a handle to the class method like so:

Now we need something to swap it with. What if we had a method inside a SomeTestClass class like the following just for testing purposes?:

We can grab a handle to the method like so:

The actual call to swap the implementation between the saveSomeThings and forTesting_SaveSomeThings is done using method_exchangeImplementations like this:

The SomeTestClass prefixes the originalMethod and swizzledMethod because I am storing them as static members of the SomeTestClass.

Those are all the magical pieces of this puzzle! Besides being on github, here is a complete Swift playground example to see it all in context:

At CARFAX, I have been fortunate enough to work on such interesting challenges like the one above in Swift, Objective-C and Java based languages. Since CARFAX is a growing company with opportunities that open up from time to time, you might want to checkout the CARFAX Career link.

Regardless, I hope you found the above information interesting and useful. Enjoy!

Hit Your Own Server On Your Mac With Your iPhone

To truly evaluate the user experience, there is no substitute for having the app on your iPhone and in your hands. Yet, it’s rare that a person can make an iPhone app that doesn’t depend on a server of some kind.

If you don’t have a server deployed somewhere yet, what can one do? Well, you can hardcode values in the app. However, that can be more trouble than it’s worth. Also, you’re not testing the whole app end to end. So, what one can do is create a mock server that returns hardcoded values using Node.js or some other framework. Great!

Just one thing, the mock server your iPhone depends on is not ready to be deployed. It’s on your machine only. What to do?

You can run the server locally on your mac and have your iPhone hit it over wireless. Sounds easy enough. Right?

After figuring out your IP address of your machine for the phone to hit, changing the iPhone app to hit whatever URL it needs, and probably temporarily turning off App Transport Security so you can hit it with an http as opposed to an https URL, you may find that your iPhone app still cannot hit the machine your mock server is running on.

Stack Overflow to the rescue! After digging into the google world, I found the key sentence I was looking for in a Stack Overflow post:

I turned off my WI-FI on my Mac and then turned it on again, which solved the problem.

Although I’m not positive, it seems like I had to flip the wireless from on to off and back to on more than once. To test that the phone can reach the machine, I used safari on the iPhone to check that I can hit anything at all on that machine.

Once I figured all this out, I was so happy that I decided to write this for others to use. If it wasn’t for Stack Overflow and our community of knowledge sharers, where would we be today?

Vision Versus Implementation

When a vision is shared and agreed upon, that’s a good feeling. A direction has been laid out. Metaphorically, the compass has a true north to point towards. What confuses people sometimes is the difference between a vision and an implementation of that vision.

What’s the risk? Who cares? Well, let’s come up with a crazy simple example. Let’s say the vision is to go after fruit. The leader says:

We want fruit.

So, someone eventually says,

We need to do these things to get oranges. It’s what the leader wants. Don’t you support our fruit vision?

The vision was changed into an implementation. What even compounds the confusion is that the leader had suggested that for a specific team, the implementation of the vision will probably be apples.
Now, it’s easy to see the error in this case when dealing with apples and oranges. It can be harder when a generic word like “initiative” is used.

In this case, what can help is to add on “vision” or “implementation” as needed. For example, someone can propose that a specific team support the “initiative-vision” by using this specific “initiative-implementation.” If a certain implementation doesn’t work, one can try a different implementation without throwing out the whole vision.

Separating out the the vision versus the implementation enables a certain amount of freedom and likelihood of success. It makes the vision more resilient, adaptable, and much more likely to succeed as it gets more fully embraced within the entire group.

May your visions bear fruit. Try not to go bananas while going after it.

Fire! Wife, Apple Watch, and Meditation are Heroes

Ring! Ring! There goes my Apple Watch. The iPhone is in another room and my hands are dirty-dishes-gross. “That’s weird and annoying”, I think reflexively to myself. My wife is calling but she just left.

With the final ring sounding, I quickly do the right thing regardless of my thoughts. I rinse off a pinky finger and answer the call on my Apple Watch with it. I hear her Apple Watch’ed voice say loudly “Get a trashcan full of water and …. <something about a bin>.” What’d she say? After quickly rinsing off my hands, I grab a trashcan, yank the trash out, and mutter about needing caffeine while filling it up with water.

Next, I’m outside. Hmm! Lots of smoke is coming from the trash bin area. Uh oh… A quick emotion check reveals slight concern and the thought that I better get out there soon and see what’s up. I’m slightly surprised about how matter-of-fact my mind feels.

Keeping a clear mind is a credit to the meditation training I’ve done over my life and most recently received from my two favorite meditation apps. At some point, I run toward the smoke and check out the situation. Oh! This fire could spread quickly!

My wife had emptied the wastebasket full of water and tells me to get the fire extinguisher. “Good thinking”, I reflect while running back. I dug it out from the back of the closet, run it out to her, and she puts the fire out while I am running back for more water. Success!

A photo of the inside trash bin area that caught fire.

Where the Fire Started Inside the Bin Area

Just then, the maintenance person shows up that my wife had called. Good. He can do any needed follow up with whomever.

Fire scorched trash bin area fence

Fire Scorched Fence Outside of the Bin Area

Let’s recap. The trash bin area is completely surrounded by a dry timber fence. If I hadn’t been wearing my Apple Watch, had my meditation training, and/or my hero wife hadn’t seen the fire, it might have gone completely up in flames. As my wise wife said, who knows if a floating fire ember would have started another fire on a nearby home?

As far as who the hero is that kept people and property safe, the credit goes to my wife.

This is also a moment of gratefulness. I am grateful for my wife’s levelheadedness. I’m also thankful to Apple for their innovation and specifically my Apple Watch. Finally, I feel lucky to have experienced first hand the fruit of all of my meditation training which kept the whole event in perspective and kept me from overreacting.

May you also be as blessed as me in such times!

An Apple iOS Distribution Certificate Dying

In an iPhone developer’s life, there is sometimes mystery around some of the Apple related administrative work that is needed. Certificates expire, Provisioning Profiles have to get regenerated, and test devices come and go.

One interesting question was brought to my attention recently:

If the iOS Distribution Certificate expires, will the iPhone apps in the App Store still work?

Yes. The iPhone apps will still work. From the Apple documentation:

If your Apple Developer Program membership is valid, your existing apps on the App Store will not be affected.

So, it’s well understood that Distribution Certificates expire. What about if someone adds a test device, will that invalidate the iOS Distribution Certificate? The short answer is “no.” Devices are added to Provisioning Profiles as opposed to certificates.

For detailed information, look at the Registering Devices Using Member Center section of the Maintaining Identifiers, Devices, and Profiles Apple documentation and Exporting Your App for Testing (iOS, tvOS, watchOS).

I hope that clears up some of the mystery around an iOS Distribution Certificate dying and point to some helpful Apple documentation.