68 Matching Annotations
  1. Last 7 days
  2. Feb 2024
    1. The data on the 463 courses at UT Austin can be found in the evals data frame included in the moderndive package
  3. Jan 2024
    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

  4. Nov 2023
    1. Just to add details to your post, in case it isn't clear for others, as it wasn't for me, when you select the "set default" grade option from the top, you want to put a - (the dash key) in the box before checking to override existing grades.

  5. Oct 2023
    1. When we were shooting the pilot for Twin Peaks, we had a setdresser named Frank Silva. Frank was never destined to be in TwinPeaks, never in a million years.

      Because Frank Silva was a proverbial slip in David Lynch's living zettelkasten process, he ended up appearing in Twin Peaks by way of the serendipity of Lynch's method of combinatorial creativity.

  6. Jun 2023
    1. This sample bassline was performed by Joseph Makwela of Mahlathini and the Mahotella Queens8. The bass is played with a plectrum and the notes are played staccato. The drum set plays a steady kick drum9 on all four beats in the bar and plays a syncopated snare drum10 pattern that accentuates the staccato notes of the bass
    2. Figure 1.1
  7. Dec 2022
    1. Does our most powerful force not come from the depths of our capacities to #love, #care for and #serve nature and all its beings, including ourselves?

      !- good insight : markets do not set the direction, but subordinate to the direction set by our capacity for love and care

    2. the ultimate #guidance we need to heal Earth does not come from the #markets and our #technologies supporting them. What they are is tools, supporting a direction, facilitating transactions in a world where we do not yet speak a deep #common language of #unity, #stewardship and #coexistence but these markets and technologies should not dictate where we are headed, or else I'm afraid we are simply missing the whole point.

      !- good insight : markets cannot dictate the direction we are headed - direction should be set by our depths of capacity for love, care for nature and other living beings - markets should be viewed in the proper context, IN SERVICE to the above, not the MASTER of it

  8. Nov 2022
    1. https://www.youtube.com/watch?v=GEXF3JgdHVY

      Fountain pen network

      ink journals for keeping track of pens, ink, and samples

      ink review formats

      swab books

      q-tip swabs

      ink sample vials and tray holders

      a bulb syringe for flushing water through to clean pens is a good idea when doing many at a time

    1. Changing the second line to: foo.txt text !diff would restore the default unset-ness for diff, while: foo.txt text diff will force diff to be set (both will presumably result in a diff, since Git has presumably not previously been detecting foo.txt as binary).

      comments for tag: undefined vs. null: Technically this is undefined (unset, !diff) vs. true (diff), but it's similar enough that don't need a separate tag just for that.

      annotation meta: may need new tag: undefined/unset vs. null/set

  9. Sep 2022
    1. One common use case for rbspy is profiling slow unit test runs -- instead of spending a bunch of time adding instrumentation, you can run rbspy record ruby my-test.rb and instantly get profiling information about what's going on.
  10. Jul 2022
  11. Mar 2022
    1. The first thing I learned is good news if you have been thinking that “attention training” sounds like too much work: you can experience imme-diate benefits by beginning in small ways to exercise mindfulness regarding your attention online. In this realm, taking some control, even if it is a baby step, is far better than passively letting your attention be grabbed without reflection. Growing evidence indicates consistent exercise can strengthen self-control of attention.

      Jede Verbesserung, so klein sie auch ist, von Aufmerksamkeit, ist eine tatsächliche Verbesserung im aufmerksamen Umgang mit digitalen Medien.

    2. The analytical, inferential, perspective-taking reading brain with all its capacity for human consciousness, and the nimble, multifunctional, multimodal, information-integrative capacities of a digital mind-set do not need to inhabit exclusive realms

      Annahme: digitales mind-set und Lektürekompetenz schließen einander nicht aus

  12. Jan 2022
    1. The testinstructions behave in the same manner as the and instructions, except that theyset the condition codes without altering their destinations.

      test 指令的作用是什么?

    2. The cmp instructions set the condition codes according to the differences of theirtwo operands. They behave in the same way as the sub instructions, except thatthey set the condition codes without updating their destinations.

      cmp 指令集的作用是什么?

    3. By using a PC-relativeencoding of the jump targets, the instructions can be compactly encoded (requiringjust 2 bytes), and the object code can be shifted to different positions in memorywithout alteration.

      pc-relative encoding 的计算方式是什么,有什么优势?

    4. It is important to recognize that the suffixes forthese instructions denote different conditions and not different operand sizes. Forexample, instructions setl and setb denote “set less” and “set below,” not “setlong word” or “set byte.”

      set 指令的后缀代表的含义是什么?

  13. Dec 2021
    1. one for unsigned (mulq) and one for two’s-complement (imulq) multiplication.For both of these instructions, one argument must be in register %rax, and theother is given as the instruction source operand.

      mulq 和 imulq 分别表示什么指令集,他们的操作数有什么要求?

    2. The different shift instructions can specify the shift amount either asan immediate value or with the single-byte register %cl.

      shift 指令可以接受哪些操作数?

  14. Nov 2021
    1. As with themov instructions, the two operands cannot both be memory locations.

      binary operation 的两个操作数可以是 memory location 吗?

    2. The destination operand must be a register.

      load effective address 的 destination 需要是什么?

    3. The ability of the leaq instruction to perform addition and limited forms ofmultiplication proves useful when compiling simple arithmetic expressions suchas this example.

      leaq 在什么情况下有用?

    4. logicallybe named movzlq, but this instruction does not exist. Instead, this type of datamovement can be implemented using a movl instruction having a register as thedestination. This technique takes advantage of the property that an instructiongenerating a 4-byte value with a register as the destination will fill the upper 4bytes with zeros.

      为什么在 movz 的指令中缺少 movzlq?

    5. in memory, to a register destination. Instructions in the movz class fill out theremaining bytes of the destination with zeros, while those in the movs class fillthem out by sign extension, replicating copies of the most significant bit of thesource operand.

      那两种 move 指令针对 copy smaller source 到 larger destination,他们的做法分别是什么?

    6. The source operand designates a value that is immediate, stored in a register,or stored in memory. The destination operand designates a location that is either aregister or a memory address. x86-64 imposes the restriction that a move instruc-tion cannot have both operands refer to memory locations. Copying a value fromone memory location to another requires two instructions—the first to load thesource value into a register, and the second to write this register value to the des-tination.

      move 的 source operand 和 destination operand 分别可以是哪些类型?

    7. The most general form is shown at the bottomof the table with syntax Imm(rb,ri,s). Such a reference has four components: animmediate offset Imm, a base register rb, an index register ri, and a scale factors, where s must be 1, 2, 4, or 8. Both the base and index must be 64-bit registers.The effective address is computed as Imm + R[rb] + R[ri] . s.

      访问 $$Imm(r_b, r_i, s)$$ 的内存应该如何计算,有哪些限制条件?

  15. Aug 2021
    1. We can use the itertools.combinations function to find all possible subsets of a chord for a given cardinality.

      Ha! Found a Ruby method to do the same thing in Sonic Pi. https://in-thread.sonic-pi.net/t/exploring-modes-of-pitch-class-sets-using-chord-invert/5874/10?u=enkerli

      Glad this is explicitly mentioned here as it was my initial goal as I got into musical applications of Set Theory!

  16. Jun 2021
    1. json_array_elements_text ( json ) → setof text jsonb_array_elements_text ( jsonb ) → setof text Expands the top-level JSON array into a set of text values. select * from json_array_elements_text('["foo", "bar"]') → value ----------- foo bar
  17. Apr 2021
    1. as it stands, this only goes to highlight what a miracle, what a classic for the ages Actraiser really is, whilst confirming itself as, unfortunately, one to avoid.
  18. Mar 2021
  19. Feb 2021
  20. Jan 2021
  21. Nov 2020
    1. Others have already said how Flutter renders inside a canvas and how it's difficult/impossible for it to interact with other JS libraries (and why would you want to... the whole thing is so different that even the issues are solved by completely different libraries).
  22. Oct 2020
    1. From the molecules in the candidate pool find the one that has the maximum value for its minimum distance to molecules in the picked set (hence the MaxMin name), calculating and recording the distances as required. This molecule is the most distant one to those already picked so is transferred to the picked set.

      a good summary of MaxMin method

    1. An Euler diagram (/ˈɔɪlər/, OY-lər) is a diagrammatic means of representing sets and their relationships. They are particularly useful for explaining complex hierarchies and overlapping definitions. They are similar to another set diagramming technique, Venn diagrams. Unlike Venn diagrams, which show all possible relations between different sets, the Euler diagram shows only relevant relationships.
  23. Aug 2020
  24. Jul 2020
  25. May 2020
  26. May 2018
  27. Mar 2018
    1. significantly increasing student access and success, and eliminating racial/ethnic and socioeconomic disparities in college attainment.
  28. Nov 2017
  29. May 2017
  30. Nov 2016
  31. Sep 2015
    1. Associative Elements in associative containers are referenced by their key and not by their absolute position in the container.

      set可以通过key访问,不支持[] 下标访问。 而且set的值不能更改,只能插入和删除。set保存的是非重复的排序的元素。

  32. Mar 2015
    1. an objective set for the Sprint that can be met through the implementation of Product Backlog. It provides guidance to the Development Team on why it is building the Increment. It is created during the Sprint Planning meeting. The Sprint Goal gives the Development Team some flexibility regarding the functionality implemented within the Sprint. The selected Product Backlog items deliver one coherent function, which can be the Sprint Goal. The Sprint Goal can be any other coherence that causes the Development Team to work together rather than on separate initiatives.

      an objective set for the Sprint that can be met through the implementation of Product Backlog. It provides guidance to the Development Team on why it is building the Increment. It is created during the Sprint Planning meeting. The Sprint Goal gives the Development Team some flexibility regarding the functionality implemented within the Sprint. The selected Product Backlog items deliver one coherent function, which can be the Sprint Goal. The Sprint Goal can be any other coherence that causes the Development Team to work together rather than on separate initiatives.