Mary Dickson Diaz

Code, Life, Learning

Category: Coding (page 1 of 7)

go on now

Hello readers!

It’s been awhile. Look how big my baby is now:

HUGE. And so many teeth. He’s walking all over, including all over his dada, and keeping us on our toes.

But I digress.

Earlier this year I had the opportunity to go to GopherCon. Since I resumed work in March, most of the work I’ve been doing has been in Go:

I rewrote an API service from Java to Go. The service has a handful of endpoints to manipulate filter strings including create, edit, get by id and get (all) by org, and uses some customized middleware based on go-kit for logging and etc.  Figuring out my way around all the company-specific middleware was complicated because it was created by a former employee to make Go development easier for Java developers (I am not a Java dev). Luckily, my very talented co-worker Amy had recently built a similar Go service and I was able to use her work as a template of sorts — while still dealing with a number of unique challenges to the project. Today, this “marketer” API runs in production servicing the marketer platform and a number of additional endpoints and services have been added.

Continue reading

making a baby blanket (smaller)

sleeping baby in a baby blanket

I’m scheduled to return to work this week, which makes it the perfect time to pick up another project (not). Nonetheless, I’ve been wanting to knit something for Aurelio for some time, and Ravelry’s declaration that they won’t steer away from “political knits” inspired me to go check out some patterns.

I found a simple baby blanket with a repeating pattern that adds some lacy details — baby loves this because he can stick his lil fingers in the holes. Here’s the pattern:

CO 107 st
Row 1: knit
Row 2: purl (and all even rows)
Row 3: k3, * k2tog, yo, k2 *
Row 5: knit
Row 7: k1, * k2tog, yo, k2 *, k2
Finish with row 1 or 5.

The elements in * are repeated for the remaining stitches in the row.

Now, I want my blanket to be smaller than the pattern. A mini-blanket. But the thing with knitting is you can’t just pick an arbitrary number to cast on or else you’ll break the pattern and wind up ☠️. So how do I figure out how many stitches to cast on?

Option 1: Overengineer a ruby solution to visualize the pattern, then guess and check at cast-on numbers to figure out which ones work.

What an EXCELLENT idea. Let’s do just that.

I started with some nested functions, like this:

…then realized I was breaking the rule of DRY (Don’t Repeat Yourself). Let’s get a bit more object-oriented, shall we?

that’s better, now I don’t need to pass on the width to all those functions, I can use the object’s instance-accessible @width property.

Coded correctly, the pattern passes with the default cast-on width, and breaks when a width breaks the pattern.


Doesn’t work:

I used the guess and check method to find a variety of cast-on options that don’t break the code, including 107, 99, 87, 75, 63, 51, 55, 7, 11. What do all these numbers have in common?  And how can we identify them without testing via an elaborate visual chart?

There must be a more mathy way to solve this, right?

Option 2: Ask Mary’s Mom

My mom is a skilled seamstress and knitter/crocheter, not to mention a Mensan, so I knew she would know how to reduce a pattern without all that hub-bub above.  I sent her the pattern and asked her what my cast-on options are. She said:

Looks to me like the pattern is just 4 stitches +3 on the edges, so you could cast on 7 or 11 or 15 or 51.

4 and 3… going back to our tested numbers, we find that they are congruent modulo 4, meaning they give the same remainder (3) when divided by that number. Put another way, any multiple of 4 (the pattern), plus 3 (the stitches on either side), will work (4 * 10 + 3 = 43 = works).

Don’t forget to remove the blanket from the crib once baby falls asleep.

If you all have any additional knitting or math questions for my mom I am happy to pass them along.

where do we golang from here

go gopher

The Golang gopher, because every blog post needs an image

When I was getting ready to go on leave, I asked some colleagues what languages and programming skills they recommend I study up on in my free time. The company that hired me was acquired one week after I started working there, and just before I left we were in the process of merging engineering teams and technologies. As the new products and systems development shift to other programming languages (ugh, Java), I won’t get to use Ruby on Rails as often.

One senior member of my team (with two small children) wisely rejected the notion of “free time” during maternity leave. Beyond that, I can’t for the life of me remember what anyone recommended. I’m pretty sure “who knows what tech we’ll be using, learn what you want” was the consensus.

So I’m using the rare programming time I have to focus in three areas:

  1. Code challenges in Ruby (I did about half of this year’s Advent of Code and sponsored a Code Fellows leaderboard for students and alumni)
  2. React, a JavaScript library for building user interfaces — mainly through Code Fellows new 501 level professionals course
  3. Golang, a compiled, statically typed language used for systems development (like Java, but not stupid Java)

