You too can -print0


Do you use the command line a lot? Do you search for files with find(1)? Do you send lists of files to xargs(1)? Do the files sometimes have names with spaces, apostrophes, and other special characters in them? Do you think it is great that find -print0 takes care of that when you produce filenames, and xargs -0 takes care of that when you consume them?

Do you write your own command line tools?

Do your command line tools generate lists of files? Can I send the output of your tools to xargs, even if the files have names with special characters in them?

You too can separate filenames in the output of your command line tools with a null character instead of a newline.

This is how I usually do it in Python:


import argparse

parser = argparse.ArgumentParser()
parser.add_argument('-0', '--print0', action='store_true')
args = parser.parse_args()

for filename in generate_filenames_somehow():
    if args.print0:
        print(filename, end='\x00')

Joseph Smith


[This is the transcript of a talk I gave in church on Sunday, June 26, 2016.]

When Christ was on the earth he organized a church so that the gospel could be taught to all nations. He chose certain men as his apostles and gave them authority to preach the gospel and perform ordinances. Even after his death, resurrection, and ascension to heaven Jesus Christ directed his church through visions and revelation to his apostles.

These apostles were prophets. They taught the true doctrine of Christ. Through revelation they helped to answer questions and clarify misunderstandings about Christ and his gospel. Above all, they testified of Jesus Christ: that he was the Son of God; that he died and was resurrected; and that through his atonement all mankind may saved from sin, become perfect, and live with God again.

When these early apostles died, the authority to lead the church was gone. Members of the early Church of Jesus Christ could still rely on the Holy Ghost for personal revelation, but there was no longer a man called by God to direct the church. Without this revelatory link, many truths of the gospel were lost. Argument and division splintered the church.

The apostle Paul prophesied of this. Referring to the second coming of Christ, he said, “for that day shall not come, except there come a falling away first”.

The prophet Nephi also foresaw this. He said,

For it shall come to pass in that day that the churches which are built up, and not unto the Lord, when the one shall say unto the other: Behold, I, I am the Lordʼs; and the others shall say: I, I am the Lordʼs; and thus shall every one say that hath built up churches, and not unto the Lord — And they shall contend one with another; and their priests shall contend one with another, and they shall teach with their learning, and deny the Holy Ghost, which giveth utterance.

Along with this falling away, ancient prophets also foretold of a restoration. The apostle Peter called it “the times of restitution of all things, which God hath spoken by the mouth of all his holy prophets since the world began.” Isaiah called it “a marvellous work and a wonder”. It was even prophesied that the Lord would raise up a prophet named Joseph.

And so this is the situation we find the world in. There are many churches, all claiming to be the Lordʼs church and fighting with one another. The authority to speak in the name of Jesus Christ and to perform the ordinances of his gospel is nowhere to be found on the earth.

Through prophecies given anciently, God promised to restore the truths of the gospel. To do this, God needed a prophet on the earth again. In the words of Elder Neil L. Andersen, “Jesus Christ chose a holy man, a righteous man, to lead the Restoration of the fulness of His gospel. He chose Joseph Smith.”

President Wilford Woodruff taught, “Joseph Smith was kept in the spirit world for thousands of years to be born in the flesh at the right time, and to be inspired of God, to be visited by Him, and to be qualified and prepared for the mission given into his hands.”

Brigham Young likewise testified, “It was decreed in the counsels of eternity, long before the foundations of the earth were laid, that he, Joseph Smith, should be the man, in the last dispensation of this world, to bring forth the word of God to the people, and receive the fulness of the keys and power of the Priesthood of the Son of God.”

Joseph experienced first-hand the religious confusion of his day. Reflecting on that time in his life, he wrote, “so great were the confusion and strife among the different denominations, that it was impossible for a person young as I was, and so unacquainted with men and things, to come to any certain conclusion who was right and who was wrong.”

Fortunately, Joseph was raised by righteous parents who taught him the importance of the scriptures. He studied the Bible on his own. Joseph recalled this feeling after reading James 1:5: “Never did any passage of scripture come with more power to the heart of man than this did at this time to mine. It seemed to enter with great force into every feeling of my heart.”

Joseph had most likely read this scripture before, or heard someone else in his family read it. When you read the scriptures, do you ever get the feeling that you are hearing a verse for the very first time, even though you know youʼve read it before? Pay attention to that feeling. That is the Holy Ghost telling you that that scripture is important for you at that moment. It may be an answer to a question that is troubling you, or, like it was for Joseph, instructions for what to do to obtain an answer.

Joseph learned that “spiritual questions deserve spiritual answers from God.”

And so when he was 14 years old, Joseph Smith went to a quiet spot in the forest near his home to pray for direction. What were you doing when you were 14 years old? Iʼll tell you what I was doing. I was writing in my journal about how much I love Star Wars.

