IFTTT Automation: Post Instagram posts with specific hashtag to Squarespace Blog

This tutorial walks you through how to set up IFTTT and Google Scripts to automatically post an instagram photo to your Squarespace blog if you use a specific hashtag.  The hashtag trigger I set up for @pirruccello is #bpdotcom.

Initial Set Up:

  1. On Squarespace, under Blog Settings, enable post by email and record the email address provided. If you email this address it creates a new blog post.
  2. Using IFTTT, set up "New photo by you tagged" trigger for Gmail, with the hashtag you desire.  (Mine is #bpdotcom)  Set the rule to email yourself a photo email with the following body: 
    {{SourceUrl}} {{Caption}}
  3. Go to https://script.google.com and create the following script. Use your email address in place of YOUR@EMAIL.ADDRESS in the following script, and use your Squarespace Post By Email Address in place of YOURSQUARESPACE-BLOG-EMAIL@address.com:
function sendCorrectEmail() {
  var instagramThreads = GmailApp.search('from:(YOUR@EMAIL.ADDRESS) to:(YOUR@EMAIL.ADDRESS) subject:(instagram:)', 0, 25);

  for(var i = 0; i < instagramThreads.length; i++) {
    var messages = instagramThreads[i].getMessages();

    for(var j = 0; j < messages.length; j++){
      var body = messages[j].getPlainBody();
      var urlEndIndex = body.indexOf(" ");
      var url = body.substring(0, urlEndIndex);
      var content = body.substring(urlEndIndex + 1, body.length - 1);

      var newBody = "<center><img src='" + url + "' /><br /><br /><i>instagram: </i>" + content + "  </center>";


      GmailApp.sendEmail("YOURSQUARESPACE-BLOG-EMAIL@address.com", content, newBody);
    }   
  }

  //delete all threads
  if(instagramThreads.length > 0) {
    GmailApp.moveThreadsToTrash(instagramThreads);
  } 
};

4.  In Google Scripts, click the Resources dropdown and configure a time based trigger to automatically check your email every minute.

5.  Make an Instagram post and use the hashtag you set up - within a few minutes, your post should show up (see @missmazade's cute puppy in my post below for an example of an automatic Squarespace blog post of an Instagram photo via a specific hashtag.)

 

DIY Fashion: How to recreate the Hunter S. Thompson 1970s Interview Shirt (Sketch pattern file included)

Making the design yourself:

  1. Sketch (or other design software)
  2. This Sketch Source File
  3. A PrintAllOver.me account to print the shirt. Or you can print the fabric on Spoonflower and find a pattern maker.
  4. Pictures from the 1970s Playboy Interview with Hunter S. Thompson

Buy the Hunter S. Thompson shirt:

See it on PrintAllOver.me

Click the image to buy&nbsp;this on PrintAllOver.me

Click the image to buy this on PrintAllOver.me


STEP 1: FIND THE PATTERN

When the going gets weird, the weird turn pro.
— Hunter S Thompson (Fear and Loathing in Las Vegas)
For source image, check out the Medium Hunter S Thompson Article

For source image, check out the Medium Hunter S Thompson Article

The first images I could find appeared to have alternating oval and circle patterns in red, leading my friend Evan to create the following pattern:

STEP 2: WE HAVE TO GO DEEPER

I found some higher resolution photos which showed that the outer edge of the shapes was scalloped and the inner edges consisted of octagons, squares and circles.  HST was a fan of bold patterns.

STEP 3: MAKE A COPY

Download this Sketch file, or use Sketch/any design software to copy the pattern.

Sketch is intuitive design software, available here.

 I originally used the color picker from one of the color HST photos, but then I opted for a more saturated color to print better on the fabric

Screen Shot 2015-01-25 at 4.52.15 PM.png

STEP 4: PRINT THE SHIRT

Export a large image file from Sketch with a very large number of copies of the pattern to upload to PrintAllOver.me

Then, upload the exported image file to PrintAllOver.me and place an order

STEP 5: RECEIVE A PACKAGE

Here's how the shirt will look; it's a perfect custom gift for the Hunter S Thompson fan in your life.  For those curious, it's machine washable (cold with like colors).  Here is the page for the shirt below: PAOM HST Shirt

Structs and Tydefs in Objective C

A struct is a structure that holds multiple related pieces of data.  

struct Song {
    int id;
    char name;
    float songLength;
    float bpm;
}

A typedef defines an alias for a type declaration, allowing you to use that alias like a standard data type. With the declaration below, you would then be able to instantiate new songs like "Song richGirl" (opposed to "struct Song richGirl;")

typedef struct {
    int id;
    char name;
    float songLength;
    float bpm;
} Song;

String format specifiers in Objective-C

To include a variable in a string in objective-c, you can use string format specifiers with optional length modifiers.

  • %i  - Integer
  • %c - character
  • %d - Signed decimal Integer
  • %e - Scientific notation using e character
  • %E - Scientific notation using E character
  • %f - floating point decimal
  • %g - the shortest of either %e or %f
  • %G - the shorter of %E or %f
  • %s - string
  • %u - unsigned decimal

Full list: String Format Specifiers - Apple