Mary Dickson Diaz

Code, Life, Learning

Tag: twitterbot

build something with socrata’s api — check

weed violations screenshotTop of my to-do list has been to build something using data from the City of Seattle data portal (data.seattle.gov), powered by Socrata. This one is not particularly useful, but I’ll share with you anyway!

One of the things I like least about homeownership is the need to keep up a yard. Thankfully I’ve never received nastygrams about yard care, but I’ve heard some horror stories. One couple in Texas was in the process of removing a dead tree from their yard — they had just cut it down and into transportable sized pieces, and piled and covered the logs up with a tarp, and THE NEXT DAY they got a note demanding they remove “tree debris” from their yard within three days or pay a penalty.

Anyway, in that frame of mind I giggled through the “weed and vegetation code citations” available via public record. Since Washington legalized marijuana last year, I had an idea in my mind to track code citations like these:

  • Large overgrown blackberries and vegetation encroaching sidewalk
  • Hazardous vegetation encroaching on sidewalk forcing pedestrians into street
  • OBSERVED LARGE TREE ON PROPERTY NO SIGNS OF RODENTS AND NO BEES WERE PRESENT DURING A SUNNY DAY

…and present them as our city’s most pressing weed violations.

Clever? Maybe. Half-baked? Definitely. My first idea was to tweet out the description of the citation, with a google maps street-view image of the address in question. That might be visually interesting but seemed like a huge invasion of privacy, so I quickly shelved it. I have no interest in actually shaming the property owners.

So instead I started with the easiest path, tweet the generic descriptions, to see where that led me. Here are the “get-started” steps:

  1. Register for a developer key with Socrata
  2. Identify the data set you want at data.seattle.gov (for me: code violations)
  3. Use developer key to access the API (I used a Ruby gem from Socrata) to fetch that data set
  4. Filter (for code group: “weed and vegetation”) and collect results in an array
  5. Set up a Twitter API client to talk to twitter, via a new twitter account if needed (I recycled an existing bot!)

Continue reading

watch someone code something weird

Last week Darius Kazemi made a twitter bot via live-code. It’s really fun to see his thought process and trial/error. He plays with RiTa for JavaScript, a natural language processor (which ironically, might be exactly what I need for a non-bot project… stay tuned!).

He uses Node, JavaScript, and something called “grunt” to initiate the project (starts at 7 mins in if you want to skip ahead).

Josh walked in while I was watching and commented “Darius is such a great teacher.” He is! Love to see this live coding.

Maybe I will attempt a live-code (or record-code) session. Could be a good way to get over my fear of video and also impose a strict “make something in an hour” timeline.

I have a month to play (more on that to come as well) so this is all timely. 🙂 Enjoy!

p.s. this post is for Jessie, my favorite/only reader.

protest bots

I have to share this great new tool from dream team Darius Kazemi and DeRay Mckesson:

Screen Shot 2015-07-17 at 1.58.22 PM

If you follow, it will say something aspirational about you. Later, it will become a tool for prominent social activists to respond to onslaughts of people asking the same questions, trolling, or parroting misinformation.

I’ve been pretty sad the past few days following the Sandra Bland story, so I’m thrilled to see this marriage of technology and activism as something somewhat “in my wheelhouse” and hope it will lead to more projects and collaborations.

Also notable:

  • Block Together — required for intermediate+ Twitter users. Share your blocked accounts with trusted contacts and follow theirs for automatic blocks of hateful, misogynistic accounts (see this tweet to get started).

mission unlocked

Hey friends,

After compiling all these great twitter bot resources I’ve been on a bot kick, creating two new ones in the past few days. I should probably diversify my projects some more, but in the meantime it’s such a great way to learn and practice code, git, and tools to deploy.

CHALLENGE #1: Can you do it in JavaScript?

answer = #achievementunlocked

Darius Kazemi is something of a legend in botland (he’s the creator of the Harry Potter sorting bot, among others), and has posted a tutorial for a simple example bot that re-tweets a hashtag once an hour.  I have, in my pile of unfinished projects, big plans for the twitter handle *unlock achievemt* but I got stuck awhile back when I couldn’t figure out how to auto upload pictures. So in the meantime, I’ve set it to re-tweet something from the #achievementunlocked hashtag once an hour, with pretty great results:

Screen Shot 2015-04-18 at 12.36.49 AM

Continue reading

top bot

OK, you want to talk bots? Let’s talk bots! First, let’s go back…

WAAAAAY back. A few weeks ago, I got a nice mention on Twitter from a procrastinating grad student who found my tutorial and used it to set up Ecce , a Publilius Syrus twitterbot (I had to wikipedia that).

Continue reading

week 2, what it do?

Hi everyone, Mary here, checking in for a Python – Week 2 update.

BUT FIRST: it is Friday at 3:30, I have a monster headache, and my ongoing lack of internet at home has made pretty much everything more difficult this week. However, you have come to this here website and by God, you shall have content!

Continue reading

finishing the bot

finishing the bot
how you have to finish the bot…
how you watch the rest of the world from a window–
while you finish the bot

mapping out a .py
what you feel for twitter’s API
what you feel when errors that come through heroku go

“tweet status update failed on third try…”

I have been watching Stephen Sondheim musicals basically non-stop and this song seems most appropriate for the past few days. “Oh there’s a new lecture out…. BOT.” “I should get started on that javascript pre-work…. BOTBOTBOT.” “It’s 2:30 in the morning…. BOOOOOOOTTTT”

twitterscreenshot

My bot is now deployed and fully-functioning out in The Cloud, thanks to Joel!

>>Ok I have a twitter bot and I want to run it but not from my personal computer, help

The above link tells the story of how I went from here (functioning bot, living on my laptop) to here (functioning bot, living on GitHub/running on heroku). First, you’ll need to install heroku and follow the directions to get started, here. After that, follow Joel’s directions and you’re golden.

I hope you didn’t have other things to do today.

UPDATE 6/25/15

This is part 2 of the tutorial.

Part 1: Build a Twitter Bot with Python

Part 3: Top Bot

build a twitter bot with python

This year I set out to learn how to make twitter bots, accounts that automatically interact with twitter in some way, whether through tweeting set content at regular intervals, watching for and responding to code words, or responding in a certain way when tweeted at. I learned the basics of Twitter API interaction at UW’s Community Data Science Workshop last November, and have since been inspired by other people doing cool stuff with bots.

Witness:

For more great examples, check out 52bot project.

A few nights ago, as I was reading about the reunion of the women of Bletchley Park, I clicked through to the Honour Roll and found a database that looked like it might translate well into a twitterbot. Using a subset of data and some internet tutorials, a test bot took maybe an hour or two tops to set up (and I was so thrilled when it worked!). The time-consuming part has been 1) finding a way to reliably keep it tweeting; and 2) pulling and cleaning up the full dataset to fit twitter’s 140 character limit (in my test run, I just told twitter “print the first 140 characters and ignore the rest” but for the full deployment, I wanted to edit the longer bios to make them fit).

Ok, so without further ado, here’s the bot:

And here’s how I made it!: Continue reading

© 2017 Mary Dickson Diaz

Theme by Anders NorenUp ↑