« first day (512 days earlier)      last day (940 days later) » 

12:00 PM
Yes. They're not using earphone. They use the effing speakers :(
 
yes, I've been noticing it more and more actually - worse, talking on the phone on speakers
 
@CodyGray Most don't. But you always have one generation that's trying to make the point that the rules don't apply to them. They're not mature at this point and there's no reasoning with them. They also don't have means to not use public transport (apart from bicycling, but they're at that lazy age.. )
 
@OlegValter I can't hear anything on my phone now unless it's on speaker.
So if I forgot my earbuds and I'm out in public and need to take an important call, I have no choice :-(
@Scratte Hard to listen to YouTube videos on a bicycle, no?
 
I do not think that all the conversations I heard so far did not have a choice :)
 
@CodyGray No.. people to that too. They just keep the phone in the pocket. They use earplugs though :)
 
12:03 PM
unless their relatives are monsters
 
I think there is probably pocket lint crammed into the phone's speaker (the one you put up to your ear).
But I can't see it and I can't get it out.
I did successfully fish a bunch of pocket lint out of my phone's charging port a while back. Now, the charger plug makes a satisfying "click" when inserted, instead of wanting to fall out. :-)
Productive tasks that Cody can do during a meeting...
 
I don't listen to music when I bicycle at all. I want to hear the traffic.. I don't like it when stuff comes out of nowhere. Like cars from behind me.
 
Like the bass drop?
Oh, right, cars. :-)
If they're electric, you won't hear the cars anyway, though.
 
I always check traffic around me. It's saved my life (or health) a few time..
@CodyGray Yes you do :) There's a law that says electric cars have to be noisy at less than 20km/h now. They have speakers for that. They emit a low humming sound.
 
Haha, really?
 
12:07 PM
A few blind people were hit.. so they made the law especially for blind people.
 
Oh yeah, that's a thing in the US, too, apparently. I did not know that.
 
Because at low speeds they're really completely silent, and people would just walk out just in front of them
 
WORKING!!
Now... Should I just change the const to a let, or should I use Oleg's code?
 
time will tell, time will tell
 
Haha. What?
 
12:13 PM
my fingers are currently itching to type "ignore" to test bot's new user blocking functionality :)
@CodyGray sorry, I couldn't help myself
 
@OlegValter help
 
@CodyGray what would you like to get help on?
 
what to do
 
@OlegValter What?
 
Oleg was making fun of me :-(
 
12:17 PM
@CodyGray sorry, cannot tell you what to do. I can answer common questions about JavaScript, TypeScript, HTML, CSS, Node.js, and Apps Script. Type @Oleg help for more info
 
@Oleg help
 
@bad_coder That to me is a sign of a terribly poor country.. that in many cases are causing their own problems because no one respects the laws of the state.
 
@KevinM.Mansour what would you like to get help on?
 
@OlegValter What's Apps Script?
 
@OlegValter Why are Scratte and I sharing a brain?
 
12:18 PM
@CodyGray Which one are we sharing? :)
 
@KevinM.Mansour Apps Script is a server-side JavaScript-based programming language developed by Google
 
@OlegValter Oh yeah, by the way, we get a bunch of low-quality help-desk style questions about that on SO. Maybe you could take care of those? Kthx.
 
@CodyGray Nice. So, you're not the only person that making fun of people now. ;)
 
ok, joking aside
@CodyGray I used to take care of those
it got too depressing
so I moved to TypeScript where I am happy :)
 
@OlegValter Wow. Very informative. Never heard about Apps Script before.
 
12:22 PM
All this time, and you've been writing Apps without a Script?
 
want to witness the true horror?
it is a synchronous JavaScript-based language
 
@CodyGray What does the "K" mean "Kthx"?
 
@KevinM.Mansour OK
        let flagInfo      = dismissLink.parents(".flag-info");
        if (!flagInfo.length)
        {
           flagInfo = dismissLink.parents(".comment").find(".flag-info");
        }
 