I’ve wanted to learn React for awhile — it’s hot right now and a lot of places that would have used something like Backbone or Angular are switching to React. With my friend Emily teaching the class and my mom in town to help watch baby, the timing was as good as it gets. My work is looking at Go as a replacement for certain Java-based API endpoints. And code challenges are just mommy’s brain candy, so I do them in the language I’m most comfortable with (Ruby).

Here’s a little checklist of learning resources for my own reference (and yours, if any of this sounds interesting):

Code Challenges:



There, it feels good to have a list so when I have precious minutes to program I can just plow through it.

Why am I using my time away from work to do work-related things??

  1. I enjoy it.
  2. I’m building skills so I can do work I enjoy for my current job and future opportunities.
  3. I want to stay “fresh” (and not forget everything I trained for).

This little guy doesn’t mind as long as I get lots of snuggles in with him:

leo four ways

Bedtime and besos,


report from railsconf

This past week I was fortunate to attend my first major conference as a software developer, under the RailsConf 2016 Opportunity Scholars & Guides program. Look at these cuties!


Here’s me with my awesome guide Jason:


And some sticker swag:20160508_110123

Continue reading

“we didn’t think about it”

Oh boy, readers, you are in for a treat. Today I found myself thinking simultaneously 1. “gosh I haven’t blogged in a while” and 2. “wow I’ve been doing a lot of yelling on the internet.”

So let’s talk about some praise-worthy and “what were they thinking” situations and why I’ve started being more mouthy. (And by “yelling” I mean giving people politely phrased but tough and mostly unsolicited feedback.)

Exhibit A:

Text box saying: NICE GUYS "Yep, that's right. We're just straight up nice guys. Developers your mom would want you to work with."

I got a LinkedIn recruiting message asking me to check out this website, which I did and I found the bullet point above. To confirm my hypothesis that no women were involved in this design decision, I did a search on their own site and LinkedIn and found 0 women out of 16 current or former employees. I responded saying that I wasn’t interested, and that if they planned to pursue female developers (which I hoped they would!) they might consider changing this language. I wasn’t sure what kind of response I would get but I expected to be told that they meant “guys” generically and I should lighten up, and I braced for impact.

Instead of talking down to me, the person thanked me for the feedback and said that he’d have his team look into changing it right away. By the end of the day, their website looked like this:


Kerning issues aside, isn’t that much better? I don’t want to give the guy too many accolades for doing the right thing, but I was surprised and impressed with his solutions-oriented, non-defensive reaction. I was like, yo, this is a business problem for you, and he was like: wow, you’re right, and thank you for telling me.

RIDING HIGH ON A WAVE OF SUCCESS AND POWER, I decided to fix some other parts of the internet.


Exhibit B:

The email LinkedIn sent me was titled “15 Questions every Rails developer should ask himself.”

BE IT SO NOTED: This email came to me. I did not go out looking for examples of sexism in tech channels on the internet. It arrived to my personal email account demanding attention from me and who knows how many other of the 60,000 members of the Ruby on Rails LinkedIn community (some of whom, I wager, are not men).

SUBMITTED FOR ADDITIONAL CONSIDERATION: The last time I responded to someone’s use of “guys” for a multi-gendered group (the group in question was actually entirely female) by suggesting that “all” would be a more inclusive language choice, I got a 4 page essay private messaged to me about how I hurt this person’s feelings by correcting him in public, and how he works so hard to help women and setbacks like this make him not even want to try, and on and on and on. He did not understand why his public comment might warrant a non-confrontational, polite, public response from me. People, it seems, would much prefer that you call them out on their💩 in private.

But I was high on power and also I can’t keep my mouth shut, so I prepared for the storm 💩🌂:

A blog post titled "15 questions every Rails developer should ask himself"

This response is fine. I would prefer he correct the actual article in front of us, but I’m willing to give the benefit of the doubt that LinkedIn makes that difficult. I’m also impressed with the Rails community for not piling on, though this was quite recent and time will tell.

Exhibit C:

The last and latest comes from our friends over at Hired, who — for those keeping score — rejected me and my friends from their job seeking site after we put a few hours of effort into building a profile, and then sent a “we’re sorry” email that concluded “and could we ask you to recommend us to your more experienced friends?” thus no longer serving as a “we’re sorry” email at all.

