OpenLLM-France/wikimedia huggingface dataset:
# Muggles' Guide to Harry Potter/Characters/Andrew Kirke
## Overview

Andrew Kirke is a Beater on the Gryffindor Quidditch team. Along with Jack Sloper, he takes over for Fred and George Weasley.

## Role in the Books
### Order of the Phoenix

In the last meeting of Dumbledore's Army before Christmas, Angelina Johnson tells Harry that they have finally managed to get replacement Beaters. Alicia Spinnet says the new beaters are Andrew Kirke and Jack Sloper, and that they are nowhere as good as Fred and George, but were the best of a very bad lot.
On February 14th, Ron says that he can't go to Hogsmeade because Angelina wants a full day's practice. Ron is sceptical that it will help, because Sloper and Kirke are even worse than he is.
The following weekend, in the match against Ravenclaw, it is mentioned that one of the low points of the game is Kirke shrieking and falling backwards off his broom as Zacharias Smith zooms towards him with the Quaffle.

### Half-Blood Prince

When try-outs happen, Kirke is passed over; the new Beaters are Jimmy Peakes and Ritchie Coote. It is not mentioned whether Kirke tries out for his position or not.

## Strengths

Andrew appears to have at least some knowledge of Quidditch. He is shown to not be a particularly good Beater, but he does successfully try out for the position. As a result, he is eventually part of a team that wins the Quidditch Cup.

## Weaknesses

Despite liking Quidditch, Andrew is not very good at it.

## Relationships with Other Characters

Andrew is presumably on relatively good terms with Jack Sloper, as they work together as Beaters on the Quidditch team. By association, he will also know everyone else on the Quidditch team.

## Questions

Study questions are meant to be left for each student to answer; please don't answer them here.
* Why is Andrew on the Quidditch team when he is not very good at Quidditch?
* How old do you think Andrew might be? Why is this?
# Muggles' Guide to Harry Potter/Characters/Andromeda Tonks
## Overview

Andromeda Tonks, wife of Ted Tonks and mother of Nymphadora Tonks, was born into the Black family, but has been disowned.

## Role in the Books
### Order of the Phoenix

When Harry and Sirius Black are discussing the tapestry of the Ancient and Honorable House of Black, Sirius mentions Andromeda in passing, saying she has been removed from the tapestry for the unforgivable crime of marrying a Muggle-born wizard, Ted Tonks. Nymphadora Tonks is their daughter.

### Deathly Hallows

When Harry first sees Andromeda, he almost mistakes her for her sister, Bellatrix Lestrange, and is on the point of casting a jinx at her, but cannot find his wand. She, like her husband, is dismayed to hear that they had been ambushed by Death Eaters, and is concerned that her daughter may have gotten hurt.

## Strengths

We don't see much of Andromeda, but we know she must have significant strength of character to marry Ted Tonks, a Muggle-born, in the full knowledge that this would cause the Black family to effectively cast her out.

## Weaknesses

Her family – especially Nymphadora Tonks – is her weakness. This being all the family she has, with the Blacks disowning her, she will be concerned, perhaps overly so, with the wellbeing of her husband and daughter.

## Relationships with Other Characters

She is Bellatrix Lestrange's and Narcissa Malfoy's sister. She was the middle Black daughter, Sirius Black's cousin, but she was disowned for marrying the Muggle Ted Tonks. (He is not really a muggle, but being descended from Muggles is not considered to be a true Wizard.) Her parents are Druella and Cygnus Black. She is the mother of Nymphadora Tonks, mother-in-law of Remus Lupin, wife of Ted Tonks, and grandmother of Teddy Remus Lupin.

## Questions

Study questions are meant to be left for each student to answer; please don't answer them here.
* Do you think anyone in Andromeda's family accepted her choice of husband? Why or why not?
# Shrink-to-fit
### Intent

Minimize the capacity of a container just enough to hold existing range.

### Also Known As

"Swap-To-Fit", introduced by Scott Meyers in his book "Effective STL".

### Motivation

Standard library containers often allocate more memory than the actual number of elements in them. Such a policy results in an optimization of saving some allocations when a container grows in size. On the other hand, when size of the container reduces, there is often leftover capacity in the container. The leftover capacity of the container can be unnecessary wastage of memory resources. Shrink-to-fit idiom has been developed to reduce the extra capacity to a minimum required capacity and thereby saving memory resources.

### Solution and Sample Code