KTHX may refer to: KTHX, a radio station (94.5 FM) licensed to Sun Valley, Nevada, United States KWEE, a radio station (100.1 FM) licensed to Dayton, Nevada, that had used the KTHX-FM call sign from 1997 to 2021 kthx, internet slang for "okay, thanks" KTHX, an alumni association at KTH, Royal Institute of Technology, Stockholm Sweden
 
What's the shortcut for that?
 
12:25 PM
@Scratte well there's the difference, music isn't noise. And live music isn't a boombox. And expecting silence in public transportation isn't realistic, and so on...
 
Is there some kind of empty-length coalescing operator?
 
nope
 
Hrmpf.
 
@bad_coder Noise is subjective! Which is the entire point.
Maybe I like to listen to screaming babies. And then it's not noise to me. Would you want me setting up a boombox in a buss with the sound of screaming babies?
 
@CodyGray Oh. OK. :)
 
12:27 PM
That's where that sound always comes from on buses?!
Damnit, Scratte!
Sometimes you are even on my airplane flights!
 
@CodyGray well, sorry :( Does such an operator even exist?
 
@CodyGray You started to write UserScripts?
 
I could also just play an instruments and make it live. Playing only out of tune song. And screaming out of tune on the already out of tune "music". Does the fact that I like it, make it "not noise"?
Or team up with a buddy playing the tuba.. :D
 
@Scratte you've certainly set up your chatter box in chat :P
 
@OlegValter Probably!
 
12:31 PM
@bad_coder I used to have this argument with a neighbor claiming that "their" music wasn't "noise". But since it's unwanted by me.. it's most certainly noise to me.
 
@KevinM.Mansour I've been writing and maintaining them for a long time
@Scratte I can play the tuba!
 
@CodyGray well, I mean, we did get a nullish-coalescing operator, but I never heard of an operator that only proceeds if the collection is not empty (which would be cool to have, come to think of it)
 
@Scratte well, in the house hold (as well as the street) noise levels are regulated. The neighbor is free to listen to music provided the dB's in your house are below a certain level.
 
@CodyGray You can learn, or better not really learn. Just blow into the thing.. then we can find bad_coder and play "music" for them :D
 
@OlegValter Yes! Because I want to write that as a const declaration!
 
12:33 PM
@CodyGray Nice.
 
@Scratte No, no. I mean... I can actually play. Or, I used to be able to. Haven't played in years. So I might not be very good now. But I used to be reasonably good.
 
@bad_coder In my city there's actually laws about unnecessary noise. Which includes people screaming and music. It doesn't include noise coming from construction because it's not possible to remove the noise it makes. But it's very possible to talk instead of screaming and you can just turn the boombox off.
@CodyGray I'm impressed. Also.. Ii misread. I don't just write out typos, I read typos.. or rather stuff that's not there :D
 
@CodyGray I get your pain :) However other than twisting the structure a little to avoid mutation at a cost of an even uglier construct, nothing can be done here, methinks
 
@Scratte I'm afraid that there's laws about breathing in your city.
 
@Scratte It was not my principal instrument. My principal instrument was the euphonium. But I could also play the tuba. And bass trombone once, in a jazz band.
 
12:35 PM
@Scratte that's measured in dB's unecessary being subjective.
 
@KevinM.Mansour There surely are! Laws about air quality and pollution, to protect the right to breathe.
                    let   ids  = flag.data("flag-ids");
                    ids        = ids.split ? ids.split(';').map(id => +id)
                                           : [ids];
That looks like a mess, too.
 
@bad_coder The boombox must be turned off on construction sites.. to reduce unwanted noise. Anyone is allowed to pick whatever noise they want to listen to as long as it's not forced onto others. And making something make noise just for the sake of the noise is very mush avoidable.
 
@CodyGray why is there a check for split? :)
 
