Programming

That’s cool. Decorators are one of the features I should probably learn more about.

1 Like

There’s something sad about a day of googling to do fairly simple stuff like manipulate an array in bash, finding 20 different ways to do everything (all of them wrong according to the comments under the SO answer), finally getting it working, and still having no idea if you can add or remove spaces at any point in the syntax w/o breaking the code. And instead of something you can be proud of for all that, you get this terror:

#!/bin/bash

# Get Major version from buildpsec.yml
MAJOR_VERSION=$1

# Get array of docker image tags for abcdea/ea-wordpress on our remote hub
IMAGE_TAGS=$(curl -u abcdeabuild:$2 https://hub.docker.com/v2/repositories/abcdea/ea-wordpress/tags/?page_size=100 | jq -r '.results|.[]|.name')
echo ${IMAGE_TAGS[@]}

# Start at patch version = 0 if this is a new major version
INCREMENTED_PATCH_VERSION=0

# If patches already exist, loop over array of DOCKER_IMAGES, save patch version #s to array, sort array, incrememt version #
PATCH_NUMBERS=()
for tag in $IMAGE_TAGS; do
  # split string of format "X.X.X.Y" into array and add Y to new array
  if [[ $tag == "$MAJOR_VERSION."* ]]; then
    echo $tag
    splitArr=(`echo $tag | tr '.' ' '`)
    PATCH_NUMBERS+=(${splitArr[3]})
  fi
done

if [[ "${#PATCH_NUMBERS}" -ne "0" ]]; then
  # sort array
  IFS=$'\n' sorted=($(sort -V <<<"${PATCH_NUMBERS[*]}"))
  unset IFS

  # get last element of array
  HIGHEST_PATCH_VERSION="${sorted[${#sorted[@]}-1]}"

  echo "HIGHEST_PATCH_VERSION=$HIGHEST_PATCH_VERSION"

  # increment last element (patch version #)
  INCREMENTED_PATCH_VERSION=$((HIGHEST_PATCH_VERSION+1))
fi

Such a beautiful expressive language that doesn’t feel at all like 100 completely different paradigms created by 100 monkeys banging away on typewriters. Once you learn a little of the syntax you can pretty much figure out the rest.

Seriously though, in what kind of language is this:

if [[ $tag == "$MAJOR_VERSION."* ]]; then

not equivalent to this:

if [[$tag == "$MAJOR_VERSION."*]]; then

???

So fun that learning each of these things is a few hours of beating your head against the wall, and knowing I have 1000s more to go. People who like bash are masochists.

I’d consider myself easily one of the top 5% bash scripters in the world, it’s a little arrogant sure, but man I’ve written and maintained easily 100k+ lines of this shit over the years. It’s the WORST language but it isn’t the language’s fault. It’s how people try to use it.

It’s meant for quick and dirty type of jobs. It’s not at all meant to be a full blown programming language, and right now as I’m trying to re-write the discourse installer to support kubernetes, it’s a 3000+ line nightmare of bash, that even I can admit is beautifully written - the thing with bash though is it’s usually only comprehensible to the person who wrote it.

any time i see someone trying to manipulate arrays or strings like in the script you had my first question is why the fk would you just not use python?

Well because I don’t know python that well. I also need to run docker commands in the same script (not shown). Is it easy to execute shell commands inside python?

This is AWS codebuild container btw. It comes with node and python preinstalled.

Normally I’d tend to go with node when I get in over my head with bash. But I’d have to install node-exec or whatever to run the docker commands. Right now I don’t have a package.json and no need to run npm install, which slows down the CICD process. So I wanted to just tough it out with bash.

yea it’s less “easy” and readable but you basically just use like system.exec or some shit to run shell commands. exactly the same thing and python can manipulate strings and arrays beautifully.

1 Like

So I’m reading cracking the coding interview which is pretty good but this might be the single most dumb/naive/bad ROI thing I’ve ever read:

The Linux screen of death on my plane

1 Like

ok full stack interview at micro$oft lets go. ~2 days is enough to learn how to optimize mongo performance right? Another job interview successfully acquire due to Hitler btw. Really.

1 Like

it is official. i will be taking my coding talents to google.

13 Likes

grats, go read some xoogler shit if you haven’t already

1 Like

Dunno, I’ve conducted interviews where it was clear someone had encountered the problem before. There’s some amount of acting skill required to pull off making it seem like you haven’t seen the problem before and “working” it in a way that seems like a way people actually engage with problems and articulate their thought process.

So not only did those people strike me as slightly dishonest, they also made themselves look kind of dumb by being unable to articulate how they were approaching the problem.

Yeah I mean for sure you have to sell it but if you have recently worked through something like a LC medium its just a massively huge ROI to fake it to get through the interview and get an offer. To abuse a double negative LC mediums are not asked by companies that don’t pay well.

So what if you decide to bluff and claim you’ve seen the problem when you haven’t, because you have no idea how to do it and you just want a different question. How often do they call?

Love it but if I was giving the interview and had the misfortune of having to ask LC mediums and some dude/gal said that to me I’d almost certainly say “cool since you know the solution walk me through it rq and we’ll move on” yeah.

interviewer:
show me how you would write an algorithm to show that P != NP

2 Likes

I was kind of wondering this too.

That would be my line as well. Both as a bluff catcher and as a small reward for being prepared.

God I suck at leetcode. I don’t even have like a starting point approach a ton of these mediums. I’ve been doing googling and like everyone says it just takes time (grinding). Imagine a surgeon having to do a appendectomy for free while being stared at to get a job.

1 Like

i was saying almost the exact same thing to someone earlier. i’ve come to the conclusion the only way i can improve is by working on “real” projects that focus on whatever i want to improve on, and the more passionate i am about it the better. it doesn’t flex the algorithm puzzle muscles as much, but solving these puzzles was not usually a huge challenge for me, I struggle mightily with the code part.

i dont know why they present so many hard algorithm type problems in interviews, I have yet to see a real world problem that really required this deep type of thinking.

People do it because that’s what’s fashionable at the moment. Back in the day it used to be these bullshit open-ended “puzzle questions” that supposedly provided clues as to the lateral-thinking capability of applicants. There’s an interesting book about this from 2004 called How Would You Move Mt. Fuji?.

People just do whatever industry leaders do out of a cargo-cult mentality because there is no way to separate good applicants from bad in an interview. Some years ago, Google were keeping records of their interview process. When they would hire someone, in addition to approving the hire, the interviewers would predict how well the applicant would subsequently perform in their jobs. They found that the correlation between predicted and actual performance was zero. This led them to overhaul and simplify their interview process.

4 Likes