Twitter Book Maker

Finally got around to finishing a script that will take a Twitter Archive and turn it into a set of images suitable for printing as a photo book. This takes a tweet like this one:


and turns it into an image like this one:

Or a tweet like this one:


would become an image like this one:



I wrote it for tweets that have single images with no other links. It works best if the account doesn't have a lot of RTs, @replies or links as those don't really translate well to a photo book.

If the script gets a tweet with no image, it will represent the text as an image. So a tweet like this one:

looks like this:
 And, I did end up using the Blurb Books 7x7" format which worked pretty well.

Thank you to @Dr.Drang, who wrote Completing my Twitter Archive which is a helpful post and I used some of his code.

The TwitterBookImages script is:

How To Make A Glowing Lightsaber

Guest post by my son below. Please note that this how-to involves putting lights inside of foam, which is likely to be a fire hazard if left on. 

DO NOT LEAVE ONE OF THESE ON UNATTENDED!

Here is all the stuff you’ll need:
  1. a string of LED lights
  2. duct tape
  3. black electrical tape
  4. scissors
  5. a knife

IMG_20151024_154715.jpg

First, I cut the noodle in half.
IMG_20151024_154846.jpg

I did three layers of duct tape.
IMG_20151024_155342.jpg

Then I put on 6 strips of black tape.
IMG_20151024_155925.jpg

Then I cut the inside of the pool noodle.
IMG_20151024_160421.jpg

Then I folded the lights 3 times.  
IMG_20151024_160628.jpg

Then I put the lights in with the switch on the bottom.
IMG_20151024_161014.jpg

This is what it looks like in action.
IMG_20151024_161137~2.jpg

If you have a small cell phone, you can put it in too to make lightsaber sounds.

AGAIN: DO NOT LEAVE ONE OF THESE ON UNATTENDED!

Barn-Raising Community - Missing Jake Brewer


Picture of a barn being raised.

One of the remarkable things about working on team CTO as part of the Office of Science and Technology Policy (OSTP) at the Executive Office of the President (EOP) is that a very large percentage of our teams are temporary. That means that the very small more permanent staff here builds and rebuilds teams even more quickly than startups in Silicon Valley.
Picture of completed barn


What is remarkable is not only that those quickly made teams work together well, but also that they come together as a community so thoroughly. This barn-raised community can seem constructed or fictional at times. We work hard together and the focus is often on getting work done rather than building community so we don’t always realize that we are building a strong community.
Blueprint of barn


Then on Saturday, Jake Brewer, a Senior Policy Advisor on team CTO and huge inspiration to many inside and outside of government died while participating in the Ride to Conquer Cancer. Jake joined team CTO in June and has been working hard on connecting the nation’s tech and innovation assets (people, places, tools, data, and methods) to its opportunity creation efforts, enabling all Americans to take part in, contribute to, and benefit from the economy of the future. More than that, Jake was an overwhelmingly friendly, crazily optimistic, always energized, and incredibly caring part of the team CTO, OSTP, and EOP communities. The reality and strength of those communities was made startlingly apparent by his passing. The barn we were raising is now missing a wall and every other bit is shuddering from the blow.
Cross section of a barn

Jake was a big part of the strength of our team and we will miss him dearly. I will miss his smile, attitude, and presence. I am also sad that I won’t get to see his next set of wonderful things come to pass in the world. But I am thankful to have known and worked with him. I am thankful he was part of our community and for the dents he made in the universe.   

All images from The James Way, James Manufacturing Co., Fort Atkinson, Wisconsin (1917) and available in the public domain via Google Books.

New Job


And, in honor of the new gig, here's a very old public domain picture of the White House from Theodore Roosevelt's Programme of Exercises and Illustrated Inaugural History, 1905. 


  

Label Emails Awaiting Response

I have been horrible at responding to personal email while taking time off. Rather than declare bankruptcy or write a pithy autoresponder, I was spurred by an acquaintance to figure out a way to mark threads in Gmail that may be awaiting a response from me. As a result, I got to learn about Google Scripts, finally sign up for my own Github account and virtually meet @hijonathan.

Jonathan Kim had the opposite problem from me. He sent a bunch of emails that he wanted to be reminded of when the recipient had not responded. He wrote a great script and published how to install it. I made some very slight modifications to his script to do the opposite (see below).

The AwaitingResponse.js script will look through your inbox for threads messages to you that are between 5 and 14 days old but that you have not responded to. It will label those messages “AR” and you can then use a search like this one to diligently respond to those messages. It is easy to customize the script to search a different label, such as just messages Gmail has categorized as “priority,” or for a different period of time.

