« first day (4262 days earlier)      last day (909 days later) » 

07:39
const
    getTask = s => s.split(' - ', 1)[0],
    uniqueBy = fn => s => v => (w => !s.has(w) && s.add(w))(fn(v)),
    data = ["task A - memberA", "task A - memberB", "task B - memberA"],
    result = data.filter(uniqueBy(getTask)(new Set));

console.log(result);
An answer on a newbie's question...
Like wtf, how is he supposed to understand what's happening there?
downvote
I obviously did :D
But considering the 350k rep that user has...
eh is that the obscure-person-I-shall-not-name?
Obviously
08:14
@Cerbrus I didn't need to read that to know who you mean. The code is pretty distinct.
I've added an answer there... It can be so much more simple
But yea, that user has a talent of making things overcomplicated
Also, today, in how not to explain an answer:
hint:
some method returns true or false
includes method return true or false
substr method return sub string from string i.e task name
refer MDN tutorials for more details
@Cerbrus heh, you have to admire the amount of knowledge required to even get a grasp on what's going on here
@Cerbrus rhymes with creamer?
Hm no
Rhymes with Bolts
Boltz!
08:23
creamer bolts
anyways, I aint debugging that if the output is not expected
won't pass my CR
*Creamah
If you pronounce it with a thick aussie accent xD
I pity the team that has to work with her code though
To be honest, I admire a lot of the code she does. It's interesting. Even if it might not be the best or the clearest one.
Shit like that won't fly where I work. "Dude, don't overengineer that shit, just use a filter"
But wouldn't want it as production code, though.
08:27
To be honest, I don't
she's got a massive library of utility functions, like that uniqueBy
Jam enough of them into one snippet and you'll get your desired output eventually
@NDC8 I suggest you to upgrade js part of your brain. have a look at the answer for second case. — Vikas Acharya 2 mins ago
Lol what?
> I suggest you to upgrade js part of your brain
lol closed it
what a fucking shit question
Just do a matrix-style download! "I know JS!"
Yea, only reason I answered it is in a hope to drown out the crap
(I can dream rite?)
I added another example, could you please help me solve that one? — NDC8 12 mins ago
he went far lol
@Cerbrus Reminder to take your regular medical checkup. It's best to detect JS in your brain early if it is to be treated.
Isn't JS chronic?
08:35
gotcha request for facilities, working at 80% of time with full salary! I have a js chronic disease dammit!
@Cerbrus It's asynchronic :P
3
@VLAZ Ba-dum-tss
09:26
I'm fighting with React :/ ...please check this:
<Button onClick={removeFile(file)}>
    Remove
</Button>

{props.duration < minSec ? () => removeFile(file) : <h6>Too short.</h6>}
why the hell the button is OK (remove the file when clicked) but the array function doesn't work (() => removeFile(file))
it's not fired at all
() => removeFile(file) isn't calling a function
That like var fn = ()= > removeFile(file), which you would still need to call: fn()
what you did is creating a function object. That's all
09:53
Thanks, but how can i do? I need to call 'removeFile()' when that condition is met. Or it's not possible? I tried inside useEffect and still not work
To call the function just use removeFile(file)
Remove () =>
if the function is in the same component, just call this.yerrFunction()
10:13
I see...but there's another problem, the function does nothing and from console I got this: "Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it."
does that removeFile function return a React Element?
if you're in a rendering component, react expects only react elements there
just have it returning something like <p>File removed</p>
(also, imo you need to rethink your design a bit, this is not an appropriate place to manage files)
look around for some examples in blogs / react docs
10:35
> If the problem is readability, you could probably try object destructing. So, your assigment would look something like this:

> const {
> student: {
> age = ''
> } = {}
> } = data
Ugh, hate chat formatting
> If the problem is readability, you could probably try object destructing. So, your assigment would look something like this:
const {
  student: {
    age = ''
  } = {}
} = data
So, yeah, if readability is the problem, I don't think destructuring is more readable here. For the record, the context is replacing the optional chaining in const age = data.student?.age ? data.student.age: '';
I tried in any sauce, still not work.
    const removeFile = file => () => {
        console.log('filetoRemove', file)
        const newFiles = [...files];
        newFiles.splice(newFiles.indexOf(file), 1);
        setFiles(newFiles);

        return <p>File Removed</p>
    };
never fired
of course I already checked the condition
4b0
4b0
10:52
where you call that ?
Before ask debug and console matter more ........... otherwise everything is guess
11:27
@4b0 I said that...the condition is met, because if I render a string instead of call the function is fine. The function is fine too, since I can call onClick from button. So what's I'm not debugging?
11:54
today all is a piece of s***... maybe cause it's friday 17th, I don't know
const files = acceptedFiles.map(file =>
                Object.assign(file, {
                    name: props.name,
                    preview: URL.createObjectURL(file)
                })
            );
            setFiles(files);
