Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for hkotsuboâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #284386 | Initial revision | — | about 3 years 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) |
— | about 3 years ago |
Edit | Post #277341 |
Post edited: Linking to relevant (and related) question |
— | about 3 years 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) |
— | about 3 years ago |
Suggested Edit | Post #277341 |
Suggested edit: Linking to relevant (and related) question (more) |
helpful | about 3 years ago |
Edit | Post #284327 |
Post edited: |
— | about 3 years ago |
Edit | Post #284311 |
Post edited: Rephrasing based on the comments, removed irrelevant tags |
— | about 3 years ago |
Suggested Edit | Post #284311 |
Suggested edit: Rephrasing based on the comments, removed irrelevant tags (more) |
helpful | about 3 years ago |
Edit | Post #284327 | Initial revision | — | about 3 years 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) |
— | about 3 years 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) |
— | about 3 years ago |
Edit | Post #284263 | Initial revision | — | about 3 years 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) |
— | about 3 years 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) |
— | about 3 years 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) |
— | over 3 years 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 | over 3 years ago |
Edit | Post #282066 |
Post edited: |
— | over 3 years ago |
Edit | Post #280959 |
Post edited: |
— | over 3 years ago |
Edit | Post #284200 |
Post edited: |
— | over 3 years ago |
Edit | Post #284200 | Initial revision | — | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years ago |
Edit | Post #284097 |
Post edited: Removed noise, added correct syntax highlight |
— | over 3 years ago |
Suggested Edit | Post #284097 |
Suggested edit: Removed noise, added correct syntax highlight (more) |
helpful | over 3 years 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) |
— | over 3 years ago |
Edit | Post #284101 |
Post edited: |
— | over 3 years ago |
Edit | Post #284101 | Initial revision | — | over 3 years 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) |
— | over 3 years ago |
Edit | Post #284092 |
Post edited: |
— | over 3 years ago |
Edit | Post #284092 |
Post edited: |
— | over 3 years ago |
Edit | Post #284092 | Initial revision | — | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years ago |
Edit | Post #283861 |
Post edited: My pronouns: he/him |
— | over 3 years ago |
Suggested Edit | Post #283861 |
Suggested edit: My pronouns: he/him (more) |
helpful | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years 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) |
— | over 3 years ago |
Edit | Post #283669 |
Post edited: |
— | over 3 years ago |
Edit | Post #283669 | Initial revision | — | over 3 years 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) |
— | over 3 years ago |
Edit | Post #283625 |
Post edited: |
— | over 3 years ago |
Edit | Post #283625 |
Post edited: |
— | over 3 years ago |
Edit | Post #283625 |
Post edited: |
— | over 3 years ago |
Edit | Post #283625 | Initial revision | — | over 3 years 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) |
— | over 3 years ago |
Edit | Post #283624 | Initial revision | — | over 3 years ago |