@Scratte you know what a dB is?
 
@bad_coder And to be very honest about it. I don't care what you like.. not everyone will like it. So turn it off.
 
12:38 PM
@OlegValter I do not know. You are the JavaScript expert: you are supposed to tell me!
 
@Scratte you get 10/10 for tolerance.
 
Seriously, I assume(d) it is/was there to check whether the item is empty?
 
@KevinM.Mansour There is. It's a law about pollution. Everyone must be able to breathe.
 
:-)
 
@CodyGray no, there is no need, the check is ingrained in the split method
it actually checks...
 
12:39 PM
So what's that [ids] thing? Making an array out of it? Does it need an array made out of it? Maybe it isn't already an array?
 
that ids is an array
 
@Scratte I meant something different but yes, surely there's. :)
 
but in a very peculiar way
 
@bad_coder It's not about tolerance. Tolerance to noise is already being applied with all the noise that's unavoidable. This is about respecting others and not forcing them to extend the tolerance to things that they don't have to.
 
I also have to mention that .map(id => +id) is the same as .map(Number) :)
 
12:40 PM
@Scratte yeah, like other people's reasonable and moderate exercise of freedom.
 
so...
 
@bad_coder You are free to listen to whatever you like in your earplugs.
 
@OlegValter Therefore... const ids = flag.data("flag-ids").split(';').map(+id); is equivalent?
 
.map(+id) is an error :)
 
But... you said...
Hmm. What's Number?
 
12:42 PM
+ operator is not the same as constructor function
very similar, but not the same
 
+ operator doesn't implicitly convert something to an integer?
Hmm, I guess this isn't C.
 
no, it converts everything to a float :)
 
Ack. Well. Same difference?
 
@CodyGray joking aside - .map(+id) is wrong because it is "map with a callback that is a result of converting id to number"
 
12:43 PM
@bad_coder I'd file a complaint too. Even if I liked the music.
 
whereas Number is a function - a callback that accepts one parameter and returns a number from it
so... these are equivalent:
Number(id) and +id
and these thus are:
id => +id and Number
and thus when used in .map:
 
@Scratte it's a good thing we have freedom and it's a fundamental right.
 
.map(Number) and .map(id => +id)
 
@bad_coder I think it's no secret that we don't much agree on a lot of things.
To me freedom does not mean: You have a right to annoy and bother other people.
 
const ids = flag.data("flag-ids").split(';').map(Number);
is exactly equivalent to the original?
 
12:47 PM
not exactly :)
 
:-(
 
that depends on what the heck is going on with the result of calling data("flag-ids")
 
Space-separated string of numeric IDs?
 
I suspect it can return either a string (which can be, well, split) or... something else
 
This is a data attribute. How could it return something other than a string?
Blah blah because JS is not strongly typed blah blah suckage.
 
12:49 PM
@CodyGray except that I think it is a jQuery method :)
which I suppose can return whatever
and that's why the check for split is there. Still off-putting to me
give me a moment
 
Timer started
 
ah, yes, 'tis definitely jQuery
my question is... why not typeof ids === "string"? the idiomatic way to check types
 
Dude, remember what I said about this being written by a C++ guy?
No chance that they know the idiomatic JS way of doing anything.
 
well...
kind of JS 101 :) but they might've liked the brevity of looking for a method name
 
I might like the brevity of you just telling me the code that you think is correct :-)
 
12:55 PM
oh, come on, let an old hag to chat a little, will ya? :)
 
I'm letting Scratte say everything he wants to say!
2
I've even stopped typing it before he gets a chance.
 
it's... too much fun :)
joking aside, I am trying to understand the check myself to tell you what I think could be done
where's a really helpful comment when one needs it? :)
 
What do you need help with? What, specifically, is not working in your code? Please edit your question to clarify. If you haven't already, please review our advice on creating a minimal reproducible example. — Cody Gray ♦ 21 secs ago
In fact, I just wrote one!
 