TypeError: Cannot set property name of #<File> which has only a getter
Thanks React for the wonderful day
This works if I remove this line: "name: props.name,"
what the heck
arghhhh
it was because 'name' was already set as variable!
12:12
Which if any can be closed as duplicates?
https://stackoverflow.com/questions/41532889/add-a-line-in-between-two-lines-in-a-file-from-bash
https://stackoverflow.com/questions/8971314/how-to-insert-a-line-in-a-file-between-two-blocks-of-known-lines-if-not-already
https://stackoverflow.com/questions/22497246/insert-multiple-lines-into-a-file-after-specified-pattern-using-shell-script?answertab=scoredesc#tab-top
 
1 hour later…
13:26
hello
@berriz Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
so basically i have this function to make a json object out of a char string
@berriz Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
@berriz Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
    const stValids = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

    function mapCharStringToJSON(string) {
        const strCharArray = string.split('');
        let JSONobj = new Object();
        let i = 0;
        for (let char of strCharArray) {
            JSONobj[char] = i;
            i = i + 1;
        }
        const JSONstring = JSON.stringify(JSONobj);
        console.log(JSONstring);
        return JSONobj;
    }
// output: {"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,"a":0,"b":1,"c":2,"d":3,"e":4,"f":5,"g":6,"h":7,"i":8,"j":9,"k
@berriz Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
13:32
and a function to get the numbers of the letters
@berriz Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
1 message moved to Trash can
function shift(string) {
    const stringArr = string.split('');
    for (const currentChar of stringArr) {
        const a = alphabet[currentChar];
        console.log(a);
    }
}
/* expected output:
7
4
13
11
14
output:

*/
i was running shift(inputString);, inputString being the arguments, and the code was ran using node index.js henlo
You know that split gives you an array and arrays have .forEach functions to go through each elements?
but since you're splitting on empty string, you should better to just loop through the string itself
for (const char of yourString) { ... }
 
1 hour later…
14:45
@AncientSwordRage Dunno, I'm not an SME on bash/sed. I've at least used the tools.
But on the other hand the bash tag and family are "weird". Something tagged bash + sed usually means "I'll take any command line tool".
> To edit the file in-place with original one backed up with a .bak extension: sed -i.bak
:O
So this one's fun. I'm working on a mobile app, trying to send a midi message that needs to be sent over two messages with bluetooth to a bluetooth chip that combines the two messages into one and sends it in to the hardware as midi
That's awesome.
Never knew you could edit into a new file like that.
both messages have the same opening sequence, and yet somehow, sending both messages results in an entirely different action occuring on the device
it's like pressing start button causing the trunk to open
There is a midi command for causing the other action to occur, but it doesn't even have a similar opening sequence
and... the old app works just fine, so i know it's gotta be me sending the wrong message
i wish i had a way of seeing what it was receiving
15:03
No debug option?
That sucks.
nope. it's hardware from 2015, all the test articles are long gone
i can see what i'm passing to flutter, and convert that into the hex values that represent the integers i'm seeing to confirm they're all the same values the old app is seeing, but, it doesn't come out that way
(i do have the sourcecode for the old app)
I've confirmed with a dev who built the hardware that my message lengths and all are correct,
15:30
hmm... i wonder if this is an ios vs android situation
15:41
does void 0 means undefined?
I have not quite get it
@DimitrisPapageorgiou yes
does the below mean that the right operand does not equal to undefined then?
void 0 !== u.ownerSVGElement
It's the same as undefined !== u.ownerSVGElement
hmm...I was about to ask just this,,,why would someone use void 0 instead of undefined?
There is almost no reason for a human to do it. But minifiers do this all the time
||> "undefined". length - "void 0".length
15:50
@VLAZ 3 Logged: [ ] Took: 1ms
@VLAZ I am not surprized by your answer...thx
There are very few cases I can think of the void operator being used by a programmer. And they are mostly hacky anyway. I don't think there is anything you can use void for that can't be done better without it.
@VLAZ true, I use it often, and I am not a human. There is no reason for a human to use it indeed
What do you use it for?
@DimitrisPapageorgiou void 0 used to have a use case when undefined was writeable to get the "true" undefined, nowadays there's no real reason
15:54
@OlegValteriswithUkraine Just to keep you on your toes - it's sort of writeable still. Hacky but can happen.
@VLAZ just as a shortener, honestly
||> ((undefined) => console.log(undefined) )(4)
@VLAZ undefined Logged: [ '4' ] Took: 0ms
@VLAZ that's cheating :)
Yeah, I guess. But still - not something you can do with null
15:56
although that's nice to keep in the back of my mind - I forgot it is still a valid identifier as a parameter name
Yeah, remember it. Just in case you hate the people who would maintain your code in the future.
Even if that's just you.
I wonder if it exists anywhere in real code. Oh, well, who am I kidding, of course it does
I dread the day I find this somewhere.
I feel it's inevitable.
|| pizza or pizza
let's check GH
@VLAZ did you just break James?
15:58
Did I make that too hard of a choice for James?
|| choose pizza or pizza
pizza
15:59
no, it's just the image
eh, @JamesBot, are you all right?
It's contating something called "lorempizza" and that site seems to be down or something.
|| status
I am currently alive!
But how are you? Feeling well?
@JamesBot bold of you to claim that
Look, we don't existence-shame here
16:02
lol, "\(undefined\)" broke GH search
did you try defining your search criteria? :P
heh, reminds me of me not reading "do not put * at the start of the search query" on a site which resulting in bringing it down for about an hour
OK, I don't know what people in this room thing about pineapple on pizza (I don't mind but also don't buy it) but here is something I just found: pizza with figs.
The ingredients state: tomato sauce, prosciutto crudo, figs, parmesan
btw, we have an italian cafe that experiments with pizza every week - recently they made one with beetroot pesto (quite delicious, though)
Hi everyone, do you know how to prevent TerserWebpackPlugin from dropping an unused variables when processed by WebPack?
for example:
I define a variable and used to define a css position with js but when I minimize this Script TerserWebpackPlugin remove this variable.
```
const SCROLLTYPE = '';

' position: ' +
SCROLLTYPE +
';\n' +
```
16:11
@OliviaP. Hmm, apparently there is a property called unused which has to be set to "keep_assign" to prevent this.
At least according to something I found on Terser
But let me see if I can find how the webpack plugin is supposed to be configured.
@OlegValteriswithUkraine Bug fan of pesto. I'd love to try beetroot one.
@VLAZ it was pretty cool - I even asked for the recipe - the only difference (apart from the beetroot, ofc) turned out to be the use of walnuts
and the pizza had actual walnuts on it
module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          compress: {
           unused: "keep_assign"
          },
        },
      }),
    ],
  },
};
@VLAZ Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
finally fixed it...
@OliviaP. See above - that is supposed to disable the behaviour, from what I read
16:21
@OlegValteriswithUkraine Heh, that's the old-school one that was used to protect from global undefined overwrites
On the other hand that eval...
@VLAZ yea, I was surprized to find it reasonable (although void 0 is still better, IMO)
lol, I didn't even read the comments. Yeah, it's explaining the "closure pattern" where you protect yourself from random hijacking of # or undefined :D
12 years ago, so it checks out.
 
