Categories
Current Events Programming

Avocado Labs talk today at noon (EST): Meet Matthew Pegula of Deeplocal!

Avocado Labs an Auth0 project whose goal is to keep developers and techies — and people who want to become developers and techies — connected through high-quality online talks.

Today at noon Eastern (17:00 UTC), join Avocado Labs’ Twitch channel to meet Matthew Pegula, Director of Creative Technology at the technology/experience design studio Deeplocal.

He’ll be talking about some of their cool projects, including a project called “Connected Mistletoe”, which keeps distant people connected over the holidays:

Here’s the brief for the talk:

Matthew Pegula works at Deeplocal, a creative technology and experience design studio based in Pittsburgh, PA. They’re a group of engineers and creatives who use technology to tell stories and create experiences in novel ways. At first glance, their projects don’t always jump out as being overly technical or software-driven, but that’s sort of the idea: the technology enables the story, it doesn’t overshadow it. Matthew is going to show a few of their favorite projects, talk about the technology that’s driving them, and some of the challenges they ran into along the way.

Matthew Pegula is a software engineer who has been lucky enough to blend his interests in technology, design, writing, and engineering into a career that encompasses them all. He has a BS in computer science from Allegheny College and leads the Creative Technology team at Deeplocal.

If you’d like to attend this online event, please read the code of conduct, then point your browser at Avocado Labs’ Twitch channel.

Categories
Current Events Tampa Bay

What’s happening in the Tampa Bay tech/entrepreneur/nerd scene (Week of Monday, December 21, 2020)

Once again, here’s the weekly list of events for events for Tampa Bay techies, entrepreneurs, and nerds. Every week, on GlobalNerdy.com and on the mailing list, I scour the announcements for events that are interesting to or useful for those of you who are building the future here in “The Other Bay Area, on The Other West Coast”.

This list covers events from Monday, December 21 through Sunday, December 27, 2020.

Events — especially virtual, online ones — can pop up at the last minute. I add them to the list as I find out about them. Come back and check this article from time to time, as you might find a new listing that wasn’t there before!

Have a safe and happy holiday!

This week’s events

Monday, December 21

Tuesday, December 22

Wednesday, December 23

Thursday, December 24

Friday, December 25

Merry Christmas!

While a number of events appear to be scheduled for this day on Eventbrite, Meetup, and other sites, they were probably posted on “autopilot” and most likely aren’t happening.

Saturday, December 26

Sunday, December 27

Do you have any events or announcements that you’d like to see on this list?

Let me know at joey@joeydevilla.com!

Join the mailing list!

If you’d like to get this list in your email inbox every week, enter your email address below. You’ll only be emailed once a week, and the email will contain this list, plus links to any interesting news, upcoming events, and tech articles.

Join the Tampa Bay Tech Events list and always be informed of what’s coming up in Tampa Bay!


Categories
Humor Process

We’ve all been there: “Let’s add one more feature!”

Categories
Programming What I’m Up To

My solution to Advent of Code 2020’s Day 8 challenge, in Python

Welcome to another installment in my Advent of Code 2020 series, where I present my solutions to this year’s Advent of Code challenges!

In this installment, I share my Python solution to Day 8 of Advent of Code, titled Handheld Halting.

Spoiler alert!

Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 8 challenge.

The Day 8 challenge, part one

The Kittenbot Meowbit handheld game console. Tap to find out more.

The challenge

Here’s the text from part one of the challenge:

Your flight to the major airline hub reaches cruising altitude without incident. While you consider checking the in-flight menu for one of those drinks that come with a little umbrella, you are interrupted by the kid sitting next to you.

Their handheld game console won’t turn on! They ask if you can take a look.

You narrow the problem down to a strange infinite loop in the boot code (your puzzle input) of the device. You should be able to fix it, but first you need to be able to run the code in isolation.

The boot code is represented as a text file with one instruction per line of text. Each instruction consists of an operation (accjmp, or nop) and an argument (a signed number like +4 or -20).

  • acc increases or decreases a single global value called the accumulator by the value given in the argument. For example, acc +7 would increase the accumulator by 7. The accumulator starts at 0. After an acc instruction, the instruction immediately below it is executed next.
  • jmp jumps to a new instruction relative to itself. The next instruction to execute is found using the argument as an offset from the jmp instruction; for example, jmp +2 would skip the next instruction, jmp +1 would continue to the instruction immediately below it, and jmp -20 would cause the instruction 20 lines above to be executed next.
  • nop stands for No OPeration – it does nothing. The instruction immediately below it is executed next.

