10 Things I Learned at My First Hackathon

IMG_4450

I forgot to mention it last week, but I finally attended my first hackathon! Ryan helped me score tickets to TechCrunch Disrupt’s Hackathon, a 24 hour test of “coding endurance.” This was the big time! I pulled together a small team of San Francisco Learn-ers, plus my roommate.

I didn’t have a concrete goal for the event. Mostly I just wanted to take it all in and have fun, meet some new people and feel inspired. Our team ended up pivoting at the last minute and running out of time to finish our project,  but I did learn a ton just by being there. So, in no particular order of importance, here are some tips for your first hackathon:

  1. Don’t go hungry – Usually food and drinks are available, but just in case there’s nothing to your liking, pack some backup snacks and drinks.
  2. Be comfy – Wear layers. Wear stretchy pants. It might get cold if they jack up the AC. In our case, the event was held in a huge drafty refurbished pier that was right on the water. Cold wind blew through the open doors at all hours. My classmate who was only in a t-shirt was miserable by nightfall.
  3. Decide whether you’re going to sleep over and if so, bring a sleeping bag! I felt like an idiot at first for bringing mine, but as the hours crept on, the sleeping bags came out. Some people even brought cots!
  4. If possible, form your team beforehand, and pick a team leader. It seems like it naturally comes about based on whose idea is used, but it helps so much having one person keeping everyone else on task.
  5. Possibly more important, come to the event with project ideas, and an idea of what technologies you’d like to use. We spent wayyyy too long just bouncing around ideas.
  6. There were some great API workshops at the hackathon, but you would have a leg up if you spent the day before the event brushing up on the available APIs. You can find this information on the hackathon’s website. Just check out the rules or sponsors section.
  7. GitHub + Trello = Organization! We immediately created a repo for our work, but having a Trello board would have helped us keep tabs on the state of the project. GitHub has a new projects feature, which is very similar to Trello, so I’m looking forward to using that in my next group project.
  8. You may be going HAM on your project, but be sure to make some time to network! Chat with the reps manning the booths, do silly things to get schwag (I jumped through so many hoops with Cisco Spark to score pizza for my team), meet your neighbors… and of course be nice to the poor staff working the event.
  9. Don’t be afraid to change your project idea at the last minute. All the cool kids are doing it. We changed ours at oh… approximately 7pm.
  10. Your project doesn’t have to be perfect. Just get the damn thing working enough to show it off. Don’t make it any more complicated than you need to!

Here are some more pictures from the event:

IMG_4452

IMG_4459
Several hours in and the tables were covered in pizza, candy, charging cables, coffee, schwag, and… makeshift standing desks
Midnight
Midnight
3am study break
3am study break
IMG_4475
4 am

 

IMG_4474
Sleepy time

Ruby Basics: Inject & Reduce

As you might imagine, my days have been full of all things job hunt. I mentioned earlier that a large part of my preparation is learning data structures and algorithms for the dreaded technical interview.

But before one even gets to the technical interview, there’s usually the coding challenge or toy problem. This can appear several different ways. Perhaps HR sends you a link to a private and timed HackerRank challenge. Or maybe suddenly your 15 minute meet and greet phone call turns into a 45 minute surprise technical screen (true story). Coding challenges are their own unique pressure.

Most code challenges that I’ve encountered so far have involved string or array manipulation. I suppose that these problems are good indicators for how comfortable you are with the basics, and based on your style, how well you know your language of choice.

Ruby’s Inject (AKA Reduce) is a lovely method that makes your code SO MUCH CLEANER. It’s great stuff, you just gotta learn the pattern. Here’s the official description of Inject/Reduce from the Ruby docs:

Combines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator.

If you specify a block, then for each element in enum the block is passed an accumulator value (memo) and the element. If you specify a symbol instead, then each element in the collection will be passed to the named method of memo. In either case, the result becomes the new value for memo. At the end of the iteration, the final value of memo is the return value for the method.

If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo.

Inject is great for those problems that are like “what’s the product of all the odd numbers found in this array?” Here’s a simple example problem that shows the use of reduce. It’s from Codewars.com.

  • Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 integers. No floats or empty arrays will be passed.
  • For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7.
  • [10, 343445353,3453445, 3453545353453] should return 3453455.
  • Tip: Do not modify the original array but create a new one.
  • Create a function that calculates the sum of the two lowest numbers given an array of positive integers.

My First Pass Solution:

In my initial answer I decided to grab the last two numbers with min, which returns an array of the two smallest values which I saved under the variable lowest_nums. Then I returned the sum of these two elements.

But there is a better way!

In the top example, we’re chaining inject on to the result of numbers.min(2). It will take that array and perform the + operation on all of the elements of the array. The second example is the same function but in block form. It’s more verbose, but I think it’s easier to understand upon a quick glance.

Whether you go the symbol or block route, in both cases you can pass inject a starting value like this