@CodyGray Huh? :)
 
1:00 PM
What I do not understand is why do a check for a split method and then still shove the ids value into an array if it does not have one
 
Because you want it to be an array? So if it's an array, it has a split method. If not, then you want to make it an array.
 
and now for a revelation
arrays do not have a split method
only strings do :)
 
Huh.
OK.
So, if it's a string (has a split method), split it, making it an array. If not, make it an array.
Seems logical.
 
yeah, it does, I just do not understand what else could it be :) A number, I suppose?
 
Yeah, likely
 
1:03 PM
the only reasonable explanation on my mind
ok, having established that..
 
Array.from()?
 
nah, there is no need
 
@CodyGray Just don't wear pants..
 
It needs to be an array!
 
There's a splice method for arrays, no?
 
1:05 PM
but Array.from is for converting iterables into arrays :)
 
Iterables. I see.
 
so... having established that, the conclusion is that apart from being a bit more semantic with typeof ids === "string", there is really nothing to be done
 
Heh
Fail.
 
I mean
(A) This was a ridiculous amount of work to conclude that there is no change/improvement possible.
(B) I'm irritated again that I have to have a non-const variable for something that is logically constant.
 
1:09 PM
well, you can call data() twice - re:(B)
 
Why would I want to do that??
 
to avoid irritation of having a non-const variable at a cost of irritation of having a useless call :)
 
Screwed comin' and goin'.
 
so pick your poison :)
this is why I avoid working with jQuery nowadays (as there is really not that much need for it to be cross-browser)
you could just as easily do:
[...document.querySelectorAll(".flagged-post-row .flag-row")]
and then map over it while accessing data attributes on a JS representation of each element
.map(({ dataset }) => { const ids = dataset["flag-ids"]?.split(";") || []; // do everything else })
 
Idea was to get less ugly...
2 hours ago, by Oleg Valter
(() => {

    const doPost = () => Promise.reject();

    const retriable = (retries = 0) => {
        doPost()
            .then(() => {
                // all ok, proceed
            })
            .catch(() => {
                console.log( `attempt failed: ${retries+1}` );

                if(retries >= 5) return;

                retriable( ++retries );
            });
    };

    retriable();
})();
OK, so I'm going to do this ^^
 
1:17 PM
@CodyGray are you sure it is uglier than:
fp.find(".flag-row")
                            .map(function () {
                                const flag = $(this);
                                let ids = flag.data("flag-ids");
                                ids = ids.split ? ids.split(';')
                                    .map(id => +id) : [ids];
and this is what it turns into (basically):
[...document.querySelectorAll(".flagged-post-row .flag-row")]
.map(({ dataset }) => {
    const ids = dataset["flag-ids"]?.split(";") || [];
});
 
Oh, you're replacing the whole thing. Hmm.
I don't know. I tend to find the first one more readable?
 
maybe I am just too far gone :)
ugh. Forgot to map to numbers, sorry
[...document.querySelectorAll(".flagged-post-row .flag-row")]
.map(({ dataset }) => {
    const ids = (dataset["flag-ids"]?.split(";") || []).map(Number);
});
 
In your Promise code, why are you using then and catch instead of fail and done?
 
because then and catch are native promise methods and fail and done are methods on jQuery's Deferred object :)
 
Ah.
 
1:22 PM
yeah
 
Problem is, the migrateTo helper function returns the jQuery thingadongdong
 
they have the same operational meaning, though
 
And I don't want to change that
 
@OlegValter If you attach something via $el.data("foo", bar) then $el.data("foo") returns the same data you attached. E.g., array, or a plain object or whatever. Otherwise, if just reading a data-* attribute, it returns a string. Not a fan of this after I found jQuery was doing it. Means that you can get inconsistent data.
 
yeah, I took a quick look at the docs - been a long time since I used any of this
I really don't like the "I am so helpful I will get you a gun and shoot you if you ask me" features
 
1:24 PM
@OlegValter Might be a single number, I assume.
 
keep reading, almost there :)
 
Ah, OK, will get there soon.
 
we got to the same conclusion and thus, well, I do not see any venue for optimization
 
Oh, by the way
 
@CodyGray you don't need to
 
1:26 PM
I know now why I am retrying in a loop....
 
I only used then/catch because it makes for a runnable code out of the box
 
Because if the question is closed, migration fails, so I have to reopen it first. The code does that. But then it needs to try again.
Instead of copy-pasting the code again and putting it after the reopenQuestion call, I just put the whole business in a loop.
Soooo.... you'd probably say the code to migrate should be in a functor.
 
good guess :)
 
:53256732
Array.from(document.querySelectorAll(".flagged-post-row .flag-row"), ({ dataset }) => {
        const ids = (dataset["flag-ids"]?.split(";") || []).map(Number);
    })
^ also possible
 
wait a sec...
 
1:29 PM
Ugh, can you quote and post multiline code at the same time?
 
@VLAZ Nope!
 
oh, wow, I forgot that Array.from accepts an optional callback that acts as a map
 
I see. Well, you'll have to live with that horrible thing, then.
 
@VLAZ Hmm. That's... weird. :-)
 
Array.from(xs).map(fn) works like Array.from(xs, fn)
 
1:31 PM
btw, something I completely forgot exists because I took a liking to the spread syntax
 
While we're on the subject of syntax...
What is the more reasonable syntax for that migration POST?
Because I'm doing that now. And then I'm planning to be not doing that.
 
[closed as needs details or clarity] :)
 
