83 Matching Annotations
  1. Last 7 days
  2. 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

    1. You can see how the constant jumping between these two tools in the first scenario is super annoying, and also very risky as none of the changes you make in Figma are also automatically being updated in the same GitLab designs.
    2. As a positive example of where this works well: Our VS Code GitLab Workflow extension allows users to not only see comments that were written inside the GitLab UI, but also allows these users to respond to these comments right from the IDE, the tool where they actually have to make these changes.
    1. 1:15 violence, rape, murder, ... executive order to dissolve chaz and restore order.<br /> too bad, murder is exactly where my fun starts. but this world is ruled by militant pacifists,<br /> who only replace serial murder with overpopulation and mass murder every 100 years, aka "war".<br /> they only replace death with accumulated "debt"... idiots. idiocracy is here and now.

    1. you don't start a feminist revolution by arguing with your dad. (Marjorie laughs) He might be the one who needs to change, but that doesn't mean that you start there. 00:22:55 You start by talking to each other. We need to come together. We need to have solidarity.
      • for: system change - where to start

      • paraphrase

        • You don't start a feminist revolution by arguing with your dad. He might be the one who needs to change, but that doesn't mean that you start there.
        • You start by talking to each other. We need to come together. We need to have solidarity.
        • We need to have a common narrative and analysis and understanding of what's happening.
        • And I think a common understanding of pathways of change and we need that core nucleus of people who really are working for system change.
        • I think that's where we start. And hopefully, the narrative and the clarity that we can bring will be compelling enough that we will win more hearts and minds
      • comment

        • cascading social tipping points
  3. Dec 2023
  4. Sep 2023
    1. "Surrendering" by Ocean Vuong

      1. He moved into United State when he was age of five. He first came to United State when he started kindergarten. Seven of them live in the apartment one bedroom and bathroom to share the whole. He learned ABC song and alphabet. He knows the ABC that he forgot the letter is M comes before N.

      2. He went to the library since he was on the recess. He was in the library hiding from the bully. The bully just came in the library doing the slight frame and soft voice in front of the kid where he sit. He left the library, he walked to the middle of the schoolyard started calling him the pansy and fairy. He knows the American flag that he recognize on the microphone against the backdrop.

  5. Jun 2023
  6. Apr 2023
    1. were almost wholly conducted by women;

      Fredrick Douglas observed that the convention was ran by mostly women. He says depsite the different opinions and view points, these women maintained good decorum. He says their proceedings were marked by ability and dignity. At this convention, he would see these women read grievances and other documents setting forth the rights for women.

    2. On July 19-20, 1848, 68 women and 32 men attended the First Women’s Rights Convention which was held in the upstate New York town of Seneca Falls

      When- July 19-20th, 1848 Who- 100 people (32males/68females) Fredrick Douglas attended and wrote his impressions about the convention in a newspaper. Article named, The North Star What- Very first womens rights conventions. Article : The North Star Where- NewYork, Seneca Falls.

    1. Fredrick Douglas was one of one hundred people who attended the very first womens rights conevention. Located in New York, Seneca Falls. Frederick Douglas is the author of the article, The North Star. Dated July 28th, 1848. Article is about

  7. Mar 2023
    1. gaga's third question where are we going is what i want to address in these talks 00:05:26 it may seem unanswerable who can foretell the human course through time but i think we can answer it in broad strokes by answering the other two questions first 00:05:40 if we see clearly what we are and what we've done we can recognize human behaviors that persist through many times and cultures and knowing these can tell us what we 00:05:52 are likely to do and where we are likely to go from here
      • Wright points out that answering the first two questions
        • is the key to answering the third one
    2. the artist managed to harness his grief to produce a vast painting more a mural in conception than a canvas in which like the victorian age itself he demanded 00:04:31 new answers to the riddle of existence he wrote the title boldly on the image three childlike questions simple yet profound where do we come from 00:04:46 what are we where are we going the work is a sprawling panorama of enigmatic figures amid scenery

      Paul Gauguin's painting: - Where Do We Come From? What Are We? Where Are We Going? - https://en.wikipedia.org/wiki/Where_Do_We_Come_From%3F_What_Are_We%3F_Where_Are_We_Going%3F#:~:text=Que%20sommes%2Dnous%20%3F,the%20themes%20of%20the%20Gospels%22. - Wright uses this painting as a appropriate introduction to his work tracing human progress because to answer the third question - where are we going? - requires answering the first two - where do we come from? - what are we?

  8. Dec 2022
    1. The next two questions are where to play and how to win. These twochoices, which are tightly bound up with one another, form the very heart ofstrategy and are the two most critical questions in strategy formulation.

      The two most important questions in strategy formulation are: where to play and how to win. They define the specific activities of the organisation.

    Tags

    Annotators

    1. I have yet to see a Snapd or Flatpak build of Audacity that I'm happy with. Those builds are beyond our control as they are made by 3rd parties. I do find it mildly annoying that Flatpak direct users that have problems with their builds to us.

      annotation meta: may need new tag: the runaround?

  9. Jul 2022
    1. Many of the workers reported that first thing in themorning, or after any interruption in their thought(like a ‘phone call), they have the “where was 1?”problem in a complex and ill-defined space of ideas.The layout of physical materials on their desk givesthem powerful and immediate contextual cues torecover a complex set of threads without difilcultyand delay, “this is my whole context, these are mypersonal piles”

      Following interruptions by colleagues or phone calls at work, people may frequently ask themselves "where was I?" more frequently than "what was I doing?" This colloquialism isn't surprising as our memories for visual items and location are much stronger than actions. Knowledge workers will look around at their environments for contextual clues for what they were doing and find them in piles of paper on their desks, tabs in their computer browser, or even documents (physical or virtual) on their desktops.

  10. Jun 2022
    1. For Jerome Bruner, the place to begin is clear: “One starts somewhere—where the learner is.”

      One starts education with where the student is. But mustn't we also inventory what tools and attitudes the student brings? What tools beyond basic literacy do they have? (Usually we presume literacy, but rarely go beyond this and the lack of literacy is too often viewed as failure, particularly as students get older.) Do they have motion, orality, song, visualization, memory? How can we focus on also utilizing these tools and modalities for learning.

      Link to the idea that Donald Trump, a person who managed to function as a business owner and president of the United States, was less than literate, yet still managed to function in modern life as an example. In fact, perhaps his focus on oral modes of communication, and the blurrable lines in oral communicative meaning (see [[technobabble]]) was a major strength in his communication style as a means of rising to power?

      Just as the populace has lost non-literacy based learning and teaching techniques so that we now consider the illiterate dumb, stupid, or lesser than, Western culture has done this en masse for entire populations and cultures.

      Even well-meaning educators in the edtech space that are trying to now center care and well-being are completely missing this piece of the picture. There are much older and specifically non-literate teaching methods that we have lost in our educational toolbelts that would seem wholly odd and out of place in a modern college classroom. How can we center these "missing tools" as educational technology in a modern age? How might we frame Indigenous pedagogical methods as part of the emerging third archive?

      Link to: - educational article by Tyson Yunkaporta about medical school songlines - Scott Young article "You should pay for Tutors"


      aside on serendipity

      As I was writing this note I had a toaster pop up notification in my email client with the arrival of an email by Scott Young with the title "You should pay for Tutors" which prompted me to add a link to this note. It reminds me of a related idea that Indigenous cultures likely used information and knowledge transfer as a means of payment (Lynne Kelly, Knowledge and Power). I have commented previously on the serendipity of things like auto correct or sparks of ideas while reading as a means of interlinking knowledge, but I don't recall experiencing this sort of serendipity leading to combinatorial creativity as a means of linking ideas,

  11. May 2022
    1. Where around hooks shine is when you want to run an example within a block. For instance, if your database library offers a transaction method that receives a block, you can use an around to cleanly open and close the transaction around the example.
  12. Mar 2022
    1. And it’s easier to share a personal story when you’re composing it 280 characters at a time and publishing it as you go, without thinking about or knowing where the end may be. It’s at least easier than staring down a blank text editor with no limit and having to decide later how much of a 2,500 word rant is worth sharing, anyway.

      Ideas fill their spaces.

      When writing it can be daunting to see a long blank screen and feel like you've got to fill it up with ideas de novo.

      From the other perspective if you're starting with a smaller space like a Twitter input box or index card you may find that you write too much and require the ability to edit things down to fit the sparse space.


      I do quite like the small space provided by Hypothes.is which has the ability to expand and scroll as you write so that it has the Goldilocks feel of not too small, not too big, but "just right".


      Micro.blog has a feature that starts with a box that can grow with the content. Once going past 280 characters it also adds an optional input box to give the post a title if one wants it to be an article rather than a simple note.


      Link to idea of Occamy from the movie Fantastic Beasts and Where to Find Them that can grow or shrink to fit the available space: https://harrypotter.fandom.com/wiki/Occamy

  13. Oct 2021
  14. Sep 2021
    1. Users think every Webpack tool/config problem is a problem with a specific package and opens an issue asking for support on the package instead of Webpack. In the past year alone, I’ve had to deal with hundreds of Webpack issues on my repos.
  15. Jul 2021
  16. Jun 2021
    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!!
  17. May 2021
  18. Apr 2021
    1. We are are continuing our commitment to creating our games that are free and widely accessible anyone that is curious by making our game files available under Creative Commons license BY–NC–SA 4.0. That means we will continue offering a full, free print-and-play kit for Pax Pamir, and later this campaign, John Company! Anyone can use, remix, and share the game, so long as they do not use it for commercial purposes. 
    1. however, if this is relevant to just one spec, you don't necessarily need to include devise helpers to all your controllers specs, you can just explicitly include those helpers in that one controller describe block: require 'spec_helper' describe MyCoolController include Devise::TestHelpers it { } end
  19. Mar 2021
    1. Application: 3-D Shape RegistrationAn important problem in model-based recognition is to find the transformation of a set of datapoints that yields the best match of these points against a shape model. The process is oftenreferred to asdata registration. The data points are typically measured on a real object by rangesensors, touch sensors, etc., and given in Cartesian coordinates. The quality of a match is oftendescribed as the total squared distance from the data pointsto the model. When multiple shapemodels are possible, the one that results in the least total distance is then recognized as the shapeof the object.Quaternions are very effective in solving the above least-squares-based registration problem.
    1. I'm kinda stuck at the moment, going around in circles. Everything is really heavily coupled. I would like to get to the point where no load is called from within processors, but i'm not sure if that's possible. Currently the API and the caching strategies are fighting me at every step of the way. I have a branch where i'm hacking through some refactoring, no light at the end of the tunnel yet though :(
    1. it's super hard to test master because i have no idea which gems need to be updated. is there a guide on how to take a rails 4.2 project to master sprockets without everything mysteriously exploding? ill try to make a repro case but its hard to tell where to even start
    1. Knowing about the wiring mechanics in Trailblazer is one thing. However, the real fun starts with nesting activities. That’s when the ideas of encapsulation, interfaces and reducing dependencies really come into play.
  20. Feb 2021
    1. Trailblazer extends the conventional MVC stack in Rails. Keep in mind that adding layers doesn't necessarily mean adding more code and complexity. The opposite is the case: Controller, view and model become lean endpoints for HTTP, rendering and persistence. Redundant code gets eliminated by putting very little application code into the right layer.
    1. ActiveInteraction plays nicely with Rails. You can use interactions to handle your business logic instead of models or controllers.
    2. Why is all this interaction code better? Two reasons: One, you can reuse the FindAccount interaction in other places, like your API controller or a Resque task. And two, if you want to change how accounts are found, you only have to change one place.

      Pretty weak arguments though...

      1. We could just as easily used a plain object or module to extract this for easy reuse and having it in only one place (avoiding duplication).
    1. The non-determinism is why cache invalidation — and that other hard problem, naming things — are uniquely and intractably hard problems in computer science. Computers can perfectly solve deterministic problems. But they can’t predict when to invalidate a cache because, ultimately, we, the humans who design and build computational processes, can’t agree on when a cache needs to be invalidated.
    1. This nav bar by Chris Coyier is a great example of something that makes more sense as a flexbox than grid.
    2. 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.
  21. 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. Great, I can use vw to scale text so it doesn't look puny on a desktop! Perfect... Oh. Huh, now the text is too small to read when viewed on a phone. Okay, well I can just use "max(x,y)" to make sure it doesn't get shrunk beyond a minimum size. Perfect... Oh. Hmm. Looks like "max" isn't supported properly by Chrome. Okay, well guess I'll just use "px" again.
    1. CSS Grid Layout excels at dividing a page into major regions or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives.
  22. Dec 2020
  23. Nov 2020
    1. Prettier’s printWidth option does not work the same way. It is not the hard upper allowed line length limit. It is a way to say to Prettier roughly how long you’d like lines to be. Prettier will make both shorter and longer lines, but generally strive to meet the specified printWidth. Remember, computers are dumb. You need to explicitly tell them what to do, while humans can make their own (implicit) judgements, for example on when to break a line. In other words, don’t try to use printWidth as if it was ESLint’s max-len – they’re not the same. max-len just says what the maximum allowed line length is, but not what the generally preferred length is – which is what printWidth specifies.
  24. Oct 2020
    1. Yeah I see what you're saying. In my case, I had a group of classes that relied on each other but they were all part of one conceptual "module" so I made a new file that imports and exposes all of them. In that new file I put the imports in the right order and made sure no code accesses the classes except through the new interface.
    1. He says that he sees the combination of long form pieces and Q&A as a new level of support. “We used to have level one, which was sending a ticket to the help desk, and it was something we could easily resolve for you. Level two was a more complex problem that maybe required an engineer or specialist from a certain team to figure out. I look at this new system as a level zero.” Before sending us a ticket, folks can search Teams. If they find a question that solves the problem, great. If they need more details, they can follow links to in-depth articles or collections that bring together Q&A and article with the same tags.“
  25. Sep 2020
    1. I took the same approach with _layout.svelte and not just for the svelte-apollo client. Except I put all of that setup into another module (setup.js) and imported from _layout. I just couldn't stomach having all that code actually in my _layout file. It's for layout, supposedly, but it's the only component that is a parent to the whole app.
    2. I got this working by using _layout.svelte as the point to initialise and set the Client we can then use getClient in each route that uses this layout.
    1. I think this is such a fantastic viewpoint. Sometimes in order to reach our overall goal, we have to "cast down our bucket" in compromise or be the first to extend the olive branch. I like that he used this same analogy for the white southerners as well. We all have to compromise to some degree to reach progress.

  26. May 2020
    1. For general questions, use cases, or anything else that does not fit into one of the above cases, please post in the GitLab Forum or on a third-party help site.
    2. If you're in a paid tier on GitLab.com or GitLab Self-managed, you're entitled to Support. Please open a support ticket after reviewing our Statement of Support
    3. If you're a free user on GitLab.com and are having one of the following specific issues please file a support ticket after reviewing the Free Plan Users Section in our Statement of Support
    1. Account Support If you haven't received your confirmation email, you can request to resend your confirmation instructions via our confirmation page.

      This Account Support section only includes one possible problem related to account support

      If you haven't received your confirmation email, you can request to resend your confirmation instructions via our confirmation page.

      What about if you have any other issue with your account? How would you get support then? This would be a good opportunity/place to describe what to do in that case.

      Presumably the answer is to submit support requests at <del>https://gitlab.com/gitlab-com/support-forum</del> (to be shut down) or in the community forums.

    1. We're closing the Support Forum issue tracker in favor of the Community Forum and support channels. We recognize that the Support Forum issue tracker has not received much attention in the last few months, and want to redirect our community members to locations that are regularly monitored by GitLab staff. As a result, this issue will be moved to the GitLab product issue tracker and triaged there.
  27. Dec 2019
    1. Types of questions and where to ask: How do I? -- ask on Server Fault (tell them what tags to use -- your product tag at minimum) I got this error, why? -- ask on Server Fault I got this error and I'm sure it's a bug -- report it on your own site I have an idea/request -- report it on your own site Why do you? -- ask in your own community (support forum, etc) When will you? -- ask in your own community
  28. Dec 2015