Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read

Activity for hkotsubo‭

Type On... Excerpt Status Date
Comment Post #285130 In the PHP file you're getting `$_POST['email']`, which means that it's getting the email sent by the client (if the backend will get another email that the client side can't know, then where/how it will be done?). Well, it seems that there is a *lot* of missing information, please edit the question ...
(more)
about 5 hours ago
Comment Post #285154 @#54710 Have you read [the link I suggested](https://software.codidact.com/posts/284849)? I believe it explains what you need to know
(more)
about 6 hours ago
Comment Post #285130 @#36363 "send data" means making a http request, using fetch with POST method (there's an example in the [docs](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#supplying_request_options)). And you can use [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) t...
(more)
about 9 hours ago
Comment Post #285130 @#36363 Then I suggest you to edit the question and add this information there. But anyway, if you want to execute behavior.php, you'll have to send data to it (which is basically what I described above)
(more)
about 17 hours ago
Comment Post #285148 Regarding string handling, [this post](https://software.codidact.com/posts/284849) might be helpful
(more)
about 20 hours ago
Comment Post #285130 After the last edit it's still unclear what you mean by "*apply backend behavior*". Do you have a `form action="URL A"` and want to send all its data to URL B using JavaScript?
(more)
about 23 hours ago
Edit Post #285135 Post edited:
Missed one extra backtick in code block, now it should be correct
1 day ago
Suggested Edit Post #285135 Suggested edit:
Missed one extra backtick in code block, now it should be correct
(more)
helpful 1 day ago
Edit Post #285135 Post edited:
Better title, fix code block
1 day ago
Suggested Edit Post #285135 Suggested edit:
Better title, fix code block
(more)
helpful 1 day ago
Comment Post #285130 Not sure if that's what you need, but if I understood correctly, it'd be something like this: ```javascript let form = // get the form somehow (for example, with querySelector) form.addEventListener('submit', function(e) { e.preventDefault(); // don't submit the form fetch('backend.url') ...
(more)
1 day ago
Edit Post #285104 Post edited:
Remove clutter and try to come up with a better title
3 days ago
Edit Post #285105 Post edited:
3 days ago
Edit Post #285105 Post edited:
3 days ago
Edit Post #285105 Initial revision 3 days ago
Answer A: What does a variable followed by parentheses ("ptr()") mean?
`void (ptr)()` defines a function pointer. It says that `ptr` is a pointer to a function. But that function must have a `void` return type, and take no parameters (that's what the empty parentheses defines). Then, `ptr = PrintHello` assigns the `PrintHello` function to the `ptr` pointer (and it ...
(more)
3 days ago
Suggested Edit Post #285104 Suggested edit:
Remove clutter and try to come up with a better title
(more)
helpful 3 days ago
Comment Post #285019 @#36363 Could you add a link to the website, so we can at least check the HTML and try to see what the problem is? Because your code *should* work. Just double checking the basic stuff: what does `document.querySelector("#example")` return? When you run your code, does any error message appear in th...
(more)
7 days ago
Comment Post #285019 Maybe - and that's a *wild guess* - the JavaScript code is running before the HTML is loaded, and it can't find the input field. Check if the `script` tag is before the form and change it to be after. Or add an event listener to run after the page is loaded: ```javascript document.addEventListene...
(more)
8 days ago
Comment Post #284981 @#36363 I've made a simple test: ```javascript var old = document; document.write('abc'); console.log(old === document); // true ``` Which means that the document didn't change (only its child nodes). Another test to check if child nodes changed: ```javascript // keep reference to origina...
(more)
9 days ago
Comment Post #284981 @#36363 My understanding is that the document itself is not removed, only its child nodes. But I'll make more tests as soon as I can
(more)
11 days ago
Edit Post #284981 Post edited:
12 days ago
Edit Post #284981 Initial revision 12 days ago
Answer A: document.open() and the DOM tree of the loaded (closed) browser window on which it works
At the documetation you linked, if you click on "which will clear the document", it'll go to the documentation for `document.open`, and that page says in the beginning: > All existing nodes are removed from the document. And once removed, you can't retrieve them. Making a test in this page, ...
(more)
12 days ago
Edit Post #284941 Post edited:
Typo
15 days ago
Edit Post #284941 Post edited:
15 days ago
Edit Post #284941 Post edited:
16 days ago
Edit Post #284941 Initial revision 16 days ago
Answer A: Understanding createTreeWalker method in the context of replacing strings (or parts of them)
> How does storing replaced strings in the `node` variable makes a change in the text appearing to the end user? In your case, you're changing the `textContent` property. When accessed, it returns the text content of a node, concatenated with the text content of its descendants, and changing its v...
(more)
16 days ago
Edit Post #284928 Post edited:
19 days ago
Edit Post #284928 Post edited:
19 days ago
Edit Post #284928 Initial revision 19 days ago
Question Code block in comments is highlighted only when viewed in the thread's link
Code blocks inside comments are hightlighted only if I'm on the comment's thread page. If I view it on the post itself (after expanding the respective thread), it's not highlighted. Example: in this post I clicked on the comment thread to expand it, and the code block is not highlighted: code...
(more)
19 days ago
Comment Post #284911 @#53305 To add a little bit more pedantry, the filter predicate doesn't have to be exactly a boolean, because in Python [any object can be tested for truth value](https://docs.python.org/3/library/stdtypes.html#truth-value-testing). Which means I can do this: ```python values = ['abc', '', [], ['...
(more)
19 days ago
Comment Post #284853 @#36363 You're welcome, glad to help!
(more)
25 days ago
Edit Post #284842 Post edited:
Change title to make more clear what the question is about
26 days ago
Suggested Edit Post #284842 Suggested edit:
Change title to make more clear what the question is about
(more)
helpful 26 days ago
Edit Post #284853 Post edited:
some "future-proof" stuff
26 days ago
Edit Post #284853 Post edited:
some "future-proof" stuff
26 days ago
Edit Post #284853 Post edited:
26 days ago
Edit Post #284853 Initial revision 26 days ago
Answer A: Change font-family with JavaScript
To do that, you could change the selector from `body` to ``, as the other answer said. By selecting only `body`, it won't change child elements that has defined a more specific rule, and that's why you need to set the style for all of them. But there are some corner cases that I think it's worth e...
(more)
26 days ago
Comment Post #284806 @#54649 I've made [this test](https://ideone.com/EkRHga) and surprisingly using string slices is faster than doing the math. Try to change the algorithm and see if it makes some difference
(more)
28 days ago
Comment Post #284806 @#54649 For quick performance tests you can use the [`timeit` module](https://docs.python.org/3/library/timeit.html). I've made [a simple example](https://ideone.com/xjEhaR), and creating the function inside the loop was about 50%~60% slower.
(more)
29 days ago
Comment Post #284806 You're creating the function inside the loop, so for every iteration a new function is created. But that's not needed at all, creating it just once outside the loop is enough. Not sure how much it'll improve performance, but it certainly won't make it worse
(more)
30 days ago
Edit Post #284803 Post edited:
Improve title, make text more concise, add tags
about 1 month ago
Edit Post #284804 Post edited:
about 1 month ago
Suggested Edit Post #284803 Suggested edit:
Improve title, make text more concise, add tags
(more)
helpful about 1 month ago
Edit Post #284804 Initial revision about 1 month ago
Answer A: Separate digits of a number in groups with different sizes
Before we start, I'd like to be a little bit pedantic regarding `00002451018` being a number. When we talk about numeric types/values, the zeroes at the beginning are irrelevant: `2`, `02` and `000002` all refer to the number two. The numeric value is `2`, and only the representation - the way the...
(more)
about 1 month ago
Edit Post #284710 Post edited:
about 1 month ago
Edit Post #284710 Post edited:
about 1 month ago
Edit Post #284710 Initial revision about 1 month ago
Answer A: How do I support tab completion in a python CLI program?
It depends. Do you want to have autocomplete on the shell the program runs in, or do you want the program to intercept the TAB key and do the autocomplete by itself? Shell autocomplete If you're running your program in a Linux shell, and want to autocomplete in the shell's command line (such ...
(more)
about 1 month ago
Comment Post #284612 I agree that having some way to indicate the relevant versions can be useful in many cases, but I don't know what's the best way to do it (if I come up with something, I'll certainly post an answer). SE's attempt seems to be convoluted, but I guess only time will tell...
(more)
about 2 months ago
Comment Post #284649 @#53949 There's no accept, but we have [this](https://meta.codidact.com/posts/284455) (totally optional, though)
(more)
about 2 months ago
Edit Post #284649 Post edited:
about 2 months ago
Edit Post #284649 Post edited:
about 2 months ago
Edit Post #284649 Initial revision about 2 months ago
Answer A: What is the purpose of `if __name__ == '__main__'`?
It makes difference if the script is being imported. Let's suppose I have a file `myfile.py`: ```python myfile.py def somefunction(): print('do some stuff') print('calling function:') somefunction() ``` If I execute it directly (such as `python myfile.py`), the output is: ```n...
(more)
about 2 months ago
Edit Post #284633 Post edited:
minor fixes (removed duplicated "when", added punctuation, etc)
about 2 months ago
Suggested Edit Post #284633 Suggested edit:
minor fixes (removed duplicated "when", added punctuation, etc)
(more)
helpful about 2 months ago
Edit Post #282066 Post edited:
fix typo
about 2 months ago
Edit Post #284597 Post edited:
about 2 months ago
Edit Post #284597 Initial revision about 2 months ago
Answer A: What is HEAD in Git?
First we need to understand what a Git repository actually is. For that, refer to this article: it explains that a Git repository is actually a DAG (Directed Acyclic Graph). I'm not going into the mathematical details (which can be checked here), but basically, we can think of a Git repository as a s...
(more)
about 2 months ago
Edit Post #284596 Initial revision about 2 months ago
Question What is HEAD in Git?
In Git documentation, there are lots of references to the term "HEAD". But what exactly is it? Some places refer to it as "a pointer to the current branch". So it's a branch? What is it used for?
(more)
about 2 months ago
Edit Post #282753 Post edited:
about 2 months ago
Comment Post #284465 @#36363 `div` doesn't work, but `span` and `p` seems to do. Check [this test](https://a.dev.codidact.org/posts/315) I've made on the dev server.
(more)
2 months ago
Comment Post #284444 Whether is cheap or not, it depends. If you think it is, then go for it :-) Just reminding that it's not only one instance, there's also the cost of an extra method call every time you get/set/delete an attribute. If that's not a concern, and you think is worth the convenience of having the syntat...
(more)
2 months ago
Comment Post #284386 @#36363 I'm very sorry if I sounded arrogant or offensive. It really wasn't my intention. I've just tried to give constructive feedback - but it seems that I have completely failed, and for that I again sincerely apologize. Anyway, I stand by my answer. To understand the terminology (bubbling, pro...
(more)
2 months ago
Comment Post #284465 If you're just looking for a shorter way to write the left-to-right mark character, there isn't. Are you editing the HTML directly? Because you can set specific parts of the page to have a different text direction. Ex: `מתודת <span dir="ltr">document.write()</span>` - if the page is configured as ...
(more)
2 months ago
Comment Post #284465 @#36363 If you put the text inside HTML, with `dir` attribute set to "rtl", it works: `<div dir="rtl">מתודת document.write()</div>` (at least in the editor's preview it worked, not sure if it will in the rendered post)
(more)
2 months ago
Comment Post #284444 Sorry, I meant "additional instance for each dictionary".
(more)
2 months ago
Comment Post #284444 If that's a good idea, it depends on what you need. Is this functionality (syntatic sugar) worth the overhead of having an additional class for each dictionary you want to wrap? It's hard to tell without knowing the requirements and/or motivations to have such class (it's only syntatic sugar/"ters...
(more)
2 months ago
Edit Post #284424 Post edited:
Ops, fixing markdown
2 months ago
Suggested Edit Post #284424 Suggested edit:
Ops, fixing markdown
(more)
helpful 2 months ago
Edit Post #284424 Post edited:
Added code from the answer, rephrased some parts, changed tags
2 months ago
Suggested Edit Post #284424 Suggested edit:
Added code from the answer, rephrased some parts, changed tags
(more)
helpful 2 months ago
Comment Post #284420 @#36363 And I apologize for sounding like an accusation, I really didn't mean that.
(more)
2 months ago
Comment Post #284420 @#36363 If you have problems with long texts, I'm afraid there's nothing I can do to help. You asked lots of things, and in order to answer everything, it needs a reasonable amount of text (and I also admit I have difficulty to be succint, which makes things even "worse" for you). It seems we got to...
(more)
2 months ago
Comment Post #284420 @#36363 It is - IMO - one of the most confusing things of the language...
(more)
2 months ago
Comment Post #284420 Anyway, I'm also a non-native speaker of English, and don't know how to make the answer clearer... Perhaps we both must work on our English skills :-)
(more)
2 months ago
Comment Post #284420 @#36363 Well, I would say that JavaScript as a whole is a confusing language. Have you studied about [this](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this)? :-)
(more)
2 months ago
Comment Post #284420 @#36363 You asked **lots** of things, including many misconceptions and misunderstandings about the language, and there was no way to address all of them with a short answer. Complaining that it's "too long", and saying that due to your junior level you can't understand advanced topics, are wrong rea...
(more)
2 months ago
Edit Post #284420 Post edited:
2 months ago
Edit Post #284420 Post edited:
2 months ago
Edit Post #284420 Initial revision 2 months ago
Answer A: What problem does innerHTML solves?
tl;dr According to the documentation, `innerHTML` property "gets or sets the HTML or XML markup contained within the element". Basically, "that's all", but let's see it in more detail. > It makes the element we work on to be copy-pasted into a new empty document No, the property itself d...
(more)
2 months ago
Edit Post #284419 Initial revision 2 months ago
Answer A: Are there practical reasons for designing a method-only class/object?
It depends. Regarding "grouping functions/methods": as a general rule, you should group things that make sense to be together. Yes, it's a very broad and generic rule, and somewhat subjective. How you group those things, though, depends on a lot of factors. The other answers covered some aspect...
(more)
2 months ago
Comment Post #284415 Complementing the comment above, when you set the value of something, you're replacing the old value by the new one, which is the same as changing the value. To me, both words can be used interchangeably - unless there's a special use case where they can differ (in the that case, could you provide th...
(more)
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Comment Post #284386 @#36363 As you removed `setInterval`/`setTimeout` from the question, I've also removed that from the answer - and also did a complete rewrite, hope it's more focused now.
(more)
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Post edited:
2 months ago
Comment Post #283058 @#53249 I'm kinda ambivalent when it comes to Unicode. I have many rants about it (I believe lots of things could've been done differently), but on the other hand, I don't have a better solution and recognize the huge effort behind it. I love that they could come up with a solution for a complex prob...
(more)
2 months ago
Edit Post #284386 Post edited:
2 months ago
Comment Post #284386 @#36363 Anyway, I've updated the answer (but I'll review it again later). Perhaps you should edit the question and make clear what are the exact things that you want to know. Do you want to know how events work, or just the meaning of specific terms (or something else)? I tried to cover everything, ...
(more)
2 months ago
Comment Post #284386 @#36363 I had no way to be sure about what you know and what you don't, hence I tried to put everything I thought it was relevant. And, as I said in the answer: "*when I say "events", I'm talking about [this](https://developer.mozilla.org/en-US/docs/Web/API/Event)*" <- this link goes to the relevant ...
(more)
2 months ago
Edit Post #284386 Post edited:
2 months ago
Edit Post #284386 Initial revision 2 months ago
Answer A: What is the main difference between event delegation to other event handling patterns in JavaScript?
tl;dr The purpose of `addEventListener` is to define what happens when an event is triggered at some element. But it also allows us to implement event delegation, due to the bubbling/propagation behaviour. Explaining the terminology Bubbling Suppose I have this HTML: ```html A par...
(more)
2 months ago
Edit Post #277341 Post edited:
Linking to relevant (and related) question
2 months ago
Comment Post #284355 Please take this as constructive criticism. If you want to create a programming language, perhaps you should go back a few steps and first study some relevant topics such as parsers/lexers, [BNF](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form), grammars, etc. To start with a simple parser/lex...
(more)
2 months ago
Suggested Edit Post #277341 Suggested edit:
Linking to relevant (and related) question
(more)
helpful 2 months ago
Edit Post #284327 Post edited:
2 months ago
Edit Post #284311 Post edited:
Rephrasing based on the comments, removed irrelevant tags
3 months ago
Suggested Edit Post #284311 Suggested edit:
Rephrasing based on the comments, removed irrelevant tags
(more)
helpful 3 months ago
Edit Post #284327 Initial revision 3 months ago
Answer A: Why is the switch statement not executing the correct case blocks?
The problem is the fallthrough behaviour of `case` statements. Basically, once a `case`'s condition is met, all the others after that are also executed. Example: ```java int x = 2; switch (x) { case 1: System.out.println("one"); case 2: System.out.println("two"); ...
(more)
3 months ago
Comment Post #284274 `open` accepts only one URL. You'll probably have to add a callback after the first request is finished: ```javascript ajax.onload = function () { // Request finished, make another AJAX call here var anotherAjax = new XMLHttpRequest(); // anotherAjax.open, send, etc... }; ajax.send...
(more)
3 months ago
Edit Post #284263 Initial revision 3 months ago
Answer A: What are the disadvantages of using static methods in Java?
> Is it better to use static method? I don't like to think of `static` (or any other language feature/mechanism) in terms of bad/worse and good/better (although I do that too, I constantly try to avoid it). What I usually try/prefer to do is to understand how something works, why it exists, the...
(more)
3 months ago
Comment Post #284256 @#54212 Less code != better. Just because you typed less characters, it doesn't necessarily mean it's "better" (BTW, most IDE's can autocomplete the imports for you, which makes this point even more irrelevant, IMO). What you should seek is clear, concise, semantic and correct code, regardless of its...
(more)
3 months ago
Edit Post #284193 Post edited:
MathJax is not enabled in this site; changed formula to textual form (probably the best that can be done in this case)
3 months ago
Suggested Edit Post #284193 Suggested edit:
MathJax is not enabled in this site; changed formula to textual form (probably the best that can be done in this case)
(more)
helpful 3 months ago
Edit Post #282066 Post edited:
3 months ago
Edit Post #280959 Post edited:
3 months ago
Edit Post #284200 Post edited:
3 months ago
Edit Post #284200 Initial revision 3 months ago
Answer A: How to run a remote JavaScript file from GitHub?
As you're using userscripts, I'm assuming this code is supposed to run in a browser. Hence, you could download the scripts and add its contents to the page's DOM (by using a `script` element). For that, you can use the Fetch API: ```javascript fetch('http://your.script.url', { cache: "no-store...
(more)
3 months ago
Comment Post #284160 In that case, I suggest you to edit the question and make it more clear what happened. As currently written, it gives the impression that the XML is not displayed at all (at least I had this impression)
(more)
3 months ago
Comment Post #284160 I'm using Chrome and, although it shows the same message you've got, it actually shows the XML, see: https://software.codidact.com/uploads/LqhGnpwbtbMQ3wuTCWePjTua - that said, what exactly is your browsing showing and what did you expect to see?
(more)
3 months ago
Edit Post #284097 Post edited:
Removed noise, added correct syntax highlight
3 months ago
Suggested Edit Post #284097 Suggested edit:
Removed noise, added correct syntax highlight
(more)
helpful 3 months ago
Comment Post #284103 A simple approach is to have a dictionary (so you store as `vars['x'] = x_value`). Of course this doesn't handle different scopes, but for a very simple interpreter, it's a starting point... As a side note, this has absolutely nothing to do with being OOP or not.
(more)
3 months ago
Edit Post #284101 Post edited:
3 months ago
Edit Post #284101 Initial revision 3 months ago
Answer A: How to make the text box such that its placeholder goes up and arranges itself in the centre of the border upon clicking?
The basic ideia is to create an `input` with a "fake" placeholder, and a `span` that will serve as the actual placeholder text. Then you group both inside a `label`, like this: ```html Enter your password ``` Note the `input`'s "fake" placeholder (just a single space). We'll use it ...
(more)
3 months ago
Edit Post #284092 Post edited:
3 months ago
Edit Post #284092 Post edited:
3 months ago
Edit Post #284092 Initial revision 3 months ago
Answer A: What input functions can I use in TIO's PHP?
You could use `fgets` to read from `STDIN`. And to print the message, just use the short tag (``): ```php Try it online! Of course you could also do: ```php <?php echo 'Hello, '.fgets(STDIN).'!'; ``` And there are also other functions you could use, such as `filegetcontents("php://...
(more)
3 months ago
Comment Post #283975 If I understood correctly, `require` seems to be the way to go. If you're getting an infinite loop, the problem probably isn't `require` itself, but something that the required script is doing
(more)
3 months ago
Edit Post #283861 Post edited:
My pronouns: he/him
3 months ago
Suggested Edit Post #283861 Suggested edit:
My pronouns: he/him
(more)
helpful 3 months ago
Comment Post #277488 For anyone wondering about the "demons flying out of the nose" meme, [here's the relevant link](https://groups.google.com/g/comp.std.c/c/ycpVKxTZkgw/m/S2hHdTbv4d8J?hl=en)
(more)
3 months ago
Comment Post #283861 I'd appreciate the nomination, but I'm not willing to be a moderator, nor do I have the condition to do it right now. If this changes in the future, I'll let y'all know, but for now, I'm afraid I can't.
(more)
3 months ago
Comment Post #283839 Regarding warnings, they're usually meant to tell you "*Hey, there's something strange here, you should take a look*". You shouldn't ignore them, unless there's a very good reason - which is not the case of your code, IMO.
(more)
3 months ago
Comment Post #283839 Yes, it can crash, because this leads to undefined behaviour. Try to search for a number that's not in the array, what will it return? I've tested in a Ubuntu machine, with g++ (it returns `6`) and clang++ (*Illegal instruction* error), but as all undefined behaviours, this can vary a lot. IMO, you s...
(more)
3 months ago
Comment Post #283712 Although it "works", it's not the only solution (and IMO, not even the best - for many reasons that don't fit in this space, I usually don't consider global variables as my first choice). You could pass the variable as an argument to the function, for example (or, depending on what you need, make the...
(more)
4 months ago
Edit Post #283669 Post edited:
4 months ago
Edit Post #283669 Initial revision 4 months ago
Question Is there a workaround to highlight code blocks if the language doesn't have syntax highlight enabled?
I've seen that recently two requests to add syntax highlight to some languages were deferred (this and this). According to the status-deferred tag description: "the requested feature will not be implemented in the near future". From that description, my understanding is that there's not a timel...
(more)
4 months ago
Edit Post #283625 Post edited:
4 months ago
Edit Post #283625 Post edited:
4 months ago
Edit Post #283625 Post edited:
4 months ago
Edit Post #283625 Initial revision 4 months ago
Answer A: How to parse a date with more than 3 decimal digits in the fractions of second?
The solution depends on the Java version you're using. First, let's see the solution for earlier versions, that doesn't use `SimpleDateFormat`. Then we'll see why the problem happens and alternatives for older versions. JDK >= 8 For JDK >= 8, you can (should/must?) use the `java.time` API. It...
(more)
4 months ago
Edit Post #283624 Initial revision 4 months ago
Question How to parse a date with more than 3 decimal digits in the fractions of second?
I'm using `SimpleDateFormat` to parse a string containing a date/time, but the result has a different date, hour, minute, second and millisecond: ```java SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS"); Date date = sdf.parse("2021-10-01T10:30:45.123456789"); Syste...
(more)
4 months ago
Edit Post #283597 Post edited:
4 months ago
Edit Post #283597 Post edited:
4 months ago
Edit Post #283597 Post edited:
4 months ago
Comment Post #283596 I've updated my answer, now that I confirmed that `example` is the `ul`'s class
(more)
4 months ago
Edit Post #283597 Post edited:
4 months ago
Edit Post #283597 Initial revision 4 months ago
Answer A: Function.prototype.call()
TL;DR To count the number of `li` items, just do: ```javascript console.log(document.querySelectorAll('ul.example > li').length); ``` That's all, no need to complicate with `filter.call` (but I'll explain that too, hang on). Adapt that to your HTML Of course you could change the se...
(more)
4 months ago
Comment Post #283596 You don't need to add everything, just the first 4 or 5 lines or so. I just want to confirm if `example` is the `ul`'s class
(more)
4 months ago
Comment Post #283596 Also, if you're testing the code in browser's console, that explains the `undefined`, because calling `console.log(whatever)` in browser's console prints the `whatever` value and also prints the return of `console.log` function (which is `undefined`). Anyway, please confirm where/how you're testing t...
(more)
4 months ago
Comment Post #283596 Can you provide an example of the HTML? I'm assuming that `.example` refers to the `ul` element, but it'd be nice if you could confirm that
(more)
4 months ago
Edit Post #282855 Post edited:
4 months ago
Edit Post #282855 Post edited:
4 months ago
Suggested Edit Post #283196 Suggested edit:
Fixed code block and rephrased a little
(more)
helpful 4 months ago
Comment Post #283058 @#53305 Thanks! Regarding "celebrate excellent answers", perhaps something similar to bounties? I don't know, there are some discussions about not having rep at all, so maybe we'll need another way to do it...
(more)
4 months ago
Edit Post #283058 Post edited:
4 months ago
Edit Post #283058 Post edited:
4 months ago
Edit Post #283059 Post edited:
4 months ago
Edit Post #283059 Initial revision 4 months ago
Question Enable syntax highlighting for D language
According to this answer, Codidact uses highlight.js for syntax highlight, and "support whatever languages are enabled by default in that package". And according to this table (in highlight.js GitHub), D language is enabled by default (no need for additional packages), but it also says that "our d...
(more)
4 months ago
Edit Post #283058 Post edited:
use D syntax highlight in code blocks
4 months ago
Edit Post #283058 Post edited:
4 months ago
Edit Post #283058 Initial revision 4 months ago
Answer A: How to get string length in D?
> what ways can I get a string's length in D? There are many different ways, and that will depend on the content of the strings, their types, and how you define the terms "character" and "length". If you're dealing only with ASCII characters, using `length` - as pointed by the other answers - w...
(more)
4 months ago
Edit Post #282908 Post edited:
4 months ago
Edit Post #282908 Initial revision 4 months ago
Answer A: What's the difference between =, == and === operators in JavaScript?
Assignment (`=`) `=` is the assignment operator: it assigns a value to "something". One important detail is that an assignment expression not only assigns a value, but it also returns it. This allows chaining, such as: ```javascript x = y = z = 1; // all variables will be assigned the value...
(more)
4 months ago
Edit Post #282855 Post edited:
5 months ago
Edit Post #282855 Post edited:
5 months ago
Edit Post #282855 Initial revision 5 months ago
Answer A: What's the difference between Inheritance and Polymorphism?
> What you're asking is a very broad topic, and it'd require entire books to cover everything. For the sake of simplicify, I'll just stick to the basics. Inheritance Inheritance can be explained as an "is a" relation, or a specialization of a especific type. Borrowing (and extending) the e...
(more)
5 months ago
Edit Post #282832 Post edited:
I've tried to rephrase the question, making it more clear and focused (also, removed tag with typo and replaced by one with correct spelling)
5 months ago
Suggested Edit Post #282832 Suggested edit:
I've tried to rephrase the question, making it more clear and focused (also, removed tag with typo and replaced by one with correct spelling)
(more)
helpful 5 months ago
Edit Post #282753 Post edited:
5 months ago
Comment Post #282752 Yes, in this case, if you merge only branch A, it won't include B. Another alternative is to apply specific commits, using `cherry-pick`: https://git-scm.com/docs/git-cherry-pick
(more)
5 months ago
Edit Post #282753 Post edited:
5 months ago
Edit Post #282753 Post edited:
5 months ago
Edit Post #282753 Post edited:
5 months ago
Comment Post #282752 I've answered the first part (merge both A and B). Regarding the second part ("*backport feature-A without bringing along feature-B in the future*"), I didn't understand what you want to do...
(more)
5 months ago
Edit Post #282753 Initial revision 5 months ago
Answer A: What's the correct way to merge a branch and its dependent branch back to master?
> I think a branch is a set of commits Well, technically no, it's not. But first things first. DAG (Directed Acyclic Graph) Personally, Git became much more easier to understand after I've read things like this. The "whoa" moment was when it compares Git to a DAG (Directed Acyclic Grap...
(more)
5 months ago
Comment Post #282752 I'm guessing that `feature/null-rows-VER-74021-VER-75002` is branch A and `feature/ct-comparisons-VER-75425` is branch B, and you want to merge both to master, right?
(more)
5 months ago
Comment Post #282752 If I understood correctly, just merging B is enough, as B was branched from A (thus, B "contains" all A commits, as there were no further commits in A). Can you add the output of `git log --graph --format="%ad %h [%p] %d"`, just to confirm how your repo history is?
(more)
5 months ago
Comment Post #282732 With HTML, you can't. You could use another script language, but I don't know of any that is supported by all browsers (at least not widely supported like JavaScript is)
(more)
5 months ago
Comment Post #282673 @#8046 I saw that the post is working now, but the OP user is not deleted. Was the user restored? I'm just curious to know what happened. Anyway, thanks for fixing it!
(more)
5 months ago
Edit Post #282673 Initial revision 5 months ago
Question Error 500 in one specific post (the rest of the site is fine)
I've got a HTTP Error 500 when trying to access this post. Here's the quote error ID's: `ef4f6ec1-8d0f-4be3-9553-36e01b5f01c4` and `bbeb9bf9-2c58-43b1-be05-c9e914bb80bf`. I've browsed to another posts and pages and all of them are working fine. It seems that only that specific post causes the...
(more)
5 months ago
Comment Post #282670 `while (min < max)` - this is an infinite loop, because both `min` and `max` never change their values anywhere in the loop. Thus, `i` ends up accessing some position out of the array's bounds, which usually causes a segfault - I didn't test the code to see if there are more problems, but at a first ...
(more)
5 months ago
Comment Post #282532 If I understood correctly, **maybe** what you actually need is a Static Site Generator: https://snipcart.com/blog/choose-best-static-site-generator (I use Jekyll for my personal blog, BTW). Not sure if that's what you're looking for, but take a look at the concept in general, maybe it's a different a...
(more)
5 months ago
Edit Post #282544 Post edited:
Improved grammar, formatted code
5 months ago
Suggested Edit Post #282544 Suggested edit:
Improved grammar, formatted code
(more)
helpful 5 months ago
Comment Post #282532 Perhaps you should edit and clarify the question. At least for me, I'm failing to see what the actual problem is. Why can't you use PHP (as you confirmed you're already using) as some `include`'s will do the job, and why limiting the number of lines is such a serious issue/requirement (so "serious" t...
(more)
5 months ago
Comment Post #282532 I'm afraid you're focusing on the wrong issues. 80 lines is not large, and nesting is good to make things easy and convenient for the dev team: it makes the code clearer and easier to understand and maintain (on the other hand, keeping everything in one non-nested line just for the sake of having few...
(more)
5 months ago
Comment Post #282525 I've seen those being called "single page" and "multi page" forms. But I don't believe there's a formal standard for that
(more)
5 months ago
Edit Post #282486 Post edited:
Improved grammar, added tags
5 months ago
Comment Post #282487 If we're meant to be pedantic/technically accurate, we'd never call it "string", but if you call it that way, people - at least anyone familiar with the language - will usually know that you actually mean "*a contiguous sequence of chars terminated by the null character (`\0`)*" (regardless of how it...
(more)
5 months ago
Comment Post #282487 @Istiak‭ Actually, it's a little bit more complicated than that. A pointer to some type `T` is, let's say, "interchangeable" with an array of `T` (actually, the pointer points to the array's first element). In C, a string is actually an array of chars (terminated by `\0`), so a `char *` (a pointer to...
(more)
5 months ago
Suggested Edit Post #282486 Suggested edit:
Improved grammar, added tags
(more)
helpful 5 months ago
Edit Post #282354 Post edited:
6 months ago
Edit Post #282354 Initial revision 6 months ago
Answer A: Accessibility standard/s for multilined <input type="text"> fields
The standard for multi-line text input is to use a `textarea`. Don't use `input type="text"`, it won't work. I'm not sure why you don't want to use a `textarea`, but after reading this answer, I hope you'll understand why an `input` is not the correct solution. Definitions MDN defines `input ...
(more)
6 months ago
Comment Post #282344 `input type="text"` is single line by definition. If you want multiline input, use a `textarea` - unless there's a good reason to not use it (and I don't see - and can't imagine - any reason for that)
(more)
6 months ago
Comment Post #282283 @elgonzo There's still the challenge of code-golfing the code (make it as small as possible). But as I said, I'm not the best one to suggest anything about that, so it's "left as an exercise to the reader (aka Derrick)" :-)
(more)
6 months ago
Edit Post #282283 Post edited:
6 months ago
Edit Post #282283 Post edited:
6 months ago
Edit Post #282283 Post edited:
6 months ago
Edit Post #282283 Initial revision 6 months ago
Answer A: Where did my proper divisor sum program went wrong?
When you do `x=y=z=[]`, you're making `x`, `y` and `z` point to the same list. Example: ```python x=y=z=[] add element to x x.append(1) add element to y y.append(2) but x, y and z all point to the same list print(z) # [1, 2] ``` So the first thing to fix is this, set a different list to...
(more)
6 months ago
Edit Post #282233 Post edited:
6 months ago
Edit Post #282233 Post edited:
6 months ago
Comment Post #282233 @elgonzo AFAIK, lists in Python can't be preallocated. You can create one with N elements, and then use those already-created spaces. I've tested here, but that didn't make the code much faster.
(more)
6 months ago
Comment Post #282233 And the `timeit` module already takes care of most "disturbances", and does the tests as clean as possible, running each test lots of times and doing some other stuff that I admit I don't fully know (but I've read some docs mentioning some things it does to eliminate any disturbances). Anyway, I incr...
(more)
6 months ago
Comment Post #282233 @elgonzo The "unbalanced in the beginning" took `1.2465003237593919e-05` seconds - note the scientific notation, with "e-05" in the end, which actually means `0.0000124...` seconds.
(more)
6 months ago
Edit Post #282233 Post edited:
6 months ago
Edit Post #282233 Post edited:
6 months ago
Edit Post #282233 Initial revision 6 months ago
Answer A: Detecting balanced parentheses in Python
Instead of replacing the brackets, you could do just one loop, and keep a stack with the opening brackets. Every time you find a closing bracket, check if it corresponds to the stack top: if it's not, the string is invalid, else, pop the opening bracket and proceed to the next character. Do it unt...
(more)
6 months ago
Edit Post #282227 Post edited:
fixed typo and added tag
6 months ago
Suggested Edit Post #282227 Suggested edit:
fixed typo and added tag
(more)
helpful 6 months ago
Edit Post #282229 Initial revision 6 months ago
Answer A: Counting Sundays without Python date module
First of all, I've added a `print` in your code to show the dates: if days % 7 == 0 and currentday == 1: print(f'{currentyear}-{currentmonth:>02}-{currentday:>02}') sundays += 1 And in the first lines I've noticed that you're actually counting the Tuesdays: ```none 190...
(more)
6 months ago
Edit Post #282164 Initial revision 6 months ago
Answer A: How can I emulate regular expression's branch reset in Java?
Currently, Java 16 is the latest version, and there's no support to branch reset yet. But one - still far from ideal - alternative is to use lookarounds: ``` Pattern pattern = Pattern.compile("([aeiou]+(?=\\d+\\W+)|[123]+(?=[a-z]+\\W+))"); Matcher matcher = pattern.matcher("ae123. 111abc!!"); w...
(more)
6 months ago
Edit Post #282066 Initial revision 6 months ago
Answer A: What does the "\s" shorthand match?
The complete set of characters matched by the `\s` shorthand varies according to the language/API/tool/engine you're using. In addition to that, there might be configurations that change this behaviour. In a general way, `\s` - at least in the engines that I've seen - always include the following...
(more)
6 months ago
Edit Post #282065 Initial revision 6 months ago
Question What does the "\s" shorthand match?
I've seen some regular expressions (regex) using `\s` when they want to match a space, but I noticed that it also matches line breaks. Example: the regex `[a-z]\s[0-9]` (lowercase ASCII letter, followed by `\s`, followed by a digit) matches both `a 1` and ```none b 2 ``` Because `\s` matc...
(more)
6 months ago
Edit Post #282006 Post edited:
6 months ago
Edit Post #282006 Post edited:
6 months ago
Edit Post #282006 Initial revision 6 months ago
Answer A: Why is this client code getting the wrong date for a few hours a day?
First of all, we need to understand what a JavaScript `Date` actually is. And surprisingly, it's not exactly a date (at least not in terms of having unique values for day, month, year, hour, minute and second). A JavaScript `Date` actually represents a timestamp. More precisely, according to the...
(more)
6 months ago
Comment Post #281886 Actually, `print` will add a new line if you set `$\ = "\n"`. The doc mentions that: "*If the output record separator (`$\`) is not `nil`, it is appended to the output*" - as the [default value is `nil`](https://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/variable.html#bslash), `print` won't nor...
(more)
7 months ago
Comment Post #281871 Actually, `print` will add a new line if you set `$\ = "\n"`
(more)
7 months ago
Comment Post #281762 From my experience, the main issue in any ticket system is when users can't explain their problem with enough details (and we need to contact them to get those details). Markdown, as a markup language, (with **formatting purposes only**), wouldn't help to solve this problem - because it's a communica...
(more)
7 months ago
Edit Post #281730 Post edited:
formatting
7 months ago
Suggested Edit Post #281730 Suggested edit:
formatting
(more)
helpful 7 months ago
Comment Post #281585 I agree that in most cases we simply shouldn't do it. But the main subject of the question is Zalgo Text, so how could I show an example without actually showing it? I believe the question is a valid case where this should be done, otherwise the post would lack important information. Anyway, if the d...
(more)
7 months ago
Edit Post #281552 Post edited:
7 months ago
Comment Post #281555 I recognize this is probably a minor issue, as text like that will be rarely used in posts, so I don't mind if this issue gets low priority.
(more)
7 months ago
Edit Post #281555 Initial revision 7 months ago
Question Text with many diacritic marks are not displayed correctly in posts
When posting this question, I noticed a difference between editor's preview and the post's final render. When editing, the preview correctly shows the Zalgo Text: But after the post is saved, it's rendered in the browser like this: Note that part of the text (the diacritics at the to...
(more)
7 months ago
Edit Post #281551 Post edited:
7 months ago
Edit Post #281551 Post edited:
7 months ago
Edit Post #281552 Post edited:
7 months ago
Edit Post #281551 Post edited:
7 months ago
Edit Post #281552 Initial revision 7 months ago
Answer A: How does Zalgo Text work, and how can I prevent my application from accepting it?
First, let's see how Zalgo Text works. Unicode Combining Characters Unicode defines the concept of combining characters. Basically, some characters can be combined with others, to "make/create" different ones (you can also say that they can modify other characters). > Example: in Portu...
(more)
7 months ago
Edit Post #281551 Initial revision 7 months ago
Question How does Zalgo Text work, and how can I prevent my application from accepting it?
A Zalgo Text is something like this: T̃͟͏̧̟͓̯̘͓͙͔o̤̫͋ͯͫ̂ ̥͍̫̻͚̦͖͇̌ͪ̇ͤ̑̐͋̾̕i̢͖̩͙͐͑ͬ̄̿̍̚ͅn̵̢̼̙̳̒̄ͥ̋̐v̡̟̗̹̻̜͕̲ͣ̐ͤͤ͒́oͫ͂̆͑ͩ҉͇̰͚̹̠̫͔̗k̷̭̬̭͙̹̺̯ͩ̌̾̒̋̓ͤ͛͘͠e̥͙̓̄̕ ̵̫͈ͪţ̱̺̺̑̿̉̌͛̂̇h͙̣̬̓̂͞ę̡̲̟͎͉̟͛̓̉̆̉͘ ͍̯̱͎̬͍ͬ̒ͣͩ͟͡ḥ̗͖̝̮̗̼ͮ̋̉̃͐̿ͪͅi̞͉̯͖̞͉̙ͬͦ̄͋̈̂ͥ̊́̕v̶̝̼̫͔̬̯̯ͯ͑̈͠e̪͓͕̦̪̗̠ͯ͛͌̀̉͘ͅ-̍̉ͦ̈́͌͏̸͉͍͖̥͓̭̗̖mͣͣͪ̇͂͏̳̤̺...
(more)
7 months ago
Comment Post #281511 I guess "*passwords and other data*" refer to the passwords themselves saved in your browser config (so it offers an option to auto-fill login forms). After you login, each website might set a cookie with your token/credential info, but Chrome has no way to know which cookies are related to authentic...
(more)
8 months ago
Comment Post #281288 When handling dates in a system, one should prefer to send/receive in a standard format (to make parsing easier), and only when presenting this to users, a specific localized format is chosen - BTW, that's exactly what browsers (and probably your mail client) do: internally, the `input` value is in I...
(more)
8 months ago
Comment Post #281288 Date formats are specific to locale/culture/country/etc. What makes sense to one doesn't necessarily make to another (in Japan, the "normal" order is year-month-day, in USA, month-day-year, and so on - nobody is "wrong"). But ISO 8601 is not intended to be locale oriented, because it was designed to ...
(more)
8 months ago
Comment Post #281288 ISO 8601 is intended to be "locale agnostic" and unambiguous, and this "biggest to smallest units" approach is IMO a good choice, with advantages already pointed by previous comments. It's an information exchange format, not a human friendly one (although it *is* friendly once you get used to it)
(more)
8 months ago
Comment Post #281288 According [to MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date), the displayed format of `input type=date` can change according to the browser's locale. My guess is that mail clients might do something similar when interpreting HTML. Not sure if this can be changed (without s...
(more)
8 months ago
Edit Post #281169 Post edited:
8 months ago
Edit Post #281168 Post edited:
Adding tags
9 months ago
Suggested Edit Post #281168 Suggested edit:
Adding tags
(more)
helpful 9 months ago
Edit Post #281169 Initial revision 9 months ago
Answer A: SQL timestamp for daylight saving day when clock goes 1 hour back.
This behaviour is documented here: > "... an ambiguous timestamp that could fall on either side of a jump-back transition is assigned the UTC offset that prevailed just after the transition." So, when there's an ambiguous timestamp (when a local date/time occurs twice: first in Daylight Saving ...
(more)
9 months ago
Comment Post #281036 @MonicaCellio I noticed that it also happens in other sites (example: https://meta.codidact.com/posts/281048) - Would it be worth posting this problem in Codidact Meta? Or having it just here is enough?
(more)
9 months ago
Edit Post #281050 Post edited:
9 months ago
Edit Post #281050 Post edited:
9 months ago
Edit Post #281050 Post edited:
9 months ago
Edit Post #281050 Post edited:
9 months ago
Edit Post #281050 Initial revision 9 months ago
Answer A: How to match standard email addresses with regex?
Matching a valid email address can be as complicated as you want it to be. If you want to be compliant with RFC 5322, the regex will be a monster (see below). But if you want a subset of it, with predefined arbitrary rules, then your monster will be a little less scary. Considering the simpl...
(more)
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Post edited:
9 months ago
Edit Post #281036 Initial revision 9 months ago
Question Border-bottom of inline code is (sometimes) not displayed when it's in the last line of a paragraph
After I wrote this answer, I could notice that, when there's inline code in the last line of a paragraph, sometimes the border-bottom of the inline code text is not displayed. One case is when the paragraph is followed by either a horizontal line or a code block: inline code with border-bottom...
(more)
9 months ago
Edit Post #281035 Post edited:
9 months ago
Edit Post #281035 Initial revision 9 months ago
Answer A: What are field separators in operating-programming languages (such as Bash)?
In Bash, `IFS` is an internal variable and it stands for "Internal Field Separator" <- according to this link, it "determines how Bash recognizes fields, or word boundaries, when it interprets character strings". Its default value is a "whitespace" (space, tab, and newline), but you can change it ...
(more)
9 months ago
Comment Post #280959 @CodeFarmer I've upated the answer, but based on your edit, I think the options that I've had previously suggested might work
(more)
9 months ago
Edit Post #280959 Post edited:
9 months ago
Edit Post #280959 Post edited:
9 months ago
Edit Post #280959 Initial revision 9 months ago
Answer A: Python Regex to parse multiple "word. word. word."
First of all, let's understand why your regex didn't work. The first part is `\w+\.\s`, which is "one or more alpha-numeric characters" (`\w+`), followed by a dot and a space (`\.\s`). If the regex was only this, it would match `THIS. ` &nbsp;(the word "THIS", plus the dot and space after it). ...
(more)
9 months ago
Comment Post #280933 You're closing the parentheses before `format`, so you're calling `format` on the value returned by `print` (which is `None`). It should be `print("{} {}".format(inspect.currentframe().f_code.co_name, path.basename(__file__)))` - https://ideone.com/4z9NRl
(more)
9 months ago
Comment Post #279716 @MonicaCellio Now it's working. Also, I could post this comment, so the other problem that I reported ([this one](https://software.codidact.com/posts/279715)) seems to be fixed as well
(more)
11 months ago
Edit Post #280097 Post edited:
Typo and some formatting
12 months ago
Suggested Edit Post #280097 Suggested edit:
Typo and some formatting
(more)
helpful 12 months ago
Edit Post #279599 Post edited:
Fix link
12 months ago
Edit Post #279716 Post edited:
about 1 year ago
Comment Post #279715 @Someone I noticed that the notification inbox is not working, but only in some pages. Couldn't find a pattern though
(more)
about 1 year ago
Comment Post #279716 @ArtOfCode Yes, I do. I've also added some more info, maybe it helps
(more)
about 1 year ago
Edit Post #279716 Post edited:
about 1 year ago
Edit Post #279715 Post edited:
about 1 year ago
Edit Post #279716 Post edited:
about 1 year ago
Edit Post #279716 Initial revision about 1 year ago
Question I can't choose any tags when posting a question
The problem described below occurs in Windows 10 and Chrome 87.0.4280.66 (64 bits, JavaScript enabled). I could post this question only in mobile (Chrome/iOS 14.2), where the problem doesn't occur. I also tested in MacOS 10.5.5/Chrome 83.0.4103.116, and the problem doesn't occur (all 3 tests - Window...
(more)
about 1 year ago
Edit Post #279715 Initial revision about 1 year ago
Question Error 500 when trying to comment
I've tried to post a comment in this question, and when I clicked in "Post" button, I've got this error message: > 500 Internal Server Error > If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wr...
(more)
about 1 year ago
Edit Post #279599 Post edited:
about 1 year ago
Edit Post #279609 Post edited:
about 1 year ago
Comment Post #279611 The answers are restored, thanks!
(more)
about 1 year ago
Comment Post #279609 @MonicaCellio The answers are restored, thanks!
(more)
about 1 year ago
Comment Post #279611 Thanks for the quick response. Good luck!
(more)
about 1 year ago
Edit Post #279609 Initial revision about 1 year ago
Question I answered a question that was deleted, then undeleted, and my answer disappeared
Yesterday I answered this question. This morning, when I visited site, the question has disappeared, so my guess is that it was deleted. But now I saw that it was undeleted (I initially thought that it was posted again, but I don't think that's the case because my vote is still there), but it h...
(more)
about 1 year ago
Answer A: How can I write an egrep (grep -E) regexp that matches lines containing two stanzas in arbitrary order?
> Can that even be done without having to repeat either or resorting to more advanced processing than pure regular expressions I don't think it can. If you don't want to repeat `x1=y2` and `c5=d6`, you'll have to use more advanced features, such as lookaheads: grep -P "^(?=([^;]+; )x1=y2)(?...
(more)
about 1 year ago
Edit Post #279002 Post edited:
about 1 year ago
Edit Post #279002 Post edited:
Formatting / added android tag
about 1 year ago
Comment Post #278540 In regex, parentheses create a capturing group (which means that anything that matches the expression inside them becomes a separate group). My guess is that, when a group is present, only its contents are kept and the rest are ignored/removed - I couldn't find any info about that in the docs, though...
(more)
about 1 year ago
Comment Post #278063 Related: https://software.codidact.com/q/277225
(more)
about 1 year ago
Suggested Edit Post #277896 Suggested edit:
Formatting tag names
(more)
declined over 1 year ago
Edit Post #277898 Post edited:
over 1 year ago
Edit Post #277898 Post edited:
over 1 year ago
Edit Post #277898 Post edited:
over 1 year ago
Comment Post #277901 I was about to ask that. Why put `.git` in `public_html` folder in the first place?
(more)
over 1 year ago
Edit Post #277898 Initial revision over 1 year ago
Answer A: Can regex be used to check if input conforms to a very strict subset of HTML?
tl;dr Although it can be done with regex (and work for "most" cases), I still prefer to use a parser. Long answer I'd use something such as `DOMParser` to do the job: ```javascript let validTags = ['p', 'span', 'br', 'i', 'b', 'u']; let validAttribs = ['style', 'href']; function vali...
(more)
over 1 year ago
Edit Post #277860 Post edited:
over 1 year ago
Edit Post #277860 Post edited:
over 1 year ago
Edit Post #277860 Post edited:
over 1 year ago
Edit Post #277860 Post edited:
over 1 year ago
Edit Post #277860 Post edited:
over 1 year ago
Edit Post #277860 Initial revision over 1 year ago
Answer A: Function call; `this` gets bound to unexpected value
This MDN link might help to explain that: > When a function is called as a method of an object, its `this` is set to the object the method is called on. Which is your first example (calling `obj.a()`). But the link above also mentions that "this behavior is not at all affected by how or where t...
(more)
over 1 year ago
Edit Post #277410 Post edited:
over 1 year ago
Edit Post #277331 Post edited over 1 year ago
Edit Post #277410 Initial revision over 1 year ago
Question "Review suggested edit" page doesn't display Markdown source correctly
I recently suggested an edit to an answer. Basically, I formatted some code, adding code fences around it: suggest edit - editor shows newlines But at the "Review suggested edit" page, the differences are not clearly displayed. It shows all the answer text in a single "line": pending e...
(more)
over 1 year ago
Suggested Edit Post #277331 Suggested edit:
formatting
(more)
helpful over 1 year ago
Edit Post #277397 Initial revision over 1 year ago
Answer A: Why don't format specifiers work with lists, dictionaries and other objects?
When you use the variable without any format specifier (`print(f'{variable}')`), internally its `str` method is called. Considering your `Test` class, it already has this method: ```python class Test: def init(self, valor): self.valor = valor def str(self): print('c...
(more)
over 1 year ago
Edit Post #277396 Initial revision over 1 year ago
Question Why don't format specifiers work with lists, dictionaries and other objects?
When I want to print a number or a string, I can use f-strings (Python >= 3.6) or `str.format`, and I can use just the variable between braces, or use format specifiers. Ex: ```python num, text = 10, 'abc' passing just the variables print(f'{num} {text}') or #print('{} {}'.format(num, text)...
(more)
over 1 year ago
Edit Post #277331 Post edited over 1 year ago
Suggested Edit Post #277331 Suggested edit:
Formatting
(more)
helpful over 1 year ago
Comment Post #277232 I like the idea of using categories, we could use them to have canonical articles, and tag wikis would be restricted to usage instructions (perhaps with a link to the corresponding article?). Not sure about the category name and guidelines though - if I think of something, I'll post as another meta q...
(more)
over 1 year ago
Edit Post #277225 Post edited:
over 1 year ago
Edit Post #277222 Post edited:
over 1 year ago
Edit Post #277223 Post edited:
over 1 year ago
Edit Post #277225 Initial revision over 1 year ago
Question Can regular users add tag wikis? And what are the guidelines for creating them?
Checking the list of tags, I noticed that all of the tag wikis are empty, like this: empty tag wiki I also noticed that I can't edit those info. Will it be possible for regular users to add tag wikis?[^1] And if there is such possibility, what are the recommendations for creating those wi...
(more)
over 1 year ago
Edit Post #277223 Initial revision over 1 year ago
Answer A: How can I emulate regular expression's branch reset in Java?
I've kinda found a very limited, not so elegant, far from ideal "solution", using `replaceAll`: ```java String regex = "(?:([aeiou]+)[0-9]+|([123]+)[a-z]+)\\W+"; System.out.println("ae123.".replaceAll(regex, "$1$2")); System.out.println("111abc!!".replaceAll(regex, "$1$2")); ``` This prints...
(more)
over 1 year ago
Edit Post #277222 Initial revision over 1 year ago
Question How can I emulate regular expression's branch reset in Java?
I've got this sample regex: ```java Pattern p = Pattern.compile("(?:([aeiou]+)[0-9]+|([123]+)[a-z]+)\\W+"); ``` It basically has the following parts: - one or more lowercase vowels (`[aeiou]+`), followed by one or more digits (`[0-9]+`), or - one or more digits 1, 2 or 3 (`[123]+`), follo...
(more)
over 1 year ago