Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

07-16-2018 , 10:16 PM
Excellent, well done jmakin!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-16-2018 , 11:57 PM
Yea awesome stuff, keep learning, you are doing great.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-17-2018 , 11:31 AM
Any JS people religiously use reduce in place of chained array methods? Specifically filter/map. It irritates me to see things like expressions that push into the accumulator but I guess it makes sense and removes multiple loops? IDK.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-17-2018 , 12:00 PM
I've had the same question, am interested in the answer. I recently used reduce when the use case was comparing two objects for changes and then outputting the changes.

I don't really ever think to use it unless it's a situation like that, where I have multiple things and wanna create a different output, I reduce the output.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-17-2018 , 12:06 PM
+1 nice job jmakin!

I tend to use filter/map when the input is a collection and the output is also a (transformed) collection. I tend to use reduce when the output is some singular object or value. It never occurred to me to use reduce with a collection as the accumulator. It seems like it might be a little surprising given the semantic naming of the functions, and I probably would only do it if it really did have performance benefits and they seemed important, but I don't have a strong opinion.

I think I like the way map lets you just think about what each item in the new collection will be, rather than seeing boilerplate logic for the generation of the new collection.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-17-2018 , 12:10 PM
Quote:
Originally Posted by well named
It never occurred to me to use reduce with a collection as the accumulator.
yeah this is a relatively new discovery for me too and I guess it makes sense as a kind of pseudo forEach that holds its own result? But I've always used it in its literal "boil down" return result before. I wonder about large count arrays if you'd actually see performance increases.. or even how to find that out.

I'm quickly starting to find out that React really doesn't like having arrays of more than ~1000 in the dom and its a common thing in the thing I'm working on which is an api that no one thought "hey we should have built in server side pagination" duh?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-17-2018 , 01:55 PM
This video is quite literally how I learned to use reduce:

** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-17-2018 , 08:02 PM
Reduce when the logic you need to apply to each iteration could depend on an accumulated result.

Simple example might be picking the first x elements in an array that pass some condition.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 02:13 PM
My resume seems to have hit a spam vortex sometime after noon yesterday. I'm getting barraged with calls from people like "Chad", who is clearly calling from Bangalore or something - to offer me a Java job in Northbrook, IL. Cybercoders is responsible I bet. They did actually send me a possible job today - delete.

Other job hunt thoughts:

I talked to Netflix again, they're starting some LA stuff. At least this time I know it's a long shot - and what kind of stuff they're looking for. So don't hold back on my take home stuff.

A recruiter was trying to get me in with Fandango, which I was kind of ambivalent about as my ex works there, it's a drive, and they have a wall of food which will be a constant struggle for me. I wonder how many shops consider that free food might actually be a negative for some? But they said my resume looks "dated". Which is kinda lame imo when they have my ex pitching me as a rock star dev. Who knows if that's the real reason. One role is node+react. Wouldn't most shops be like "Ok you don't have much react, but we have an inside reference that you're a great dev and you have multiple other SPA frameworks, so that's good."? The other role is just straight DevOps with no node, so I can't use node to leverage my way in there.

If I don't get a job in the next week I'm going to go into a cave and built a react-based app with a docker back end and CI/CD flow - then put strong DevOps and react on my resume. I already know the app I want to build.

I didn't get the dysfunctional microservices startup. They wanted a "decision maker". Did they ask me when I'd made decisions? Nope. I didn't want them either. But I wanted them to want me.

I had a phone interview yesterday with a CTO that went perfect I thought until the last question. He wanted to know what I'd done to troubleshoot node latency issues. I actually have a bunch of those but it was clear none of my answers were what he was looking for. I'm expecting to hear back "X company is going to pass. They're looking for someone with more network latency troubleshooting experience." He asked if we thought about switching to rust. No, we didn't think about changing engines on the plane mid-flight, that would be stupid. The job is fully remote which is a) sweet, but b) makes me question how serious they are. Also they still think microservices are the bee's knees, so we had a long interesting discussion about that.

Most unique phone interview so far is a two-person female-run/young-women-focused startup that has a loyal user base and is funded by an incubator. Somehow they've cobbled together the functionality they need with basically no in-house technology. Which is kinda cool imo. Sort of the anti-tech tech company. I always like the idea of using off the shelf before building from scratch, but lol the companies I work for are never willing to settle for even 95% of everything they want. So we build it from scratch every time. She asked me a question that basically was trying to get at how do you coworkers see you, and she clearly wanted not just lollipops and rainbows answer. I told her I was like the dad in Modern Family - gruff but lovable. I thought that was pretty good for off the top of my head.

It's becoming obvious that I'm not going to just walk into multiple instant job offers at the salary I'm asking. They really want all the boxes ticked. Which is understandable. I just gotta try to keep my confidence up.

My recruiter did say that LA companies are super picky about checking all the boxes for some reason. He said he worked in the Bay Area and they were more focused on just getting good people.

I have my first live interview tomorrow for a job I'm pretty sure I don't want. I spent $600 at Nordstrom's on my best attempt at a "CTO outfit". Dress for the job you want lol.

Last edited by suzzer99; 07-18-2018 at 02:24 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 03:21 PM
For the first time ever basically I have to use my own calendar app (not Outlook). So I'm using calendar on my iphone. I realized it would be nice to sync to my Mac calendar. Does it work? Nope. Everyone is synced up to my iCloud account and seems happy. But nothing is getting pushed to my Mac. Off to google.

Just once. Just ****ing once it would be nice of something actually worked.

Did all this stuff - still no sync. https://www.imobie.com/support/how-t...ot-syncing.htm Added dummy events on both ends. Still no sync.

Lot's of weird warnings about deleting data off my iphone though. So there's a non-zero chance I lose my existing calendar and/or contacts. That's nice.

Edit: ok I found the problem. Cellular Data was turned off for calendars and reminders. So my phone wasn't pushing. Yes I am dumb but an indication somewhere might be nice.

Last edited by suzzer99; 07-18-2018 at 03:35 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 03:57 PM
Pretty much everyone I know that relies on iCal is dropping meetings regularly because iCal ****ed something up.

Never had issues with Google calendar though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 04:03 PM
absolutely take a week and learn react/redux and make something using premade components i.e. material-ui/semantic/ant.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 04:04 PM
I actually already did that - for my main job when I evaluated a bunch of JS frameworks. Problem is it was 1.5 years ago and I forgot everything. I would never survive a grilling.

I also did a little for the side job, but we had a main react guy.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 05:30 PM
Just bombed a whiteboard coding session - worst ever in my life. I'm so rusty from 7 months off. I couldn't even remember indexOf. Getting old sucks. I meant to practice more but I got in late last night. Lesson learned.

First we talked about 20 minutes, which went well. Then the interviewer told me that he'd start easy then see how many we got through. Yay pressure. So of course I got stuck on the first problem. After about 25 minutes he basically did the coding equivalent of ushering me off the stage. I really just wanted to solve the damn problem. Of course as soon as we hung up I went and solved it.

Here's the problem I gut stuck on btw:

Code:
// return the first letter that repeats in a string

function findFirstRepeat(input) {
  // code here
}

findFirstRepeat("abcdebcd") // should return "b"
findFirstRepeat("abba") // should return "a"
My solution:
Spoiler:
First problem was I broke the string into an array of chars instead of just doing string manipulation. Once I switched to string manipulation it came pretty easy.

Code:
function findFirstRepeat(input) {
  let repeatChar = 'none found';
  while(input) {
    repeatChar = input.substr(0,1)
    input = input.substr(1);
    if (input.indexOf(repeatChar) > -1) input = null;
  }
  return repeatChar;
}

console.log(findFirstRepeat("abcdebcd")) // should return "b"
console.log(findFirstRepeat("abba")) /


I feel so stupid right now. Good thing I have another big interview in 23 minutes! No whiteboarding though I think. I feel bad for all the devs we did this too now. Although we never put that much pressure or timeboxed them like that.

Last edited by suzzer99; 07-18-2018 at 06:00 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 06:49 PM
Suzzer, am I understanding it correctly that your solution takes the first char, then checks the rest of the string to see if it repeats? Isn't that O(n^2)?

I think if we aren't too worried about solution space, a better solution would be to start with an empty array and add 1 to the index that represents a given char value until we find our first one that repeats. That would be O(n) always.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 06:49 PM
Your solution is O(n^2), there's a solution that should be O(n)

Basically, go through string, keeping a hash between character and number of times seen. Every time you see a char increment it in the has.

Then go through the string again, return the first character that has a count > 1
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:03 PM
I like Rusty's approach but we can early return as soon as we find a character that already exists in our hash instead of going all the way through the string, then doing it again.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:06 PM
Quote:
Originally Posted by fredd-bird
I like Rusty's approach but we can early return as soon as we find a character that already exists in our hash instead of going all the way through the string, then doing it again.
Not true based on the example output.

It doesn't want the character that repeats first. It wants the character closest to the beginning of the string that has a repeat. This requires two passes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:12 PM
I HATE when they mention a q being "easy". Always throws my confidence lol
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:14 PM
Quote:
Originally Posted by blackize5
Not true based on the example output.

It doesn't want the character that repeats first. It wants the character closest to the beginning of the string that has a repeat. This requires two passes.
Ohh, I see that now in the "abba" example. I made an incorrect assumption after reading this: "// return the first letter that repeats in a string".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:17 PM
Yeah the wording of the question as written is not great, I initially thought the same thing.

I actually like the idea of an array of int[256] - it's very language agnostic and in many languages probably faster than a hashmap and the code is likely easier to understand/shorter. You'd have to make sure to say that you are expecting the string to be ascii, wouldn't work for unicode.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:27 PM
Just keep track of the seen characters in a set. No need for keeping track of counts and relooping.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 07:55 PM
Quote:
Originally Posted by :::grimReaper:::
Just keep track of the seen characters in a set. No need for keeping track of counts and relooping.
You have to know which ones you've seen more than once. I think you misread it the same way I originally did. In the string "abba" the right answer is "a" not "b"

i.e. it's "the first letter in the string that has duplicate somewhere else in the string" not "the first match encountered left to right"

Of course there's no reason to count past 2 for any of them but that's an implementation detail.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 08:10 PM
Quote:
Originally Posted by fredd-bird
Ohh, I see that now in the "abba" example. I made an incorrect assumption after reading this: "// return the first letter that repeats in a string".
Yep, same here. Spent about 10 minutes on the wrong problem. Lesson learned, don’t ignore the expected output if it’s given to you.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-18-2018 , 08:27 PM
What kind of data structure could you use that’s like a hash map, but automatically sorted by creation order? You could do that, where the key to the hash map is the letter, and the value is the number of occurrences. Then loop over the word once, and then loop over this sorted Hashmap thing until you hit the first instance with a value > 1. So that’s more like N+x instead of N^2.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m