59 Matching Annotations
  1. Sep 2023
  2. Aug 2023
  3. Jun 2023
  4. Mar 2023
    1. Your answer (422) makes sense to me. This is also what Rails (respond_with) uses when a resource couldn't be processed because of validation errors.
  5. Sep 2022
  6. Aug 2022
    1. Sure, you can try to solve that problem by using a one-word alternative for any multi-word phrase, but that's not always possible. Instead of relying on luck, being at the mercy of copy writers, and artificially limited to only allowing one-word items, IMHO you would be better off finding a general design solution that works even for multi-word phrases. Adjusting the letter-spacing and margin between items in your list isn't that hard
  7. Jul 2022
  8. May 2022
    1. You should mentioned what you listed after the word try_files. Here's what I ended up using that seemed to work: try_files $uri $uri/index.html $uri.html /index.html; The /index.html at the end needs to match the fallback: 'index.html' part of your adapter-static config. Otherwise going directly to a route that doesn't have a matching file at that path -- such as any route with a dynamic param like [id] -- will result in a 404.
  9. Dec 2021
  10. Nov 2021
    1. I can't blame you. This problem seems anything but a newbie question! I was surprised when I noticed that this post (which was the only post I could find about trying to use chromedriver with flatpak chromium) in the linux4noobs forum. I've been using Linux as my primary desktop for ~15 years and this problem has stumped me too.
    2. I'm having this problem too. Trying to use chromedriver with com.github.Eloston.UngoogledChromium (also tried org.chromium.Chromium) on Pop!_OS and selenium/webdriver (I'm using it with Ruby/capybara).This was the only post I could find (so far) about using chromedriver with a flatpak chrome/chromium... I wish someone would answer how or if this is possible.I created a chrome wrapper script that launches the flatpak, so that I could point to the script as my binary location. Did you do the same?It manages to open a window but the window is empty, and it just hangs for a hwile, and then eventually fails with:unknown error: DevToolsActivePort file doesn't exist (Selenium::WebDriver::Error::UnknownError) Any ideas how to get it working? I'd rather not install the "official" (proprietary software) Chrome binary on my system.Like you said, I never had any problems back in the good old days when we had deb packages for chromium. But now that we have to use a flatpak, I wonder if that's what the problem is — maybe chromedriver can't communicate directly with the chrome process because it is isolated/containerized??
    3. As soon as I installed a Chrome deb everything worked.sudo dpkg -i \~/Downloads/google-chrome-stable\_current\_amd64.deb It's unfortunate that that's the only way I could get it to work.
  11. Sep 2021
  12. Jul 2021
    1. Sure, the slow way is always "good enough" — until you learn a better way of doing things. By your logic, then, we shouldn't have the option of including "Move to" in our context menus either — because any move operation could be performed using the cut and paste operations instead? The method you proposed is 6-7 steps long, with step 4 being the most onerous when you're in a hurry: Select files "Cut" "Create New Folder" Think of a name for the new folder. Manually type in that name, without any help from the tool. (We can't even use copy and paste to copy some part of one of the file names, for example, because the clipboard buffer is already being used for the file selection.) Press Enter Press Enter again to enter the new folder (or use "Paste Into Folder") "Paste" The method that Nautilus (and apparently Mac's Finder) provides (which I and others love) is much more efficient, especially because it makes step 4 above optional by providing a default name based on the selection, coming in at 4-5 steps (would be 3 steps if we could assign a keyboard shortcut to this command like Mac apparently has ): Select files Bring up context menu (a direct shortcut key would make this even sweeter) Choose "New Folder With Selection" Either accept the default name or choose a different name (optional) Press Enter Assuming "Sort folders before files" option is unchecked, you can continue working/sorting in this outer folder, right where you left off: Can you see how this method might be preferable when you have a folder with 100s or 1000s of files you want to organize it into subfolders? Especially when there is already a common filename prefix (such as a date) that you can use to group related files together. And since Nemo kindly allows us to choose which commands to include in our context menu, those who don't use/like this workflow are free to exclude it from their menus... Having more than one way to accomplish something isn't necessarily a bad thing.
  13. Jun 2021
    1. git diff-index --name-status --relative --cached @ might be a bit easier to parse (and only includes staged files so you don't have to do an extra step to filter them). Also, I couldn't use git status --porcelain because my Rails app is in a sub-folder so I needed the list of files to be relative to the Rails root instead of relative to the git repo root (although git status in general seems to respect the --relative option, git status --porcelain seems to not).
    1. https://github.com/rycus86/githooks is a really option for managing hooks It is... safe (it uses an opt-in model, where it will ask for confirmation whether new or changed scripts should be run or not (or disabled)) configurable handles a lot of the details for you lets you keep your hooks nicely organized. For example:
    1. Same feature in TypeScript¶ It's worth mentioning that other languages have a shortcut for assignment var assignment directly from constructor parameters. So it seems especially painful that Ruby, despite being so beautifully elegant and succinct in other areas, still has no such shortcut for this. One of those other languages (CoffeeScript) is dead now, but TypeScript remains very much alive and allows you to write this (REPL): class Foo { constructor(public a:number, public b:number, private c:number) { } } instead of this boilerplate: class Foo { constructor(a, b, c) { this.a = a; this.b = b; this.c = c; } } (The public/private access modifiers actually disappear in the transpiled JavaScript code because it's only the TypeScript compiler that enforces those access modifiers, and it does so at compile time rather than at run time.) Further reading: https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties https://basarat.gitbook.io/typescript/future-javascript/classes#define-using-constructor https://kendaleiv.com/typescript-constructor-assignment-public-and-private-keywords/ I actually wouldn't mind being able to use public/private modifiers on instance var parameters in Ruby, too, but if we did, I would suggest making that be an additional optional shortcut (for defining accessor methods for those instance vars) that builds on top of the instance var assignment parameter syntax described here. (See more detailed proposal in #__.) Accessors are more of a secondary concern to me: we can already define accessors pretty succinctly with attr_accessor and friends. The bigger pain point that I'm much more interested in having a succinct shortcut for is instance var assignment in constructors. initialize(@a, @b, @c) syntax¶ jsc (Justin Collins) wrote in #note-12: jjyr (Jinyang Jiang) wrote: I am surprised this syntax has been repeatedly requested and rejected since 7 years ago. ... As someone who has been writing Ruby for over 10 years, this syntax is exactly that I would like. I grow really tired of writing def initialize(a, b, c) @a = a @b = b @c = c end This would be perfect: def initialize(@a, @b, @c) end I'm a little bit sad Matz is against this syntax, as it seems so natural to me. Me too!! I've been writing Ruby for over 15 years, and this syntax seems like the most obvious, simple, natural, clear, unsurprising, and Ruby-like. I believe it would be readily understood by any Rubyist without any explanation required. Even if you saw it for the first time, I can't think of any way you could miss or misinterpret its meaning: since @a is in the same position as a local variable a would normally be, it seems abundantly clear that instead of assigning to a local variable, we're just assigning to the variable @a instead and of course you can reference the @a variable in the constructor body, too, exactly the same as you could with a local variable a passed as an argument. A workaround pattern¶ In the meantime, I've taken to defining my constructor and list of public accessors (if any) like this: attr_reader \ :a, :b def new( a, b) @a, @b = a, b end ... which is still horrendously boilerplatey and ugly, and probably most of you will hate — but by lining up the duplicated symbols into a table of columns, I like that I can at least more easily see the ugly duplication and cross-check that I've spelled them all correctly and handled them all consistently. :shrug: Please??¶ Almost every time I write a new class in Ruby, I wish for this feature and wonder if we'll ever get it. Can we please?
    1. Thanks, this was just what I was looking for! This is a perfect appropriate use of instance_eval. I do not understand the nay-sayers. If you already have your array in a variable, then sure, a.reduce(:+) / a.size.to_f is pretty reasonable. But if you want to "in line" find the mean of an array literal or an array that is returned from a function/expression — without duplicating the entire expression ([0,4,8].reduce(:+) / [0,4,8].length.to_f, for example, is abhorrent) or being required to assign to a local, then instance_eval option is a beautiful, elegant, idiomatic solution!!
    2. instance_eval is analogous to using tap, yield_self, … when you are dealing with a chain of method calls: do use it whenever it's appropriate and helpful! And in this case, I absolutely believe that it is.
  14. Feb 2021
  15. Jan 2021
  16. Dec 2020
  17. Oct 2020
  18. Sep 2020
    1. The dynamic routes are a great way to keep the routing.rb DRY and avoid unneeded dependencies between the routing and the controller files That is exactly the problem: I've already defined the (white)list of actions in the controller; I just want to make them all available via routes. I shouldn't have to repeat myself in the routes file.
  19. Aug 2020
  20. Jul 2020
  21. Jun 2020
  22. May 2020
    1. Updated to add .join. Also looked like the 2nd example was missing result.save so added that too. Haven't tested the code, so hopefully it is correct...
  23. Apr 2020
  24. Mar 2020
  25. Feb 2020
  26. Jan 2020
  27. Dec 2019
  28. Nov 2019
  29. Oct 2019
    1. The comment length is limited to 600. But sometimes I want to post a link to some code on typescriptlang.org/play whose URL is ~ 650 chars long.