Hired is a RailsConf sponsor, where I am thrilled to be heading next week as an official Rails Scholar. RailsConf is planned and organized by some truly lovely people and I have been enjoying connecting with the scholars, a diverse group of fellow newbies to the Rails community.

Which is why it was so disappointing that in user stories highlighted on their RailsConf promotional page, Hired included only three women and less than 10 people of color, all requiring a deep page scroll to uncover. In fact the first 16 profiles are all white men.

I wasn’t the only person who noticed the sea of white male faces, either:

A tweet exchange

Can I get that in a block quote?

“We didn’t think about it” is always a disappointing excuse for glaring lack of diversity. – @HayleyCAnderson

As it was in the beginning, is now and ever shall be, world without end, forever and ever, amen.

For the record, their eventual response:

…is one step above “Sorry u were offended,” a step below think about it and don’t say anything at all, and miles below “thank you for bringing this to our attention, we’ll take immediate action to rectify the situation” (and then do it) like my friend in Exhibit A.

Closing Statement:

So much of what I’ve shared in this blog post, and other incidents I’m not sharing, is carelessness — a case of not thinking, of limited perspective, of not getting feedback from the right people before hitting “send.” A lack of knowledge of how far your message will travel and who it might inadvertently knock over on its journey.

I have started vocally, publicly (if the offense is public let the correction be public, says I, so we can all learn), pointing this out to people — and so far I haven’t gotten buried for it. The ability to do so comes from a place of privilege (I am, after all, white, well-connected, and financially secure enough to speak up without concern of losing my job) but also of confidence —

I’m starting to identify more as a developer everyday, and so the injuries feel more personal.

You tracked this mud in my house. You’d better believe I’m gonna say something.

Internet! What mouthy battles are you fighting this month? Share ’em so we can cheer you on!

<3 Mary

video yourself whiteboarding

I’m taking a weekly class with Kal Academy, a refresher course on data structures and algorithms. I can’t say enough good things about Kal’s classes — they are small, personalized, affordable, positive learning environments. Very worthwhile if you are a woman in technology in the greater Seattle area. In addition to the data structures and algorithm classes, which are mandatory for anyone who wants to improve at technical whiteboard exams, she also offers classes in business intelligence and object-oriented programming (in Microsoft stack).

Our homework this week (and ongoing) is to video ourselves whiteboarding. This is intimidating and potentially embarrassing, so of course I am sharing it with the world. Behold the screen capture worth 1000 words:

youtube video capture

Slow clap, YouTube. 👏 Watch it here:

And here’s the final code (after some refactoring):

I highly recommend going through this exercise if there is a technical interview in your future. It will improve your practice and give you confidence. This session lasted about 30 minutes but felt much longer. I had to re-do my code a few times, which felt more awkward than it looks. (Verdict: not terrible for a first attempt, but I’ll get better.)

Technical note: I used YouTube live on-air with Google Hangouts enabled. The directions are not very clear, but I was able to set my video to private (only those with link can view) and the recording worked fine and was instantly available on my YouTube channel. I did not attempt to do any screen sharing.

It’s a different experience to whiteboard without anyone giving you real-time feedback than with it. But, try it and tape it anyway.

Kal is collecting the videos and sharing with the class, so we’ll get to see a few other people’s approaches and solutions, which is always super useful. (Share yours in the comments if you try this!)

Need some sample whiteboard questions? Try not to think about them too long before you start the camera rolling, that’s cheating.

These are all fucking terrible, except maybe #8.

Better sources:

Happy (live) coding!

how to use the wordpress rest api in rails

Folks, if you’re reading this over at, my Rails portfolio site, things are about to get real meta. Several weeks ago I RSVPed for a WordPress Developer’s meetup called Introduction to the REST API. I’ve used APIs with Rails, Angular, and in Twitterbots– an API (application program interface) is simply a way to transfer information from a server to a client, often using a format called JSON (JavaScript object notation). APIs are key to mobile apps that access the same database as a web based site. “REST” (representational state transfer) means that a system understands a set of standard verbs used to communicate over HTML, including: GET, POST, PUT, DELETE, etc. You can use an AJAX (asynchronous JavaScript and xml) call to transmit data via the REST verbs and either fetch data, post new data, update existing data, or delete a record, and the information will be persisted in a database somewhere behind the scenes.

That’s a lot of acronyms. Here have a picture:

how APIs work, sort of


Long story short: I’ve had this WordPress blog since I started coding, and since then I’ve coded other web sites “from scratch,” including a professional portfolio site, that are much easier for me to customize and that add legitimacy to my claim of web developer. So that is what I want to share with potential employers but I *also* want them to see my awesome technical blog posts so they will think “She sounds cool and writes good. Let’s pay her money in exchange for her time!” UNTIL NOW the way to do that was to direct people to this site,, and hope that they will also go check out, or vice versa. Awkward.

The WordPress API allows me to import blog posts from and render them as a tab on If you have any sort of non-WordPress site and you’d like to link to or display your blog posts, you can do that with the WordPress REST API. I’ll walk you through what I did to get this working in a Rails app:

Continue reading

try rails 5

Hey folks! Last week wrapped up my second teaching assistant commitment, and while I managed to get myself invited back (barely) (I have more to say about this), I’m taking a break to focus on building skills and job seeking.

On the menu for today: let’s talk Rails 5. This’ll be short, since I need to dive into it.

Screen Shot 2016-02-03 at 3.21.29 PM


BUT FIRST… version control.

Since I finished my Ruby on Rails training in 4.something, Rails released a beta version of 5.0, and Ruby has also released a new version, from 2.2 -> 2.3. I’ve fought hard against installing a ruby version manager after disastrous attempts with rvm and rbenv, which hate each other, and will leave your development environment totally FUBAR if you’re not careful. So I nuked everything and avoided any Ruby version control, until now– and now I know better, and there’s no longer any excuse. My instructor says “try chruby!” so chruby it is!

I followed these instructions… including the setup for powder, which is my Rails development server of choice. I installed Ruby 2.3.0 as default and 2.2.4 as a “so then we’ll have it”. Apparently I had been using a version of ruby called 2.2.3p173.  Gross. No more!:

(Oh right, I have to update to El Capital also. Dammit.)


So now we have software version control, sweeeeet. However, that version control does not extend to Rails, so how to play with the new version without destroying my current install (most recent stable version)?

Option 1: Clone the Rails repo and create a new Rails app from that starting point. 

I followed this guide for how to clone the Rails repo and then create a new Rails API app using the latest beta version (“edge”):

Fun! This worked as expected. I did have to run a bundle install before the bundle exec rails new etc would work. If you go this route, at the end your gemfile will contain this line:

gem 'rails', github: "rails/rails"

Option 2: Create a Rails app like normal and then update the gemfile with desired Rails version

Do you really have to clone the entire Rails repo? Probably not, right? In my second attempt, I tried to teach an existing Rails app to use the new version. The latest beta release in has this language for your gemfile:

gem 'rails', '~> 5.0', '>= 5.0.0.beta2'

However, that did not work. This did!

gem 'rails', '5.0.0.beta2'

I had to run a bundle update after bundle install, but otherwise everything went smoothly.


Well, my install worked a bit TOO well, and now all new Rails apps are initiating with 5.0. That was not my intention, but it should be easy enough to switch back if needed. Funny enough, when I run a new Rails app now, this is what the gemfile looks like:

gem 'rails', '>= 5.0.0.beta2', '< 5.1'

YMMV. Gentle reminder: Rails 5 is not currently recommended for production environments.

“A tree house, a free house, a secret you and me house…”

EDIT: Shortly after this post, I heard back from Pierce County that the partnership is ending shortly due to new financial obligations that Treehouse is requiring to continue offering free access for all of their cardholders. And sure enough, the links in this post are no longer working. So, I’ll leave the post up for posterity but this deal no longer applies. 🙁 Sorry gang. 

Happy new year, dear readers! 2016 started for me with a whirrr and a bang and a wahoo! and other noises indicative that your cozy holiday break is OVER, friend. Get up and get moving, we’ve got class/meet-ups/projects/job applications/interviews to knock out.

One of my resolutions was to finally get signed up for a free Treehouse membership via Pierce County Library System (which has a reciprocal relationship with King County Library System and other library systems in the greater Seattle area). And this might have remained a hypothetical “I should get to that… soon” if not for one of my new 301 students, who was like, “or you could do it now!” (Thanks Ron and Yun Joo!)

It’s simple to do, and Treehouse has some great tutorials for beginning and more experienced programmers seeking to expand your skills. If you live in the Greater Seattle Area, please take advantage of this!

Sign up for Treehouse with Pierce County Library partnership

Here’s how to do it…

Step 1: Get you a Library Card

You already have a library card with your local library, yes? If not, go do that. Then, navigate over to the Pierce County sign-up page and fill in your information. For “local branch” select any of them, you won’t be needing it for the e-learning resources. For “Reciprocal Borrowing Agreement” select “King County Library System” or whichever one applies. Submit the form and wait for a welcome email with card number.