Shrink-to-fit idiom is as simple as the one given below.
The first half of the statement, std::vector<int>(v), creates a temporary vector of integers and it is guaranteed to allocate memory just enough to hold all the elements in the parameter, v. The second half of the statement swaps the temporary vector with v using the non-throwing swap member function. swap is very efficient, amounting to little more than swapping pointers between the vectors. After swapping, the temporary goes out of scope and deletes the memory originally held by v, whereas v retains the memory allocated by the temporary, so it has just enough to hold the original elements in v.
* ↑ ISO/IEC 14882:1998 does not appear to document this behavior of the copy constructor. Where is this behavior guaranteed?
A more reliable solution (notably for std::string, which may be implemented using reference counting, but also for std::vector, whose copy-constructor might copy the other vector's excess capacity) is to use the "range constructor" instead of the copy constructor:
* ↑ http://www.aristeia.com/BookErrata/estl1e-errata.html (search for "string(s.begin, s.end).swap(s)")

### Solution in C++11

In C++11 some containers declare such idiom as function shrink_to_fit, e.g. vector, deque, basic_string. shrink_to_fit is a non-binding request to reduce capacity to size.

### Related Idioms

* Clear-and-minimize
* Non-throwing swap

### References

* Programming Languages — C++ draft standard.
# Smart Pointer
### Intent

To relieve the burden of duplicating changes to the signature of the body class in its handle class when Handle Body idiom or Envelope Letter idiom is in use.

### Also Known As

* En Masse (whole) Delegation

### Motivation

When Handle/body idiom is used, it may become necessary to duplicate the interface of the body class in the handle class because handles are used by the user code. This duplication is often tedious and error prone. Smart Pointer idiom is used to relieve this burden. Smart Pointer idiom is often used along with some sort of "smartness" in the handle class such as reference counting, automatic ownership management and so on.

### Solution and Sample Code

There are at least two overlapping ways of implementing the smart pointer idiom depending upon the intended use.
* Completely pointer like semantics
* Less pointer like semantics
Both of the above variations define an overloaded arrow operator in the so called "handle" class. Lets begin with the completely pointer like semantics.
Using the -> operator alone mitigates the problem of duplicating interface of body class in the handle class. An alternative is to overload deference (*) operator as show in the code snippet above but it is not as natural as the earlier one. If the Handle abstraction is a some sort of pointer abstraction then both the overloaded operators should be provided (e.g., std::auto_ptr, boost::shared_ptr). If the Handle abstraction is not a pointer like abstraction then * operator need not be provided. Instead, it could useful to provide const overloaded set of arrow operators because client always interacts with the handle class objects. For the client code, handle is the object and hence const-ness of the handle should be propagated to corresponding body whenever it's appropriate. In general, the obscure behavior of being able to modify a non-const body object from within a constant handle should be avoided. Unlike pure pointer semantics, in some cases, automatic type conversion from Handle class to Body class is also desirable.
An alternative to using member conversion functions is to use the Non-member get idiom as shown below. The overloaded non-member get functions must be in the same namespace as the Handle class according to the Interface Principle.

### Known Uses

* std::auto_ptr (Completely pointer like semantics)
* boost::shared_ptr (Completely pointer like semantics)
* CORBA Var types in C++ (TAO_Seq_Var_Base_T< T > Class in TAO (The ACE ORB) - less pointer like semantics)

### Related Idioms

* Handle Body
* Envelope Letter
* Reference Counting
# Temporary Proxy
### Intent

To detect and execute different code when the result of overloaded operator is either modified or observed.

### Also Known As

operator proxy

### Motivation

The index operator (operator) is often used to provide array like access syntax for user-defined classes. C++ standard library uses operator in std::string and std::map classes. Standard string simply returns a character reference as a result of operator whereas std::map returns a reference to the value given its key. In both cases, the returned reference can be directly read or written to. The string or map class have no knowledge or has no control over whether the reference is used for reading or for modification. Sometimes, however, it is useful to detect how the value is being used.
For example, consider an UndoString class, which supports a single undo operation in addition to the existing std::string interface. The design must allow an undo even though the character is accessed using the index operator. As mention above, std::string class has no knowledge of whether the result of operator will be written to or not. The temporary proxy can be used to solve this problem.

### Solution and Sample Code

The temporary proxy idiom uses another object, conveniently called proxy, to detect whether the result of operator is used for reading or writing. The UndoString class below defines its own non-const operator, which takes place of std::string's non-const operator.
The new operator returns an object of proxy type. The proxy type defines an overloaded assignment operator and a conversion operator. Depending on the context how the proxy is used, the compiler chooses different functions as shown below.
In all the output expressions (std::cout) above, the proxy object is used for reading and therefore, the compiler uses the conversion operator, which simply returns the underlying character. In the assignment statement (ustr[0] = 'm';), however, the compiler invokes the assignment operator of the proxy class. The assignment operator of the proxy object saves the original character value in the parent UndoString object and finally writes the new character value to the new position. This way, using an extra level of indirection of a temporary proxy object the idiom is able to distinguish between a read and a write operation and take different action based on that.
Caveats
Introducing an intermediary proxy may result in surprising compiler errors. For example, a seemingly innocuous function modify fails to compile using the current definition of the proxy class.
The compiler is unable to find a conversion operator that converts the temporary proxy object into a char &. We have defined only a const conversion operator that returns a const char &. To allow the program to compile, another non-const conversion operator could be added. However, as soon as we do that, it is not clear whether the result of conversion is used to modify the original or not.
# More C++ Idioms/Small Object Optimization

As seen in boost::function to implement type erasure but faster than the heap allocated holder object
# Thin Template
### Intent

To reduce object code duplication when a class template is instantiated for many types.

### Motivation

Templates are a way of reusing source code, not object code. A template can be defined for a whole family of classes. Each member of that family that is instantiated requires its own object code. Whenever a class or function template is instantiated, object code is generated specifically for that type. The greater the number of parameterized types, the larger the generated object code. Compilers only generate object code for functions for class templates that are used in the program, but duplicate object code could still pose a problem in environments where memory is not really abundant. Reusing the same object code could also improve instruction cache performance and thereby application performance. Therefore, it is desirable to reduce duplicate object code.

### Solution and Sample Code

Thin template idiom is used to reduce duplicate object code. Object code level reusable code is written only once, generally in a base class, and is compiled in a separately deployable .dll or .so file. This base class is not type safe but type safe "thin template" wrapper adds the missing type safety, without causing much (or any) object code duplication.
The base class may be fat: it may contain an arbitrary amount of code. Because the base class uses only non-inline functions, its code is only generated once. But because the casting is encapsulated in the inline functions in the class template, the class is typesafe to its users. The templated class is thin, because it does not generate much code per template instantiation.

### Known Uses

Symbian OS relies on this idiom a lot. For example,
where CArrayFixBase does all the work

### References

Symbian Essential Idioms: Thin Templates
# Safe Bool
### Intent

To provide boolean tests for a class but restricting it from taking participation in unwanted expressions.

### Motivation

User provided boolean conversion functions can cause more harm than benefit because it allows them to participate in expressions you would not ideally want them to. If a simple conversion operator is defined then two or more objects of unrelated classes can be compared. Type safety is compromised. For example,

### Solution and Sample Code

Safe bool idiom allows syntactical convenience of testing using an intuitive if statement but at the same time prevents unintended statements unknowingly getting compiled in. Here is the code for the safe bool idiom.
Reusable Solution
There are two plausible solutions: Using a base class with a virtual function for the actual logic, or a base class that knows which function to call on the derived class. As virtual functions come at a cost (especially if the class you're augmenting with Boolean tests doesn't contain any other virtual functions). See both versions below:
Here's how to use safe_bool:
In C++, address of protected members functions can't be taken in a derived class. Derived class could be a standard class, a class template or a specialization of a class template. Some implementations of safe bool idiom declare safe_bool_base::this_type_does_not_support_comparisons as protected, address of which can't be taken in the derived class - a requirement in reusable safe bool idiom.
An insightful discussion on the boost mailing list initiated by Krzysztof Czainski resulted in an implementation of safe bool idiom using CRTP as well as another using macros.

### C++11

The C++11 standard provides explicit conversion operators as a parallel to explicit constructors. This new feature solves the problem in a clean way.

### Known Uses

* boost::scoped_ptr
* boost::shared_ptr
* boost::optional
* boost::tribool

### References

http://www.artima.com/cppsource/safebool.html
* ↑ N2437: Explicit Conversion Operator Draft Working Paper
* ↑ http://stackoverflow.com/questions/6242768/is-the-safe-bool-idiom-obsolete-in-c11
* ↑ http://stackoverflow.com/questions/13193766/isset-or-operator-void-or-explicit-opertor-bool-or-something-else
# Scope Guard
### Intent

* To ensure that resources are always released in face of an exception but not while returning normally
* To provide basic exception safety guarantee

### Motivation

Resource Acquisition is Initialization (RAII) idiom allows us to acquire resources in the constructor and release them in the destructor when scope ends successfully or due to an exception. It will always release resources. This is not very flexible. Sometime we don't want to release resources if no exception is thrown but we do want to release them if an exception is thrown.

### Solution and Sample Code

Enhance the typical implementation of the Resource Acquisition is Initialization (RAII) idiom with a conditional check.

### Known Uses

* boost::mutex::scoped_lock
* boost::scoped_ptr
* std::auto_ptr
* ACE_Guard
* ACE_Read_Guard
* ACE_Write_Guard
* ACE_Auto_Ptr
* ACE_Auto_Array_Ptr

### Related Idioms

* Resource Acquisition Is Initialization (RAII)

### References

* Generic: Change the Way You Write Exception-Safe Code — Forever
* SCOPE_FAILURE and SCOPE_SUCCESS in C++: ScopeGuards without need to release/commit by hands
# Tag dispatch
### Intent

Simplify writing multiple SFINAE-constrained overloads.

### Motivation

Tag dispatching is a useful complement to enable_if. It can also be used in conjunction with trailing return type and decltype, which uses expression SFINAE.
It is most useful when you have multiple overloads for the same function, and they all have conditions for when they can be called. With just enable_if, you have to test for not just the overloads condition, but also the negation of all other overloads' conditions, lest you get overload ambiguity. Tag dispatch will help reduce the mess:

### Solution

This works because exact match is a better match than a base class, which in turn is a better match than base of base, etc. Tag dispatch can also be used when the tag carries useful information, not just a preference ordering. For example, one can dispatch on typename std::iterator_traits<It>::iterator_category and have different algorithms for std::random_access_iterators and std::forward_iterators.

### C++20

C++20 added concepts and requires statements, which entirely eliminates the need for tag dispatching where the constraints include both A and A && B or both A and A || B for some A and B explicitly or in the definitions of concepts. The following code implements std::advance as an example.
# Introduction to Psychology/Sensation and Perception

Sensation and perception are related but different concepts. Sensation is the input about the physical world that is produced by our sensory receptors. Perception is the process by which the mind selects, organizes, and interprets sensations. Our eyes see, our ears hear, our hands touch--or do they? Without interpretation, there is no point to sensation.

## How many senses are there?

If you asked the person on the street how many senses there were, it is almost certain that you would hear "Five: sight, hear, taste, smell, and touch." This is the classical concept of human senses. However, researchers have identified two more:
* Kinesthesia, which is the sense of position of the parts of the body
* Vestibular senses, which detect gravity, linear acceleration, rotary acceleration, and overall provide balance
Taste and smell are related, and both use receptors located in the mouth and other tissues that line other cavities.
The sense of touch is actually a group of subsenses, which could be better-called the somatic senses (somatic means "body"). These subsenses include:
* Mechanoreception, which is the perception of pressure or vibration on the skin
* Thermoreception, which is the perception of heat
* Nociception, which is the perception of pain.

## Sensory receptors

Sensory receptors are cells that are specialized for the task of transduction, or converting physical energy into neural impulses. There are many different types of sensory receptors, such as:
* Rods and cones in the retina, which transduce light.
* Cilla in the ear, which transduce sound
* Pressure, vibration, heat, and pain receptors in the skin
* Chemical receptors in the nasal cavities and mouth
* Muscle spindles

## Gestalt Effect

People have a tendency to see information and sensory images in tiny pieces. As pieces are sensed they form a larger pattern or picture.
# Introduction to Psychology/Scientific Experiment

Experimental psychological research is conducted in the laboratory under controlled conditions. This method of research attempts to rely on an application of the scientific method to understand behavior and mental processes. Examples of such measurements of behavior include reaction time and various psychometric measurements. Experiments are conducted to test a particular hypothesis.
As an example of a psychological experiment, one may want to test people's perception of different tones. Specifically, one could ask the following question: is it easier for people to discriminate one pair of tones from another depending upon their frequency? To answer this, one would want to disprove the hypothesis that all tones are equally discriminable, regardless of their frequency. (See hypothesis testing for an explanation of why one would disprove a hypothesis rather than attempt to prove one.) A task to test this hypothesis would have a participant seated in a room listening to a series of tones. If the participant would make one indication (by pressing a button, for example) if they thought the tones were two different sounds, and another indication if they thought they were the same sound. The proportion of correct responses would be the measurement used to describe whether or not all the tones were equally discriminable. The result of this particular experiment would probably indicate better discrimination of certain tones based on the human threshold of hearing.
Experimental psychological research is not restricted to the laboratory. In a natural setting, a manipulation of the situation can be made to see what is its effect on behavior. For example, one piece of research in environmental psychology measured the littering behavior of picnickers in a park as the result of litter already at the site. On random hours and random days, when the picnic area was vacant, the researchers made the area clean or left trash, and then observed how the site was left after the next picnickers visited.
The key phrase to describe an experiment is similar people in different situations. The similarity of the people is achieved by random assignment (This resembles the phrase 'random selection', but they are very different in meaning and in practice). The different situations are created by manipulation of some situational variable. In the previous paragraph, that variable was the absence or presence of litter when the picnickers arrived.