For example, consider the following program:

These instructions are visited in this order:

First, the nop +0 does nothing. Then, the accumulator is increased from 0 to 1 (acc +1) and jmp +4 sets the next instruction to the other acc +1 near the bottom. After it increases the accumulator from 1 to 2, jmp -4 executes, setting the next instruction to the only acc +3. It sets the accumulator to 5, and jmp -3 causes the program to continue back at the first acc +1.

This is an infinite loop: with this sequence of jumps, the program will run forever. The moment the program tries to run any instruction a second time, you know it will never terminate.

Immediately before the program would run an instruction a second time, the value in the accumulator is 5.

Run your copy of the boot code. Immediately before any instruction is executed a second time, what value is in the accumulator?

Importing the data

Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into a Jupyter Notebook running a Python kernel.

This involves pasting it into a triple-quoted string and then assigning its value to the variable main_raw_input:

Building the data structure

With the data imported, the next step was to build an appropriate data structure. Since today’s puzzle was based on simplified microprocessor instructions, I thought that the data structure should do the same.

I wanted my data structure to look like the table below, which shows the instructions from extracted from the first five lines of the data given to me:

Index Opcode Operand
0 acc 37
1 acc -4
2 nop 405
3 jmp 276
4 acc 39

Here’s the function that I wrote to convert the input data into the data structure:

With the function defined, here’s how I used it to create the data structure, which I assigned to a variable named instructions:

I then wrote accumulator_value_at_first_repeat(), the function that would use the data structure contained within instructions to solve the first challenge:

When run, it sets up the following variables:

  • program_length: The number of instructions in the data structure.
  • program_counter: The program’s equivalent of the “program counter (PC)” register in a microprocessor; contains the index the instruction to be executed.
  • accumulator: The program’s equivalent of an accumulator in a microprocessor. For those of you who aren’t familiar with what happens at the microprocessor level, think of the accumulator as a “scratchpad” variable where you do all the math.
  • executed_instructions: A set (which means that every value in it is unique) of the indices of all the instructions that have already been executed. We use it to determine if a given instruction has already been run, at which point we should stop the program and see what the value in the accumulator is.
  • repeat_instruction_encountered: A flag that should be set to True when an instruction is about to be executed a second time.

The function’s main loop performs a greatly simplified version of a microprocessor’s “fetch-decode-execute” cycle:

  1. Fetch the current instruction, which is the one whose index is specified by program_counter.
  2. See if the instruction has been executed before. If this is the case, exit the loop; otherwise, recording this instruction as having been executed.
  3. Decode the current instruction:
    • If the instruction is jmp, add the operand value to program_counter and go back to the start of the loop.
    • If the instruction is acc, add the operand value to accumulator.
    • If the instruction is nop, do nothing.
    • If the instruction is anything else, display an error message.
  4. After the loop is done, if the repeat_instruction_encountered flag is set, we’ve found the value we’re looking for — display it! Otherwise, display a message saying that we’ve reached the end of the instructions without ever repeating one.

I ran the function…

…and got my result: 1801.

The Day 8 challenge, part two

The TinkerGen GameGo programmable handheld game console. Tap to find out more!

The challenge

After some careful analysis, you believe that exactly one instruction is corrupted.

Somewhere in the program, either a jmp is supposed to be a nopor a nop is supposed to be a jmp. (No acc instructions were harmed in the corruption of this boot code.)

The program is supposed to terminate by attempting to execute an instruction immediately after the last instruction in the file. By changing exactly one jmp or nop, you can repair the boot code and make it terminate correctly.

For example, consider the same program from above:

If you change the first instruction from nop +0 to jmp +0, it would create a single-instruction infinite loop, never leaving that instruction. If you change almost any of the jmp instructions, the program will still eventually find another jmp instruction and loop forever.

However, if you change the second-to-last instruction (from jmp -4 to nop -4), the program terminates! The instructions are visited in this order:

