He was jobless and living on the streets of New York. One day, Mr Leo Grand, 37, was given a chance to learn to write computer code.
Now he has released his own app called Trees for Cars. It is a carpool app which hopes to save the environment by helping New York commuters share rides, the New York Post reported.
The stranger who went up to Mr Grand gave him two choices - two months of coding lessons or US$100 (S$125) in cash.
"I can go through US$100 in a few days," news portal Business Insider quoted Mr Grand as saying. "But he told me I could have a laptop and learn how to do something and I figured it could turn into something more."
Mr Grand, who lost his job at insurance firm MetLife in Manhattan and was priced out of his apartment, opted for the lessons. And 3,621 lines of code later, he released his first mobile app. It went live on the App Store on Tuesday, around the same time it went live for Android users, tech website Mashable reported.
The stranger who became his teacher is Mr Patrick McConlogue, a 23-year-old programmer.
Mr Grand charged his laptop at an apartment building, then headed out to the street where he has been living since 2011 to learn code from used books from Amazon and with the help of Mr McConlogue.
The two began their lessons in August. The first two months consisted of outdoor lessons conducted on the city benches near Chelsea Piers, where Mr Grand slept. When Mr McConlogue headed off to work, Mr Grand would spend about four hours on his own practising writing code and studying the books provided.
Four months later, their hard work paid off. The app, available for the iPhone, iPad and Android, is sold at 99 US cents. The profit will go towards Mr Grand's future projects.
Get The New Paper for more stories.