Archive for October, 2011
Out of college for 5 years
Harvard apparently has a tradition of collecting mini-autobiographies of its graduates every five years. I’m coming up on my fifth year reunion, and I decided to try to hack the process by seeing if I can get them to print a bit.ly link to a google docs presentation. So far I haven’t gotten any indignant howls from the editors, but we aren’t at the deadline yet.
I thought I’d share the presentation because it’s a pretty good summary of where I am and hope to be going.
We are all the 1%
I like the name “Occupy Wall Street” more than I like the “99%” slogan. I can get behind occupying Wall Street. It probably needs some occupying. Going after the 1%, though, I have a hard time with. I don’t have a million dollars, but I think I’m in the 1%. Same with my friends. We’re not in the 1% of wealth. But we’re in the 1% of something. I have some friends who can do graphic design better than 99% of everyone else in the country. I also have some friends who are in the top 1% of America in terms of their physics knowledge. I know some 1% dancers. Some 1% artists.
I bet if you think about it, you can come up with something that you’re better at than 99 of every hundred people you meet. That’s because people have incredibly diverse sets of talents. The people in Zuccotti Park are part of the 1% of people who care enough and are active enough to get out onto the streets for their beliefs. That’s a really important 1% too.
I passionately believe in the 1%. It makes me happy to see my friends do amazing things that I could never do in a thousand years. It’s exciting, it’s inspiring, it’s what makes us human. “Occupy Wall Street” is possible because of a huge collection of talented people. The tools of the modern revolutionary, in the Arab world and here in the U.S., were put together by technology visionaries like Steve Jobs and the founders of Twitter. A lot of them made a lot of money doing it. I hope they don’t feel isolated because they’re part of the 1%; I’d like them to be comfortable marching side-by-side with the protesters, because they believe in a lot of the same things.
People are rallying in support of “Occupy Wall Street” because we’ve failed collectively to make sure everyone has access to economic opportunities. Creating economic opportunity is a huge challenge, and no one has all the answers. People are angry because the government and the finance sector haven’t contributed much to solving the problem. The honest truth is, they probably never will. Real change comes bottom-up. It comes from people going out there and creating economic opportunity for themselves and for others. If we want change, we need to be the 1%; we need to be ourselves at our best, and share our talents with the world.
I want us to create a world where you can’t walk five feet without tripping over economic opportunity. I want opportunity to pour from every town and city in this country and every city and nation in the world. The only way that happens is if we embrace the 1%; embrace challenge, embrace creation, embrace being our best and making the world a better place. Be the 1% — we’re all counting on you.
Self-experimentation, the programming-free version
Thinking about it, my previous entry on how I set up a self-experiment over text messages might be a little intimidating for the non-programming crowd. It assumes you know how to ssh into a web server and run terminal commands, set up cron jobs, and have some basic fluency in Python and SQL.
So I wanted to point out that you can get to an 80% solution using no coding at all, just ifttt. The goal, remember, is to get a text message throughout the day with a prompt, and then reply back to that text message and have your response saved. If you don’t care about randomizing the times of day, or auto-generating the metrics, you can do this without any technical knowledge at all.
Step 1. Set up the prompts. Create an ifttt task (see my last post for how to do this) with the “Date & Time” channel as the trigger and the SMS channel as the action. Pick the times of day you want to get emailed, and write the question you want emailed to you.
Step 2. Set up the data capture. If you don’t have an Evernote account, create one — it’s free! Create a notebook within Evernote for storing the results of your experiment. Then, create an ifttt task with the SMS channel as the trigger, and the Evernote channel “create a note” as the action. For the note text, put {{Message}}; this will copy the body of the text message you send in. For the notebook, put the name of your new experiment notebook. Now, every time you reply to a text from ifttt, the reply will be saved in your notebook.
Look ma, no code!
Self-experimentation using ifttt and a dash of python
Per my previous post on making the world a more joyful place, I’m interested in self-experimentation. There are a lot of cool things that open up if you can take a scientific approach to your own life, but in the past I haven’t been able to follow through because I lacked the discipline to record data regularly.
What I really want is for data collection to be totally mindless. My ideal is, I get a text message asking me the question, and all I have to do is reply to the message. This is really easy for me since I generally reply to text messages in real time.
Setting something like that up used to be a lot of work. But thanks to a new free service, if this then that, I was able to super-easily set up a simple experiment where I get texted a yes / no question at 5 random times each day, and have the data be automatically collected for me! Here’s a walk-through of how I did it. You’ll need: the internet, an ifttt account, a gmail account, an evernote account, and a webserver where you can publish python scripts and run cron jobs (I use dreamhost — it’s super-cheap shared hosting, perfect for lightweight little things like this).
Prelude: ifttt basics.
ifttt lets you create dead-simple automated tasks by connecting “triggers” (which can be anything from you sending ifttt a email or text message, to you posting on facebook or twitter), to “actions” (which can be ifttt sending you an email or text message, or posting something to a 3rd party account). It integrates with pretty much every popular webservice on the internet, and it’s almost so self-explanatory that it hurts:
Step 1: Generate the reminders.
If you’re okay with setting the exact time you get the message, this part is pretty much done: go into ifttt, and create a task with a “Date & Time” trigger and an SMS action.
For me, I wanted to add some randomness to when I get the reminders, so I had to do a little more work. On my web server, I created a script that, when run, sends an email from my gmail account to ifttt. I created a file “email_google.py” with the following contents:
import os import smtplib import mimetypes from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email.MIMEAudio import MIMEAudio from email.MIMEImage import MIMEImage from email.Encoders import encode_base64 import base64 def send_mail(recipient, subject, text): user = 'fake@gmail.com' pw = 'crazy_random_fake' msg = MIMEMultipart() msg['From'] = user msg['To'] = recipient msg['Subject'] = subject msg.attach(MIMEText(text)) mailServer = smtplib.SMTP('smtp.gmail.com', 587) mailServer.ehlo() mailServer.starttls() mailServer.ehlo() mailServer.login(user, pw) mailServer.sendmail(user, recipient, msg.as_string()) mailServer.close() print('Sent email to %s' % recipient)
And then another file “send_reminder.py” that does the actual work:
import random import email_google import time time.sleep(random.randint(0, 110) * 60) #subtracting 10 minutes to account for ifttt being slow email_google.send_mail('trigger@ifttt.com', '#myexperiment', 'body')
What this does is sends an email to ifttt anywhere from 0 to 110 minutes after the script is started. I then run this script using a cronjob (“python /path/to/script/send_reminder.py”) — dreamhost’s control panel provides a nice gui for setting up cron jobs so I didn’t have to do this by hand.
Then in ifttt, I set up a task with an email trigger with the hashtag #myexperiment, and an SMS action that sends me the reminder. So whenever the script on my server gets kicked off, it waits a few minutes, then emails ifttt, which sends me a text message!
Step 2: Capture the reply.
I want to be able to reply back to the text message and have that information saved in a database. First, I created a database on my webserver using the sqlite3 command: I ssh’ed in and ran “sqlite3 my_db”. That pops up the sqlite3 command line tool; I ran “create table log (time, input);” to create a table to store the data, and then “.exit” to leave sqlite3.
I then created a simple script that stores a one-word response to the database. I created the file “accept.py” with the following contents:
#!/usr/bin/python print "Content-type: text/html\n\n" import cgi import cgitb cgitb.enable() import sqlite3 form = cgi.FieldStorage() input = form["input"].value.lower() if input in ('yes', 'no'): con = sqlite3.connect('my_db') con.execute('insert into log select datetime(), ?', [input]) con.commit() print 'success'
This file goes on my web server. I needed to run “chmod 755 accept_input.py” to let Apache run it as a script. What this does: when I go to http://myserver.com/path/to/my/folder/accept.py?input=yes, it saves “yes” to my database, and records the time at which it happened. Likewise, changing the url to “?input=no” saves “no”.
Finally, I need to make ifttt visit that url when I send it a text message. I created a task with an SMS trigger. But what should be the action? Right now ifttt doesn’t have a “visit url” action. However, we can fake it by using the Evernote channel’s “create a link note” channel, which creates a link in your notebook based off of a given url. Evernote visits the url to create the note, so the server registers the hit. We need to get the “yes” or “no” message we send into the url, so I set the “Link URL” field of the action to “http://myserver.com/path/to/my/folder/accept.py?input={{Message}}”.
Voila! Every time we text a reply to ifttt, the body of the reply (a “yes” or “no”) gets stored in our database!
Step 3. Review the results.
I want to see the results of the experiment! For me, the thing I want to track is the percentage of “yes”s for a given day and how that changes over time. So, I wrote one more python script that reads the database and outputs a table:
#!/usr/bin/python print "Content-type: text/html\n\n" import cgi import cgitb cgitb.enable() import sqlite3 con = sqlite3.connect('my_db') results = con.execute(""" select date(time), (sum(case when input = 'yes' then 1 else 0 end) +0.0) / count(*) from log group by date(time); """) print """ <html> <head> <style> td { padding: 3px; } table, tr, td { border: 1px solid black; } </style> </head> <body><table> """ for row in results: print "<tr><td>", row[0], "</td><td>", row[1], "</td></tr>" print '</table></body></html>'
Save that to your webserver, and remember to run “chmod 755” on it if necessary! Now, you can visit the url of that script and see a nice little report on your experiment.
Bonus step: Backing things up
I’m paranoid, and because dreamhost is cheap shared web-hosting (no offence, guys), I’m not 100% sure a server crash won’t annihilate all my hard-won data! So I set up one more ifttt task to back it up. I used the “Date & Time” trigger, setting it to run once a month. For the action, I told it to save a given url to my Dropbox account which is what I use for all my personal backups. What url? The url of the database… sqlite3 saves its data as a simple file, so when we ran “sqlite3 my_db” above, it created a file called my_db. Since it is in the same folder as your scripts, you can just point your browser to “http://myserver.com/path/to/my/folder/my_db” and it will download the latest version of the database. Or, in our case, have ifttt download it automatically and save it to your dropbox!
Conclusion:
I’m falling in love with ifttt. There’s a lot of stuff that I had to do manually with python and cron jobs, but ifttt is new and I can imagine as they improve their service, more and more of the steps above will be able to be completely automated. In the past, setting something like this up would have been a big pain (although I hear twilio makes interacting with text messages reasonably easy)… but we live in the future, ladies and gentlemen!
Life in an Open Universe
I’m continuing to update my thinking about the philosophy / social change project I’ve been writing and talking to people about. I just finished re-articulating to myself what I’m trying to do, and I’d like to share it:
Project Statement
I want to increase the amount of joy in the universe. That is the goal of this project. More specifically, I want to develop a practical understanding of how to help people achieve a state of bliss, and moreover a scalable understanding: I want a series of techniques that can create exponential growth of happiness across the world. My vision is a universe where a life of fulfillment and joy is the status quo for a new person being born, anywhere in the world.
I see this project as falling under the discipline of engineering. I am interested in psychological or cognitive research insofar as accurate understanding of the world is important to the project’s success, but I’m more interested in achieving results than I am in obtaining knowledge. If I find something that works, and I can’t quite explain why it works, so be it. I also see this project as somewhat philosophical, because I believe that achieving the goal will require a strong theory of what happiness is: but again, the point of the theory is to yield results, not the other way around.
Here’s what I mean by joy: an intense gratitude to be alive, combined with a heightened awareness of experience. When I think of joy, I imagine myself 80 years old on my death bed, looking back on my life and facing death with perfect calm because I know that I lived my life to the fullest and I don’t have any regrets or unfinished business. In fact, I don’t even need to pretend I’m 80: right now, in this moment, if I died, would I be thinking “wait wait no I didn’t…” or would I be full of positive emotion, appreciative for the time I’ve had even though there’s more stuff I could do with more time.
I believe joy is a process of continually emptying ourselves of our desires, externalizing them into the world. It is a stream of wanting, acting, and experiencing the results, wanting more, acting further, and again experiencing. We fill with desire; we flush ourselves of it by courageously pursuing it; we experience the blissful calm of emptiness, and into that void we fill with desire once again. Each time through the loop, we grow as people, losing our old selves and gaining ourselves anew.
The fundamental prerequisite for joy is the belief that there is effective action we can take to realize our desires. I think that most unhappiness in the world comes from believing the opposite, that we are powerless to take effective action. This powerlessness creates a stagnation in the process of emptying ourselves of desire: unfulfilled dreams curdle inside of us, and we lose touch with basic experience because our minds are full of stale thoughts. We imagine fantasies, but because we never experience them, we don’t grow past them, but keep experiencing the same mental movies over and over. Instead of feeding ourselves on the richness of new experience, we gnaw on sawdust.
For much of human history, and still today in many parts of the world, the objective circumstances were such that for most people, only extraordinary skill could yield effective results: most people were lucky to eke by and survive. A sense of powerlessness was in fact realistic for most people. I suspect that the Eastern tradition of viewing the goal of life to be emptying oneself of desire arose as a synthesis of two recognitions: that the source of all misery was unrealized desire, and that for the average person, realization of desire was impossible.
I believe that for the industrialized world, we are in a historical position to move beyond that compromise philosophy. Although we still live with pain, sickness, and loss, we do live in a world where the potential for positive experience is such that the ups can match the downs. There’s enough adventure, pleasure, love and beauty to be had in the world that a life of seeking fulfillment isn’t doomed to perpetual frustration.
I see the biggest obstacles today as psychological rather than material. We have material freedom: for most of us, having a roof over our heads and food on the table may sometimes be a struggle but is by and large achievable. However, we don’t always have psychological freedom: we don’t always believe in our ability to get what we want, or even always know what we want. Even though our objective circumstances are those of safety and material wealth, our minds are often still run by fear.
To some degree, this is a result of the process of industrialization itself. Although it achieved massive material wealth, it isn’t conducive to psychological freedom. Rather, the logic of mass production runs to uniformity: the more elements in a system are the same, the easier it is. We can see the results of that thinking in our educational system, which marches students forward through the grades like widgets on a conveyor belt, testing them at regular intervals to establish quality and then shipping them off to appropriate destinations. We can also see that thinking in the 9 – 5 treadmill of ranks, promotions, three weeks of vacation a year and eventual retirement and pension.
Freedom and joy, on the other hand, are individual. We all want different things: free-minded, joyful people explode in their diversity. The essence of freedom is lack of fear, the knowledge that you can take risks and do what you want without getting kicked out of the system. Happy people don’t all wear the exact same tie.
The truly great gift we have, which I am personally very grateful for, is that the economic imperative in our society is transitioning from uniformity to creative diversity. The biggest business challenges are no longer “how do we produce more stuff”, but “what kind of stuff should we produce”? Design, innovative research, and entrepreneurship are becoming increasingly important. The new millionaires are people like Steve Jobs: people who can work with desire and bring a vision to life. We are a fortuitious moment in history where I believe what is needed for joy aligns well with what is needed for economic prosperity. This is the time to create a world where people are happy: we are in a place where I think a society based on happiness can actually work.
So, my vision is a world where joy is a birthright, not a rare occurence. My guiding assumption is that building this world is a practical goal. My hypothesis is that the biggest current obstacle is that society still trains people counterproductively, and that working together we can re-train ourselves to become proficient at achieving our desires, to believe we’re capable of getting what we want out of life and to take effective action to make it happen.