What happened in answer to Joseph Smithʼs prayer was the beginning of the dispensation of the fulness of times. In his own words:

I saw a pillar of light exactly over my head, above the brightness of the sun, which descended gradually until it fell upon me. […] When the light rested upon me I saw two Personages, whose brightness and glory defy all description, standing above me in the air. One of them spake unto me, calling me by name and said, pointing to the other — This is My Beloved Son. Hear Him!

God the Father and his son, Jesus Christ, visited Joseph Smith. Christ told Joseph that none of the churches on the earth at that time taught the fulness of the gospel. None of them had the authority to act in the name of Jesus Christ. Joseph was promised that the truths of the gospel and the authority to organize Christʼs true church would be given to him.

Joseph Smithʼs work was just beginning. When he was 17 years old, Joseph was visited by an angel named Moroni. Joseph learned about an ancient record that he would later translate by the power of God, The Book of Mormon.

What were you doing when you were 17 years old? Iʼll tell you what I was doing. I was writing in my journal about being excited to check my email.

As part of his message, the angel Moroni told Joseph “that [his] name should be had for good and evil among all nations, kindreds, and tongues, or that it should be both good and evil spoken of among all people.” In what way are you fulfilling this prophecy? Do you speak good or evil of the prophet Joseph Smith? Neil L. Andersen said, “Gain a personal witness of the Prophet Joseph Smith. Let your voice help fulfill Moroniʼs prophetic words to speak good of the Prophet.”

When he was 21 years old, Joseph received the record that Moroni had told him about. After some moving around to escape constant persecution, he was 23 years old when he took about two months to translate a book that is over 500 pages long. What were you doing when you were 23 years old? I was in college and I donʼt think I could even read 500 pages in two months.

While translating the Book of Mormon, Joseph learned much about the gospel of Jesus Christ. He learned about priesthood authority. He was visited by John the Baptist, and later by the ancient apostles Peter, James and John. These angelic visitors conferred on Joseph Smith the priesthood, or the authority to act in the name of Jesus Christ.

When Joseph was 24 years old, now holding the proper authority, he formally organized the Church of Christ. After hundreds of years, the church that Jesus Christ himself had organized was now back on earth. And Joseph Smith was the prophet that Christ had chosen to do this work.

In the years that followed, revelation continued to flow to the church through the prophet Joseph. He called other men as apostles. He organized missionary work. He directed the construction of temples and the Lord revealed to him the temple ordinances such as baptism for the dead and the endowment, and eternal marriage. Many of the revelations he received were recorded in what is now the book of Doctrine and Covenants.

The Lord Jesus Christ said:

[…] I have sent forth the fulness of my gospel by the hand of my servant Joseph; and in weakness have I blessed him; And I have given unto him the keys of the mystery of those things which have been sealed, even things which were from the foundation of the world, and the things which shall come from this time until the time of my coming […]

Josephʼs testimony of Jesus Christ is this:

And now, after the many testimonies which have been given of him, this is the testimony, last of all, which we give of him: That he lives! For we saw him, even on the right hand of God; and we heard the voice bearing record that he is the Only Begotten of the Father — That by him, and through him, and of him, the worlds are and were created, and the inhabitants thereof are begotten sons and daughters unto God.

The truthfulness of The Church of Jesus Christ of Latter-day Saints rests on the truthfulness of the First Vision and the other revelations the Lord gave to the Prophet Joseph.

I have a testimony that Joseph Smith was chosen by Jesus Christ to restore the gospel and organize his church. I know that the authority to lead the church and speak in the name of Jesus Christ has been conferred through latter-day prophets in an unbroken line and that The Church of Jesus Christ of Latter-day Saints is directed by Jesus Christ through a prophet today.

In the name of Jesus Christ, amen.

Podcasts on Android


John Gruber linked to Benjamin Mayoʼs 9to5Mac analysis concerning iOSʼs dominance of podcast listening. Mayo writes that most iOS podcast listeners are using Appleʼs first-party podcast app:

Clearly, having the app preinstalled on the system (as of iOS 8) drives a lot of usage.

This is a big deal. Android – at least on Googleʼs Nexus devices – has never shipped with a podcast app preinstalled. Google had their own podcast app, Listen, from 2009 to 2012. They discontinued it because there were plenty of other podcast apps available on the Google Play Store.

(Ironically, podcast subscriptions in the Google Listen app were migrated to Google Reader. Google shut down Reader less than a year later.)

With the lack of a podcast directory and no first-party app, it is clear that Google doesnʼt care about podcasts. But if they are serious about the future of advertising, they would do well to pay attention. Advertising in podcasts is probably the only kind of advertising that I actually pay attention to.

Follow the Prophet


[This is the transcript of a talk I gave in church on Sunday, June 28, 2015.]