Gah! Scratte taught me this is chat, where I can ask my questions without anyone ever closing them!
 
Sounds like you should downvote that for not being helpful.
 
OK. Problem statement: I want to migrate by calling the helper function FlagFilter.tools.migrateTo. I want to check if it failed because the question is already closed. If so, I want to reopen the question, and then retry migration. When migration succeeds, I want to reload the page.
If migration fails, I want to display an annoying pop-up message box.
 
1:37 PM
see? Closure works! :)
 
Next you're going to tell me that this isn't a code-writing chat room :-(
 
well, I can't - this is a code-writing room :)
 
"What have you tried so far?"
 
We did that before you got here :-)
 
Was a joke, I was looking at the code already.
 
1:41 PM
so... joking aside, I am trying to understand the "more reasonable syntax for that migration POST" - so, what exactly are you asking for? [no puns, really]
 
14 mins ago, by Cody Gray
Soooo.... you'd probably say the code to migrate should be in a functor.
Is that correct? And if so, what would that look like?
 
oh, sorry, I thought I confirmed that
15 mins ago, by Oleg Valter
good guess :)
as for what it would look like
 
@CodyGray At least that not something you learned from me :)
 
I have other sources, too :-)
 
I'd like to help, but I don't know what a functor is
 
1:45 PM
define functor
 
functor can mean:
- a function; an operator.
 
Err, yeah.
How about "anonymous function" or "lambda"?
Both are probably more appropriate terms in this case, anyway.
 
In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) are associated to topological spaces, and maps between these algebraic objects are associated to continuous maps between spaces. Nowadays, functors are used throughout modern mathematics to relate various categories. Thus, functors are important in all areas within mathematics to which category theory is applied. The words category and functor were borrowed by mathematicians from the philosophers...
cc @Scratte
 
That looks like a mapping function.
 
1:46 PM
Better link: What are C++ functors and their uses? (at least, if you want to know what Cody is thinking)
 
@Scratte Sort of. A good example of a functor is Optional in Java.
 
@CodyGray That is a problem for me. Because I do not know C++ and the scrollbar on the right side is tiny.. and I think it would take me a few days (yes: DAYS) to read it.
 
Ah, see, there's a simple trick.
 
@VLAZ An object that can hold a null value? Or rather can hold nothing :)
 
