- Sep 2024
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
In practice when people use ||, they do mean ?? (whatever its spelling). It just so happens that most of the time, it does what you want, because you happen to not be dealing with Booleans. But the semantics you mean to express is not about "truthness", but about "nilness". And occasionally you get bitten because false does exist, and behaves differently.
-
- Aug 2024
-
-
top ranks and the tl;dr: the case for critcism
-
- Jul 2024
-
www.theguardian.com www.theguardian.com
Tags
- The case for a supply-side climate treaty
- Norges Bank Investment Management
- Norwegen
- by: Ajit Niranjan
- Centre for International Climate Research in Oslo (Cicero)
- Norwegian Climate Foundation
- Erlend Hermansen
- Greenpeace
- Anne Karin Sæther
- Beyond Oil & Gas Alliance
- Oslo
- fossil fuel nonproliferation treaty
- Frode Pleym
- Fossile Expansion
Annotators
URL
-
- Jan 2024
-
mongoosejs.com mongoosejs.com
-
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 theAnimal
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 theAnimal
schema. When you create an instance of theAnimal
model (e.g., a dog), you can then callfindSimilarTypes
on that instance to find other animals with the same type. The method uses thethis.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 theAnimal
model.
Tags
Annotators
URL
-
- Nov 2023
-
-
In API design, exceptional use cases may justify exceptional support. You design for the common case, and let the edge case be edge. In this case, I believe lib deserves ad-hoc API that allows users to do exactly that in one shot:
-
- Oct 2023
-
www.derstandard.at www.derstandard.at
-
4 Einwohner:innen der indonesischen Insel Pari haben in der Schweiz eine Klimaklage gegen den Schweizer Zementkonzwern Holcim eingereicht, einen der größten Treibhausgas-Emittenten der Welt.Durch die globale Erhitzung wird Pali viel öfter überflutet als früher. https://www.derstandard.at/story/3000000189643/inselbewohner-klagen-schweizer-konzern-wegen-klimasch228den
Tags
- expert: Anna Leitner
- expert: Parid Ridwanuddin
- actor: Holcim
- expert: Yvan Maillard-Ardenti
- case: Asmania et al. vs Holcim
- NGO: ECCHR
- NGO Friends of the Earth
- mode: legal action
- institution: Climate Accountability Institute
- NGO: Hilfswerk der Evangelischen Kirchen der Schweiz (HEKS)
- country: Indonesia
- NGO: Global 2000
Annotators
URL
-
-
-
In einem der wichtigsten laufenden Prozesse gegen Fossilunternehmen hat der Staat Kalifornien 5 amerikanische Firmen verklagt. Ein Ziel ist es, einen Ausgleichsfonds für zukünftige Schäden einzurichten, zu denen es durch die bewusst wahrheitswidrige Werbung und Kommunikation der Unternehmen gekommen ist. https://www.nytimes.com/2023/09/15/business/california-oil-lawsuit-newsom.html
Informationen des Gouverneurs von Kalifornien: https://www.gov.ca.gov/2023/09/16/people-of-the-state-of-california-v-big-oil/
-
- Sep 2023
-
www.liberation.fr www.liberation.fr
-
international du droit maritime des Nations Unies basé à Hambourg en Allemagne
Eine Koalition kleiner Inselstaaten hat beim internationalen Seegerichtshof eine Aussage zur Belastung der Ozeane durch Treibhausgase beantragt. Wenn diese als Verschmutzung im Sinne des Seerechts anerkannt wird, lassen sich damit Klagen gegen die Industriestaaten auf Einschreiten gegen die globale Erhitzung begründen. https://www.liberation.fr/environnement/pollution/des-etats-insulaires-intentent-une-action-en-justice-pour-proteger-les-oceans-20230911_ATZV3N2EAZCMXEWEKUZ32ACL4Q/
-
-
www.ncbi.nlm.nih.gov www.ncbi.nlm.nih.gov
-
Recent work has revealed several new and significant aspects of the dynamics of theory change. First, statistical information, information about the probabilistic contingencies between events, plays a particularly important role in theory-formation both in science and in childhood. In the last fifteen years we’ve discovered the power of early statistical learning.
The data of the past is congruent with the current psychological trends that face the education system of today. Developmentalists have charted how children construct and revise intuitive theories. In turn, a variety of theories have developed because of the greater use of statistical information that supports probabilistic contingencies that help to better inform us of causal models and their distinctive cognitive functions. These studies investigate the physical, psychological, and social domains. In the case of intuitive psychology, or "theory of mind," developmentalism has traced a progression from an early understanding of emotion and action to an understanding of intentions and simple aspects of perception, to an understanding of knowledge vs. ignorance, and finally to a representational and then an interpretive theory of mind.
The mechanisms by which life evolved—from chemical beginnings to cognizing human beings—are central to understanding the psychological basis of learning. We are the product of an evolutionary process and it is the mechanisms inherent in this process that offer the most probable explanations to how we think and learn.
Bada, & Olusegun, S. (2015). Constructivism Learning Theory : A Paradigm for Teaching and Learning.
Tags
Annotators
URL
-
- Mar 2023
-
stackoverflow.com stackoverflow.com
-
Just because the code is described as part of the WebDAV spec doesn't mean it's WebDAV-specific! Status codes are supposed to be generic.
-
- Oct 2022
-
ricksfreeautorepairadvice.com ricksfreeautorepairadvice.com
-
Your alternator is NOT a chargerThe alternator’s job is to supply the power needed for all electrical items on the vehicle, plus replenish the battery from the last start up. The alternator is not a battery charger so much as it is a battery maintainer. If the alternator has to recharge an overly discharged battery, the alternator will become over-worked, which will shorten its life.If you use your alternator to charge your dead battery, you will overheat the alternator during its charging process. The greater the amperage flowing through it, the higher the heat an alternator creates.Maximum Alternator Output Only Occurs at high RPMSAfter you start your car with jumper cables, the voltage regulator sees a discharged battery and commands maximum field in the rotor. But at 600 RPM, the alternator can only provide about 1/4th of its rated output. Let it idle for a long period and all you’ll do it overheat the rotor windings and burn up your expensive alternator. A 110-amp alternator can only output 110-amps at RPMS of 2,500 or more. So don’t even think about letting it idle to recharge the battery.A battery charger costs $40. A new Alternator $350Not exactly brain surgery, is it?The correct way to deal with this situation is to jump the battery (using a jumper pack is much safer than jumper cables) and driving it to a place where you can place a REAL battery charger on the battery.
Is this outdated info?
According to https://hyp.is/n7ZQpFF0Ee24ZbcIYA3xVQ/www.reddit.com/r/Cartalk/comments/aoks7b/how_much_idling_needed_after_jump_start_to/ it is. Which advice should we trust?
-
-
www.reddit.com www.reddit.com
-
This was much more of an issue a generation ago, when your ‘74 Chevy Nova or ‘69 Ford F-100 had a 35 amp alternator. Any car made in the last 15-20 years will have a 75 amp alternator as a bare minimum, and ratings well north of 100 amps are common in larger vehicles.There’s dozens of amps of headroom to charge the battery at idle speed, especially if you turn off the lights, stereo, HVAC, etc. That said, it’ll charge even more quickly if you drive the car.
This seems like more sound/trustworthy advice than the replied-to's advice/info.
-
This will KILL your alternator. You should get a battery charger or a trickle charger. Alternators go through hell when trying to recharge a fully depleted battery.
-
- Sep 2022
-
github.com github.com
-
in my personal opinion, there shouldn't be a special treatment of do-end blocks in general. I believe that anything that starts a "block", i.e. something that is terminated by and end, should have the same indentation logic
-
- Aug 2022
-
stackoverflow.com stackoverflow.com
-
It's a great way to test various limits. When you think about this even more, it's a little mind-bending, as we're trying to impose a global clock ("who is the most up to date") on a system that inherently doesn't have a global clock. When we scale time down to nanoseconds, this affects us in the real world of today: a light-nanosecond is not very far.
-
Which of these to use depends on the result you want. Note that by the time you get the answer, it may be incorrect (out of date). There is no way to fix this locally. Using some ESP,2 imagine the remote you're contacting is in orbit around Saturn. It takes light about 8 minutes to travel from the sun to Earth, and about 80 to travel from the sun to Saturn, so depending on where we are orbitally, they're 72 to 88 minutes away. Any answer you get back from them will necessarily be over an hour out of date.
-
When we have our git rev-parse examine our Git repository to view our origin/HEAD, what we see is whatever we have stored in this origin/HEAD. That need not match what is in their HEAD at this time. It might match! It might not.
-
Exaggeration of System Parameters
Tags
- may be out of sync
- testing
- good point
- considering the extreme case
- not necessarily the case
- taking things to extremes
- interesting idea
- considering the extreme case: long times
- interesting way of thinking about it
- may be stale
- challenging one's assumptions
- making too many assumptions
- in sync
Annotators
URL
-
- May 2022
-
watermark.silverchair.com watermark.silverchair.com
-
DICER1 syndrome is an autosomal-dominant,pleiotropic, tumor-predisposition disorder arisingfrom pathogenic germline variants in DICER1, whichencodes an endoribonuclease integral to processingmicroRNAs
DICER1 is the gene name. PubMed ID, HGCNCID, and Variant: I can't find Inheritance Pattern: autosomal-dominant The disease entity: DICER1 syndrome The type of mutation: germline. Zygosity: not known. Family Information: a family was used, DICER1 carriers, and non DICER1 variant used, some of the family members had tumors from DICER1 Case Information: mean age is 34, the range of age is 18.6 to 43 years, male, and female used, ethnicity can't find Case Presenting HPO: cancer testing, chemotherapy, radiotherapy gnomeAD: 9.2,8.3.2 Mutation type: Pleiotropic, loss of function, missense
-
- Mar 2022
-
github.com github.com
-
There are a couple of reasons why you may want to do this.
-
- Dec 2021
-
Local file Local file
-
the Center for CommunityChange (CCC)
The case
-
- Sep 2021
-
learn-eu-central-1-prod-fleet01-xythos.s3.eu-central-1.amazonaws.com learn-eu-central-1-prod-fleet01-xythos.s3.eu-central-1.amazonaws.com
-
the primary causes of extreme poverty are immaterial, theylie in certain deficiencies in education, organization, and discipline”(p. 159). Poorcountries, in his view, did not need more technology or physical infrastructure ormore foreign aid to eliminate poverty.
-
- Jul 2021
-
github.com github.com
-
apart from [Websockets], which is unnecessarily complex for non-browser applications
-
- Jun 2021
-
Local file Local file
-
CASE OFABDULAZIZ, CABALES AND BALKANDALI v. THE UNITED KINGDOM
CASE OF ABDULAZIZ, CABALES AND BALKANDALI v. THE UNITED KINGDOM
-
-
basarat.gitbook.io basarat.gitbook.ioClasses1
-
If an access modifier is not specified it is implicitly public as that matches the convenient nature of JavaScript 🌹.
-
- Apr 2021
-
unix.stackexchange.com unix.stackexchange.com
-
What produces that text, and what do you want to use it for?
-
- Mar 2021
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
A one-liner alternative for hash-only cases can be implemented using Enumerable#reduce: root = {} [:a, :b, :c].reduce(root){@1[@2]||={}}[:d] = 'E' # root => {:a=>{:b=>{:c=>{:d=>"E"}}}}
-
I think the issues/problems specified in the comments are not present with a Hash-only implementation. :) I would be supportive of re-considering this feature just for use with a Hash, where I believe 80% of the real-life use cases would (and do) exist. I have encountered this need before in the wild, but not with Arrays.
-
-
blog.izs.me blog.izs.me
-
Those sorts of complaints are like saying that someone is not a buddhist unless they speak Pali.
-
-
github.com github.com
-
The docs say: "When using Rails and Sprockets in development mode, no assets are concatenated."
-
- Feb 2021
-
sobolevn.me sobolevn.me
-
Not all cases can be covered and easily restored. And sometimes when we will reuse this function for different use-cases we will find out that it requires different restore logic.
-
So, the sad conclusion is: all problems must be resolved individually depending on a specific usage context. There’s no silver bullet to resolve all ZeroDivisionErrors once and for all. And again, I am not even covering complex IO flows with retry policies and expotential timeouts.
-
-
en.wikipedia.org en.wikipedia.org
-
Supporting languages may use monads to abstract away boilerplate code needed by the program logic.
-
-
github.com github.com
-
But ActiveModel doesn't support out of the box argument parsing, e.g. having a datetime attribute be a datetime attribute and a boolean attribute be a boolean attribute.
Doesn't it now, with the (newer)
ActiveModel::Attributes
API?
-
-
-
The press release also quoted a UA assistant provost for institutional research who explained that while the swipes of student ID cards were not used in the current student retention analytics, about 800 other data points were
The research in questions was not currently being used by the institution to improve rention, but other student data was already being used for that purpose
-
The researcher noted that the data she had used had been anonymized before she was given access to it—however, she added that if/when her research might inform the ongoing efforts to improve student retention, the student’s personal details would be “shared” with the students' academic advisers.
The data was anonymized before she was given access, but she admitted that there might be interest in sharing students' personal details with academic advisors
-
She then used that data to create large networks mapping which students interacted with one another and how often.
The researcher sought to track the personal interactions of students with one another
-
On the university’s website, a press release
The university share the finding of the research after the fact
-
At the University of Arizona, for example, a researcher analyzed the swipes of student ID cards at locations across campus, “to see what they reveal about students' routines and relationships, and what that means for their likelihood of returning to campus after their freshman year.”
Fact. Student ID Cards Collect Data Fact. A researcher was given access to this data for her own purposes.
-
-
github.com github.com
-
The main realization came when I figured out that the main_model was just another association. This means we can move a lot of logic to just that class and reason about it a lot better.
-
-
en.wikipedia.org en.wikipedia.org
-
As with other software patterns, MVC expresses the "core of the solution" to a problem while allowing it to be adapted for each system.
-
-
www.honeybadger.io www.honeybadger.io
-
Honeybadger isn't a single page app, and it probably won't ever be. SPAs just don't make sense for our technical requirements.
-
- Jan 2021
-
blog.linuxmint.com blog.linuxmint.com
-
We don’t do politics, and we certainly don’t do religion. You’re bringing these here by using terms such as “politicians” or “evil”.
Does "evil" refer to religion? Or perhaps they meant "evil" in a more general way, as a more extreme version of "bad".
-
-
-
This syntax easily provides all the features of components, like let: bind: and on:. <svelte:fragment /> is just a component with a special name.
-
-
stackoverflow.com stackoverflow.com
-
“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.
-
-
discourse.ubuntu.com discourse.ubuntu.com
-
but that doesn’t mean that confining applications is not a benefit also to FOSS applications, security is an issue that needs to be addressed with many layers of measures no mater what licensing approach you use to license the software
-
- Nov 2020
-
uxdesign.cc uxdesign.cc
-
Note: Yes, it is sentence case, and yes, there should be a full stop if it was true sentence case — but for the love of all things good and designy, please don’t add a full stop.
-
-
github.com github.com
-
When you do import '../scss/application.scss', you're telling webpack to include application.scss in the build. This does not mean it's going to be compiled into your javascript, only that webpack now compiles and knows how to load this file.
Not necessarily the case that importing something into a JS file means the thing being imported is also JS.
-
- Oct 2020
-
-
In summary TLS uses PKI to secure information over the internet. However, it is important to note that TLS supports other encryption standards which are not part of PKI.
-
-
-
Without elegant ways of expressing loops/iterators (like angular does with directives), the primary way to keep JSX readable thus becomes copying and pasting.
I'm not quite sure I understand this (so until I do, I'm not sure I agree)...
Why does he think copying and pasting is the only way to make it readable? Like he pointed out, you can extract JSX snippets and use loops within JSX. But maybe he means (his previous point), that people often don't do that. Hmm. 
-
-
2ality.com 2ality.com
-
trusktr herman willems • 2 years ago Haha. Maybe React should focus on a template-string syntax and follow standards (and provide options for pre-compiling in Webpack, etc).
Well anywho, there's other projects now like hyperHTML, lit-html, etc, plus some really fast ones: https://www.stefankrause.ne...
React seems a little old now (and the new Hooks API is also resource heavy).
• Share ›  Michael Calkins trusktr • 4 years ago • edited That's a micro optimization. There isn't a big enough difference to matter unless you are building a game or something extraordinarily odd.
• Share › −  trusktr Michael Calkins • 2 years ago True, it matters if you're re-rendering the template at 60fps (f.e. for animations, or for games). If you're just changing views one time (f.e. a URL route change), then 100ms won't hurt at all.
-
- Sep 2020
-
engineering.mixmax.com engineering.mixmax.com
-
You can see that Rollup mapped browser globals called "React" and "ReactDOM" to variables called "React" and "ReactDOM". The latter are what you imported by writing import React and import ReactDOM. (The variable names don't have to be the same as the browser globals, but it's common.)
-
- Aug 2020
-
tamino.wordpress.com tamino.wordpress.com
-
COVID-19: Doing It Right. (2020, July 3). Open Mind. https://tamino.wordpress.com/2020/07/03/covid-19-doing-it-right/
-
-
english.stackexchange.com english.stackexchange.com
-
As a web designer, I hate that "log in" creates a visual space between the words. If you line up "Log In Register" - is that three links or two? This creates a Gestalt problem, meaning you have to really fiddle with spacing to get the word groupings right, without using pipe characters.
Sure, you can try to solve that problem by using a one-word alternative for any multi-word phrase, but that's not always possible: there isn't always a single word that can be used for every possible phrase you may have.
Adjusting the letter-spacing and margin between items in your list isn't that hard and would be better in the long run since it gives you a scalable, general solution.
"Log in" is the only correct way to spell the verb, and the only way to be consistent with 1000s of other phrasal verbs that are spelled with a space in them.
We don't need nor want an exception to the general rule just for "login" just because so many people have made that mistake.
-
-
svelte.dev svelte.dev
-
count_value
going against the grain? or ?
-
- Apr 2020
-
www.techopedia.com www.techopedia.com
-
A language that features polymorphism allows developers to program in the general rather than program in the specific. $(document).ready(function() { recordAdModuleData(2964, "impressions","Dictionary Ad"); });
-
- Oct 2019
-
quillette.com quillette.com
-
black Americans have been making rapid progress along most important dimensions of well-being since the turn of the millennium.
testing annotatioins
-
- Apr 2019
-
cran.r-project.org cran.r-project.org
-
Directed Acyclic Graph (DAG) with nodes representingrandom variables
-
- Mar 2018
-
inside.tru.ca inside.tru.ca
-
Las aplicaciones aumentan el acceso a la justicia
-
- Dec 2015
-
lenbakerloo.com lenbakerloo.com
-
More than 100 years ago Mr. Sherlock Holmes
Few people know this but Sherlock was actually born in Russia in 1792 and didn't change his name until much later.
-
- Feb 2014
-
euro.ecom.cmu.edu euro.ecom.cmu.edu
-
Law of the Case
-
-
www.lawnerds.com www.lawnerds.com
-
MINTURN, J. The plaintiff occupied the position of a special police officer, in Atlantic City, and incidentally was identified with the work of the prosecutor of the pleas of the county. He possessed knowledge concerning the theft of certain diamonds and jewelry from the possession of the defendant, who had advertised a reward for the recovery of the property. In this situation he claims to have entered into a verbal contract with defendant, whereby she agreed to pay him $500 if he could procure for her the names and addresses of the thieves. As a result of his meditation with the police authorities the diamonds and jewelry were recovered, and plaintiff brought this suit to recover the promised reward.
- Plaintiff makes a verbal contract with defendant. In return for $500, plaintiff will find defendant's stolen jewels.
- Plaintiff had knowledge of whereabouts of jewels at contract formation.
- Plaintiff is a special police officer and has dealings with prosecutor's office.
- Defendant published advertisement for reward.
- Plaintiff finds stolen goods and arranges return.
-