God is our Father and we are his children. His greatest desire is that we, as His children, grow to become like He is. He has prepared a plan, the Plan of Happiness, to accomplish this great work, “to bring to pass the immortality and eternal life of man.”

Every person in this room, every person in this city, every person who has ever been born or who will ever be born, made the choice to come to Earth to participate in this plan. We “sang together, and all the sons [and daughters] of God shouted for joy”.

Because of the fall of Adam, when we are born on Earth we are separated from God. We also pass through a veil of forgetfulness that blocks our memories of the premortal existence.

If we are separated from God, and we cannot remember what we knew before we were born, how then can we follow the Plan of Happiness that we were so excited about?

God our Father established a pattern to teach His children on Earth the Plan of Happiness so that we may return to live with Him. He teaches His plan to a prophet and gives that prophet the authority to teach others in His name.

God has followed this pattern, beginning with Adam, the first man, and continuing through the ages until we come to His prophet today, Thomas S. Monson.

How do we know this? The prophets did not just teach the people around them. They also recorded important revelations, which were handed down through generations as scripture. The scriptures record the beginning of prophets on earth:

And in that day the Holy Ghost fell upon Adam […]

And in that day Adam blessed God and was filled, and began to prophesy concerning all the families of the earth, saying: Blessed be the name of God, for because of my transgression my eyes are opened, and in this life I shall have joy, and again in the flesh I shall see God.

And Adam and Eve blessed the name of God, and they made all things known unto their sons and their daughters.

We know of many ancient prophets because we have the scriptures before us. Adam, Enoch, Noah, Abraham, Moses, Isaiah, and others in the Old Testament. Peter, James, John, Paul, and others in the New Testament. Lehi, Nephi, Jacob, Alma, Mormon, Moroni, and others in the Book of Mormon. Even our children know these names.

All these men were chosen by God, taught the Plan of Salvation, and given authority to speak in the name of God.

With the exception of the words of Christ recorded in the New Testament, and a handful of other sacred moments we know of, the majority of what we consider the “word of God” was delivered through a prophet.

We often sing:

Come, listen to a prophetʼs voice, And hear the word of God

The Lord has declared through modern-day revelation:

These words are not of men nor of man, but of me; wherefore, you shall testify they are of me and not of man;

For it is my voice which speaketh them unto you; for they are given by my Spirit unto you, and by my power you can read them one to another; and save it were by my power you could not have them;

Wherefore, you can testify that you have heard my voice, and know my words.

When we hear a prophet speak in the name of the Lord, we can testify that we have heard the voice of the Lord.

Sister Carol F. McConkie, who is currently serving in the Young Women General Presidency, recently taught us the importance of following the prophet. She said:

When we choose to live according to the words of the prophets, we are on the covenant path that leads to eternal perfection.

I am familiar with the sad story of a man who chose not to believe the revelation and counsel given through the prophet. At first, in order to get along with other members of his family, he did appear to follow the prophet. But his obedience proved to be only hollow actions. His heart was just not in it, and he often complained about the inconvenient things the prophet asked him to do.

You may be familiar with this story, too. The manʼs name was Laman.

Laman saw the prophet of God as merely a man, and did not recognize the divine calling and authority given by God to that man.

On the other hand, Laman had a brother that faithfully followed the prophet, doing whatever he was commanded to do. Because Laman did not seek to understand the ways of the Lord, he developed deep feelings of resentment toward his righteous brother, Nephi.

What was the legacy Laman left by not following the prophet? He hated his brother, Nephi, and wanted to kill him. He taught his children to hate the children of Nephi.

And thus [the Lamanites] have taught their children that they should hate [the Nephites], and that they should murder them, and that they should rob and plunder them, and do all they could to destroy them; therefore they have an eternal hatred towards the children of Nephi.

One manʼs choice brought hundreds of years of hatred, war, destruction, and death to generations of his descendants.

Sister McConkie continues:

The Lord [gives us] the opportunity to choose to believe and obey the words of the prophet.

We heed prophetic word even when it may seem unreasonable, inconvenient, and uncomfortable. According to the worldʼs standards, following the prophet may be unpopular, politically incorrect, or socially unacceptable. But following the prophet is always right.

If we are to follow the teachings of the living prophet, perhaps I should give some examples of recent counsel from our prophet today, President Monson. In General Conference just two months ago, he taught us the importance of worshipping in the temple. He said,

Inside this sacred sanctuary, we find beauty and order. There is rest for our souls and a respite from the cares of our lives.

As we attend the temple, there can come to us a dimension of spirituality and a feeling of peace which will transcend any other feeling which could come into the human heart. We will grasp the true meaning of the words of the Savior when He said: “Peace I leave with you, my peace I give unto you. … Let not your heart be troubled, neither let it be afraid.

Such peace can permeate any heart – hearts that are troubled, hearts that are burdened down with grief, hearts that feel confusion, hearts that plead for help.