inject(0, :+) or inject(0) { |sum, n| sum + n }

but if you don’t, as seen in my examples above, then it assumes the starting amount that is operated on is 0.

Happy injecting!

 

Meetups: Women Who Code SF

wwc

Event: Ruby and Web Tuesdays

This is a study group and you are welcome to work on anything you would like in our friendly and helpful environment. Organizers and core team members of the Ruby Study group will be present to help you with any Ruby related questions. We welcome many levels of attendees: brand new beginners, coders new to Ruby/Rails, experienced Rubyists, and anyone in between. Work on tutorials, personal projects, or just network! 

Agenda

6:30 Dinner 

7:00 Introductions

7:05 – 7:15 Introduction to Premise Data by Yang Hong

7:15 – 7:25 “Authentication, Authorization, and Why You Need Them Both!” with Ellie Day

7:25 – 9 Code!

Group: Women Who Code SF

Women Who Code is a global nonprofit organization dedicated to inspiring women to excel in technology careers by creating a global, connected community of women in technology. The organization tripled in 2013 and has grown to be one of the largest communities of women engineers in the world.

Women Who code is a professional community for women in tech. We provide an avenue for women to pursue a career in technology, help them gain new skills and hone existing skills for professional advancement, and foster environments where networking and mentorship are valued.

Location: Premise Data

Experience: So, I went to a Women Who Code study group way back, about 5 months ago! It was WWCode East Bay’s Programming and Dev study group held at Clef. I had a mixed experience at that event, mostly due to the long commute and lack of structure to the night.

My experience at the Ruby and Web Tuesdays (why don’t they just call it Ruby Tuesdays???) study group was much better, and I can attribute most of that to the fact that we were all there to study Ruby. There were two quick talks to start off the night (an overview of Premise Data, the company who was hosting the study group that night, and a very clear introduction to authentication and authorization), and they were both interesting, but also just the right length. Turnout at this event was stronger, with about 30 people. The women I met were of all skill levels, some a few years into web development, and one woman who had just created her GitHub account the other day! I got a bit of studying done, and managed to help a person or two, but as usual, going to this study group was really more about being around other people.

Verdict: It was a positive experience in a supportive environment. I’m definitely adding it to my regular rotation of meetups, and since it happens every other week, I think that’s sustainable.

Getting Started with Python for Data Science Presentation

I was poking around through my GitHub, trying to clean things up and find bits to highlight for my portfolio, and I came across this presentation I gave on getting started with Python for data science. Thought that I might as well share it here. It’s from last year, but I updated it in February and most of it is still relevant.

Highlights include: 

  • Why learn Python? How can we use Python to work with data?
  • Getting started: Installation Options and Orientation
  • Editing / Running existing scripts, Installing Modules…
  • APIs & reading documentation
  • Ideas for first projects w/ social media data
  • Additional resources for learning

Algorithms: Compute the nth Fibonacci Number

So I’ve been using a variety of resources for studying algorithms, from InterviewCake to FreeCodeCamp to Coursera, and many more. This is a problem that keeps coming up everywhere, so I thought that it would be helpful to walk through it.

Problem: Write a function fib(n) that takes an integer n and returns the nth Fibonacci number. Example functionality: fib(1) => 1, fib(3)=> 2, fib(5) = 5.

Background: In the Fibonacci sequence, each number is the sum of the previous two Fibonacci numbers. The first few numbers (0 and 1) are base cases. Here are the first few numbers of the sequence:

0, 1, 1, 2, 3, 5, 8, 13, 21…

Approaches:

Since Fibonacci numbers are created by adding together previous numbers in the sequence (also themselves Fibonacci numbers), handling this with recursion is an option.

fib(n) = fib(n – 1) + fib(n-2)

Recursive Solution:

Adding in base cases for 0 and 1, the function would look something like this.

def fib(n)
   if n == 0 || n == 1 # base cases
       return n
   end
   return fib(n-1) + fib(n-2)
end

Of course all of this recursion will require a lot of time, O(2^n) to be exact. This exponential time cost comes from the fact that we’re repeating quite a bit of work. Memoization is a technique that we can use to save results and avoid repeated work, but instead of recursion, we can also go the other way and solve the problem iteratively, AKA “Bottom up.”

Iterative Solution: 

def fib(n)
   # edge cases of negative entries, 0 and 1
   if n < 0
       raise Exception, “Index can’t be negative.”
   elsif n == 0 || n == 1
       return n
   end

   first_num = 0
   second_num = 1

   (n-1).times do
       current_num = first_num + second_num
       first_num = second_num
       second_num = current_num
   end
   return current_num
end

The time complexity for this version of the solution depends on just how big n is, so O(n). The recursive solution is beautiful and short, but I think that the iterative version makes more sense in my head. Shockingly, it’s also faster!

Scroll To Top