40 Matching Annotations
  1. Feb 2024
    1. if (( ${#} == 0 )) ; then while read -r __my_function ; do my_function "${__my_function}" done else target_utility "${@}" fi

      I like it pretty well, in many ways more than G-Man's answer. I like the use of while read. I'd probably prefer non-recursive solution most of the time though, esp. if instead of a function we would be spawning a subshell (script) to achieve the recursion, like in ...

    2. Also unclear why the answer is criticized for providing a "more general case" since the OP said "You are right, this [base64] was just used as an example, though.
    3. (It seems reasonable to assume users are often expected to occasionally adapt answers rather than expect to use them verbatim.)
    4. This answer is one of various possible solutions for a "Bash function that accepts input from parameter or pipe" since the OP indicated [in a comment] that base64 was not the actual problem domain. As such, it makes no attempt to assure input is able to be directly read from a file.
    5. but in a different situation target_utility "${@}" could represent more complex code
    6. Though the OP's issue may not present a problem ideally resolved through use of recursion, other reader's problems may benefit from using it, or, from considering use of an wrapper function:
    7. The title of the question is what triggered the process of finding this Q/A for material that aided development of the above to solve a real life problem described by the title. The OP declared that base64 decode was not the "real" problem; pedantic constraint of answers to a particular "example" seems less helpful. When this question and its answers were key to helping solve real problems, alternate answers can be gifts to the community in recognition of the fact that many more people will use this Q/A to solve problems. Since the answer is on-topic per the title, I feel it is "game on".
  2. Jan 2024
    1. Another example are issue boards. They represent elegant use of a good infrastructure ­— it is all just a smart use of labels. It would be very complex feature without the use of labels.
    2. Issue relations are meant to be the basic infrastructure to build on (at least that is how I meant it when I posted the original feature request). Just like the labels are just a binary relation between a issue and a "label", the relations should be just a ternary relation between two issues and a "label". Then you can build issue task lists on top of the relations like you've built issue boards on top of the labels.
    3. We already have a very nice example of such tool and its great use: the Board, where labels are used to store metadata and the Board is built above this storage. Do the same with the relations -- simple metadata storage to build on.
    4. Such a generic approach will allow the Relations to fit any reasonable workflow, because possible relations are defined by users, just like the Labels are.
  3. Apr 2022
    1. This would work if your transaction only wraps a single model's save operation. I need to wrap at least Node + Version + Attachment

      looking for a callback that you can register to happen after current transaction is committed, not just after_commit of model -- though actually, that might fire precisely when current transaction is committed, too (except that it might only get triggered for nested transactions, not the top-most transaction), so it could maybe go there ... but I think the problem is just that it doesn't belong there, because it's not specific to the model...

      I guess the OP said it best:

      I am not looking for model based after commits on update/create/etc, I want to be able to dynamically define a block that will be executed only if the current (top-most) transaction passes:

  4. Jan 2022
  5. Sep 2021
  6. Aug 2021
  7. Jul 2021
  8. Mar 2021
    1. xdg-open should do the same thing - actually, it will call gnome-open, or kde-open, or whatever, depending on your desktop environment. Thus it's more portable.
    2. The advantage is that you can use gnome-open for almost all file-types, URIs and directories. It's one command to learn, instead of trying to remember about obscure commands like sensible-browser
  9. Feb 2021
    1. One way to alleviate this configuration fatigue is by making configuration consistent and composable. That’s what Sprocket’s new “manifest.js” seeks to do.
    1. Not all cases can be covered and easily restored. And sometimes when we will reuse this function for different use-cases we will find out that it requires different restore logic.
    2. But why do we return 0? Why not 1? Why not None? And while None in most cases is as bad (or even worse) than the exceptions, turns out we should heavily rely on business logic and use-cases of this function.
    3. So, the sad conclusion is: all problems must be resolved individually depending on a specific usage context. There’s no silver bullet to resolve all ZeroDivisionErrors once and for all. And again, I am not even covering complex IO flows with retry policies and expotential timeouts.
    1. while ActiveForm currently fits 99% of my use cases, I do sometimes make modifications based on the product requirements
    2. I will continue to use form objects and push changes into the repo when I feel they are universally relevant and valuable.

      new tag?:

      • code that is universally relevant/valuable
      • non - _-specific logic
  10. Jan 2021
    1. A Svelte component that monitors an element enters or leaves the viewport/parent element. Performant and efficient thanks to using Intersection Observer under the hood. Can be used in multiple projects including lazy loading images, infinite scrolling, playing/pausing the video when in the viewport, tracking user behaviour firing link pre-fetching and animations and many many more.
  11. Oct 2020
    1. In the many projects I have maintained so far, sooner or later I always run into the same issue: circular module dependencies. Although there are many strategies and best practices on how to avoid circular dependencies. There is very little on how to fix them in a consistent and predictable way.
    2. This is how I solve circular dependency issues nowadays.
    1. As we've briefly seen already, you can listen to any event on an element with the on: directive:
  12. Sep 2020
  13. Apr 2020
  14. Jan 2020
    1. I understand this is a relational division type problem, involving having and count. These posts describe what I want to do, but I can't figure out how to apply the examples to the particular case above: