RubyConf 2016 – Am I a developer yet?

As luck would have it, RubyConf occurred during my job search. The 3 day conference was $400, which ain’t bad at all, but at the time I couldn’t justify plunking down 400 bucks for a ticket, then 350 for a flight to Cincinnati, then another 200-400 for a hotel, not to mention however much money for food and cabs and such. Still… I didn’t have a job… maybe it was worth the investment?

In early October I applied for a diversity/adversity scholarship. Unsurprisingly I didn’t get selected (I haven’t had true adversity in my life in a long time, doing just fine all things considered), but there was a silver lining: I learned that I could volunteer for a free conference ticket. The ticket was a regular ticket including daily breakfast, lunch and snacks. Doing the math in my head, if I stayed with a friend I would really only be paying for airfare and cabs/dinner/snacks. Maybe not even food at all if I hit up the right happy hours.

They asked for 12 hours of help over 3 days, which seemed fine to me, so I signed up. It’s been a few weeks since I got back – nearly forgot to write it up! Here are some thoughts I’ve had about the conference.

Post-Election

  • RubyConf was right after the election, and it felt very strange to be in such a festive atmosphere. It felt like I shouldn’t be silly, I shouldn’t be networking or taking lots of pictures, I shouldn’t be eating fried chicken and trying to collect as much schwag as possible. Apparently other people were feeling that way as well, there was an informal group led venting about the election.
  • Somewhere in my late night social-media fueled stupor I ran into someone’s post-Trump blog post where they said they couldn’t find state by state listings of minority owned businesses. I found this database of certified businesses, but it could use some improvement. This seems like a good idea for my next toy project (maybe make it more of a Yelp clone?), but I feel like somebody must have already done this, right??? How does this not already exist?

Vs. ForwardJS?

This conference felt very different from ForwardJS, as it should have. It was basically the complete opposite of ForwardJS.

  • out of town  / hometown
  • planned a month in advance / planned a couple days before
  • 3 days of programming vs 1 day
  • No workshops / Paid workshops
  • Ruby / JS
  • Volunteering /  Attendee
img_5058
Milling about between talks

Volunteering

TBH, besides being cheap, volunteering seemed like a great option because I would be able to bond with the other volunteers over the shared work. I felt a little lonely at ForwardJS, and wanted to make sure that didn’t happen at a 3 day long event. I knew that they were recording the talks, so I wasn’t really going to miss anything.

Volunteering turned out to be pretty much all positive. One unforeseen benefit: I was working the registration and information booth, so I got to talk to Ruby celebs multiple times over the course of the conference. And in general once I’d already talked to someone, even if it was just to answer a question, I felt fine walking up to them and chatting later. It felt less weird for some reason.

img_5030
Opening keynote

Imposter Syndrome

Actually, there was one moment that felt a little awkward. I went up to talk to a company that I’d applied at a while back. I didn’t make it through their code challenge, but I wanted to tell them that I liked what they were trying to do, and the thought that they’d put into the assignment. The booth was a bit chaotic, so I didn’t find quite the right opening to talk about it. I moved over to the side. One of the booth folks came over to talk to me, then looked down at my badge, or maybe my red RubyConf staff shirt, and said “Oh, sorry I thought you were a Rubyist. You’re staff.”

0_X <- my face

Not gonna lie, had a mini-existential crisis. Do I look like a coder or not*? Sort of, because you talked to me, but not because of the badge… but I can be both… ;o

I talked about the volunteering, and how it was a great way to score a free ticket and meet people in a different way. After a bit of chatting, I ended up mentioning my new job**, and he actually knew some people there! Well what a great coincidence! Couldn’t have come at a better time as I was feeling insecure. Inside my insecure head: I AM A RUBY PERSON AND HEY SOMEBODY YOU KNOW HAS EMPLOYED ME. SO THERE! I AM FOR REAL. RILLY THO.

img_5065
Q & A w/ Matz on the future of Ruby

Content

The variety of content was great, but I gravitated more toward career talks and a few specific technical sessions. They had a content track called “Life After Bootcamps” which seemed timely.

There were also lightning talks at the end of the second day, and wow! People really wanted to share. They kept coming up to the info booth asking when we were putting out the sign up sheet, and then once we did it was a mob.

People

The first day I was a little starstruck, but quickly I realized that everyone was nice – attendees, other volunteers and staff, vendors, speakers. There were a pretty decent amount of women at the event (more at ForwardJS I think), and lots of female speakers. They did a good job making the conference inclusive – there were gender neutral bathrooms, a lactation room, and free childcare offered onsite. Free childcare!!! I will never have kids, but that makes me very excited!

Highlights

  • On the first day I got to meet Matz! I gave him back his cellphone, which he left in junior ballroom D 🙂 .
  • Meeting folks from a couple of companies I applied to (and got rejected from) was one of the things on my conference to-do list, and it wasn’t nearly as awkward as I thought it might be. TaxJar in particular were nice enough to find me first, right as I was stuffing my face. 🙂
  • The fried chicken and catfish on day 2 was really good. 😀
A "Three way "
Skyline Chili! Kind of weird!

* To be fair, for some reason I am often mistaken for a retail worker when I’m out shopping (Old Navy, Kinko’s…). I don’t think that I look particularly helpful, so who knows. Maybe I look young. Maybe my sweater folding game is good?

** Oh right, I got a job! Forgot to mention it here.

img_5071
Bye RubyConf!

Printing a Multiplication Table of the First 10 Prime Numbers

Ok, for a change of pace let’s break away from sorting algorithms and do this problem:

Printing a Multiplication Table of the First 10 Prime Numbers

Code Here

I got this as a coding challenge a few days ago and finally got a chance to tackle it this weekend. The prompt asks for the user to create a program that runs on the command line, and it should print out a multiplication table to STDOUT. I feel like I’ve seen similar problems elsewhere, but this one had the twist that it wanted the multiplier numbers to be primes.

Other rules: Make it flexible for N # primes, write some tests, don’t use Ruby’s Prime class, package yer code.

I started out this challenge by trying to understand clearly what the problem was. Print out a multiplication table? Like this?

039827b

Oooooooooooooh. Haven’t seen one of those in a long time.

So the top row and the first column would be populated with primes. Hmm…

Since I couldn’t use Ruby’s Prime class from the standard library, writing a method for finding primes seemed like the first thing to do.

I wanted to make my program flexible so you could create multiplication tables of different sizes. So I created a method to pull the first n primes into an array.

And finally actually printing out the actual table! Formatting was the biggest pain here.

After I was done with these methods, I thought I was good to go. HA! Nope, still got to package it up and write some tests. I was going back and forth, but I’ll talk about the tests first.

I decided to go with RSpec, so I created a gemfile and added in the requirement. Then I created some spec docs and started going to town. I really only had 3 methods to test, and I decided to do 2 tests for each. It’s been a while since I watched ThoughtBot’s TDD lecture, and my subscription to their site has lapsed, so I decided to keep it as simple as possible. An RSpec tutorial I was reading was referencing a “Calculator” class in its tests, so I thought “Oh, I might as well bundle up the 3 methods into a MultiplicationTable class.” So I went back and changed that, and my tests.

All of the tests were pretty simple except for the print_tables one. Again, it all came down to formatting. I wasn’t sure how to check what was being printed to STDOUT. I came across stringio and some helper methods on StackOverflow, threw them into my spec_helper, and then it was on. I could capture and check what was being printed to the console. Still, it was tricky to figure out what string I was looking for here. RSpec failure messages came to the rescue as I just copied the extremely ugly failure string  (making sure #’s were correct) and pasted into my tests.

Hooray! My tests were looking for the right things now. Nevermind that when I ran the tests I got this little deprecation warning:

screen-shot-2016-10-16-at-2-16-45-am

Um… ok. Sure I can go back and change that easily. Nope, getting errors after I tried to fix it. I’ll go back and deal with it later.

I started out thinking about how to package my program. My mind wandered to gems, which of course made me think about my NPR Stories Gem. I looked at my gem to check out the basic structure, see what I was still missing in my multiplication table project. Then I got sidetracked for about 30 minutes trying to push my NPR gem to RubyGems. I hadn’t yet actually published my NPR gem for a variety of different failures, but this time I realized one major reason- I had to actually build the gem first with:

gem build npr_stories.gemspec

then I could push it to RubyGems. D’oh. That was embarrassing. Now that it was published, and robots were already scraping it, I wanted to make sure that it worked, so I spent some more time trying to edit and test my NPR gem, then I remembered that I had to finish this coding challenge. Right. And of course there was a typo in my gemspec file. Not worth doing a whole gem update for a single letter typo.

Ok, back to multiplication tables! So I could package this multiplication table as a gem for easy installation…But is it even worth it? If so, I should have set this up as a gem to begin with so I could have used this bundler command that pulls together all those files and folder structure for you:

$ bundle gem my_gem

I decided to do it anyways and created a new repo to play with. I just copied over my tiny amount of code thus far.

15 minutes later I abandoned ship and returned to my original repo. Creating a gem just didn’t make sense to me for something so small. Hmmmm… how did I want this to run on the command line? I created a bin folder & executable, and also a CLI class with a simple interface.

And after a few hiccups it’s working!

screen-shot-2016-10-16-at-2-15-21-am

The last step I had was to write a README doc. Whew! That was a lot of work for such a simple little ask. It would have gone faster if I hadn’t indulged my little diversions to other projects and down multiple rabbit holes.

Algorithms: Insertion Sort

I wanted to make Insertion Sort part of a two-fer with Selection Sort, but it honestly took me a minute to figure out how to implement.

Continuing the card game analogy of earlier, if Selection Sort is scanning your hand and moving the smallest items down to the left, eventually ending up with a fully sorted hand…

Insertion Sort is like when a dealer gives you a new card. You look over what you’ve got so far, and add the card to its rightful spot. Similar to Selection Sort, Insertion Sort also operates on the idea of a “sorted” section and  an “unsorted” section.

When an item (let’s call it A) is larger than the element to its immediate left (B), the two aren’t swapped like in Bubble Sort. Instead, you hold on to A’s value, and then reassign B’s value to the spot array[A]. So it’s like you are sliding B’s value down the line. Then you compare A with the item in the index to the left again (C). If A > C, you can then put A down in array[B]’s original spot. Otherwise, you need to keep working to the left and shifting over elements until you find the right spot for A. When you finally assign A to its spot, you’re done with inserting A. Then you repeat the process with the next item in the “unsorted” section.

I had some issues wrapping my head around how to move items down the line, making room for the array, initially thinking about a recursive solution, but really all I needed was a while loop.

 

Algorithms: Selection Sort

I’m still working my way through implementing the basic sorting algorithms in Ruby, so maybe I should just make this a special “Intro Sorting Week.” There, sounds like a fun holiday, right? Today we’re talking selection sort.

Selection Sort

Selection sort is where you scan the array, pick the smallest element, and then swap it with the first element. Then you scan the rest of the array again, look for the next smallest element, and then swap it with the second element… Y’all see where I’m going with this?

It creates a sorted subarray on the left, and an unsorted subarray on the right. You work your way through smaller and smaller subarrays until the entire array is sorted. The algorithm is called selection sort because it repeatedly SELECTs the next smallest element and swaps it into place.

A common example of real life selection sort is when you’re playing cards and you are organizing your hand. You look over your hand, and SELECT a card and move it to its rightful place on the left (creating a sorted section), and continue working through until your hand is sorted. To me this isn’t the greatest example, because you’re not necessarily swapping the items when you select and sort a minimum card. It’s more like the cards are individually going both left and right, and often you can move multiple cards at a time. But that’s just me and how I organize my cards… back to Selection Sort.

The good: Selection sort is easy to understand. It’s also faster than bubble sort, but given how awful BS is (ever notice that bubble sort is BS?) that’s not much of an accomplishment. Selection sort is also in place, so it saves you space.

Downsides: This sorting algorithm takes a long long time. O(n^2) even in its best case. Ouch! Also it’s important to note that it’s not stable.

Here’s my selection sort done with two for loops:

Algorithms: Bubble Sort

Bubble sort! I stumbled across this clip while looking for video algorithm explanations.

Wow, even Obama knows what’s up. Bubble sort ain’t where it’s at.

The idea behind bubble sort is that given an array, you can go through the array, item by item, and compare each item with the item that is next in line. If the first item is larger (or comes after) the second item, then you should swap the pair. Continue these pair comparisons until you get to the end and then repeat. After enough times running through the array, you will come to the point where the array is sorted, and you’ll find that you’ve made no swaps.

There are some advantages to bubble sort. It’s easy to understand how it works. It uses up a constant amount of auxiliary space, it’s stable, and in the best case scenario, when the array is already sorted, it takes linear time.

Alas, bubble sort is mostly impractical. In application, bubble sort can take O(n^2). Not great.

Here’s my implementation of bubble sort in ruby. It’s really all about that swap flag.

** EDIT : After some thinking, I realized that during each iteration there is no need to check the items at the end since the largest item will “bubble up” to the top. The subarray that you are looping through will get smaller & smaller. This can be accomplished by iterating backwards over the array and decreasing the area searched, but I haven’t added this yet. Surprisingly, Bubble Sort could be a little less terrible.

Scroll To Top