(Edit: I didn’t receive a card number yet, but a reference librarian tells me: “Normally you’ll receive your temporary card number immediately and then receive a follow-up welcome email, but I’ve just verified with our IT folks that we’re experiencing some technical issues.” So, persevere!)

Step 2: Register on Treehouse

Once you have your Pierce County Library card number and PIN number (last 4 digits of your phone number), head over to the Treehouse Pierce County registration page and sign up for a new account. You’ll need to use an email address you haven’t already used with Treehouse, and you can sign up for a new one if needed with gmail or any free email service. I’m hoping that I’ll be able to transfer my existing Treehouse progress from my old account to the new one, and I’ll update when I find out if this is possible (but I’m expecting I’ll need to start from scratch).

Step 3: Be Classy

You’re now eligible to start taking classes or working on any of the Treehouse developer tracks that you choose! Here are some goodies:

  • Object-Oriented JavaScript with Andrew Chalkley
  • ActiveRecord Basics (for Rails) with Hampton Catlin
  • Harnessing the Power of VIM — I haven’t taken this one yet, but it’s on my list.
  • Learn Java Track — ditto to above (I did complete the Rails developer track)

With Treehouse, you get a public profile to show off what you’ve learned. Share yours in the comments when you successfully get registered!

Step 4: High-Five a Librarian

You probably want to hug them right now, but opt for an expression of gratitude that respects their personal space instead. Like maybe a nice note on Twitter about how awesome this partnership is that they can re-tweet, or go pay that long outstanding library fine you’ve been putting off.


Happy studying, and spread the word! Got any favorite Treehouse courses? Link ’em in the comments!

*Title of this article from Tree House, by Shel Silverstein

reindeer games

Screen Shot 2015-12-26 at 10.52.12 PM

Happy December, readers! Christmas has come and gone and you’re probably over it already. I, on the other hand, am determined to keep making progress on the Advent of Code challenge, which has served as a happy distraction and learning opportunity this month. When I haven’t been teaching, applying for jobs, getting prodded by doctors (long story), and trying to land my first contract gig, I’ve been helping Santa and his team deliver the goods.

In the process, I learned about (and/or got more practice using):

  • object-oriented programming (OOP)
  • string manipulation & regular expression matching
  • MD5 hash conversion
  • bitwise logic operators
  • arrays and hashes
  • functional programming
  • algorithmic efficiency (Big O notation)
  • and more!

Over time, I built out my repo to include testing (for easier code refactoring) and input files (for cleaner code), as well as a README detailing my approach to each problem. I know it sounds silly–and did not impress my career counselor–but this was truly a great professional learning exercise, and I’m enjoying the opportunity to see how other people solved the problems and how to optimize my own solutions. In some cases, my approach works, but takes a long time to run. In other solutions, my approach works in theory but takes too long to return a solution. I’m still tinkering and will read up on the problems I didn’t solve before I put it away until next year.

One of my favorite exercises was Day 14, Reindeer Games, in which a set of reindeer are racing, and the objective to to find how far the winning reindeer has travelled after a given number of seconds. Each reindeer travels at a set speed (x kms/second) for y seconds, and then needs to rest for z seconds. To solve this challenge I took an OOP approach and considered “what are the Nouns involved here?”

  • We have Reindeer, each flying on a track, organized by a race. Reindeer have a name, a distance they travel every second, a fly-time and a rest-time.
  • Each reindeer flies on a Track, which belongs to one reindeer. The track knows whether its reindeer is flying or resting at any given point, how long it has been in that state, and what index it’s at on the track (how far it’s gone). The track knows how to advance a reindeer once per second depending on the reindeer’s state.
  • Organizing all this we have a third class, Race, which registers the reindeer as racers and has a “run_race” method that advances each reindeer for a given number of seconds. At the end of the race, it checks each reindeer’s track position to see who has travelled the farthest, and returns a distance.

This is my favorite type of programming to do, as I enjoy thinking through the “who knows about / controls what” in a given problem set. My solution isn’t necessarily the most efficient (though I have no real reason to believe that it’s inefficient, besides having to carve out an array with ~5,000 entries for each reindeer to mark the “track” on which they travel), but it’s straightforward enough that a non-programmer should be able to look at it and basically understand what’s going on.

Well, see for yourself:

Continue reading

Older posts

© 2017 Mary Dickson Diaz

Theme by Anders NorenUp ↑