To install and customize, follow these steps:

  1. Create a new Google Script (go to https://script.google.com/ and choose "Blank Project" and while logged into your Google account)
  2. Replace the template code in the blank project with the Awaiting Response code at https://raw.githubusercontent.com/amac0/miscpubliccode/master/awaitingresponse.js
  3. If desired, change the label to look in, the text for the label where messages will be placed and the age range to search. These are all at the top of the script and the comments will help you decide what to change.
  4. Save the script by choosing "File|Save" from the Google Script menu.
  5. Run the script by choosing "Run|main" from the Google Script menu. Go look at your inbox and make sure it worked (it may take a while).
  6. If desired, set the script to run every day by choosing "Resources|Current project's triggers" from the Google Script menu.
The script itself is:
Thank you again to @hijonathan.

Quick & Dirty For Setting Up Using Twitter in Python

Let's say you want to post to your Twitter account from a command-line python script. Here are the quick a dirty steps to get up and running with twython. There is another description at the twython site but it isn't as basic as this.

  1. Install twython with:
    sudo pip install twython
  2. Register the application on Twitter
    1. go to https://dev.twitter.com/apps
    2. fill out the form and hit "Create your Twitter application"
  3. From the App "Details" tab, click "modify app permissions" and change  to "Read and Write" (it'll take a few minutes for that to be reflected on the app details page.
  4. Go get your API Keys
    1. Click on the "API Keys" tab from the Application Detail page
    2. Copy the API key
  5. In a terminal window:
    1. fire up the python interpreter
    2. import the modules you need:
      from twython import Twython, TwythonError
    3. make a variable for your API key:
      APP_KEY = 
      and have it equal the thing you copied from the Twitter site using single quotation marks around it.
  6. Switch back to the Twitter API Key browser page:
    1. Copy the API Secret key
  7. Switch back to terminal running the python interpreter:
    1. make a variable for your API secret:
      APP_SECRET =
      and have it equal the thing you copied from the Twitter site using single quotation marks around it. 
    2. use twython to get a object by entering the following in the python interpreter:
      twitter
      = Twython(APP_KEY, APP_SECRET)
    3. then an auth object:
      auth = twitter.get_authentication_tokens()
  8. Still in the python interpreter, grab the oauth url copying the URL you see when you type:
    auth['auth_url']
  9. Past the URL into a browser, sign into your account on Twitter if prompted and click "Authorize App." You should get a code, copy that code into your python interpreter window as a variable for the PIN
    PIN = 
    1. create a variable with the AUTH TOKEN
      AUTH_TOKEN=auth['oauth_token']
    2. create a variable with the AUTH SECRET
      AUTH_SECRET=auth['oauth_token_secret']
  10. Then, in the interpreter, reconnect to Twitter and get the final authorization tokens with the PIN number that you set earlier:
    twitter = Twython(APP_KEY, APP_SECRET, auth['oauth_token'], auth['oauth_token_secret'])
    final_step
    = twitter.get_authorized_tokens(PIN)
  11. then look at final_step['oauth_token'] and final_step['oauth_token_secret'] and save them somewhere in the configuration of your app. Also be sure to copy the original APP Key and APP Secret to a variable in your app. Below I use APP_KEY, APP_SECRET, OAUTH_TOKEN and OAUTH_TOKEN_SECRET
  12. Once you are all done you can use this code in an app to test it:
    from twython import Twython, TwythonError

    APP_KEY =
    [the thing you copied from earlier in single quotes]
    APP_SECRET =
    [the thing you copied from earlier in single quotes]
    OAUTH_TOKEN =
    [the thing you copied from earlier in single quotes]
    OAUTH_TOKEN_SECRET =
    [the thing you copied from earlier in single quotes]

    # Requires Authentication as of Twitter API v1.1
    twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

    try:
        twitter.update_status(status='Just a test, please ignore')
    except TwythonError as e:

        print e
     

PS I now use Tweepy instead of Twython but all of this is similar there.

Banking Advertising



William Borsody, Financial Advertising, 1909

LAMAS Architecture

Recently got to hang out with my brother, James Macgillivray, and catch up on his and his wife's architecture firm, LAMAS. Really cool stuff he and Wei-han Vivian Lee are up too. Plus the LAMAS (Lee and Macgillivray Architecture Studio) site is cool as well and showcases a bunch of their work. Amazing to see what they have already built and looking forward to seeing what they will build in the future.