Mary Dickson Diaz

Code, Life, Learning

Category: Coding (page 2 of 7)

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 (, 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

…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 (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

where i’m from

where i'm from screenshot

I finished the first part of my #NaNoGenMo project, a “Where I’m From” poem generator.

click meeee for poetreeee

It’s nothing fancy, but I’m really pleased with how it turned out.

Some technical notes:

Continue reading



November kicked off the third installment–and my first–of National Novel Generation Month (#NaNoGenMo), with a stated goal to “Spend the month of November writing code that generates a novel of 50k+ words.”

I’ve been excited to play with natural language processing tools, so I dove right in! Procedural note: Darius has requested that participants open an issue on the shared Github repo and update from there, so that link is where I’ve been writing and tracking progress. The repo is here.

Here’s my inspiration poem. In my teaching years, this poem made the rounds — it’s great for teaching memoir and descriptive writing, and easy and satisfying for students to emulate in order to create their own “Where I’m From” poems.

Continue reading

wait, wait, don’t tell me…

Background: I was sent a coding challenge via Codility, and before diving into the (timed) test, I spent some time working on the demo. I won’t be sharing the actual code challenge, but the demo is fair game to discuss, it’s featured in a public blog post. It took me a few tries, but in a nutshell, I went from 17 points out of 100 (incorrect answer) to 64 points (mostly correct answers, complexity too high), to … well, I’m going to make you read all the way through to find out.

Continue reading

(cute and) fuzzy searching

fuzzy cat

hello? is it me you’re looking for?

Hey folks, what a ride that was! I finished my class last week and I’m working on a wrap-up post (plus wrapping up a few loose ends for class). I am officially on the market (that’s a link to my LinkedIn page) if you hear of any great web developer opportunities out there. I’m attending a talk tonight called “How to Land an Awesome Tech Job in Seattle” where hopefully someone will offer me an awesome tech job in Seattle (that’s how it works, right?)

In the meantime, my lightning talk on fuzzy searching is up!

I had entirely too much fun putting together this powerpoint and learning about edit-distance and Dice’s coefficient. Fuzzy searching is for when an exact match isn’t found, but you want to view similar results / possible matches. I haven’t used it in an app yet but I have one just waiting to be deployed. One of my colleagues implemented fuzzy search for her final project, so I got to sit down with her and look at these options to see what might work best for her needs. Very cool.

(update: pee esss I found this great primer on Levenshtein, after my talk unfortunately, but helps explain some of the confusing things about edit distance)

In related news, I gave an impromptu lightning talk on markov chains at a Code Fellows event yesterday. I wasn’t expecting to talk, but it was great experience and practice on the fly!

Wish me luck as I attempt to #escapetheroom this afternoon… !

the elephant on your desktop

(No, not that elephant.)

This elephant:

At some point in the last few weeks, I added this card to my Trello task-tracker:

All new Rails apps in postgres

And then I did nothing about it until I was trying to do something else and couldn’t get a program to load because of, oh yeah, postgres. Time to deal with that, I guess!

There are three popular options for running a Structured Query Language (SQL)based database on Rails: MySQL (owned by Oracle), sqlite3 (comes built-in with new Rails apps), and PostgresQL… the one with the elephant that’s OK to run on Heroku.

I’ve been using the Rails built-in database mostly, switching over to Postgres for production on Heroku, but it’s a best practice to use the same database for your testing, development and production environments. I can’t really speak to the differences between the three except that my perception is that MySQL is widely hated and Postgres always takes some flailing around on my part to get it to start.

$ rake db:create
$ rake db:migrate
$ rake db:reset
$ rake db:hello_is_anyone_listening

So I was excited to take on a project refactor this week built on Mongo DB, a no-SQL database. Rather than using Active Record and data migrations (hello, hello, is this thing on), Mongo stores database table information directly in the model records where they’re easy to add, delete, or change.

Hooray no migrations! Hooray another tool in my toolchest!

That bit of learning curve did not last long as we realized that what we want to build requires relational associations that a SQL-less database isn’t optimized to handle. I felt a bit sad about not getting to play with a new toy until I ran into this:

Screen Shot 2015-10-19 at 9.34.06 PM

I’ve run into this “master-slave” business before in software and my response was a big “wtf” followed by an “I’m not using this.” And so far, I haven’t had to, since there have thus far been alternatives.

So over to Postgres we go! Commere you big lovable elephant. Give mama a slobber. I shall add to my box of tricks “converted an app from a no-SQL database to Postgres” and all shall be well.

  • Here is a great (long) article by a programmer I admire titled Why you should never use Mongo DB.  This is the type of technical writing to which I aspire.
  • A cloud data storage option I am really excited about: The Art Guys Heads in a Cloud Data Storage Memory Services (I miss you, Houston!)
  • Ok FINE here is A Young Woman’s Etiquette Guide to Coding but I have to say I am annoyed to the point of dismissal that Black Girls Code (a great organization) is listed here with the byline “powered by American Express.” Probably the author meant to say “powerful black girls and women.” Yes, that’s more like it. That downer aside, some good information here.

burning the candle at both ends

Before I forget… Honkoween is coming! I made this silly little bot for Josh when he asked me “can you make me a bot that tweets a link to this video once a day through Halloween?”


Who else has wishes, while I’m granting them?

I’m doing something a bit out of character for me and *going to things* this week. Yes, on top of the 7th inning stretch of class, wherein we cram in “all the other stuff you should probably know” (I see you, binary trees).

It’s exhausting but also exhilarating to revisit some of the parts of coding that most excite me. Last night I attended an event at Seattle Public Library about open data and civic action, with speakers from various government agencies and hackathons talking about some of the resources available for making public data available to be used in interesting and productive ways (while still preserving aspects of privacy). The page is a well tended well of information just waiting for a rabbit to fall down it.

I’ve been meaning to get involved with Open Seattle for a while, and this was a good kick in the pants to do so. Particularly since they are closely affiliated with a company I’d love to work for, to do this sort of partnering with government agencies to wrangle their information full-time.

Tonight I learned about a tool algorithmia that allows you to access a multitude of algorithms and fun web tricks via API access (another thing we’re focusing on in class this week). The workshop was really well-explained, demo-ed, and paced, which I appreciated as well. It provides an easy gateway into website scraping, which is something else I’ve been wanting to try out.

Tomorrow night is Pass It On at Code Fellows, an event focused on how to encourage and facilitate more women in tech roles. I’ll already be there, so all I have to do is not leave (my favorite kind of event!).

After next week, I’ll have ample time to explore (and start looking for jobs) so I’m leaving this here as bread crumbs for myself. There’s a world of tools available to build with. Now I just need some interesting questions.

try angular

this is what angular feels like, a bit

In the last two weeks of my Code Fellows Ruby on Rails bootcamp, we’re focusing on JavaScript, JQuery, and all their friends. This week we kick off with Angular. Angular is a JavaScript tool created by Google for fast, responsive websites. I completed the (free) Code School course “Shaping Up With Angular” and I’m about to embark on a quest to connect it to a persistent database. In my case it will be a Ruby on Rails app.

But first, let’s talk Angular!


When you create a JavaScript file to hold some Angular, you initialize it like so:

var app = angular.module('gemStore', ['store-products']);

if you’re not well-versed in JavaScript, this is essentially saying: Declare a variable “app” and set it equal to an Angular module named “gemStore” that depends on another module named “store-products.” Once you’ve declared at least one module, you can get going filling it up with useful stuff like…


Controllers work similar to how they work in Rails. You can set up and assign a controller to a specific part of your webpage, and it can render and manipulate data in a variety of ways. In the tutorial, we set up controllers to manage information about the gems, the product tabs, product reviews, etc. If your code is getting repetitive and/or you want to isolate specific chunks of the page, you can create directives instead that will load a separate html page using naming-conventions (much like how Rails renders partials). Depending on what you’re trying to do, you may be able to include controller functions in a new directive and eliminate the need for a separate controller altogether. Neat!


Angular controllers are called on specific DOM elements , and operate within the scope of that element only. So for example, here’s some pseudocode:

<section id=gems ng-controller="gemController">
  <unordered list of gems>
    <gem 1>
    <gem 2>
    <gem 3>
  <end of list>
<end of section>

Outside this lovely, contained section, if you want information about gems you are entirely out of luck. Note how any of the list objects know about gems (and any child elements we might create under them, if we so choose)–basically anything that’s in the gem section family.

But not outside that family. They know about other stuff, maybe. Like maybe they know about…


If you’ve ever typed on a website and had text show up magically elsewhere, tracking as you type, that’s a two-way data-binding and Angular is a pro at it. Here, why don’t you go make some boxes to see how it works? Hmmmm… boxes. That’s not very try angular. Get it, triangular? I feel like this demo could be improved… perhaps a project for a rainy day…


Wow, that one sounds pretty grim, right? Coffee is my dependency injection these days. But we already saw this above — you remember in that top example how my app.js had an array of one element — it looked like this:

angular.module('gemStore', ['store-products']);

The app can’t run without the file where I’ve created a module named ‘store-products’, so injecting the dependency here tells my app where to look to import that info. Once it knows how to read ‘store-products’, it inherits any and all controllers and directives in that dependency JavaScript file, and the app can load as usual. Quickly, we hope!

Ok, off I go to attach this gemstore to a database… wish me luck and above-average retention as we dive into the last week of instruction (#justkeepswimming).

evolution of forms of governance in a rails app

No, this isn’t a history lesson. It’s an observation about the governing political ideologies that a Rails app takes on over time. Witness:

At Birth: Libertarian 

A basic Rails app has some sort of landing page and usually a database with CRUD (create, read, update, destroy) functionality. Without authentication or authorization, any viewer can initiate any of those functions. Visitors have autonomy to navigate and manipulate the site according to individual judgement, which is why I consider this a libertarian state. An example is something like my Robot app, which, who knows what it will look like at any given point. You’ll all been very polite in not destroying all the robots (you’ve probably been tempted, though). In theory, you can edit other people’s robots and add or delete as many as you want. I still get to determine what data gets collected on the robots, which I suppose makes this a minarchy as opposed to anarchy (users can’t alter the database or page itself). Although, if the chief role of minarchism is to protect citizens against theft, this certainly won’t do that. Quite the opposite. I can’t protect your robots, people.

Soon-thereafter: Dictatorship 

It only takes one “poop” post for the app creator to realize that people on the internet can’t be trusted, and some sort of filters are needed. The most basic filter, where most beginning programmers will start, is Admin v. Everyone Else. Using a gem called “devise” (or something similar), Rails developers can add Users, which thus enables user roles. With users enabled and a minimal amount of programing, an app can be set such that an admin user can login and create, edit, and destroy content, and everyone else can read it. This is how my WordPress site is set up: there’s a login link, but it’s tiny and hidden down at the bottom of the page, because I’m the only one who’s ever logging in. Because I’m a benevolent dictator, you may leave a comment (which has to be approved by me if it’s your first one). This page is “,” so no one is really arguing against my authoritarianism, but maybe you want to invite some friends to create content with you. The “I-have-all-power/you-have-none” model isn’t going to cut it.

One last note on dictatorship: I’ve encountered a handful of webpages that require a log-in before you can see any content. I encountered one this week, in fact, clicking a twitter link enticing advertised as “Things I Wish Someone Had Told Me When I Was Learning How to Code.” Notice there is no link, because when I tried to click through I was redirected to a multiple-page application to apply to be an approved reader. That’s totally their prerogative, but I wasn’t up for that at 7am in bed lazy-clicking my way through twitter, and ps I’m unfollowing you.

“We’re Gonna Need a Bigger Boat”: Aristocracy

When multiple people get involved in the content creation, participation and/or maintenance of your app, you’ll probably need to have users enabled and the know-how to manipulate policies (in class we used the gem “pundit”). With these, you can set more sophisticated and personalized access for your Rails app visitors. Perhaps you have admin, “authors,” “moderators,” etc. On a smaller scale, I would like for my portfolio site to have comments enabled such that anyone can access and leave a comment, whether logged in or not, and where anonymous comments are held as “pending” until approved. Comment leavers should be able to edit or delete their own comments, but not other people’s. This is where I’m a bit stuck at the moment, with my default being to revert back to dictatorship until I figure it out.

Eventually: Direct Democracy? Something else?

On a more sophisticated app, you may have not only users, but user pages and *preferences* where users have the power to control their own settings about what other users (& maybe even admin!) can CRUD. This seems like it would put more power into the hands of the users, right? More towards a democracy? Ironically, there seems to be a correlation instead between more privacy settings and controls, and the value of the data being collected and ultimately owned by the app. Read this description and tell me it doesn’t perfectly describe a popular site we all hate to love:

Totalitarianism is a political system in which the state holds total control over the society and seeks to control all aspects of public and private life wherever possible.

I use that site, too, but they’ve basically said as much as the above^^.

An alternative is *diaspora, a social network where users explicitly retain ownership of their data (and which I haven’t heard much about since the sad death of creator Ilya Zhitomirskiy a few years back). Today the diaspora foundation operates according to three key philosophies: decentralization, freedom, and privacy.

This seems like a key question for any app creator to consider from the beginning: What principles and philosophies do you want to guide your app creation? What tools and skills do you need in order to integrate them?

reviewing the rails tutorials

so you want to build pizza dot net? try rails!

so you want to build pizza dot net? try Rails!

Hey everyone!  This is my last week as a ‘person of leisure’ before class starts up in full force next Monday.  I received a coursework invitation, and the first assignment is to answer the question: “How was your Rails tutorial?” to which I respond, “…which one?

Before I even saw the question I was considering a run-down on the Rails online tutorials I tried, what I learned, recommended order, and which ones are worth salt. So, here goes! These are roughly ranked in “do this first” order unless otherwise stated.

Michael Hartl – Rails Tutorial

oops my cow is upside down

oops my cow is upside down

Continue reading

« Older posts Newer posts »

© 2020 Mary Dickson Diaz

Theme by Anders NorenUp ↑