171 Matching Annotations
  1. Apr 2024
  2. Mar 2024
  3. Feb 2024
  4. Jan 2024
    1. Driver management through Selenium Manager is opt-in for the Selenium bindings. Thus, users can continue managing their drivers manually (putting the driver in the PATH or using system properties) or rely on a third-party driver manager to do it automatically. Selenium Manager only operates as a fallback: if no driver is provided, Selenium Manager will come to the rescue.
    1. Instance methods Instances of Models are documents. Documents have many of their own built-in instance methods. We may also define our own custom document instance methods. // define a schema const animalSchema = new Schema({ name: String, type: String }, { // Assign a function to the "methods" object of our animalSchema through schema options. // By following this approach, there is no need to create a separate TS type to define the type of the instance functions. methods: { findSimilarTypes(cb) { return mongoose.model('Animal').find({ type: this.type }, cb); } } }); // Or, assign a function to the "methods" object of our animalSchema animalSchema.methods.findSimilarTypes = function(cb) { return mongoose.model('Animal').find({ type: this.type }, cb); }; Now all of our animal instances have a findSimilarTypes method available to them. const Animal = mongoose.model('Animal', animalSchema); const dog = new Animal({ type: 'dog' }); dog.findSimilarTypes((err, dogs) => { console.log(dogs); // woof }); Overwriting a default mongoose document method may lead to unpredictable results. See this for more details. The example above uses the Schema.methods object directly to save an instance method. You can also use the Schema.method() helper as described here. Do not declare methods using ES6 arrow functions (=>). Arrow functions explicitly prevent binding this, so your method will not have access to the document and the above examples will not work.

      Certainly! Let's break down the provided code snippets:

      1. What is it and why is it used?

      In Mongoose, a schema is a blueprint for defining the structure of documents within a collection. When you define a schema, you can also attach methods to it. These methods become instance methods, meaning they are available on the individual documents (instances) created from that schema.

      Instance methods are useful for encapsulating functionality related to a specific document or model instance. They allow you to define custom behavior that can be executed on a specific document. In the given example, the findSimilarTypes method is added to instances of the Animal model, making it easy to find other animals of the same type.

      2. Syntax:

      Using methods object directly in the schema options:

      javascript const animalSchema = new Schema( { name: String, type: String }, { methods: { findSimilarTypes(cb) { return mongoose.model('Animal').find({ type: this.type }, cb); } } } );

      Using methods object directly in the schema:

      javascript animalSchema.methods.findSimilarTypes = function(cb) { return mongoose.model('Animal').find({ type: this.type }, cb); };

      Using Schema.method() helper:

      javascript animalSchema.method('findSimilarTypes', function(cb) { return mongoose.model('Animal').find({ type: this.type }, cb); });

      3. Explanation in Simple Words with Examples:

      Why it's Used:

      Imagine you have a collection of animals in your database, and you want to find other animals of the same type. Instead of writing the same logic repeatedly, you can define a method that can be called on each animal instance to find similar types. This helps in keeping your code DRY (Don't Repeat Yourself) and makes it easier to maintain.

      Example:

      ```javascript const mongoose = require('mongoose'); const { Schema } = mongoose;

      // Define a schema with a custom instance method const animalSchema = new Schema({ name: String, type: String });

      // Add a custom instance method to find similar types animalSchema.methods.findSimilarTypes = function(cb) { return mongoose.model('Animal').find({ type: this.type }, cb); };

      // Create the Animal model using the schema const Animal = mongoose.model('Animal', animalSchema);

      // Create an instance of Animal const dog = new Animal({ type: 'dog', name: 'Buddy' });

      // Use the custom method to find similar types dog.findSimilarTypes((err, similarAnimals) => { console.log(similarAnimals); }); ```

      In this example, findSimilarTypes is a custom instance method added to the Animal schema. When you create an instance of the Animal model (e.g., a dog), you can then call findSimilarTypes on that instance to find other animals with the same type. The method uses the this.type property, which refers to the type of the current animal instance. This allows you to easily reuse the logic for finding similar types across different instances of the Animal model.

      Certainly! Let's go through each part and explain it in simple terms: ### 1. `this` in Mongoose: - **What is `this`?** In JavaScript, `this` refers to the current context or object. In Mongoose, particularly within methods and middleware functions, `this` represents the instance (document) the function is currently operating on. - **Why is it used?** `this` is used to access and modify the properties of the current document. For example, in a Mongoose method, `this` allows you to refer to the fields of the specific document the method is called on. ### 2. Example: Let's use the `userSchema.pre("save", ...)`, which is a Mongoose middleware, as an example: ```javascript userSchema.pre("save", async function (next) { if (!this.isModified("password")) { next(); } else { this.password = await bcrypt.hash(this.password, 10); next(); } }); ``` - **Explanation in Simple Words:** - Imagine you have a system where users can sign up and set their password. - Before saving a new user to the database, you want to ensure that the password is securely encrypted (hashed) using a library like `bcrypt`. - The `userSchema.pre("save", ...)` is a special function that runs automatically before saving a user to the database. - In this function: - `this.isModified("password")`: Checks if the password field of the current user has been changed. - If the password is not modified, it means the user is not updating their password, so it just moves on to the next operation (saving the user). - If the password is modified, it means a new password is set or the existing one is changed. In this case, it uses `bcrypt.hash` to encrypt (hash) the password before saving it to the database. - The use of `this` here is crucial because it allows you to refer to the specific user document that's being saved. It ensures that the correct password is hashed for the current user being processed. In summary, `this` in Mongoose is a way to refer to the current document or instance, and it's commonly used to access and modify the properties of that document, especially in middleware functions like the one demonstrated here for password encryption before saving to the database.

    Tags

    Annotators

    URL

  5. Nov 2023
  6. Sep 2023
    1. the conjunction of those two claims the properties exist even when they're not perceived even when they're not measured and they have influences that propagate no faster 00:06:57 than the speed of light that's local realism and local realism is false
      • for: objectivism, materialism, question, question - materialism, question - objectivism, if a tree falls in the forest
      • question
        • How would Donald respond to the question:
          • If a tree falls in the forest, does anyone hear?
          • Does he hold the same view as modern consensus of quantum physics?
  7. Aug 2023
    1. highlights the dire financial circumstances of the poorest individuals, who resort to high-interest loans as a survival strategy. This phenomenon reflects the interplay between human decision-making and development policy. The decision to take such loans, driven by immediate needs, illustrates how cognitive biases and limited options impact choices. From a policy perspective, addressing this issue requires understanding these behavioral nuances and crafting interventions that provide sustainable alternatives, fostering financial inclusion and breaking the cycle of high-interest debt.

  8. Jun 2023
  9. May 2023
    1. ```http GET /users

      200 OK Accept-Ranges: users Content-Range: users 0-9/200

      [ 0, …, 9 ] ```

      ```http GET /users Range: users=0-9

      206 Partial Content Accept-Ranges: users Content-Range: users 0-9/200

      [ 0, …, 9 ] ```

      ```http GET /users Range: users=0-9,50-59

      206 Partial Content Accept-Ranges: users Content-Type: multipart/mixed; boundary=next

      --next Content-Range: users 0-9/200

      [ 0, …, 9 ]

      --next Content-Range: users 50-59/200

      [ 50, …, 59 ]

      --next-- ```

      ```http GET /users?name=Fred

      206 Partial Content Accept-Ranges: users Content-Range: users 0-100/*

      [ 0, …, 100 ] ```

  10. Mar 2023
    1. Send the 304 Not Modified response

      ```js import etag from "etag"; import { renderToString } from "react-dom/server"; import type { EntryContext, HandleDataRequestFunction } from "remix"; import { RemixServer } from "remix";

      export default function handleRequest( request: Request, status: number, headers: Headers, remixContext: EntryContext ) { let markup = renderToString( <RemixServer context={remixContext} url={request.url} /> );

      headers.set("Content-Type", "text/html"); headers.set("ETag", etag(markup));

      // check if the If-None-Match header matches the ETag if (request.headers.get("If-None-Match") === headers.get("ETag")) { // and send an empty Response with status 304 and the headers. return new Response("", { status: 304, headers }); }

      return new Response("<!DOCTYPE html>" + markup, { status, headers }); }

      export let handleDataRequest: HandleDataRequestFunction = async ( response: Response, { request } ) => { let body = await response.text();

      if (request.method.toLowerCase() === "get") { response.headers.set("etag", etag(body)); // As with document requests, check the If-None-Match header // and compare it with the Etag, if they match, send the empty 304 Response if (request.headers.get("If-None-Match") === response.headers.get("ETag")) { return new Response("", { status: 304, headers: response.headers }); } }

      return response; }; ```

  11. Jan 2023
  12. Dec 2022
    1. This is a terrible idea. At least if there's no way to opt out of it! And esp. if it doesn't auto log out the original user after some timeout.

      Why? Because I may no longer remember which device/connection I used originally or may no longer have access to that device or connection.

      What if that computer dies? I can't use my new computer to connect to admin UI without doing a factory reset of router?? Or I have to clone MAC address?

      In my case, I originally set up via ethernet cable, but after I disconnected and connected to wifi, the same device could not log in, getting this error instead! (because different interface has different mac address)

    1. Economists explain that markets work bestwith “perfect information.” And visibilityfeeds this market by translating and sharingskills. But the price of transparency in themodern age is invaded privacy, as well as biasinherent in automated products and services
  13. Nov 2022
    1. To check whether the music symbol ♫ is being displayed in a string (if it is not being displayed on some devices), you can try measuring the string width; if width == 0 then the symbol is absent.
    2. I want to check if the String I am about to display can be displayed by my custom font.
    3. I can't find a method to check if my Typeface can display a particular String though.
  14. Sep 2022
    1. To see if you are writing good code, you can question yourself. how long it will take to fully transfer this project to another person? If the answer is uff, I don’t know… a few months… your code is like a magic scroll. most people can run it, but no body understand how it works. Strangely, I’ve seen several places where the IT department consist in dark wizards that craft scrolls to magically do things. The less people that understand your scroll, the more powerfully it is. Just like if life were a video game.
    2. So make sure to write your documentation, but do not explain your spells.
    3. This is so clear that you don’t even need comments to explain it.
    4. Another type of comments are the ones trying to explain a spell.
    5. Do not explain your spells, rewrite them.
  15. Aug 2022
  16. Jul 2022
    1. let me comment on your quantum physics i have only one objection please i think it's uh uh it's 01:01:21 what you said about the two uh sort of prototypical uh quantum puzzles which is schrodinger the double slit experiment uh it's uh it's perfect um my only objection is that in my book 01:01:34 i described of course i had a chapter about schrodinger cat but i don't use a situation in which the cat is dead or alive 01:01:46 i prefer a situation in which the cat is asleep or awake just because i don't like killing cats even in in in in mental experiments so after that 01:01:58 uh uh replacing a sleep cut with a dead cat i think uh i i i i completely agree and let me come to the the serious part of the answer um 01:02:10 what you mentioned as the passage from uh the third and the fourth um between among the the sort of the versions of 01:02:25 wooden philosophy it's it's exactly what i what i think is relevant for quantum mechanics for this for the following reason we read in quantum mechanics books 01:02:37 that um we should not think about the mechanical description of reality but the description reality with respect to the observer and there is always this notion in in books that there's observer or there are 01:02:50 paratus that measure so it's a uh but i am a scientist which view the world from the perspective of 01:03:02 modern science where one way of viewing the world is that uh there are uh you know uh billions and billions of galaxies each one with billions and billions of 01:03:14 of of of stars probably with planets all around and uh um from that perspective the observer in any quantum mechanical experiment is just one piece in the big story 01:03:28 so i have found the uh berkeley subjective idealism um uh profoundly unconvincing from the point 01:03:39 of view of a scientist uh because it there is an aspect of naturalism which uh it's a in which i i i grew up as a scientist 01:03:52 which refuses to say that to understand quantum mechanics we have to bring in our mind quantum mechanics is not something that has directly to do with our mind has not 01:04:05 something directly to do about any observer any apparatus because we use quantum mechanics for describing uh what happened inside the sun the the the reaction the nuclear reaction there or 01:04:18 galaxy formations so i think quantum mechanics in a way i think quantum mechanics is experiments about not about psychology not about our mind not about consciousness not 01:04:32 about anything like that it has to do about the world my question what we mean by real world that's fine because science repeatedly was forced to change its own ideas about the 01:04:46 real world so if uh if to make sense of quantum mechanics i have to think that the cat is awake or asleep only when a conscious observer our mind 01:05:00 interacts with this uh i say no that's not there are interpretations of quantum mechanics that go in that direction they require either am i correct to say the copenhagen 01:05:14 school does copenhagen school uh talk about the observer without saying who is what is observed but the compelling school which is the way most 01:05:27 textbooks are written uh describe any quantum mechanical situation in terms okay there is an observer making a measurement and we're talking about the outcome of the measurements 01:05:39 so yes it's uh it assumes an observer but it's very vague about what what an observer is some more sharp interpretation like cubism uh take this notion observer to be real 01:05:54 fundamental it's an agent somebody who makes who thinks about and can compute the future so it's a it's a that's that's a starting point for for doing uh for doing the rest i was 01:06:07 i've always been unhappy with that because things happen on the sun when there is nobody that is an observer in anything and i want to think to have a way of thinking in the world that things happen there 01:06:20 independently of me so to say is they might depend on one another but why should they depend on me and who am i or you know what observers should be a you know a white western scientist with 01:06:32 a phd i mean should we include women should we include people without phd should we include cats is the cat an observer should we fly i mean it's just not something i understand

      Carlo goes on to address the fundamental question which lay at the intersection of quantum mechanics and Buddhist philosophy: If a tree falls in the forest, does anybody hear? Carlo rejects Berkeley's idealism and states that even quantum mechanical laws are about the behavior of a system, independent of whether an observer is present. He begins to invoke his version of the Schrödinger cat paraodox to explain.

  17. Apr 2022
  18. Mar 2022
  19. inst-fs-iad-prod.inscloudgate.net inst-fs-iad-prod.inscloudgate.net
    1. insidious declamations should have no effect upon the wise legislators who have decreed liberty to humanity. The attacks the colonists propose against this liberty must be feared all the more insofar as they hide their detestable projects under the veil of patriotism. We know that illusory and specious descriptions have been made to you of the renewal of terrible violence. Already, perfidious emissaries have crept among us to foment destruction at the hands ofliberticides. They will not succeed, this 1 swear by all that is most sacred in liberty. My attachment to France, the gratitude that all the blacks conserve for her, make it my duty to hide from you neither the plans being fomented nor the oath that we renew to bury ourselves beneath the ruins of a country revived by liberty rather than suffer the return of slavery.

      Here Toussaint states that he refuses to let Vaublanc convince 'property' owners in St. Domingue to regress back to the use of enslavement. Toussaint also says that it he and other Blacks have gratitude to France and will not try to hide the fact they will all fight should, the "enemy of liberty" slavery return.

  20. Jan 2022
    1. The ticket which tracks issues using Gmail with Thunderbird (Bug 402793)

      Notice how it was created >= 14 years ago and is still open.

      Notice how they just keep updating it by adding "Depends on:" "No longer depends on:" (cleaner than adding the details of those related/sub issues directly here)

  21. Dec 2021
    1. The results of the study showed that object control motor skills (such as kicking, catching, and throwing a ball), were better in the children who played interactive games.“This study was not designed to assess whether interactive gaming can actually develop children’s movement skills, but the results are still quite interesting and point to a need to further explore a possible connection,” said Dr. Lisa Barnett, lead researcher on the study.“It could be that these children have higher object control skills because they are playing interactive games that may help to develop these types of skills (for example, the under hand roll through playing the bowling game on the Wii). Playing interactive electronic games may also help eye-hand coordination.”

      This is a deductive argument because the logical premise which is that video games can improve motion control skills is supported by a logical premises which is the evidence from Dr. Lisa Barnett. This premises leads to the conclusion that video games can improve motor skills.

  22. Oct 2021
    1. Finding how to check if a list is empty in Python is not so a tricky task as you think. There are few effective methods available to make your functionalities easy. And of course, list play a paramount role in python that come up with few tempting characteristics listed in the below for your reference.

      Hope so, you got the points that are listed in the above points. All the methods are very simple to write and execute! Probably, the best solution is revealed for your query of “how to Check if a List Is Empty in Python

  23. Aug 2021
  24. Jul 2021
  25. Jun 2021
    1. Prettier intentionally doesn’t support any kind of global configuration. This is to make sure that when a project is copied to another computer, Prettier’s behavior stays the same. Otherwise, Prettier wouldn’t be able to guarantee that everybody in a team gets the same consistent results.
  26. May 2021
  27. Apr 2021
  28. Mar 2021
    1. I'd suggest there ought to be config to disable source maps specifically, and specifically for either CSS or JS (not alwasy both), without turning off debug mode. As you note, debug mode does all sorts of different things that you might want with or without source maps.
    1. # This behavior can be disabled with: # # environment.unregister_postprocessor 'application/javascript', Sprockets::SafetyColons

      but it appears to no longer be possible in latest version...

    1. The HTML5 form validation techniques in this post only work on the front end. Someone could turn off JavaScript and still submit jank data to a form with the tightest JS form validation.To be clear, you should still do validation on the server.
    1. Therefore client side validation should always be treated as a progressive enhancement to the user experience; all forms should be usable even if client side validation is not present.
    2. It's important to remember that even with these new APIs client side validation does not remove the need for server side validation. Malicious users can easily workaround any client side constraints, and, HTTP requests don't have to originate from a browser.
    3. Since you have to have server side validation anyways, if you simply have your server side code return reasonable error messages and display them to the end user you have a built in fallback for browsers that don't support any form of client side validation.
  29. Feb 2021
    1. We can ask timeout to try to stop the program using SIGTERM, and to only send in SIGKILL if SIGTERM didn’t work. To do this, we use the -k (kill after) option. The -k option requires a time value as a parameter.
    1. For this one we'll define a helper method to handle raising the correct errors. We have to do this because calling .run! would raise an ActiveInteraction::InvalidInteractionError instead of an ActiveRecord::RecordNotFound. That means Rails would render a 500 instead of a 404.

      True, but why couldn't it handle this for us?

    1. Flexbox's strength is in its content-driven model. It doesn't need to know the content up-front. You can distribute items based on their content, allow boxes to wrap which is really handy for responsive design, you can even control the distribution of negative space separately to positive space.
    1. There is one situation where iframes are (almost) required: when the contents of the iframe is in a different domain, and you have to perform authentication or check cookies that are bound to that domain. It actually prevents security problems instead of creating them. For example, if you're writing a kind of plugin that can be used on any website, but the plugin has to authenticate on another domain, you could create a seamless iframe that runs and authenticates on the external domain.
    1. I normally try to figure out if that's a good solution for the problem before resorting to iframes. Sometimes, however, an iframe just does the job better. It maintains its own browser history, helps you segregate CSS styles if that's an issue with the content you're loading in.
  30. Jan 2021
    1. Ubuntu also supports ‘snap’ packages which are more suited for third-party applications and tools which evolve at their own speed, independently of Ubuntu. If you want to install a high-profile app like Skype or a toolchain like the latest version of Golang, you probably want the snap because it will give you fresher versions and more control of the specific major versions you want to track.
    1. This is open-source. You can always fork and maintain that fork yourself if you feel that's warranted. That's how this project started in the first place, so I know the feeling.
    1. If components gain the slot attribute, then it would be possible to implement the proposed behavior of <svelte:fragment /> by creating a component that has a default slot with out any wrappers. However, I think it's still a good idea to add <svelte:fragment /> so everyone who encounters this common use case doesn't have to come up with their own slightly different solutions.
    1. I’m not a dev either, so no Ubuntu fork, but I will perhaps be forced to look at Debian testing, without some advantages of Ubuntu - but now that Unity is gone (and I deeply regret it), gap would not be so huge anymore…
    2. If folks want to get together and create a snap-free remix, you are welcome to do so. Ubuntu thrives on such contribution and leadership by community members. Do be aware that you will be retreading territory that Ubuntu developers trod in 2010-14, and that you will encounter some of the same issues that led them to embrace snap-based solutions. Perhaps your solutions will be different. .debs are not perfect, snaps are not perfect. Each have advantages and disadvantages. Ubuntu tries to use the strengths of both.
  31. Nov 2020
    1. I wouldn't use Flutter for web, mobile is good though.
    2. It's super promising for web apps, just maybe not for web pages. I went from React to Svelte to Flutter for my current app project, and every step felt like a major upgrade.Flutter provides the best developer experience bar none, and I think it also has the potential to provide the best user experience. But probably only for PWAs, which users are likely to install anyway. Or other self-contained experiences, like Facebook games. It does have some Flash vibes, but is far more suitable for proper app development than Flash ever was while still feeling more like a normal website to the average user. It won't be the right choice for everything, but I believe it will be for a lot of things.