1 hour later…
17:36
posted on June 17, 2022 by Ben Mason

Hi everyone! We've just released Chrome Dev 104 (104.0.5112.10) for Android. It's now available on Google Play. You can see a partial list of the changes in the Git log. For details on new features, check out the Chromium blog, and for details on web platform updates, check here. If you find a new issue, please let us know by filing a bug. Erhu Akpobaro Google Chrome

 
1 hour later…
18:41
Hi all
Is there a way in a web app that calls various webservices in JS to tell what's the bottleneck and why?
There are the Chrome dev tools but wondered if there are other tools
19:01
For the page the browser tools should be really good. Since they give you direct information of what the browser loads and in what sequence and what data was transferred, was it cached, etc.
19:12
I think devtools is the best tool for inspecting that info, yeah
Okay, just checking. Thanks :)
19:28
I guess there are profiling tools specific to frameworks and such, but, frankly, never used any
Yeah, usually the easiest is the best
20:00
posted on June 17, 2022 by Prudhvikumar Bommana

 The Dev channel has been updated to 104.0.5112.12 for Mac, Linux and Windows coming soon. A partial list of changes is available in the log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Prudhvikumar Bommana Google Chrom

 
2 hours later…
21:43
I found this proposal interesting: Set methods. It's about adding support for set operations like union, intersection, etc. setA.intersection(setB) seems good to have.
@VLAZ that is a very, very, very nice-looking proposal. I can't fathom why the built-in Set hasn't received all those from the start
From the start, it was more important to be added to ES6. I can understand cutting down features to MVP to get in there.
But it's been 7 years and these haven't been added...
both Map and Set are sorely missing a lot of QOL methods
 
2 hours later…
23:50
hi folks
sorry for bothering you again but I've tried to keep it distant and see if I can do it on my own
So, I have this code for a Newton's method calculator and I'm having two problems --
function Newtons_Method(e) {

e.preventDefault();

var ivalue = document.getElementById("ivalue").value;
var eqvalue = document.getElementById("eqvalue").value;
var dvalue = document.getElementById("dvalue").value;
var inneranswer = document.getElementById("answer");

var answers = [];
var answer = parseFloat(ivalue); // This is the starting value
var z = 0;

// Let's start this whole thing offscreenBuffering
var newEqValue = eqvalue;
var newDValue = dvalue;
alert(newEqValue);

while (z < 10) {
Tbhe problem I'm getting write now is this line:
answer = answer - (eval(newEqValue)) / (eval(newDValue));
is generating an unexpected token.
And the second problem is something really obvious I"m missing about Javascript, how do I create a new string and get it to mutate properly?

« first day (4262 days earlier)      last day (909 days later) »