177 Matching Annotations
  1. Feb 2024
    1. The input format of the xargs command doesn't match what any other command produces. Yes, it's bizarre. With -I, xargs ignores indentation, which is why the file names with initial spaces are mangled. Do not use xargs except with the -0 option or when you know your input doesn't contain characters that would confuse it.
  2. Jan 2024
    1. I thing you are doing a very subtle mistake which will become fatal in long-term. Your strategy to take small steps that cover as much functionality as possible is reasonable, but it is necessary to be careful, as it leads to a critical state when there is too much little stuff built up without proper structure to support it.
  3. Dec 2023
    1. Cross-Account Protection does not currently send security events for Google Workspace (formerly G Suite) users.

      That's a pretty major caveat

  4. Sep 2023
    1. Also, always prefix globs with "/" or "./"; otherwise, if there's a file with "-" as the first character, the expansions might be misinterpreted as options.
    1. Note that the mere presence of this header causes premailer to be skipped, i.e., even setting skip_premailer: false will cause premailer to be skipped. The reason for that is that the skip_premailer is a simple header and the value is transformed into a string, causing 'false' to become truthy.

      They should fix this!

      lib/premailer/rails/hook.rb def skip_premailer_header_present? message.header[:skip_premailer] end

  5. Jul 2023
  6. May 2023
    1. I'm not actually setting a productivity goal, I'm just tracking metadata because it's related to my research. Of which the ZettelKasten is one subject.That being said, in your other post you point to "Quality over Quantity" what, in your opinion, is a quality note?Size? Number of Links? Subjective "goodness"?

      reply to u/jordynfly at https://www.reddit.com/r/Zettelkasten/comments/13b0b5c/comment/jjcu3cn/?utm_source=reddit&utm_medium=web2x&context=3

      I'm curious what your area of research is? What are you studying with respect to Zettelkasten?

      Caveat notetarius. Note collections are highly idiosyncratic to the user or intended audience, thus quality will vary dramatically on the creator's needs and future desires and potential uses. Contemporaneous, very simple notes can be valuable for their initial sensemaking and quite often in actual practice stop there.

      Ultimately, only the user can determine perceived quality and long term value for themselves. Future generations of historians, anthropologists, scholars, and readers, might also find value in notes and note collections, but it seems rare that the initial creators have written them with future readers and audiences in mind. Often they're less useful as the external reader is missing large swaths of context.

      For my own personal notes, I consider high quality notes to be well-sourced, highly reusable, easily findable, and reasonably tagged/linked. My favorite, highest quality notes are those that are new ideas which stem from the combination of two high quality notes. With respect to subjectivity, some of my philosophy is summarized by one of my favorite meta-zettels (alt text also available) from zettelmeister Umberto Eco.

      Anecdotally, 95% of my notes are done digitally and in public, but I've only got scant personal evidence that anyone is reading or interacting with them. I never write them with any perceived public consumption in mind (beyond the readers of the finished pieces that ultimately make use of them), but it is often very useful to get comments and reactions to them. I'm only aware of a small handful of people publishing their otherwise personal note collections (usually subsets) to the web (outside of social media presences which generally have a different function and intent).

      Intellectual historians have looked at and documented external use cases of shared note collections, commonplace books, annotated volumes, and even diaries. There are even examples of published (usually posthumously) commonplace books, waste books, etc., but these are often for influential public and intellectual figures. Here Ludwig Wittgenstein's Zettel, Walter Benjamin's Arcades Project, Vladimir Nabokov's The Original of Laura, Roland Barthes' Mourning Diary, Georg Christoph Lichtenberg's Waste Books, Ralph Waldo Emmerson, Ronald Reagan's card index commonplace, Stobaeus' Anthology, W. H. Auden's A Certain World, and Robert Southey’s Common-Place Book come quickly to mind not to mention digitized scholarly collections of Niklas Luhmann, W. Ross Ashby, S.D. Goitein, Jonathan Edwards' Miscellanies, and Aby Warburg's notes. Some of these latter will give you an idea of what they may have thought quality notes to have been for them, but often they mean little if nothing to the unstudied reader because they lack broader context or indication of linkages.

  7. Dec 2022
    1. It is possible to use values defined via v: option or X-Mailgun-Variables in your templates. However if you do so, the variables are included in the delivered message via the X-Mailgun-Variables header. If this is not desired, use the t:variables option or X-Mailgun-Template-Variables header instead.

      Why are they included in a header? Indeed that is not desired. So why not just not do that? Why is it different if you use t:variables? Why the inconsistency?

    1. Note: it is not possible to apply a boolean scope with just the query param being present, e.g. ?active, that's not considered a "true" value (the param value will be nil), and thus the scope will be called with false as argument. In order for the scope to receive a true argument the param value must be set to one of the "true" values above, e.g. ?active=true or ?active=1.

      Is this behavior/limitation part of the web standard or a Rails-specific thing?

  8. Nov 2022
    1. In our system, events are generated by physical hosts and follow different routes to the event storage. Therefore, the order in which they appear in the storage and become retrievable - via the events API - does not always correspond to the order in which they occur. Consequently, this system behavior makes straight forward implementation of event polling miss some events. The page of most recent events returned by the events API may not contain all the events that occurred at that time because some of them could still be on their way to the storage engine. When the events arrive and are eventually indexed, they are inserted into the already retrieved pages which could result in the event being missed if the pages are accessed too early (i.e. before all events for the page are available). To ensure that all your events are retrieved and accounted for please implement polling the following way:
    1. Warning: This ignores the user's keyboard layout, so that if the user presses the key at the "Y" position in a QWERTY keyboard layout (near the middle of the row above the home row), this will always return "KeyY", even if the user has a QWERTZ keyboard (which would mean the user expects a "Z" and all the other properties would indicate a "Z") or a Dvorak keyboard layout (where the user would expect an "F"). If you want to display the correct keystrokes to the user, you can use Keyboard.getLayoutMap().

      Wow, that's quite a caveat!

  9. Sep 2022
    1. Also be aware of how Ruby handles aliases and inheritance: an alias references the method that was resolved at the time the alias was defined; it is not dispatched dynamically.
    1. Calling the same filter multiple times with different options will not work, since the last filter definition will overwrite the previous ones.
  10. Aug 2022
    1. There are many questions we can ask and answer about branch names. Each one is specific to one particular repository because all branch names are local to that particular repository. Any changes anyone makes in that repository affect only that one repository, at least at the time they make them.

      which assumption? well, people make the assumption that our local repo should know some fact about the remote repo, like its default branch, without actually asking the remote about itself

    1. Bear in mind that lsof doesn't seem to present an easy solution because, once the device is disconnected, the associated names provided by lsof no longer include the name of the disconnected device.
  11. Jul 2022
    1. What ever you do, don't use a for loop: # Don't do this for file in $(find . -name "*.txt") do …code using "$file" done Three reasons: For the for loop to even start, the find must run to completion. If a file name has any whitespace (including space, tab or newline) in it, it will be treated as two separate names. Although now unlikely, you can overrun your command line buffer. Imagine if your command line buffer holds 32KB, and your for loop returns 40KB of text. That last 8KB will be dropped right off your for loop and you'll never know it.
    1. $0 can be set to an arbitrary value by the caller. On the flip side, $BASH_SOURCE can be empty, if no named file is involved; e.g.: echo 'echo "[$BASH_SOURCE]"' | bash
    1. If you don't use an intermediate variable, you need to protect the / characters in the directory to remove so that they aren't treated as the end of the search text.
    2. If the path in question is at the beginning of the PATH variable, you need to match the colon at the end. This is an annoying caveat which complicates easy generic manipulations of PATH variables.
  12. Jun 2022
    1. these two SELECT clauses are NOT equivalent, so be careful: SELECT DISTINCT(event_id, start_time) FROM ... SELECT DISTINCT event_id, start_time FROM ...
  13. Apr 2022
    1. Caution: + continues the statement but not the string. puts "foo"+"bar".upcase gives you fooBAR, whereas puts ("foo"+"bar").upcase gives you FOOBAR. (Whether or not there's a newline after the +.) But: if you use a backslash instead of the plus sign, it will always give you FOOBAR, because combining lines into one statement, and then combining successive strings into one string, happen before the string method gets called.
  14. Mar 2022
    1. The last note is that when binding commands to keyboard shortcuts it is often necessary to only have one command, not two commands connected with a pipe like we use above. You can accomplish this by invoking your piped command as a command string argumetn to a new shell like this:
    1. The code will work without exception but it doesn’t set correct association, because the defined classes are under namespace AddStatusToUser. This is what happens in reality: role = AddStatusToUser::Role.create!(name: 'admin') AddStatusToUser::User.create!(nick: '@ka8725', role: role)
    1. Active Record creates a transaction around each migration, and backfilling in the same transaction that alters a table keeps the table locked for the duration of the backfill. class AddSomeColumnToUsers < ActiveRecord::Migration[7.0] def change add_column :users, :some_column, :text User.update_all some_column: "default_value" end end
  15. Jan 2022
    1. tr '\n' '\\n' would change newlines to backslashes (and then there's an extra n in the second set). sed 's/\n/\\n/g won't work because sed doesn't load the line-terminating newline into the buffer, but handles it internally.
    1. The callback executed by setTimeout is not expected to return anything, it just ignores the returned value. Since once you enter the promise/async world in JavaScript you cannot escape, I was left to wonder what happens when the setTimeout callback returns a promise?
    1. test2 being marked async does wrap your return value in a new promise:
    2. const rejectedP = Promise.reject('-'); const finallyP = rejectedP.finally(); const result1 = rejectedP; const result2 = new Promise(resolve => { const rejectedP = Promise.reject('-'); const finallyP = rejectedP.finally(); resolve(rejectedP); }); we can see that the first snippet creates two promises (result1 and rejectedP being the same) while the second snippet creates three promises. All of these promises are rejected, but the rejectedP rejection is handled by the callbacks attached to it, both through ….finally() and resolve(…) (which internally does ….then(resolve, reject)). finallyP is the promise whose rejection is not handled in the both examples. In the second example, result2 is a promise distinct from rejectedP that is also not handled, causing the second event.
    1. You basically did var a = promise.then(…); var b = promise.catch(…); creating a branch in the chain. If promise is getting rejected now, the catch callback will be called and b will be a fulfilled promise just fine, but the a promise is getting rejected too and nobody handles that. Instead, you should use both arguments of then and write Requirement.create({id: id, data: req.body.data, deleted: false}) .then(requirement => { res.json(requirement); }, reason => { let err = {'error': reason}; res.json(err); });
    1. If at least one component has smallest unhandled error, the whole app will crash and users will not know what to do and developers will not know such an error occurred.
    2. When an error is thrown inside a Promise it looks like Firefox still calls window.onerror, but Chrome swallows the error silently.
    1. Seems easy, right? How about the below code, what will it print? new Promise((_, reject) => reject(new Error('woops'))). catch(error => { console.log('caught', err.message); }); It'll print out an unhandled rejection warning. Notice that err is not defined!
  16. datatracker.ietf.org datatracker.ietf.org
    1. User agents are advised to take special care in parsing the field value, as it might contain more than one challenge, and each challenge can contain a comma-separated list of authentication parameters. Furthermore, the header field itself can occur multiple times.
    1. For given hash, OpenStruct constructor only converts its top level keys.require 'ostruct' h = { foo: { bar: 1 } } obj = OpenStruct.new(h) obj.foo # => { bar: 1} obj.foo.bar # => NoMethodError: undefined method `bar' for {:bar=>1}:Hash
    1. It’s important to understand that an implements clause is only a check that the class can be treated as the interface type. It doesn’t change the type of the class or its methods at all. A common source of error is to assume that an implements clause will change the class type - it doesn’t!
    1. So if you subscribe to both Inbox and All mail you are in practise downloaded your mails twice. If you then delete a mail in inbox it doesnt go away in All mail. It just get the trash-tag. In my opinion you should never subscribe to All mail. You never need to see it. All you need to see are INBOX, TRASH, SENT and the folders YOU created in your gmail-account.
    1. If there is still a problem, try clearing Captcha again.  I acknowledge you wrote that you already did this, but you must open that page using the account that you are setting up in Thunderbird.  If you are signed into multiple Google accounts, the page will open with the primary account.  To be certain that you have used the correct account, please try again after signing out.

      This is a real usability issue.

      That page (https://accounts.google.com/b/0/DisplayUnlockCaptcha) doesn't even tell you which account is active or give you any way to switch.

      As a guess, I tried changing the number, like this: https://accounts.google.com/b/3/DisplayUnlockCaptcha to the same number as I saw in the URL for the account that I wanted to affect: https://mail.google.com/mail/u/3/#inbox and I think it worked (but again, no way to know for sure which account was affected).

    1. Code that is per-component instance should go into a second <script> tag.

      But this seems to conflict with https://hyp.is/NO4vMmzVEeylBfOiPbtB2w/kit.svelte.dev/docs

      The load function is reactive, and will re-run when its parameters change, but only if they are used in the function.

      which seems to imply that load is not just run once for the component statically, but rather, since it can be reactive to:

      url, params, fetch, session and stuff

      may be sufficiently like a per-instance callback, that it could be used instead of onMount?

  17. Dec 2021
    1. For what it's worth, accessing attributes with [] is not the same as using send. The latter will call the accessor method, which is what you want 99/100.
  18. Nov 2021
  19. Oct 2021
    1. const str = 'mañana mañana' const strReverse = str.split('').reverse().join('') // => "anãnam anañam" // notice how the first word has an ã rather ñ
    1. On reload, MockedGateway is reloaded, but $PAYMENT_GATEWAY is not updated because initializers only run on boot. Therefore, it won't reflect the changes.
    2. Please, do not mutate ActiveSupport::Dependencies.autoload_paths, the public interface to change autoload paths is config.autoload_paths.
    1. Org-roam capture templates are incompatible with org-capture templates.
    2. Org-roam attempts to load both the org-ref and org-cite package when indexing files, so no further setup from the user is required for citation support.
    3. You may assign multiple refs to a single node, for example when you want multiple papers in a series to share the same note, or an article has a citation key and a URL at the same time.
    1. And on any given day, developing with Svelte and its reactive nature is simply a dream to use. You can tell Svelte to track state changes on practically anything using the $: directive. And it’s quite likely that your first reactive changes will produce all the expected UI results. But as you start to rely more on UI updates based on variable or array/object changes, it’s likely that your UI will start skipping a beat and dropping values that you know explicitly to be there.
  20. Sep 2021
    1. The Code Expressly prohibits glueing dissimilar plastics together: Listed under "Prohibited Joints" "No glue joints between different tyes of plastic" REF: International Residential Code 2904.16.2 Uniform Plumbing Code 316.1.6 It is true that Oatey makes a glue that is listed as approved for both ABS & PVC however there still remains a good reason why it is not approved for glueing dissimilar types of plastics together. In a normal glueing situation the bonding material sticks to the surface of both pieces being fastened together, thus forming a bond, but such is not the case with plastic plumbing pipe and fittings. When connecting plastic plumbing fittings we must first use a solvent type cleaner/primer. While the cleaner primer does clean the fitting, its primary purpose is to soften or break the smooth glazed surface of the pipe which exposes the inner polimers. The glue then chemically softens the plastic on both the pipe wall and the fitting interior and the two surfaces then fuse together forming a chemical weld. The problem with attempting to glue dissimilar plastic is that they do not react to the glue at the same rate, therefore one material may soften and reharden again before the other surface has softened sufficiently to fuse a true weld. The end result is that while it has all the appearances of having glued together you are left with a weak joint, in the same manner as a cold solder joint.
  21. Aug 2021
    1. All answers here which mention scrollHeight/scrollWidth should be adjusted a bit to take body margins into account. Browsers apply default nonzero margins for documents' body element (and it's also applicable to content loaded into frames). The working solution I found is to add this: parseInt(window.getComputedStyle(this.contentDocument.body).margin.
    1. Now consider we want to handle numbers in our known value set: const KNOWN_VALUES = Object.freeze(['a', 'b', 'c', 1, 2, 3]) function isKnownValue(input?: string | number) { return typeof(input) === 'string' && KNOWN_VALUES.includes(input) } Uh oh! This TypeScript compiles without errors, but it's not correct. Where as our original "naive" approach would have worked just fine. Why is that? Where is the breakdown here? It's because TypeScript's type system got in the way of the developer's initial intent. It caused us to change our code from what we intended to what it allowed. It was never the developer's intention to check that input was a string and a known value; the developer simply wanted to check whether input was a known value - but wasn't permitted to do so.
  22. developer.mozilla.org developer.mozilla.org
    1. If you forget to define x in the object you pass as the second argument, or if there's some similar bug or confusion, you won't get an error -- just unexpected results.
  23. Jul 2021
    1. That's because in CSS, any value at all -- even 'disabled="false"' or whatever -- is exactly the same as 'disabled' or 'disabled="disabled"'. The opposite of 'disabled="anything"' is to not have a disabled keyword in there at all.
    1. Putting comments like these can be helpful, but it’s still set up for doing something sketchy, especially if you are new to the codebase. Being new and not being aware of all the “gotchas” a code has can certainly send you down the concern downward spiral.
    1. was due to a form that was submitted (ALWAYS SET THAT TYPE-PROPERTY ON YOUR BUTTONS!) after my onclick-event fired, but before my request had any chance to be completed.
    1. A big gotcha needs to be mentioned: When testing transaction, you need to turn off transactional_fixtures. This is because the test framework (e.g Rspec) wraps the test case in transaction block. The after_commit is never called because nothing is really committed. Expecting rollback inside transaction doesn't work either even if you use :requires_new => true. Instead, transaction gets rolled back after the test runs.
    1. This cache has a small trade-off! If we request a list of data, and the API returns an empty list, then the cache won't be able to see the __typename of said list and invalidate it.

      That's one big caveat!

  24. Jun 2021
    1. -- The array on the right side is not considered contained within the -- array on the left, even though a similar array is nested within it: SELECT '[1, 2, [1, 3]]'::jsonb @> '[1, 3]'::jsonb; -- yields false -- But with a layer of nesting, it is contained: SELECT '[1, 2, [1, 3]]'::jsonb @> '[[1, 3]]'::jsonb;
    1. should not reference any API keys or secrets, which will be exposed to the client

      How would they be exposed? Because load() lives in Svelte component files (__layout.svelte), whose code is made available both to server and client environments.

  25. May 2021
    1. this is incomplete. Yes you get a load of commits, but they no longer refer to the right paths. git log dir-B/somefile won't show anything except the one merge. See Greg Hewgill's answer references this important issue.
    1. The implicit dependencies between different versions of different services were not expressed anywhere, which led to various problems in building, continuous integration, and, notably, repeatable builds.
    1. That image only contains 200 pixels horizontally, but the browser stretches it to 400px wide or even farther!Luckily, you’ll see there’s an easy “fix” there at the end: our old good friend the width attribute!<img src="example.gif", srcset="example.gif 200w" sizes="(min-width: 400px) 400px, 100vw" width="200" /* <=== TA-DA! */ class="logo">As long as you can specify the width attribute so it reflects the true maximum size of your largest image, you won’t run into this problem of having sizes make your image wider than it naturally should go.
    2. The selected source size affects the intrinsic size of the image (the image’s display size if no CSS styling is applied).
  26. Apr 2021
  27. Mar 2021
    1. Coming from React to Svelte this did catch me out numerous times but for me I now prefer Svelte's approach, particularly because it removes some of the boilerplate around useEffect.
    1. Note that autosave will only trigger for already-persisted association records if the records themselves have been changed. This is to protect against SystemStackError caused by circular association validations.
    1. These methods should be used with caution, however, because important business rules and application logic may be kept in callbacks. Bypassing them without understanding the potential implications may lead to invalid data.
    1. Note that the :task option for step configures this element as a low-level circuit interface, or in other words, it will skip the wrapping with the task interface.

      This bit me because I didn't realize that. Was getting error:

      TypeError: no implicit conversion of Symbol into Integer
      

      Finally checked ctx and found it was an array...

      At least this is documented here.

  28. Feb 2021
    1. Using Track() with a new track semantic only makes sense when using the [:magnetic_to option] on other tasks.
    1. Of course our object doesn't have any contacts yet, so our controller will need to make sure that the form has at least one fields_for block to render by giving it one on initialization
    1. If you need your grid to utilize a gap between columns / rows, you won't be able to use the gap property when using this method. You'd instead need to resort to some negative margin manipulation to handle the extra gap space.
    1. You use grid-area, so the place for the side nav is allocated at start. If you hide (or even delete) the side nav, that won't change anything about this. You have to do a little trick: Set the width for the first column to 0 and change the grid-gap because otherwise you will have a (not needed) gap at the left.
    1. This gives me the layout with the full-width image and two sections of content placed; however, if I add the background to the sections, it will stop above the row-gap between section and the full-width image.
  29. Jan 2021
    1. In case you changed something in the [Install] directive, you may need to run sudo systemctl reenable YOURUNITFILE in order to recreate the symlinks in the .target directories.
    2. Just in case, daemon-reload isn't universal, have got to run systemctl --user daemon-reload for user services
    1. Note that the value of canvas will be undefined until the component has mounted, so we put the logic inside the onMount lifecycle function.
    1. Note: your arrow must be an HTMLElement (not an SVGElement). To use an SVG arrow, wrap it in a <div> tag with the data-popper-arrow attribute.
    1. Elements with the disabled attribute aren't interactive, meaning users cannot focus, hover, or click them to trigger a tippy.
    1. but you'll find that wherever you have an img tag inside a link, the image will have a red border under it.
    2. if you set text-decoration: underline for all links then you will have to set text-decoration: none for special links which you don't need an underline.
    1. “JSONP is JSON with extra code” would be too easy for the real world. No, you gotta have little discrepancies. What’s the fun in programming if everything just works? Turns out JSON is not a subset of JavaScript. If all you do is take a JSON object and wrap it in a function call, one day you will be bitten by strange syntax errors, like I was today.
  30. Dec 2020
    1. JSON.parse() does not allow single quotes
    2. JSON.parse() does not allow trailing commas
    3. If the reviver only transforms some values and not others, be certain to return all untransformed values as-is, otherwise, they will be deleted from the resulting object.
  31. Nov 2020
    1. true && { echo true; false; } || { echo false; true; }
    2. Bash (like all Bourne shells) has a special syntax for referring to the list of positional parameters one at a time, and $* isn't it. Neither is $@. Both of those expand to the list of words in your script's parameters, not to each parameter as a separate word.
    3. However, this construct is not completely equivalent to if ... fi in the general case.

      The caveat/mistake here is if you treat it / think that it is equivalent to if a then b else c. That is not the case if b has any chance of failing.

    4. true && ((i++)) || ((i--))
    5. Here we go again. [ is a command. It is not a syntactic marker that sits between if and some sort of C-like "condition". Nor is it used for grouping. You cannot take C-like if commands and translate them into Bash commands just by replacing parentheses with square brackets!
    1. Important caveat: in the combined expression, if the middle command has a non-zero exit status, then both the middle and the rightmost command end up getting executed.

      I don't think that is surprising, is it? Since && and || have the same order of precedence. So I think this is more of a clarification than a caveat.

      I think this is just because:

      a && b || c is equivalent to: (a && b) || c (so of course c gets evaluated if (a && b) is false (that if either a or b is false).

      I think they just mean, in this case:

      bedmap && mv || fail
      

      if mv fails, then fail still gets executed.

      Easier to see with a simpler example:

      ⟫ true && false || echo 'fail'
      fail
      
      ⟫ false && true || echo 'fail'
      fail
      

      Better example/explanation here: https://hyp.is/-foxmCVXEeuhnLM-le_R4w/mywiki.wooledge.org/BashPitfalls

      The caveat/mistake here is if you treat it / think that it is equivalent to if a then b else c. That is not the case if b has any chance of failing.

    1. The potential problem: if second_task fails, third_task will not run, and execution will continue to the next line of code - next_task, in this example. This may be exactly the behavior you want. Alternatively, you may be intending that if second_task fails, the script should immediately exit with its error code. In this case, the best choice is to use a block - i.e., curly braces: first_task && { second_task third_task } next_task Because we are using the -e option, if second_task fails, the script immediately exits.
    1. But using internal api's is dangerous as these may change when you update svelte. If you decide to use this, add a line to your project Readme.md mentioning which internal api's you used and why. Try to write it using other methods when you can.
    1. It's important to only prepend it with ~, because ~/ resolves to the home directory.
  32. Oct 2020
    1. The only tricky part is that the error will come back as meta.submitError, so you need to check for both when displaying your error.
    2. Some user experience issue with the proposed solution: This won't show up the inline field error message if you just hit on submit and other fields already contained errors since the code on the onSubmit won't be hit
    1. My version of https://svelte.dev/repl/9c7d12357a15457bb914705702f156d1?version=3.19.2 from https://github.com/sveltejs/svelte/issues/4586

      to try to simplify and help me understand it better.

      So the lack of synchronousness is only noticed inside handleClick.

      By the time the DOM gets updated, it has a consistent/correct state.

      In other words, the console.log shows wrong value, but template shows correct value. So this might not be an actual problem for many/most use cases.

    1. I too have been confused by behavior like this. Perhaps a clearly defined way to isolate atomic units with synchronous reactivity would help those of us still working through the idiosyncrasies of reactivity.
    2. For performance reasons, $: reactive blocks are batched up and run in the next microtask. This is the expected behavior. This is one of the things that we should talk about when we figure out how and where we want to have a section in the docs that goes into more details about reactivity. If you want something that updates synchronously and depends on another value, you can use a derived store:
    1. Anyway, If this is an expected behaviour, we should probably add an asterisk to the docs, describing the pitfall, because I believe many will be bitten by this.
    1. A simple rule of thumb: the name of the updated variable must appear on the left hand side of the assignment. For example this... const foo = obj.foo; foo.bar = 'baz';...won't update references to obj.foo.bar, unless you follow it up with obj = obj.
    1. Sometimes we can’t implement a solution that’s fully spec-compliant, and in those cases using a polyfill might be the wrong answer. A polyfill would translate into telling the rest of the codebase that it’s okay to use the feature, that it’ll work just like in modern browsers, but it might not in edge cases.
    1. The clean-up function runs before the component is removed from the UI to prevent memory leaks. Additionally, if a component renders multiple times (as they typically do), the previous effect is cleaned up before executing the next effect. In our example, this means a new subscription is created on every update.
    1. Note that if you are calling reset() and not specify new initial values, you must call it with no arguments. Be careful to avoid things like promise.catch(reset) or onChange={form.reset} in React, as they will get arguments passed to them and reinitialize your form.
  33. Sep 2020
    1. I don't understand why it just launches the mutation once and then it throws the error Function called outside component initialization, the only way to make it work is to do something like $: result = mutation(...) but it doesn't make sense, I don't want to run the mutation after each keystroke.
    1. Child can't update things by reassignment if you do:

      <Child bind:things={things} />
      

      but can if you do;

      <Child bind:things={$object.things} />
      
    1. Just throwing in <div class="{$$props.class || ''} otherChildClass"></div> seems the easiest, and it'll avoid undefined classes. I feel like many aren't noticing the undefined values getting inserted in their classes.
    1. It’s confusing enough, in fact, that the React team don’t trust you to write correct hooks code without using the special lint rules they devised.

      But even that introduces new problems. The only difference between the app on the left and the one on the right is that on the right, I’m using a custom useLocalStorage hook instead of useState. It behaves equivalently. So why do I have this lint warning all of a sudden?

      It turns out that certain built-in hooks have special treatment hard-coded in. So when you’re told that hooks are just functions, and you can do all the things you normally do with functions, it’s true… but there are some interesting caveats around that statement.

    1. In mapbox.js you'll see this line: const key = {};We can use anything as a key — we could do setContext('mapbox', ...) for example. The downside of using a string is that different component libraries might accidentally use the same one; using an object literal means the keys are guaranteed not to conflict in any circumstance (since an object only has referential equality to itself, i.e. {} !== {} whereas "x" === "x"), even when you have multiple different contexts operating across many component layers.
    1. The module specifier is always fixed. That is, you can’t change what you import depending on a condition. And you can’t assemble a specifier dynamically.
    1. In React, use the ternary operator (?) or a logical AND (&&). The logical AND can cause errors if the variable is not a boolean, so be careful with that one (or just stick with the ternary operator).
  34. Aug 2020
    1. Note that beforeUpdate will first run before the component has mounted, so we need to check for the existence of div before reading its properties.
  35. Jul 2020
    1. Because Svelte's reactivity is based on assignments, using array methods like .push() and .splice() won't automatically trigger updates.
  36. Jun 2020
    1. However, when you use an SD card as internal storage, Android formats the SD card in such a way that no other device can read it. Android also expects the adopted SD card to always be present, and won’t work quite right if you remove it.
  37. May 2020
    1. For instance, cor does not distribute over cand: compare (A cand B) cor C with (A cor C) cand (B cor C); in the case ¬A ∧ C , the second expression requires B to be defined, the first one does not
    1. Unfortunately, you cannot index an expression, which has a sub-query in it. If you want to index it, you need to create a function for it:
  38. Apr 2020
    1. As mentioned in StateMachines::Machine#state, you can define behaviors, like validations, that only execute for certain states. One important caveat here is that, due to a constraint in ActiveRecord's validation framework, custom validators will not work as expected when defined to run in multiple states.
    1. Google Tag Manager allows you to avoid tagging scripts as described below, although this is limited to a certain category of scripts – scripts that are not positional/do not define a position. It, therefore, does not handle embed scripts such as those related to advertising banners, youtube video widgets, facebook like buttons etc.
    1. Remember to call super in any subclasses that override teardown.

      And yet the Rails core chose not to use RSpec, citing how it would be too easy to write subject == expected on accident?

    1. For Rails 5, note that protect_from_forgery is no longer prepended to the before_action chain, so if you have set authenticate_user before protect_from_forgery, your request will result in "Can't verify CSRF token authenticity." To resolve this, either change the order in which you call them, or use protect_from_forgery prepend: true.
    1. This is pretty old now, but it should absolutely be mentioned that you can NOT always fall back to html - I suspect that MOST places that support markdown don't support html.

      Not sure if this is true, though. GitHub and GitLab support HTML, for example.

      Maybe comments on websites wouldn't normally allow it; I don't know. But they should. One can use this filter, for example, to make it safer.

    1. The rate limit can be just that - a limit rather than also dishing out punishment via the 24 hour block

      Why can't a plain rate limit (without additional blocking) by used even if not authenticated? Seems like it could.

    1. If all you want to do is print the results you might be used to leaving out the -print action. You generally don't want to do that when using -prune.
    2. which means that it'll also print out the name of the directory you're pruning, which usually isn't what you want. Instead it's better to explicitly specify the -print action if that's what you want
    1. This situation usually arises from external constraints not design choices such as my example with Sequel. My point is that assigning a value to a constant is allowed by Ruby in certain scopes and not others. It used to be up to the developer to choose wisely when to perform the assignment. Ruby changed on this. Not for everyone's good.
  39. Mar 2020
    1. Our WordPress plugin automatically blocks scripts that are generated on the server side (therefore returned by PHP by WordPress). Scripts that are inserted into the page via JavaScript after the loading process of that page are not and cannot be blocked automatically.
    1. YouTube will not collect and store info on the users, that are visiting your site, on its server unless they view the video
    2. unless they view the video
    1. While you can't completely stop YouTube from installing cookies through the embedded videos on your site, enabling privacy-enhanced mode will allow You Tube to install the cookies only when a user actually clicks to play one of the videos
  40. tonydye.typepad.com tonydye.typepad.com
    1. The absolutely worst thing that can happen in your anti-spam solution is to block a good email and not let anybody know about it!  Anti-spam solutions should always generate an NDR such that a legitimate sender can know their message didn't get through. (Of course, we know many legitimate users don't read nor understand NDRs, so there's still an issue)  A really good anti-spam solution should not only generate an NDR, but that NDR should have an "escape clause" in it that gives that legitimate user a special way to get through the anti-spam solution, if they take some reasonable steps.
    1. Cookies may not be detected by scanner if the related tag is triggered by actions such as form submission, scroll depth, timing delay, etc. These tags will need to be controlled by manual methods.

      With all these caveats listed, it makes me wonder for which tags auto-blocking does work. Only script tags inside of head?

      They are a bit vague in their "how it works" description...

    2. Cookies set by in-line scripting directly in the HTML is not supported by the auto-blocking functionality.
    1. However imagine we are creating a format string in a separate file, commonly because we would like to internationalize it and we rewrite it as: <?php$format = 'The %s contains %d monkeys';echo sprintf($format, $num, $location);?> We now have a problem. The order of the placeholders in the format string does not match the order of the arguments in the code. We would like to leave the code as is and simply indicate in the format string which arguments the placeholders refer to. We would write the format string like this instead: <?php$format = 'The %2$s contains %1$d monkeys';echo sprintf($format, $num, $location);?> An added benefit is that placeholders can be repeated without adding more arguments in the code.
    2. $format = 'There are %d monkeys in the %s';

      Compared to below:

      $format = 'The %s contains %d monkeys'
      
  41. Jan 2020
    1. before_destroy callbacks should be placed before dependent: :destroy associations (or use the prepend: true option), to ensure they execute before the records are deleted by dependent: :destroy.
    1. Please do not make the mistake of trying to reduce the HAVING clause with a little false relational algebra to: 1 HAVING COUNT(PS1.plane_name) = COUNT(H1.plane_name) because it does not work; it will tell you that the hangar has (n) planes in it and the pilot_name is certified for (n) planes, but not that those two sets of planes are equal to each other.
  42. Dec 2019
    1. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening
  43. Aug 2019
    1. The parentheses ( ... ) around the assignment statement are required when using object literal destructuring assignment without a declaration. {a, b} = {a: 1, b: 2} is not valid stand-alone syntax, as the {a, b} on the left-hand side is considered a block and not an object literal.
    2. Your ( ... ) expression needs to be preceded by a semicolon or it may be used to execute a function on the previous line.