Programming

Yeah, I had tried that based on some very popular tweet I saw. But it didn’t work. I’m not even sure why it’s happening, because it doesn’t seem to doing it all the time. I’m probably just hallucinating it.

No, you’re probably not - instagram has a seemingly random autorefresh and it will nearly make me throw my phone every time it happens. It’s beyond infuriating.

The one nice thing about the new twitter update (came out a few months ago) is you can click on stuff and not lose your place on the long scroll. That was a nightmare before. You want to see a post or check out a user? Lose your place in line and start over at the top. Much better now.

1 Like

Is there some reason why this won’t work?

Object1List.forEach(o1 => {
  obj2terms = Object2List.filter(o2 => o2.number === o1.number);
  // do some transformation on obj2terms here  
  o1.Obj1Terms.push(obj2terms);
})
1 Like

Yeah if you care about mutation you’ll have to make copies I guess. Hopefully these lists aren’t gigantic (filter probably isn’t very efficient either).

And actually I changed my original answer from map to forEach - since you don’t care about a big return value.

If you don’t want to mutate anything you could do something like this:

const newObjList = Object1List.map(o1 => {
  const elem = { 
    number: o1.number,
    Obj1Terms: [...o1.Obj1Terms]
  }
  obj2 = Object2List.filter(o2 => o2.number === o1.number)[0];
  // make a copy and do some transformation on obj2terms here  
  elem.Obj1Terms.push(obj2TermsCopy);
  return elem;
})
1 Like

Any time.

Typescript man - still not sold that it’s worth it.

2 Likes

hey I am glad we are taking the programming Q’s and discussion here. Because I think everyone from 22/programming is in here except adios of course (which actually sucks because I think he’s one of the most knowledgeable programming posters). I stick around mostly for that programming thread so if it was here, it would be really nice. That thread is monumentally helpful to me.

2 Likes

Not a programming thing, but what free password manager do you use/trust?

An unencrypted text file with mnemonics that hopefully only make sense to me.

Chrome

That’s $2/month! You have giant copper pipes and pay crazy fees to store passwords!

I don’t really like any of the options. I don’t like my browser remembering passwords and I don’t like having to go into some software to get a password that I can’t remember. I think I’m just going to use the long password I remember and infuse it with something specific about the site it’s for, but something slightly tricky (the site name backwards after the first letter of my reg pword or something). Then every password is unique enough and I can still remember them/figure them out.

1 Like

What if I’m on someone else’s computer?

For my passwords that wouldn’t matter if they got cracked, I let my browser (firefox) remember them. I enable FIPS to make it a little better, and a master password to unlock the saved pw’s.

For more important pw’s that I use often, I use a string of random words which I choose via random Wikipedia pages. Such passwords are easy to remember if you use them somewhat often.

For important pw’s that I seldom use, I use pw’s generated by KeePass. For keepass I have a master pw of 20 random chars, which is the only ridiculous pw that I have memorized. It used to be the pw for my college email, so I used to type it so often that it became baked into my muscle memory.

I’m also the weirdo who uses strings of random characters for my answers to security questions, so I have those saved in KeePass as well. I have my keepass db’s backed up on multiple drives that I don’t keep all at one location.

Yes that is best practice javascript for what you are doing (a hashmap). No conversion needed.

1 Like

myFunction(name: ObjectNamesEnum, myList: MyObject{} {

maybe?

1 Like

Well then you’re boned afaik. If it gives you a list you’ll have to do list functions (find) on it. It should give you a hash :roll_eyes:

1 Like

I’m inferring that myList looks like this: [ { name: ‘a’, dataIWant: ‘bar’ }, { name: ‘b’, dataIWant: ‘baz’ }, …]

If so, then the two versions above are not equivalent. It’s not a typescript thing, it’s just a javascript thing. It’s not clear to me what’s undesirable about just using .find(), but if you want to be able to reference one of the objects in the array by its name then you will have to map the array to a new object with the named properties.

I see I’m ponied, but whatever.

1 Like

Find is O(n), a hashmap is O(1).