I’m not going to lie, I am not very certain as to what to do here… How does one remix code? Hmm…
Actually… Hello, StackOverflow!
It’s a love-hate relationship a developer has with StackOverflow. A programmer’s paradise or hell, paradise if you find the exact code snippet or solution you are looking for, hell if you post and you get a bunch of comments about how your question is stupid (another meme about stupid questions).
What I do every day when I “borrow” code from StackOverflow is essentially remixing. I take what they present and add, subtract, and modify what I need to fit into the big picture that is the program. Like a song remixed with other snippets of songs, or a new rendition of a song, or an autotune song of some poor fellow trying desperately to become a Jedi, remixing code is really quite similar. Let me show you!
This is my problem, like those super relatable and very useful wordy math questions we all loved in high school, I have TOO MANY FLAMINGOS. I am yelling because I cannot keep track of them and honestly I am this close to sending them to a river upstate (upprovince??). To calm my frail nerves, besides popping alprazolam, I decide to keep a list of all my flamingo’s names, and I want to sort them in reverse alphabetical order. Why does this help? I find the end of the alphabet soothing (I like introverts).
Today we are using Typescript. Here is a string array of the names of my flamingos:
var myFlamingos = ["scotty", "rotty", "one eye", "begonia", "flabber jacks", "hakuna", "ma ta ta", "what a wonderful phrase", "pink", "rubber duck", "josh"];
Cool, now what? I have suddenly forgotten how to sort this list in reverse alphabetical order. Help!
Let’s hop over to StackOverflow. Actually, correction. Let’s hop over to Google to find what we need on StackOverflow because StackOverflow’s search algorithms are crap:
That second link looks promising!
Bam it’s right there:
steal “remix” it and put it into our code:
var myFlamingos = ["scotty", "rotty", "one eye", "begonia", "flabber jacks", "hakuna", "ma ta ta", "what a wonderful phrase", "pink", "rubber duck", "josh"]; var myDescFlamingos = myFlamingos.sort().reverse(); console.log(myDescFlamingos.toString()); // let's log these bad boys
And this is my output:
what a wonderful phrase,scotty,rubber duck,rotty,pink,one eye,ma ta ta,josh,hakuna,flabber jacks,begonia
Ahhh, relief. I can feel myself sinking deeper into my ugly ergonomic mesh office chair already.
I like to make jokes about stealing, but for those that are not programmers, it’s not really stealing, it’s “sharing and obtaining information.” If you asked any programmer if they could fix what they needed to fix without StackOverflow, they would probably scoff like it’s no big deal and then hobble into a soothing corner of their mom’s basement to begrudgingly read the man pages/docs and drink stale mountain dew (I don’t know).
Anywho, thanks for reading!