After the last instruction (acc +6), the program terminates by attempting to run the instruction below the last instruction in the file. With this change, after the program terminates, the accumulator contains the value 8 (acc +1acc +1acc +6).

Fix the program so that it terminates normally by changing exactly one jmp (to nop) or nop (to jmp). What is the value of the accumulator after the program terminates?

Here’s the function I wrote to solve this challenge:

The function, accumulator_value_and_halt_at_first_repeat(), is an expanded version of the function from part one, accumulator_value_at_first_repeat().

In addition to a set of instructions, it takes an additional parameter: the address of an instruction that should be changed — either from jmp to nop, or from nop to jmp.

The function still performs the “fetch-decode-execute” loop, and it exits the loop if it’s about to execute an instruction that’s already been executed. The main difference is that if the current instruction is the one flagged for change, it changes the instruction appropriately.

I wrote the accumulator_value_and_halt_at_first_repeat() function to be used by the function below:

This function goes through all the instructions in the set, looking for any jmp or nop instructions. When it finds one, it runs the program using accumulator_value_and_halt_at_first_repeat(), marking the jmp or nop instruction as the one to be changed.

This lets us modify the program, one jmp or nop instruction at a time, in order to find which change to a jmp or nop instruction is the one that allows the program to reach the end of the instructions.

Here’s an abridged version of what happened when I ran the function:

I entered 2060 as my answer, and step two was complete.

Solutions for other days in Advent of Code 2020

Categories
Programming What I’m Up To

My solution to Advent of Code 2020’s Day 7 challenge, in Python

Welcome to another installment in my Advent of Code 2020 series, where I present my solutions to this year’s Advent of Code challenges!

In this installment, I share my Python solution to Day 7 of Advent of Code, titled Handy Haversacks.

The Day 7 challenge, part one

The challenge

Here’s the text from part one of the challenge:

You land at the regional airport in time for your next flight. In fact, it looks like you’ll even have time to grab some food: all flights are currently delayed due to issues in luggage processing.

Due to recent aviation regulations, many rules (your puzzle input) are being enforced about bags and their contents; bags must be color-coded and must contain specific quantities of other color-coded bags. Apparently, nobody responsible for these regulations considered how long they would take to enforce!

For example, consider the following rules:

These rules specify the required contents for 9 bag types. In this example, every faded blue bag is empty, every vibrant plum bag contains 11 bags (5 faded blue and 6 dotted black), and so on.

You have a shiny gold bag. If you wanted to carry it in at least one other bag, how many different bag colors would be valid for the outermost bag? (In other words: how many colors can, eventually, contain at least one shiny gold bag?)

In the above rules, the following options would be available to you:

  • bright white bag, which can hold your shiny gold bag directly.
  • muted yellow bag, which can hold your shiny gold bag directly, plus some other bags.
  • dark orange bag, which can hold bright white and muted yellow bags, either of which could then hold your shiny gold bag.
  • light red bag, which can hold bright white and muted yellow bags, either of which could then hold your shiny gold bag.

So, in this example, the number of bag colors that can eventually contain at least one shiny gold bag is 4.

How many bag colors can eventually contain at least one shiny gold bag? (The list of rules is quite long; make sure you get all of it.)

Spoiler alert!

Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 7 challenge.

Importing the data

Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into a Jupyter Notebook running a Python kernel.

This involves pasting it into a triple-quoted string and then using Python’s splitlines() method to break it up into a list of strings. The result is main_raw_input:

Creating the data structure

I feel that I can never stress this enough: A key part of coming up with solutions to Advent of Code challenges is to come up with good structures for the input data.

Here’s my function that takes the initial, somewhat-massaged input data, currently living in main_raw_input, and turns it into a data structure that I could do some problem-solving with:

The create_data_structure() function creates a table that makes it easy to look up a given bag and see what bags it contains.

It takes each line in the input, which follows this general form:

[adjective and color] bags contain [one or more of
([number][adjective and color]bag(s)).

It first makes use of this regular expression…

…to separate the line into two parts:

  • The containing bag, which is captured by the (\w+ \w+) group, and
  • The contained bag(s), which are captured by the (.*) group.

The contained bag(s) are further parsed using this regular expression…

…to create a list of tuples of the form:

Here’s how I used create_data_structure() to create the data structure:

Here’s a sample of the what the structure looked like for my data:

With the data structure built, it was now possible to write a function to determine how many shiny gold bags a given bag would contain:

It’s the return of our friend:

This function checks the contents of the given bag. If there are bags in the given bag, it checks the contents of those bags and counts the shiny gold ones. If there are bags in those bags, it checks the contents of those bags and counts the shiny gold ones. And so on…

Now that I had the shiny_gold_bag_count() function, I could write another function — bags_containing_at_least_one_shiny_gold_bag() — that would apply the shiny_gold_bag_count() function to all the bags in the collection, giving me the answer to the part one:

In my case, the count was 326.

The Day 7 challenge, part two

Creative Commons photo by “Sunnya343”. Tap to view the source.

The challenge

Here’s the text of part two:

It’s getting pretty expensive to fly these days – not because of ticket prices, but because of the ridiculous number of bags you need to buy!

Consider again your shiny gold bag and the rules from the above example:

  • faded blue bags contain 0 other bags.
  • dotted black bags contain 0 other bags.
  • vibrant plum bags contain 11 other bags: 5 faded blue bags and 6 dotted black bags.
  • dark olive bags contain 7 other bags: 3 faded blue bags and 4 dotted black bags.

So, a single shiny gold bag must contain 1 dark olive bag (and the 7 bags within it) plus 2 vibrant plum bags (and the 11 bags within each of those): 1 + 1*7 + 2 + 2*11 = 32 bags!

Of course, the actual rules have a small chance of going several levels deeper than this example; be sure to count all of the bags, even if the nesting becomes topologically impractical!

Here’s another example:

In this example, a single shiny gold bag must contain 126 other bags.

How many individual bags are required inside your single shiny gold bag?

My solution was the following function:

Once again, my solution was a recursive one. This function checks the contents of the given bag. If there are bags in the given bag, it counts them and then checks their contents. If there are bags in those bags, it counts them and checks their contents. And so on…

Getting the solution was a matter of calling the function:

And for my data, the answer was 5635.

Solutions for previous days in Advent of Code 2020

Categories
Current Events

Meet the Auth0 DevRel Team — Monday, December 14 at noon Eastern / 9:00 a.m. Pacific

Here’s your chance to get to know the Auth0 Developer Relations teamthey’re holding an online meet-and-greet this Monday, December 14th at noon Eastern / 9:00 a.m. Pacific!

You can catch it on Twitch.

Here’s the description of the event:

Dev Rel, Developer Relations, Developer Advocacy, Developer avocado… What does it all mean? In this episode you will have the chance to connect and ask your questions about all of this to the very own Auth0 Dev Rel team. Maybe you just want to know what we do, or how we got here. Maybe you want to learn how to get into Dev Rel. Or maybe you just want to meet us and say hi! Whatever your reason, don’t miss this episode where we will also be hosting a secret santa live! Why? Well, that way you can also get to know us better by seeing what we would buy each other this season.

Here’s who you’ll meet…

James Quick, Senior Developer Advocate

James is a developer, speaker, and teacher with a passion for web development, design, and developer tools. He is a Senior Developer Advocate at Auth0 and has over 7 years of experience in Advocacy and Software Development. In his spare time, he runs a YouTube channel, plays co-ed soccer with his wife, spends time with his dogs, and can solve a Rubik’s cube in under two minutes.

Sam Bellen, Senior Developer Advocate

I’m a Google Developer Expert who works as a Senior Developer Advocate Engineer at Auth0. At Auth0 we’re trying to make authentication and identification as easy as possible, while still keeping it secure. After office hours I like to play around with the web-audio API, and other “exotic” browser APIs. One of my side projects is a library to add audio effects to an audio input using JavaScript.

Ana Cidre, Senior Developer Advocate

Ana is a Developer Advocate at Auth0. She has a degree in Fine Arts and a Master in International Business Economics and Management, so she is not your usual software developer. She loves to code and she especially likes Angular. As a very active member of the community, she regularly organises meetups and conferences, like the amazing ngSpain. In Spain, where she’s currently based, she’s an organiser of GDG Vigo and the founder of GalsTech, a group for women in tech from Galicia. Because she is so passionate about diversity, she is also a Women Techmaker Ambassador.

Sam Julien, Senior Developer Advocate

Sam Julien is a Sr. Developer Advocate Engineer at Auth0 and a Google Developer Expert for Angular and Web Technologies. He’s also an instructor for egghead and the author of Getting Started in Developer Relations and the Developer Microskills newsletter. His favorite thing in the world is sitting outside drinking good scotch next to a fire he built himself. You can find more of Sam’s work at samjulien.com.

Tyler Clark, Senior Developer Advocate

Tyler is a developer advocate engineer at Auth0, an egghead.io instructor, and a conference speaker. He’s worked primarily as a software engineer for the past seven years and loves getting his hands-on coding projects. His passion is in the frontend, but he also enjoys working on backend tasks. If he’s not in his office working, he’s either with his family or out playing some kind of sport.

Kristy Gutierrez, Project Management Consultant

Kristy is a Project Manager at Auth0. New to working in the tech world, Kristy’s background is rooted in outdoor education and international adventure travel. While working at Auth0 may sound like an odd fit at first, Kristy thrives on managing complex logistics, organizing information, and solving problems. She finds the behind-the-scenes work of building more efficient processes for things like our ambassador program and events very familiar turf. When she’s not tidying up her to-do list, she loves to cook, kayak, and mountain bike.

Once again, you can catch the Auth0 Developer Relations meet-and-greet on Twitch.

This is just one of many Avocado Labs productions!

This meet-and-greet is just one production of Avocado Labs, and I’ll let them describe themselves in their own words:

What is Avocado Labs?

Avocado Labs is a platform where we share expert content about web technologies. Our first approach is through online meetups. We will be hosting bi-weekly meetups which consist of two talks per meetup and each edition will be focussed on one technology. Our first episode was about Angular and more specifically Ivy, the Angular compiler. We had two incredible speakers who are renowned specialists in their fields and Google Developer Experts for Angular: Manfred Steyer and Martina Kraus.

In the future, we want to explore other ways of delivering content and figure out what the community is hungry for! We also want to bring communities closer together and find ways of doing it virtually! If you have any suggestions, please feel free to reach out to us on Twitter.

Why Avocado Labs?

This question is probably the most important. At Auth0, one of our core values is that “We give a sh^* t” and we really do! The technological community is important to us and we know that it isn’t always easy to go to a conference or a meetup, no matter what the reason might be. We believe that anyone and everyone should be able to have access to quality content and to be able to be part of a community.

We also know that right now the majority of the world is on lockdown which means that people cannot go to physical events, speakers cannot deliver amazing content, and communities cannot gather. We want to help in these times by providing at least some of this. But like mentioned above, this is an ongoing initiative. We won’t stop once things go back to “normal” – Whatever that new normal might be.

So, What Now?

Why not join us? To follow up on what we’re up to, you can follow us on Twitter. If you’re interested in attending our online events, we suggest that you join our meetup group. And if you would like to speak at one of our events, please fill out our call for papers. Also, any suggestions are more than welcome! Just send us a direct message on Twitter.

Categories
Current Events Tampa Bay

What’s happening in the Tampa Bay tech/entrepreneur/nerd scene (Week of Monday, December 14, 2020)

Once again, here’s the weekly list of events for events for Tampa Bay techies, entrepreneurs, and nerds. Every week, on GlobalNerdy.com and on the mailing list, I scour the announcements for events that are interesting to or useful for those of you who are building the future here in “The Other Bay Area, on The Other West Coast”.

This list covers events from Monday, December 14 through Sunday, December 20, 2020.

Events — especially virtual, online ones — can pop up at the last minute. I add them to the list as I find out about them. Come back and check this article from time to time, as you might find a new listing that wasn’t there before!

This week’s events

Monday, December 14

Tuesday, December 15

Wednesday, December 16

Thursday, December 17

Friday, December 18

Saturday, December 19

Sunday, December 20

Do you have any events or announcements that you’d like to see on this list?

Let me know at joey@joeydevilla.com!

Join the mailing list!

If you’d like to get this list in your email inbox every week, enter your email address below. You’ll only be emailed once a week, and the email will contain this list, plus links to any interesting news, upcoming events, and tech articles.

Join the Tampa Bay Tech Events list and always be informed of what’s coming up in Tampa Bay!