With a C++ question, if you see an answer by jalf, GMan (Nick G), sbi, Johannes Schaub, Nicol Bolas, or a handful of others, you can just read that one.
And only read the others if you are still confused or need more help.
 
1:49 PM
@CodyGray I would need more help. And I'd have to start reading a C++ tutorial. See the problem?
 
I see the problem: you're making this complicated.
 
No.. I'm not. I want to know what a functor is and the first thing I see is:
struct add_x {
  add_x(int val) : x(val) {}  // Constructor
  int operator()(int y) const { return x + y; }
 
@Scratte An object that holds a value and you have a specific way to interact with it. Optional makes the operations on the value null-safe. But an array in JS is also a functor - calling .map() on it you can pass a function which works with one element but it's applied to all elements. A functor can do anything really. Basically, the defining feature is that it has a .map() method (or equivalent - might be called something else)
 
I do not know what a struct is. And I have no clue what the first colon does. And what is operator? Is that some common method?
 
It's a structure, into which you can pass data (state) via a constructor. Because it's a structure, you can create instances of it (objects). And because it overloads operator (), you can call it like a function.
So it's an object that behaves like a function. But because it's an object, it can contain state.
 
1:52 PM
@CodyGray I do not do abstract very well.. I don't hide that fact. I need to understand it by having it explained very thoroughly with examples. So.. back to tutorials.
 
@Scratte Struct is a class where all members are public by default, instead of private by default. The first colon indicates the start of an "initializer list", which initializes the member variables of the struct/class. operator() is the method that overloads operator ().
 
OK. Fair enough. But tell me how do I read this thread without then first learning this?
 
Everyone already knows this ;-)
 
@CodyGray I'm closing the window now! ;P
 
Here is a good explanation of functors. Goes from a very basic one to a Maybe (read: Optional) in steps.
 
1:54 PM
OMG! The Wikipedia article is even worse
 
We'll wait, while you get your Ph.D in mathematics.
 
Then it goes to show different functor applications like Either and Task and more but I think the initial part is probably enough to show the idea.
 
const retriable = (retries = 0) => {
    if (retries > 2) return;

    FlagFilter.tools.migrateTo(questionId, site.baseHostAddress)
        .fail(() => {
            alert("Something went wrong: could not perform migration.");
            retriable(++retries);
        })
        .done((xhr) => {
            if (xhr.Success === "false" && xhr.Message === "This question is already closed - please refresh the page") {
                return FlagFilter.tools.reopenQuestion(questionId)
                    .fail(() => {
 
@VLAZ Haha!.. That scrollbar is also tiny :D
 
Why do you need this retriable thing?
 
1:56 PM
@Scratte Yes, but I think covering the Maybe is OK and it's probably 1/5th of the text or so.
 
@Scratte There's a giant drawing of a mason jar. You can skip that part.
 
@CodyGray for doing the necessary recursion?
 
Ah, hmm.
OK. The syntax is just weird to me, I guess.
 
"on failure increment and repeat"
 
@CodyGray No! It's essential! How do you learn without jars?
 
1:57 PM
.fail(() => {
    alert("Something went wrong: could not perform migration.");
    retriable(++retries);
})
 
OK. Thanks. I've put "functor" with the link on my todo list. I think there's noway I can get that into my schedule today.
 
"on successfully reopened question repeat without incrementing the number of retries":
.done(() => retriable(retries));
I omitted one thing, though
i.e. what do to if reopening fails
 
@OlegValter What's this?
@Scratte It's... hardly important enough for that. If a few minute explanation in chat wasn't good enough, then it's not worth more time.
 
@CodyGray method extracted from the wall of code above for demonstration purposes :) @VLAZ managed to get a message in between the label and the code
 
Ah
Instead of putting the comments in your code proper, you put them into the chat window. Clever.
 

« first day (512 days earlier)      last day (940 days later) »