My brothers and sisters, in our lives we will have temptations; we will have trials and challenges. As we go to the temple, as we remember the covenants we make there, we will be better able to overcome those temptations and to bear our trials. In the temple we can find peace.

President Monson also recently admonished us to search the scriptures to learn specifically about the Savior so that we may follow His example:

We, with Jesus, can walk the path of obedience. […] We, like Jesus, can walk the path of service. […] Other instructions given to us by the Savior are at our fingertips, found in the holy scriptures. […] He instructs us to stand up bravely for our beliefs, even when we are ridiculed and persecuted. […] The Saviorʼs example provides a framework for everything that we do, and His words provide an unfailing guide. His path will take us safely home.

We are blessed to live in a glorious time, when the words of the prophets, both ancient and modern, are readily available. We find them in books, in magazines, on our televisions and computers and phones. Do we recognize and truly appreciate this great gift? Bishop Gérald Caussé, the First Counselor in the Presiding Bishopric of the Church, said:

There are so many wonders in this world. However, sometimes when we have them constantly before our eyes, we take them for granted. We look, but we donʼt really see; we hear, but we donʼt really listen.

When we look at President Monson, do we really see a prophet of God? When we hear his words, do we really listen? I pray that we will not take the words of the prophets for granted.

We can know for ourselves that the prophets speak the word of God. Sister McConkie taught:

As we prayerfully read and study sacred prophetic word with faith in Christ, with real intent, the Holy Ghost will speak truth to our minds and hearts.

In 2008, when Thomas S. Monson became the president of the Church, I remember receiving a witness from the Holy Ghost that he was a true prophet of God. I felt a feeling of peace in my heart and I knew that I should follow his counsel.

As the years have gone by, I have strived to follow the prophet. My family and I have been blessed for heeding his counsel to hold Family Home Evening regularly, study the scriptures together, serve others, live within our means, and pray often.

With each step of obedience to the words of the Lord as delivered through His prophet, the Spirit of God has quietly confirmed truth to my heart and mind.

As we sing in the hymn, let us

heed the words of truth and light
That flow from fountains pure.

When the prophet speaks, will we be like Laman, or will we be like Nephi? The choice we make today to follow the prophet or not will affect generations to come.

I testify that God speaks through his prophet, Thomas S. Monson. Jesus Christ is at the head of this Church, and He directs the work of salvation through President Monson and those that serve with him.

I testify that I have heard the voice of the Lord through his prophets.

In the name of Jesus Christ, amen.

Building a Better Twister Spinner


I got my wife Twister for Christmas. While we were playing it on Christmas morning, she remarked that the spinner was not great. It seemed to land on Left Foot more than we expected.

My first thought was, “I could write a quick Python script to get a more random spinner result!” So I grabbed my computer and threw this together in about a minute:

import random

parts = ['Right Foot', 'Right Hand', 'Left Foot', 'Left Hand']
actions = ['Red', 'Yellow', 'Green', 'Blue']
while True:
    input('{} {}'.format(random.choice(parts), random.choice(actions)))

This is about the bare minimum I could get away with: choose a random body part and a random color and print the combination. We played this way for a while before my wife had an amazing idea.

“It would be really great if the computer could just read the spin result out loud,” she said.

I immediately thought of say, because my five-year-old daughter loves to play with say on the command line and make my computer speak. So another minute or two later I had modified my script:

import random
import subprocess

parts = ['Right Foot', 'Right Hand', 'Left Foot', 'Left Hand']
actions = ['Red', 'Yellow', 'Green', 'Blue']
while True:
    move = '{} {}'.format(random.choice(parts), random.choice(actions))['say', '-v', 'Samantha', '-r', '150', move])

Now we had nice random spins and the computer calling out the moves. But the script still required someone to press Enter after each move. The final tweak was to make it automatically call out moves after a few seconds:

import random
import subprocess
import time

parts = ['Right Foot', 'Right Hand', 'Left Foot', 'Left Hand']
actions = ['Red', 'Yellow', 'Green', 'Blue']
while True:
    move = '{} {}'.format(random.choice(parts), random.choice(actions))
    print(move)['say', '-v', 'Samantha', '-r', '150', move])

At this point I was pretty happy with the behavior of my quick little script. But I took the opportunity anyway to flesh it out a bit and allow command line options to configure various things. It was a good chance to learn how to use the argparse module.

The final script is on GitHub. It includes command line arguments for:

  • allowing “in the air” as a valid alternative to a color (our version of Twister had this move on the spinner);
  • specifying the number of seconds to wait before automatically spinning again, or requiring someone to press Enter after each spin; and,
  • making the computer speak the spins out loud (only on platforms with the say command).

This script was a fun little diversion, and now my wife and I can play Twister without needing a third person to operate the spinner!