Haseeb Qureshi locked himself out of his online accounts for two years using Ruby code as a commitment technique to curb his addiction to useless websites. When he got a job two years later and wanted to waste company time online, he discovered he couldn't access his accounts. This prompted him to use Ruby code to crack his own password and regain access. The key takeaway is that coding can be used to solve real problems in creative ways.