prompt
stringlengths
12
7.84k
context
stringclasses
0 values
response
list
response-suggestion
stringlengths
15
17.7k
response-suggestion-metadata
dict
external_id
stringclasses
0 values
metadata
stringlengths
113
129
The following article from CNN describes a Michigan police officer being put on administrative leave for having KKK material at his home: https://www.cnn.com/2019/08/10/us/michigan-officer-placed-on-leave-kkk-document-house/index.html. The materials were discovered while a potential buyer was touring his house. Although I vehemently condemn the KKK, doesn't this officer have the right to display whatever he wants in his home so long as it doesn't actively and deliberately call for violence? Aren't these articles protected under the first amendment? I realize this is an extreme example, and as a police officer his job requires interacting with all races, but unless it can be shown that he's bigoted and that it negatively affected his job performance, isn't it illegal to fire him? Employers can restrict speech according to company policy while at work, but we all have to go home at some point. Can those restrictions follow us after clocking out?
null
[]
In general, employers in the United States are free to fire you for your speech. The First Amendment does not apply to anyone except the government (other than a narrow set of circumstances where private parties act on behalf of the government or take on government roles, like when private universities employ campus police). If the officer was being fired from a job at a private company, this would not be an interesting question -- the answer would clearly be "no, there is no First Amendment claim here." That’s not to say labor laws might not come into play (for instance, federal law prohibits firing an employee for organizing a union, and some states prohibit firing for off-duty political speech); however, labor law protections exist by statute and are not derived from the First Amendment. What makes this interesting is that the government is involved. Unlike private employers, government agencies are bound by the First Amendment. In Pickering v. Board of Education, the Supreme Court held that this does restrict them in their role as employer and that they can't necessarily fire an employee for speech. Pickering imposes a balancing test, where the harm to the employee's First Amendment rights is weighed against the government's interest in efficient operation. Courts have given particular leeway to police departments punishing speech that would undermine public trust and confidence in the department. A police officer expressing racist views, even privately, can seriously hamper the effectiveness of the department if the speech gets linked back to them. For instance, see Pappas v. Giuliani, where the Second Circuit upheld the firing of an NYPD officer for anonymously mailing racist diatribes from home in his off-duty time. Another answer suggests that the main question is a public safety one: whether the officer could be trusted to carry out his duties without bias. But that's not the only legitimate consideration for the government employer. The courts have repeatedly held that public perception of an agency is a legitimate concern, especially when it comes to agencies (like the police) whose job requires maintaining good relations with the community. In Pappas, the officer was assigned as a computer operator who had no contact with the public, but he was still a police officer whose speech had a high potential to undermine NYPD community relations.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 815, "passed_quality_check": "True", "flesch_reading_ease": 52.00163265306125, "entropy": 3.904969085190806}
What does strength refer to in mathematics? Is it a formal idea?
null
[]
Suppose you have a theorem that says "If $X$, then $Y$." There are two ways to strengthen such a theorem: * Assume less. If you can reduce the number of hypotheses, but still prove the same conclusion, then you have proved a more "powerful" result (in the sense that it applies in more situations). * Prove more. If you can keep the same hypotheses, but add more information to the conclusion, then you have also produced a more "powerful" result. Here is an easy example from Geometry. Let $ABCD$ be a (non-square) rectangle. Then the internal angle bisectors of the vertices intersect at four points $WXYZ$, which are the vertices of a rectangle. (You need the condition that $ABCD$ is not a square because if it is a square then all four angle bisectors coincide at a single point.) Here are a few ways to strengthen the theorem: * The hypothesis "$ABCD$ is a (non-square) rectangle" can be relaxed to the more general "$ABCD$ is a (non-rhombic) parallelogram". The conclusion that $WXYZ$ is a rectangle still holds. * Alternatively, you can keep the original hypothesis that $ABCD$ is a (non-square) rectangle, and strengthen to the conclusion to say that $WXYZ$ is not just a rectangle, but a square. * Having done that, you can then strengthen the conclusion of the theorem even more, by noting that the diagonal of square $WXYZ$ is equal in length to the difference of the lengths of the sides of $ABCD$. * Once you know that, you can now strengthen the theorem even more by (finally) removing the hypothesis that $ABCD$ is non-square, and including the case in which the four angle bisectors coincide at a single point as forming a "degenerate" square with a diagonal of length zero.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 53, "passed_quality_check": "True", "flesch_reading_ease": 87.94500000000002, "entropy": 0.34435138057505194}
Does vegetarianism affect life expectancy? Is an average vegetarian supposed to live longer just because of their diet?
null
[]
Yes, according to a paper by the American Society for Clinical Nutrition. > Results: Our review of the 6 studies found the following trends: 1) a very low meat intake was associated with a significant decrease in risk of death in 4 studies, a nonsignificant decrease in risk of death in the fifth study, and virtually no association in the sixth study; 2) 2 of the studies in which a low meat intake significantly decreased mortality risk also indicated that a longer duration (≥ 2 decades) of adherence to this diet contributed to a significant decrease in mortality risk and a significant 3.6-y (95% CI: 1.4, 5.8 y) increase in life expectancy; and 3) the protective effect of a very low meat intake seems to attenuate after the ninth decade. Some of the variation in the survival advantage in vegetarians may have been due to marked differences between studies in adjustment for confounders, the definition of vegetarian, measurement error, age distribution, the healthy volunteer effect, and intake of specific plant foods by the vegetarians. TL;DR: * less meat = less risk of death, * less meat for a longer time = an average of a 3 year longer lifespan + less risk of death, * after 90 years of no meat it stops decreasing your risk of death. > Conclusion: Current prospective cohort data from adults in North America and Europe raise the possibility that a lifestyle pattern that includes a very low meat intake is associated with greater longevity. So yes, scientific research says that vegetarianism could help you live longer, but it primarily decreases your risk of death. (i.e. you might not live to 105, but you probably won't die at 55)
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 103, "passed_quality_check": "True", "flesch_reading_ease": 40.613157894736844, "entropy": 0.2894659154760497}
What is the difference between an object and a companion object in a class in kotlin? Example: ```class MyClass { object Holder { //something } companion object { //something } } ``` I already read that companion object shall be used, if the containing parameters/methods are closely related to its class. But why is there also the possibility of declaring a normal object in the class? Because it behaves exactly like the companion, but it must have a name. Is there maybe a difference in its "static" (I'm from the java side) lifecycle?
null
[]
There are two different types of ```object``` uses, expression and declaration. Object Expression An object expression can be used when a class needs slight modification, but it's not necessary to create an entirely new subclass for it. Anonymous inner classes are a good example of this. ```button.setOnClickListener(object: View.OnClickListener() { override fun onClick(view: View) { // click event } }) ``` One thing to watch out for is that anonymous inner classes can access variables from the enclosing scope, and these variables do not have to be ```final```. This means that a variable used inside an anonymous inner class that is not considered ```final``` can change value unexpectedly before it is accessed. Object Declaration An object declaration is similar to a variable declaration and therefore cannot be used on the right side of an assignment statement. Object declarations are very useful for implementing the Singleton pattern. ```object MySingletonObject { fun getInstance(): MySingletonObject { // return single instance of object } } ``` And the ```getInstance``` method can then be invoked like this. ```MySingletonObject.getInstance() ``` Companion Object A companion object is a specific type of object declaration that allows an object to act similar to static objects in other languages (such as Java). Adding ```companion``` to the object declaration allows for adding the "static" functionality to an object even though the actual static concept does not exist in Kotlin. Here's an example of a class with instance methods and companion methods. ```class MyClass { companion object MyCompanionObject { fun actsAsStatic() { // do stuff } } fun instanceMethod() { // do stuff } } ``` Invoking the instance method would look like this. ```var myClass = MyClass() myClass.instanceMethod() ``` Invoking the companion object method would look like this. ```MyClass.actsAsStatic() ``` See the Kotlin docs for more info.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 459, "passed_quality_check": "False", "flesch_reading_ease": 61.0186320754717, "entropy": 2.9613445485131367}
I've rooted my phone. Now what? What do I gain from rooting?
null
[]
In few words, rooting an Android system means overcome the limitations that were imposed over it by the manufacturer. People may want that for different reasons, but the main one is freedom. Having a rooted phone means you've got all the control over your device. The main reason people root phones is to install a custom ROM. Custom ROMs are often known for improvements in performance and exclusive features that are not present on manufacturer ROMs, like installing apps on sdcard or taking screenshots. Custom ROMS can also become a system update alternative for those devices that were abandoned by their manufacturers. You can see a review of popular ROMS, as an example, here. Rooting Android also allows you to uninstall stock apps that you don't use or don't want, besides those that violates user's privacy (see CarrierIQ). Another main reason for doing that is to gain more space on internal storage. A rooted device lets you install almost any app that requires root access. Those apps generally aim to do something that would not be possible without that privilege. A lot of useful apps were shown on the previous answer, but you may find a lot more available on Google Play. You can find a list of good apps here.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 49, "passed_quality_check": "False", "flesch_reading_ease": 111.45547619047619, "entropy": 0.536533782136501}
Is there a better way to determine whether a variable in ```Pandas``` and/or ```NumPy``` is ```numeric``` or not ? I have a self defined ```dictionary``` with ```dtypes``` as keys and ```numeric``` / ```not``` as values.
null
[]
You can use ```np.issubdtype``` to check if the dtype is a sub dtype of ```np.number```. Examples: ```np.issubdtype(arr.dtype, np.number) # where arr is a numpy array np.issubdtype(df['X'].dtype, np.number) # where df['X'] is a pandas Series ``` This works for numpy's dtypes but fails for pandas specific types like pd.Categorical as Thomas noted. If you are using categoricals ```is_numeric_dtype``` function from pandas is a better alternative than np.issubdtype. ```df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': [1j, 2j, 3j], 'D': ['a', 'b', 'c']}) df Out: A B C D 0 1 1.0 1j a 1 2 2.0 2j b 2 3 3.0 3j c df.dtypes Out: A int64 B float64 C complex128 D object dtype: object ``` ```np.issubdtype(df['A'].dtype, np.number) Out: True np.issubdtype(df['B'].dtype, np.number) Out: True np.issubdtype(df['C'].dtype, np.number) Out: True np.issubdtype(df['D'].dtype, np.number) Out: False ``` For multiple columns you can use np.vectorize: ```is_number = np.vectorize(lambda x: np.issubdtype(x, np.number)) is_number(df.dtypes) Out: array([ True, True, True, False], dtype=bool) ``` And for selection, pandas now has ```select_dtypes```: ```df.select_dtypes(include=[np.number]) Out: A B C 0 1 1.0 1j 1 2 2.0 2j 2 3 3.0 3j ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 187, "passed_quality_check": "False", "flesch_reading_ease": 68.08078947368423, "entropy": 0.9724556249724527}
I've come across the polynomial algorithm that solves 2SAT. I've found it boggling that 2SAT is in P where all (or many others) of the SAT instances are NP-Complete. What makes this problem different? What makes it so easy (NL-Complete - even easier than P)?
null
[]
Here is a further intuitive and unpretentious explanation along the lines of MGwynne's answer. With $2$-SAT, you can only express implications of the form $a \Rightarrow b$, where $a$ and $b$ are literals. More precisely, every $2$-clause $l_1 \lor l_2$ can be understood as a pair of implications: $\lnot l_1 \Rightarrow l_2$ and $\lnot l_2 \Rightarrow l_1$. If you set $a$ to true, $b$ must be true as well. If you set $b$ to false, $a$ must be false as well. Such implications are straightforward: there is no choice, you have only $1$ possibility, there is no room for case-multiplication. You can just follow every possible implication chain, and see if you ever derive both $\lnot l$ from $l$ and $l$ from $\lnot l$: if you do for some $l$, then the 2-SAT formula is unsatisfiable, otherwise it is satisfiable. It is the case that the number of possible implication chains is polynomially bounded in the size of the input formula. With $3$-SAT, you can express implications of the form $a \Rightarrow b \lor c$, where $a$, $b$ and $c$ are literals. Now you are in trouble: if you set $a$ to true, then either $b$ or $c$ must be true, but which one? You have to make a choice: you have 2 possibilities. Here is where case-multiplication becomes possible, and where the combinatorial explosion arises. In other words, $3$-SAT is able to express the presence of more than one possibility, while $2$-SAT doesn't have such ability. It is precisely such presence of more than one possibility ($2$ possibilities in case of $3$-SAT, $k-1$ possibilities in case of $k$-SAT) that causes the typical combinatorial explosion of NP-complete problems.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 214, "passed_quality_check": "True", "flesch_reading_ease": 86.65380434782612, "entropy": 1.4467066339730328}
Why isn't Sectumsempra an Unforgivable Curse?
null
[]
Not many people knew Sectumsempra - they'd need to know it exists to ban it. Severus Snape invented Sectumsempra while at Hogwarts, and wrote it down in his Potions book. He doesn't seem to have told many people about it, it's possible he didn't tell anyone at all. “Harry was about to put his book away again when he noticed the corner of a page folded down; turning to it, he saw the Sectumsempra spell, captioned ‘For Enemies’, that he had marked a few weeks previously.” - Harry Potter and the Half-Blood Prince, Chapter 24 (Sectumsempra) His book was hidden away until Harry found it, and Harry didn't tell the rest of the wizarding world about it either. Severus himself was seen using Sectumsempra when the Order was moving seven Harrys, and Harry had used it a few times after he found it in Snape's old book. Lupin knows of it, since he described it as one of Snape's specialties. However, they are probably some of the only people who know it - it isn't widely known like the three Unforgivable Curses. No one else, either in the Death Eaters or the Order of the Phoenix, is ever said to use it. It's likely that the Ministry didn't even know of it. Therefore, the Ministry wouldn't have even been able to make the decision to classify it as an Unforgivable Curse, since they would likely not have even known it existed. If the Ministry knew about it, would it be classified as Unforgivable? The reason it wasn't classified as an Unforgivable Curse is because the Ministry wouldn't have known about it - they would be unable to make any decision on something they don't know exists. That, by itself, doesn't say whether the Ministry would classify it as one if they knew about it. Not all potentially harmful spells are classified as Unforgivable Curses. It's nowhere near guaranteed, though, that if the Ministry knew about Sectumsempra, that they'd classify it as an Unforgivable Curse. There are other spells that could clearly do harm. Just to give a few examples - Confringo, Flagrante, and the creation of Fiendfyre are all potentially harmful but not Unforgivable. It's never mentioned why those three curses are classified as Unforgivable and others aren't, but it seems likely that it's because there are little to no uses for them that aren't evil. The punishment for using an Unforgivable Curse is a lifetime sentence in Azkaban, so only the worst curses, that are highly unlikely to ever have a non-Dark use, would be made Unforgivable. “Now … those three curses – Avada Kedavra, Imperius and Cruciatus – are known as the Unforgivable Curses. The use of any one of them on a fellow human being is enough to earn a life sentence in Azkaban.” - Harry Potter and the Goblet of Fire, Chapter 14 (The Unforgivable Curses) Now, would Sectumsempra fit the criteria for being made an Unforgivable Curse? Probably not - it cuts through things like a sword. It can be used for anything a sword, knife or other cutting tool can be used for. While using it on people might be considered Unforgivable, the spell itself is simply the act of cutting. There are many things a wizard might reasonably want to cut with no malicious intent; vegetables, rope, cloth, building materials. Because of this, it seems unlikely that even if the Ministry had known about it, it would be classified as an Unforgivable Curse. In addition, there is a countercurse for Sectumsempra. “Pushing Harry roughly aside, he knelt over Malfoy, drew his wand and traced it over the deep wounds Harry’s curse had made, muttering an incantation that sounded almost like song. The flow of blood seemed to ease; Snape wiped the residue from Malfoy’s face and repeated his spell. Now the wounds seemed to be knitting. - Harry Potter and the Half-Blood Prince, Chapter 24 (Sectumsempra) While the wounds from Sectumsempra can't be healed by simple healing spells, they can in fact be healed by the countercurse. So - Sectumsempra likely wouldn't be made Unforgivable if the Ministry knew it.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 40, "passed_quality_check": "False", "flesch_reading_ease": 45.64500000000001, "entropy": 0.13872672467257346}
How can I add a delay to a program in C#?
null
[]
Use a timer with an interval set to 2–3 seconds. You have three different options to choose from, depending on which type of application you're writing: * ```System.Timers.Timer``` * ```System.Windows.Forms.Timer``` * ```System.Threading.Timer``` Don't use ```Thread.Sleep``` if your application need to process any inputs on that thread at the same time (WinForms, WPF), as ```Sleep``` will completely lock up the thread and prevent it from processing other messages. Assuming a single-threaded application (as most are), your entire application will stop responding, rather than just delaying an operation as you probably intended. Note that it may be fine to use Sleep in pure console application as there are no "events" to handle or on separate thread (also ```Task.Delay``` is better option). In addition to timers and ```Sleep``` you can use ```Task.Delay``` which is asynchronous version of ```Sleep``` that does not block thread from processing events (if used properly - don't turn it into infinite sleep with ```.Wait()```). ``` public async void ClickHandler(...) { // whatever you need to do before delay goes here await Task.Delay(2000); // whatever you need to do after delay. } ``` The same ```await Task.Delay(2000)``` can be used in a ```Main``` method of a console application if you use C# 7.1 (Async main on MSDN blogs). Note: delaying operation with ```Sleep``` has benefit of avoiding race conditions that comes from potentially starting multiple operations with timers/```Delay```. Unfortunately freezing UI-based application is not acceptable so you need to think about what will happen if you start multiple delays (i.e. if it is triggered by a button click) - consider disabling such button, or canceling the timer/task or making sure delayed operation can be done multiple times safely.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 31, "passed_quality_check": "False", "flesch_reading_ease": 103.37909090909093, "entropy": 0.4249586373253164}
I'm trying to write a Bash script that will overwrite an existing directory. I have a directory ```foo/``` and I am trying to overwrite ```bar/``` with it. But when I do this: ```cp -Rf foo/ bar/ ``` a new ```bar/foo/``` directory is created. I don't want that. There are two files in ```foo/```; ```a``` and ```b```. There are files with same names in ```bar/``` as well. I want the ```foo/a``` and ```foo/b``` to replace ```bar/a``` and ```bar/b```.
null
[]
If you want to ensure ```bar/``` ends up identical to ```foo/```, use ```rsync``` instead: ```rsync -a --delete foo/ bar/ ``` If just a few things have changed, this will execute much faster than removing and re-copying the whole directory. * ```-a``` is 'archive mode', which copies faithfully files in ```foo/``` to ```bar/``` * ```--delete``` removes extra files not in ```foo/``` from ```bar/``` as well, ensuring ```bar/``` ends up identical * If you want to see what it's doing, add ```-vh``` for verbose and human-readable * Note: the slash after ```foo``` is required, otherwise ```rsync``` will copy ```foo/``` to ```bar/foo/``` rather than overwriting ```bar/``` itself. * (Slashes after directories in rsync are confusing; if you're interested, here's the scoop. They tell rsync to refer to the contents of the directory, rather than the directory itself. So to overwrite from the contents of ```foo/``` onto the contents of ```bar/```, we use a slash on both. It's confusing because it won't work as expected with a slash on neither, though; rsync sneakily always interprets the destination path as though it has a slash, even though it honors an absence of a slash on the source path. So we need a slash on the source path to make it match the auto-added slash on the destination path, if we want to copy the contents of ```foo/``` into ```bar/```, rather than the directory ```foo/``` itself landing into ```bar/``` as ```bar/foo```.) ```rsync``` is very powerful and useful, if you're curious look around for what else it can do (such as copying over ssh).
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 378, "passed_quality_check": "False", "flesch_reading_ease": 91.48038461538462, "entropy": 3.3914655836655125}
Is there a particular reason the elves die off so fast? After the first war against Sauron, I recall the elves being decimated, to the point that they're almost useless army-wise in the trilogy. But I'm guessing men suffered equal or greater losses as well. Anyways, other races just seem much more capable of repopulating, while is seems like there are incredibly few (if any?) elven children. Considering the fact that elves are immortal, wouldn't their population be the fastest to grow? Also the seem to be perpetually 40 years old, so aren't they eternally fertile as well? Why don't they have more kids and build bigger societies?
null
[]
Tolkien himself addresses this in an essay called "Laws and Customs Among the Eldar". There are essentially two problems: * Elvish libido diminishes over time. Contrary to popular belief (and outward appearance, from a human perspective), Elves do age; and as they get older, they get less interested in procreation. * Having children is exhausting. The Elves believe that their child-bearing process draws a heavier physical and spiritual toll on them, compared to what it does to humans. They're understandable reluctant to have a lot of kids, because what's the point in having a dozen kids if doing so might literally kill you? From "Laws and Customs": It might be thought that, since the Eldar do not (as Men deem) grow old in body, they may bring forth children at any time in the ages of their lives. But this is not so. For the Eldar do indeed grow older, even if slowly: the limit of their lives is the life of Arda, which though long beyond the reckoning of Men is not endless, and ages also. Moreover their body and spirit are not separated but coherent. As the weight of the years, with all their changes of desire and thought, gathers upon the spirit of the Eldar, so do the impulses and moods of their bodies change. [...] Also the Eldar say that in the begetting [conceiving], and still more in the bearing of children, greater share and strength of their being, in mind and in body, goes forth than in the making of mortal children. For these reasons it came to pass that the Eldar brought forth few children; and also that their time of generation was in their youth or earlier life, unless strange and hard fates befell them. History of Middle-earth X Morgoth's Ring Part 3: "The Later Quenta Silmarillion" Chapter 2: "The Second Phase" Laws and Customs Among the Eldar That last point about the toll on their mind and body is worth expanding on, and fortunately Tolkien does this later in the essay: [A]ll the Eldar, being aware of it in themselves, spoke of the passing of much strength, both of mind and of body, into their children, in bearing and begetting. Therefore they hold that the fëa [soul], though unbegotten, draws nourishment directly from the fëa of the mother while she bears and nourishes the hrondo [body; later changed to the word hroä], and mediately but equally from the father, whose fëa is bound in union with the mother's and supports it. History of Middle-earth X Morgoth's Ring Part 3: "The Later Quenta Silmarillion" Chapter 2: "The Second Phase" Laws and Customs Among the Eldar
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 530, "passed_quality_check": "True", "flesch_reading_ease": 77.51511363636365, "entropy": 3.744314631819346}
Reasons for being vegetarian or vegan other than ethical reasons?
null
[]
There are multiple reasons why people are/become Vegetarian/Vegan apart from ethics, including but not limited to * Religion/Culture - most of the worlds Vegetarians reside in India, mainly due to culture/personal beliefs but often interlinked with some of their major religions (Hinduism/Sikhism/Jainism etc) which promote the diet. Some strains of Buddhism also look positively at not eating meat, as does the Seventh-day Adventist Church. * Environment - reducing land degradation, climate change, reducing harm to bio-diversity etc. Animal agriculture causes a huge amount of problems to our planet and environment. * Health - another major point. Being Vegetarian or Vegan won't automatically improve your health of course (it's easy to live off junk food, believe me), but there are lots of scientifically proven benefits to eat a plant based diet over a standard Western diet including a lower risk of heart disease, lower BMI, lower cholesterol etc. * Political - a slightly less common reason but still; some people go Vegetarian or Vegan based on their political beliefs once they realise how much the two share intersectional values (e.g. from Anarchism to Veganarchism)
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 56, "passed_quality_check": "True", "flesch_reading_ease": 27.485000000000014, "entropy": 0.11582502554518834}
My mom has a green card that expires 2028 but has been out of the US in the UK for over a year due to COVID travel restrictions. Can she enter now?
null
[]
Assuming she doesn't have a valid Re-entry Permit, she technically doesn't have one of the accepted documents for entry of a returning immigrant, as listed in 8 CFR 211.1(a). A green card is not one of the accepted documents after an absence of more than 1 year, and she doesn't have any of the other documents, like a Re-entry Permit or an immigrant visa. However, under 8 CFR 211.1(b)(3) and 8 CFR 211.4, the immigration officers at the port of entry have the authority to waive her failure to meet the documentary requirements, if they determine that she has not abandoned residence. They often will grant the waiver if it's the first time, the absence is not too much over a year, and/or there is a good reason for not returning earlier (e.g. COVID-19). So if she manages to make it to a US port of entry, there is a good chance they will just let her in, perhaps with a warning. The officer could deny her entry, and pressure her to voluntarily sign I-407 to relinquish her permanent residency. This is voluntary, and she can refuse. If she refuses, they will give her a Notice to Appear for removal proceedings in immigration court at a later date. There, she will be able to present her case to the immigration judge, and if the immigration judge determines that she has not abandoned residence, the immigration judge can grant the waiver for her failure to meet the documentary requirements (think of it as a second opinion on the immigration officer's decision). The other option to all this is that she can apply for an SB1 returning resident visa at a US consulate (which will meet the documentary requirements since it is an immigrant visa). However, this requires showing that she could not return any earlier due to circumstances beyond her control (which may be harder to prove than showing that she did not abandon residence). Also, there is no appeal for visa denials.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 116, "passed_quality_check": "True", "flesch_reading_ease": 95.42, "entropy": 0.9201221951352379}
What is the LXX and why is it so noteworthy that there is a Greek translation of the OT? Wouldn't it be better to directly reference manuscripts in the original languages?
null
[]
Before 1947, a good case could be made that the Septuagint represented a more ancient tradition than the Masoretic versions of the Tanakh. Since the Septuagint was produced before 132 BCE (and probably in the 3rd century BCE) and the earliest known Masoretic manuscripts date to the 10th century CE, the Greek translation might have fossilized an early rendering of the Scriptures while the Hebrew continued to be copied and potentially altered. To further support the primacy of the Septuagint, the early Christian and Hellenistic Jewish texts, tended to use that translation rather go back to Hebrew sources. An interesting counter-argument arises from the observation that during the 600 years from Jerome's translation into Latin (the Vulgate) to the earliest Masoretic manuscripts, the Hebrew seems to have been faithfully copied. That suggests that Jewish scribes were exceptionally careful to duplicate their scriptures. After 1947, the evidence changed. According to Wikipedia: [Most] of the Qumran fragments can be classified as being closer to the Masoretic text than to any other text group that has survived. According to Lawrence Schiffman, 60% can be classed as being of proto-Masoretic type, and a further 20% Qumran style with bases in proto-Masoretic texts, compared to 5% proto-Samaritan type, 5% Septuagintal type, and 10% non-aligned. Joseph Fitzmyer noted the following regarding the findings at Qumran Cave 4 in particular: "Such ancient recensional forms of Old Testament books bear witness to an unsuspected textual diversity that once existed; these texts merit far greater study and attention than they have been accorded till now. Thus, the differences in the Septuagint are no longer considered the result of a poor or tendentious attempt to translate the Hebrew into the Greek; rather they testify to a different pre-Christian form of the Hebrew text". Another another article describes the meaning of the categories in detail. A few caveats are in order: * Surveying the Qumran about religious texts seems something akin to surveying a hippie commune about political issues—you're likely to experience some bias. If we could obtain a similar collection from Jerusalem, we'd likely find more agreement and likely the side of MT. Given the diversity in non-Scriptural texts, 60% seems quite solid support. * While it's unlikely, there exists a chronological possibility the scrolls associated with the Septuagint-aligned Hebrew were influenced by the Greek. (Any references one way or the other would be appreciated.) What remains therefore is a window into the community of Alexandrian Jews that produced the translation. For those who are interested in the development of Jewish belief, that can be extremely useful. N. T. Wright's book, The Resurrection of the Son of God, shows that the LXX translators chose to interpret key texts from Daniel and Ezekiel about the resurrection as literal rather than metaphorical. He argues from this that belief in bodily resurrection was more common in Jesus' day than other scholars assert.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 141, "passed_quality_check": "True", "flesch_reading_ease": 73.75411290322583, "entropy": 1.1379363585592788}
I have to disable inputs at first and then on click of a link to enable them. This is what I have tried so far, but it doesn't work. HTML: ``` ``` jQuery: ```$("#edit").click(function(event){ event.preventDefault(); $('.inputDisabled').removeAttr("disabled") }); ``` This shows me ```true``` and then ```false``` but nothing changes for the inputs: ```$("#edit").click(function(event){ alert(''); event.preventDefault(); alert($('.inputDisabled').attr('disabled')); $('.inputDisabled').removeAttr("disabled"); alert($('.inputDisabled').attr('disabled')); }); ```
null
[]
Always use the ```prop()``` method to enable or disable elements when using jQuery (see below for why). In your case, it would be: ```$("#edit").click(function(event){ event.preventDefault(); $('.inputDisabled').prop("disabled", false); // Element(s) are now enabled. }); ``` jsFiddle example here. Why use ```prop()``` when you could use ```attr()```/```removeAttr()``` to do this? Basically, ```prop()``` should be used when getting or setting properties (such as ```autoplay```, ```checked```, ```disabled``` and ```required``` amongst others). While what you want to do can technically be done using ```attr()```/```removeAttr()```, it doesn't mean it should be done - and can cause strange/problematic behaviour, as in this case. "The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the ```.attr()``` method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the ```.prop()``` method provides a way to explicitly retrieve property values, while ```.attr()``` retrieves attributes." "Properties generally affect the dynamic state of a DOM element without changing the serialized HTML attribute. Examples include the ```value``` property of input elements, the ```disabled``` property of inputs and buttons, or the ```checked``` property of a checkbox. The ```.prop()``` method should be used to set ```disabled``` and ```checked``` instead of the ```.attr()``` method. The ```.val()``` method should be used for getting and setting ```value```." - jQuery documentation for prop() Pre-jQuery 3.0 (before 2016) The reason why you should use ```prop``` over ```removeAttr()``` is that ```removeAttr()``` completely removes the ```disabled``` attribute itself - as this method would simply set the corresponding property name to ```false```: Prior to jQuery 3.0, using .removeAttr() on a boolean attribute such as checked, selected, or readonly would also set the corresponding named property to false. This behavior was required for ancient versions of Internet Explorer but is not correct for modern browsers because the attribute represents the initial value and the property represents the current (dynamic) value. - jQuery 3.0 Breaking Changes While ```prop()``` merely sets the property's underlying boolean value to false.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 524, "passed_quality_check": "False", "flesch_reading_ease": 70.3073529411765, "entropy": 2.5869804256754416}
I'm no expert in darkroom photography, but it seems a little odd that there is a type of light that doesn't affect film or developing paper etc. So why is a dark-room safelight safe?
null
[]
Photo films and papers are made from salts of silver that naturally only darken when exposed to violet or blue light. In the early days of photography, this was all that was available. Therefore these films and papers are able to be handled under any light source that does not radiate blue light. By the way, the violet and blue frequencies of light are the shortest, and are the most energetic when it comes to inducing a chemical change. These early films and papers could all be be handled safely under red light as well as yellow light. These lamps do not emit violet or blue. These blue-sensitive-only films did an OK job, with some exceptions. Women’s faces with cosmetics, like lipstick and rouge on the cheeks, came out weird. Warm tones reproduced super dark, and most times lips and cheeks turned black, void of detail on the finished picture. The bottom line is, many colors in nature reproduced incorrectly with this early blue-sensitive-only film. The cure was accidental. Professor Hermann Vogel at Berlin Technical was trying to solve the problem of halation. This results when taking a picture of bright objects, like light sources or gemstones and the like. These objects play on the film with lots of light energy. This energy often goes completely through the film and hits something behind the film. The light is then reflected back into the film. The result is a halo around bright objects. The professor had one of his students dye the silver salts yellow, thinking the yellow dye would filter out the annoying reflected blue from the rear. He tried this dyed film and it did the trick, plus the film gained sensitivity to green light. He named this blue/green sensitive film orthochromatic (Latin for correct color). The year was 1857, and the quality of film reproducing the colors of nature moved forward by a big leap. A few years later, one of his graduate students, experimenting with different dyes, discovered how to make films sensitive to blue, green and red light. This film was called panchromatic (the pan prefix in Greek means "all"). Thus panchromatic film reproduces all colors found in nature with high accuracy. The bad news was, the darkroom folks were forced to give up the red and yellow safelight. A super dim green safelight could be used for a short period of time during developing. Photo papers remained insensitive to red for the most part - no need, as they work OK with just blue and green sensitivity. Modern variable contrast photo papers have two sensitive coats, one for blue light and one for green light. We can use a safelight on these papers; it is amber with reduced brilliance. Films and papers that make color pictures are panchromatic, and most safelights are not safe. We can use infrared lamps with a specialized night vision infrared scope to view and handle most panchromatic films and papers, because these materials have low sensitivity to infrared.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 149, "passed_quality_check": "True", "flesch_reading_ease": 80.30107142857145, "entropy": 1.149515380541567}
With the command: ```ls -la * ``` I can list all my symbolic links. How can I remove all symbolic links which are linked to a special folder? For example: In my directory ```usr/local/bin``` I have the following entries: ```lrwxrwxrwx 1 root root 50 Apr 22 14:52 allneeded -> /usr/local/texlive/2011/bin/x86_64-linux/allneeded lrwxrwxrwx 1 root root 47 Apr 22 14:52 amstex -> /usr/local/texlive/2011/bin/x86_64-linux/amstex lrwxrwxrwx 1 root root 24 Apr 23 19:09 arara -> /home/marco/.arara/arara ``` Now I want to remove all links with the path ```/usr/local/texlive/```
null
[]
Please make sure to read the alternative answer. It's even more to the point although not voted as high at this point. You can use this to delete all symbolic links: ```find -type l -delete ``` with modern ```find``` versions. On older find versions it may have to be: ```find -type l -exec rm {} \; # or find -type l -exec unlink {} \; ``` To limit to a certain link target, assuming none of the paths contain any newline character: ``` find -type l | while IFS= read -r lnkname; do if [ "$(readlink '$lnkname')" == "/your/exact/path" ]; then rm -- "$lnkname"; fi; done ``` or nicely formatted ``` find -type l | while IFS= read -r lnkname; do if [ "$(readlink '$lnkname')" = "/your/exact/path" ]; then rm -- "$lnkname" fi done ``` The ```if``` could of course also include a more complex condition such as matching a pattern with ```grep```. Tailored to your case: ```find -type l | while IFS= read -r lnk; do if (readlink "$lnk" | grep -q '^/usr/local/texlive/'); then rm "$lnk"; fi; done ``` or nicely formatted: ```find -type l | while IFS= read -r lnk do if readlink "$lnk" | grep -q '^/usr/local/texlive/' then rm "$lnk" fi done ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 499, "passed_quality_check": "False", "flesch_reading_ease": 57.32669154228857, "entropy": 1.6980480327414744}
Did Aztecs know how many continents there are on earth?
null
[]
Do you know how many continents there are on Earth? Is Europe a separate continent from Asia? Is Australia the biggest island or the smallest continent? Is Antarctica an ice-locked archipelago or a continent? Are the Americas one continent or two? (All of those questions can be answered reasonably either way.) The separation of Europe from Asia into two continents happened because, from the point of view of the Greek Mediterranean world, all of Asia that mattered was across the sea from all of Europe that mattered. They knew that Europe and Asia were connected north of the Black Sea (though they didn't know how big a connection) but they didn't care, because for their purposes, they were separate continents. The idea of a continent is more a cultural thing than anything else. From a proper scientific point of view continents are probably better defined by tectonic plates so now you're dealing with twenty or so. Maybe a continent is a tectonic plate with dry land attached? That still leaves quite a few. (And how much dry land is needed? And is Los Angeles on a separate continent from New York?) If the Aztecs knew the geography of the whole Earth it would still be very surprising if they had counted continents the same way the Ancient Greeks have led us to do. And there's no evidence they knew the geography of the whole Earth and considerable evidence that they didn't.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 46, "passed_quality_check": "True", "flesch_reading_ease": 95.165, "entropy": 0.12903293757497755}
What did the Soviet Union and Russia bring to the ISS?
null
[]
Initially, everything. The ISS started out as Mir-2 with some extra modules added soon afterwards. Then lots more over the next 10 years. The initial modules, Zarya and Zvezda, which housed living quarters, reboost, attitude control, solar power, life support, and docking modules. Each additional component and module made the system better, but the ISS is still dependent on the Russian operating segment. Each function that the Russian segment supplied initially was enhanced or replaced by the US side (solar power, life support, etc.). The major component this is mostly still Russian is half the crew quarters and reboost/attitude control (beyond what the control gyros can handle). Initially the Shuttle and Soyuz provided crew services, and now only Soyuz (till SpaceX/ULA get their acts together in 2019) provides crew. Initially the Russians provided cargo (as did the Shuttle till retirement), but specifically Progress could refuel the engines on the ISS for reboost. The Russian theoretical plan is that the next two modules they launch (if ever, now, after being so delayed) Nauka and the UM will be able to separate from the ISS and form the core of their next space station. One of those theories was to take Zarya and Zvezda (or just one) with them as well.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 44, "passed_quality_check": "True", "flesch_reading_ease": 87.99727272727276, "entropy": 0.40572100388995597}
What utility can move my Windows boot partition over to another hard drive? My preference is that it would be really easy. * Boot into Windows * Pick drive to move * Pick target drive * It copies everything over, and reboots to the correct partition.
null
[]
## DriveImage XML DriveImage XML will do the job. It runs from within Windows and it can copy directly from drive to drive. A lot of people rave about it after good experiences with the software. DriveImage XML is an easy to use and reliable program for imaging and backing up partitions and logical drives. Image creation uses Microsoft's Volume Shadow Services (VSS), allowing you to create safe "hot images" even from drives currently in use. Images are stored in XML files, allowing you to process them with 3rd party tools. Never again be stuck with a useless backup! Restore images to drives without having to reboot. DriveImage XML is now faster than ever, offering two different compression levels. ## EASEUS Disk Copy EASEUS Disk Copy is a great alternative if you don't want to go for a 'hot' backup that runs from within Windows. Good review at lifehacker and on a par with DriveImage XML. They quite clearly state that it is ideal for moving from one disk to a larger one. Like other suggestions, this requires that you create a boot CD. > EASEUS Disk Copy is a potent freeware providing sector-by-sector disk/partition clone regardless of your operating system, file systems and partition scheme by creating a bootable CD. The sector-by-sector method assures you a copy 100% identical to the original. Disk Copy can be used for copy, cloning, or upgrading your original small hard drive to a new larger drive. Simply speaking, it can copy anything from the old hard drive including the deleted, lost files and inaccessible data. So, the freeware is a perfect tool for Data Recovery Wizard to recover files from a backup disk.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 211, "passed_quality_check": "True", "flesch_reading_ease": 81.50875, "entropy": 1.380744043990142}
What's the difference between ASCII and Unicode?
null
[]
ASCII has 128 code points, 0 through 127. It can fit in a single 8-bit byte, the values 128 through 255 tended to be used for other characters. With incompatible choices, causing the code page disaster. Text encoded in one code page cannot be read correctly by a program that assumes or guessed at another code page. Unicode came about to solve this disaster. Version 1 started out with 65536 code points, commonly encoded in 16 bits. Later extended in version 2 to 1.1 million code points. The current version is 6.3, using 110,187 of the available 1.1 million code points. That doesn't fit in 16 bits anymore. Encoding in 16-bits was common when v2 came around, used by Microsoft and Apple operating systems for example. And language runtimes like Java. The v2 spec came up with a way to map those 1.1 million code points into 16-bits. An encoding called UTF-16, a variable length encoding where one code point can take either 2 or 4 bytes. The original v1 code points take 2 bytes, added ones take 4. Another variable length encoding that's very common, used in *nix operating systems and tools is UTF-8, a code point can take between 1 and 4 bytes, the original ASCII codes take 1 byte the rest take more. The only non-variable length encoding is UTF-32, takes 4 bytes for a code point. Not often used since it is pretty wasteful. There are other ones, like UTF-1 and UTF-7, widely ignored. An issue with the UTF-16/32 encodings is that the order of the bytes will depend on the endian-ness of the machine that created the text stream. So add to the mix UTF-16BE, UTF-16LE, UTF-32BE and UTF-32LE. Having these different encoding choices brings back the code page disaster to some degree, along with heated debates among programmers which UTF choice is "best". Their association with operating system defaults pretty much draws the lines. One counter-measure is the definition of a BOM, the Byte Order Mark, a special codepoint (U+FEFF, zero width space) at the beginning of a text stream that indicates how the rest of the stream is encoded. It indicates both the UTF encoding and the endianess and is neutral to a text rendering engine. Unfortunately it is optional and many programmers claim their right to omit it so accidents are still pretty common.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 42, "passed_quality_check": "False", "flesch_reading_ease": 66.7871428571429, "entropy": 0.25062798801103864}
Reasons why healthy people would intentionally want to get infected?
null
[]
Because some self-proclaimed health guru claims that it's good for you to have that disease. The miracle-virus causes your body to absorb free cosmic energies. Your constantly raising body temperature is proof that it works. The headache you feel is because your brain is reconfiguring itself to become more effective. When the process is over, you will be far more intelligent. Some of our patients even gained psychic powers. The vomiting, blood-coughing, explosive diarrhea and the open sores you have all over your body are actually all the poisons your body accumulated over your life which are now leaving your body. The weakness you feel and the periodical blackouts are also part of the cleansing process. Your body is concentrating all its energy on cleaning you. That's in fact a good sign and shows that it works. Some of us were even able to communicate with alien angel-spirits during these intensive cleaning phases. All of that is of course bullshit. The infected are simply sick. The guru just claims all those pseudo-scientific benefits exist to get people to pay them ridiculous amounts of money for infecting them with the disease. Sounds ridiculous? Then you might want to take a look at the community of people drinking bleach.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 59, "passed_quality_check": "True", "flesch_reading_ease": 61.32500000000002, "entropy": 0.1751919972986273}
In The Avengers, the Council contacted Nick Fury and supposedly, they want to nuke Manhattan. Nick didn't agree so they contacted a S.H.I.E.L.D. operative to nuke Manhattan. When they found out that an unauthorized jet was trying to fly, Nick grabbed a rocket launcher and fired it at the jet, which was a decoy and the real jet was able to escape. However, why would he do that? If that was the real plane carrying a nuke enough to level Manhattan, wouldn't the nuke explode and destroy the base along with them if he fired a rocket launcher at it?
null
[]
If that was the real plane carrying a nuke enough to level Manhattan, wouldn't the nuke explode and destroy the base along with them if he fired a rocket launcher at it? No. Detonating a modern nuclear device is, in fact, incredibly difficult and merely shooting down the aircraft carrying it would not be sufficient. In fact, several aircraft carrying older nuclear devices have either crashed or otherwise been lost without the device on board detonating. It's likely that the crash might cause a release of nuclear material but detonation is practically impossible. In 1966... ...another B-52 carrying four hydrogen bombs crashed near the Spanish town of Palomares on Spain’s southeast coast after colliding with a refueling tanker. One of the four bombs was recovered virtually intact, according to The Washington Post, but two others released plutonium when their explosive triggers detonated. A fourth bomb fell into the sea, prompting a search that involved thousands of uniformed personnel, millions of dollars and 20 ships that ranged from submarines to minesweepers. The fourth bomb was eventually recovered, but radiation released by the damaged weapons required a U.S.-led effort to decontaminate 640 acres of topsoil in the farmland around Palomares, Tad Sczulc reported in the Times. Military personnel initially wore face masks and gloves as they removed the soil, according to Sczulc’s account, and more than 1,600 tons of contaminated soil were sealed in steel drums and shipped to the U.S. for disposal. Washington Post 1964 In 1964, a B-52 carrying two unarmed atomic bombs crashed in western Maryland. In 1961, two nuclear-laden B-52s went down — one near Yuba City, Calif., and another north of Goldsboro, N.C. The bombs survived both crashes without detonating
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 452, "passed_quality_check": "True", "flesch_reading_ease": 76.64664705882355, "entropy": 3.704069338102013}
Since I created my repository it appears that the tags I have been creating are not pushed to the repository. When I do ```git tag``` on the local directory all the tags are present, but when I logon to the remote repository and do a ```git tag```, only the first few show up. What could the problem be?.
null
[]
In default git remote configuration you have to push tags explicitly (while they are fetched automatically together with commits they point to). You need to use ``` $ git push <remote> tag <tagname> ``` to push a single tag, ``` $ git push <remote> --tags ``` to push all tags (or ```git push --tags``` to push to default remote, usually ```origin```). This is very much intended behavior, to make pushing tags explicit. Pushing tags should be usually conscious choice.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 251, "passed_quality_check": "True", "flesch_reading_ease": 75.47671171171173, "entropy": 2.588823034121617}
How do I add Git submodule to a sub-directory?
null
[]
You go into ~/.janus and run: ```git submodule add <git@github ...> snipmate-snippets/snippets/``` If you need more information about submodules (or git in general) ProGit is pretty useful.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 38, "passed_quality_check": "True", "flesch_reading_ease": 78.24500000000002, "entropy": 0.33288917312244237}
Given that Kohn-Sham DFT is strictly a ground-state method (at 0 K), how is it sufficient to describe materials in real-life applications?
null
[]
These are a few extra points to complement Andrew Rosen's comprehensive response: * To be absolutely clear, typical DFT calculations are not performed at 0K, a better description of what happens is that they are performed "for a static crystal". Static crystal means that the atoms are fixed at their crystallographic positions (which is what a typical DFT calculation does), but this situation is different from 0K. Even at 0K, the atomic nuclei move due to quantum zero-point motion (also called quantum fluctuations). This quantum zero-point motion is very small for compounds containing heavy elements, which means that in these cases "0K" and "static crystal" are almost the same and many people use the terms interchangeably. However, quantum zero-point motion can be very large for light elements, for example in solid hydrogen (the lightest of all compounds) it dominates even at room temperature. To perform a calculation at 0K (as opposed to a static crystal calculation), the strategy that Andrew Rosen proposed would still work if you use quantum statistics. For example, solving the vibrational problem within the harmonic approximation at the quantum mechanical level with give you the zero-point energy as the ground state of a quantum harmonic oscillator. A good reference for hydrogen is this review article. * Although Andrew Rosen is correct in that the potential energy surface is largely temperature independent, there are a few situations in which the potential energy surface does vary significantly with temperature. An example of this is provided by many perovskite crystals (e.g. $\ce{BaTiO_3}$), which undergo a series of temperature-induced structural phase transitions. For example, at very high temperatures the structure is cubic, and this structure sits at a minimum of the potential free energy surface. However, if you calculated the potential energy surface (instead of the free energy surface), then it has a double-well shape and the cubic structure is at the saddle point, so the structure will lower its energy by distorting and going to one of the minima. This is precisely what happens at low temperatures because the corresponding free energy surface acquires a double-well shape, and the system undergoes a structural phase transition. A good early DFT reference for this is this paper. * As already pointed out by others, the differences between DFT and TDDFT or $GW$-BSE are not related to the inclusion or exclusion of temperature. In this language, both TDDFT and $GW$-BSE have no temperature for the behaviour of the nuclei, and you could incoporate it in a similar fashion to what Andrew Rosen described for DFT.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 117, "passed_quality_check": "True", "flesch_reading_ease": 59.636000000000024, "entropy": 0.7101374838996547}
I don't really get the difference between gain and volume boost. So if I understand correctly, gain directly boosts a signal from a line or input while volume handles the output. Volume isn't really for boosting either. Would this mean, in most settings, getting 'close to' as much gain as possible without any hiss/background noise is ideal?
null
[]
Here's a brief overview to get you started. Hopefully this helps! * 'Gain' controls are typically used to get a good input level. So for example if you had a microphone with a very low output signal, you would boost the gain to get a better level into your mixing desk or audio interface. If you had a synthesizer plugged in you might need to turn the gain down to stop the signal distorting. Gain controls are often controlling an amplifier behind the scenes - i.e. your signal can 'gain' strength after going through the gain stage of your audio equipment. So gain is usually the first control in the signal path of your recording equipment. * 'Volume' controls on the other hand tend to be at the end of the signal chain and are more likely to be attenuating rather than amplifying the signal. So on a mixing desk, having got a good level from each input at the gain stage, you use the volume faders to adjust the relative volumes of each channel to achieve a good mix. You are not typically amplifying those signals any more though. A guitar amp is a good example of how this works. The first control is often called "Gain" or 'drive' and guitarists often deliberately turn this really high to get a nice distorted sound from a tube preamp. However, the final control is called Volume and governs simply how loud the sound coming out of your speaker is. With gain right up and volume low you can play distorted sounds without annoying the neighbours. With gain low and volume high you get a loud sound but no distortion.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 289, "passed_quality_check": "True", "flesch_reading_ease": 87.27000000000001, "entropy": 2.0584453081854823}
I recently had someone claim (on an unrelated SE site I won't link to) that it is the responsibility of a player to correctly identify their hand, that what you &quot;call&quot; your hand determines the winner: For example, you have an Ace, King, Queen, Jack, and Ten. You call your hand and say, &quot;I have a Straight!&quot; But that was a bad move on your part because you are a novice player and you did not notice that all of your cards are Spades. You actually had a Straight Flush, but now you have lost because one of the remaining players had a Full House. Your hand has not been determined until you call your hand. Is this true? Clearly you might play your hand differently if you misunderstand what you have, but I always thought that the cards speak for themselves once they are revealed. Or would it depend on the specific poker variation/house rules?
null
[]
Casinos in the US generally have the "cards speak" rule. That is, when a hand is properly tabled--exposed to everyone at showdown--it is the responsibility of all players, the dealer, floormen, and anyone else present to see that the pot is awarded to the best hand shown, regardless of what the players might say. Some players object to this rule: they believe that if a player or railbird says "Wait, Bob has a flush", that's unfairly helping a player. But the rule is clear: once the hand is tabled, others have not only the right but the obligation to help ensure the pot is awarded correctly. There are a couple of caveats: if a player only shows his hand to another player, or to the dealer, or to any other person, without properly tabling it for everyone, that player has no rights yet and those to whom the hand was shown should remain silent to protect other players' properly shown hands. But once the hand is tabled, it's fair game and everyone can and should assist in reading the hands. Finally, in some cases, if a floorman feels that a player has deliberately overcalled his hand to induce a player with a better hand to fold, he may penalize that player by awarding the pot to someone else, even possibly to a folded hand. Some California lowball clubs even had a rule that a player who remained silent rather than explicitly calling out a pair could be ruled against in this way.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 718, "passed_quality_check": "True", "flesch_reading_ease": 78.37833333333334, "entropy": 5.684358443964294}
How to get the first item from an associative PHP array?
null
[]
PHP If you don't know enough about the array (you're not sure whether the first key is foo or bar) then the array might well also be, maybe, empty. So it would be best to check, especially if there is the chance that the returned value might be the boolean FALSE: ```$value = empty($arr) ? $default : reset($arr); ``` The above code uses ```reset``` and so has side effects (it resets the internal pointer of the array), so you might prefer using ```array_slice``` to quickly access a copy of the first element of the array: ```$value = $default; foreach(array_slice($arr, 0, 1) as $value); ``` Assuming you want to get both the key and the value separately, you need to add the fourth parameter to ```array_slice```: ```foreach(array_slice($arr, 0, 1, true) as $key => $value); ``` To get the first item as a pair (```key => value```): ```$item = array_slice($arr, 0, 1, true); ``` Simple modification to get the last item, key and value separately: ```foreach(array_slice($arr, -1, 1, true) as $key => $value); ``` performance If the array is not really big, you don't actually need ```array_slice``` and can rather get a copy of the whole keys array, then get the first item: ```$key = count($arr) ? array_keys($arr)[0] : null; ``` If you have a very big array, though, the call to ```array_keys``` will require significant time and memory more than ```array_slice``` (both functions walk the array, but the latter terminates as soon as it has gathered the required number of items - which is one). A notable exception is when you have the first key which points to a very large and convoluted object. In that case ```array_slice``` will duplicate that first large object, while ```array_keys``` will only grab the keys. PHP 7.3+ PHP 7.3 onwards implements ```array_key_first()``` as well as ```array_key_last()```. These are explicitly provided to access first and last keys efficiently without resetting the array's internal state as a side effect. So since PHP 7.3 the first value of ```$array``` may be accessed with ```$array[array_key_first($array)]; ``` You still had better check that the array is not empty though, or you will get an error: ```$firstKey = array_key_first($array); if (null === $firstKey) { $value = &quot;Array is empty&quot;; // An error should be handled here } else { $value = $array[$firstKey]; } ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 46, "passed_quality_check": "True", "flesch_reading_ease": 72.61545454545457, "entropy": 0.27131327214776063}
Why do people write #!/usr/bin/env python on the first line of a Python script?
null
[]
In order to run the python script, we need to tell the shell three things: * That the file is a script * Which interpreter we want to execute the script * The path of said interpreter The shebang ```#!``` accomplishes (1.). The shebang begins with a ```#``` because the ```#``` character is a comment marker in many scripting languages. The contents of the shebang line are therefore automatically ignored by the interpreter. The ```env``` command accomplishes (2.) and (3.). To quote &quot;grawity,&quot; > A common use of the ```env``` command is to launch interpreters, by making use of the fact that env will search $PATH for the command it is told to launch. Since the shebang line requires an absolute path to be specified, and since the location of various interpreters (perl, bash, python) may vary a lot, it is common to use: ```#!/usr/bin/env perl``` instead of trying to guess whether it is /bin/perl, /usr/bin/perl, /usr/local/bin/perl, /usr/local/pkg/perl, /fileserver/usr/bin/perl, or /home/MrDaniel/usr/bin/perl on the user's system... > On the other hand, env is almost always in /usr/bin/env. (Except in cases when it isn't; some systems might use /bin/env, but that's a fairly rare occassion and only happens on non-Linux systems.)
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 66, "passed_quality_check": "True", "flesch_reading_ease": 95.42, "entropy": 0.3846852590051554}
Nowadays each graphic card has some driver in operating system that translates some (typically) standard API such as OpenGL, so that programmers use some standardized API code to tell graphics cards how and what they want to render. (Actually that's already a bit hard-core most programmers really use various game engines that do this for them). In times of old computers - how was this done? Did every programmer of every game implemented all possible various API's that old graphic cards supported? Or did the old game studios from MS-DOS times had their own "game engines" that provided some abstraction when it came to these graphic cards? I remember there were many various card vendors and I remember old games asked me which one I have - so I suppose these games contained code / drivers for all these cards?
null
[]
> Did every programmer of every game implemented all possible various API's that old graphic cards supported? Yes - but it went even deeper than that. Early graphics cards had virtually no callable code associated with them at all, the concept of "drivers" had not quite become a reality yet. There was the concept of a Video BIOS, which were extensions to the ```INT 10h``` BIOS video services, that were effectively limited to initialization and switching video modes. Instead, graphics cards, at least in DOS land, all had memory mapped display RAM, and extensive documentation was available about exactly how setting various bits in display RAM would affect the pixels that appeared on the screen. There were no drawing APIs to call, if you wanted something to appear on the screen (whether it be a pixel, a character, a line, a circle, a sprite, etc) you would write the code to move the bytes into the right places in display RAM. Entire books were written about how to write efficient code to draw graphics. There were some systems like the Borland Graphics Interface that abstracted graphics drawing primitives into an API with different drivers that one could call to draw things on different graphics cards. However, these were typically slower than what would be required for building action type games. An action game would typically be optimized for a particular graphics display mode on a particular card. For example, a popular display mode was VGA 640x480 with 16 colors. This would be listed in the software requirements, and you needed to have the right hardware to support the game. If you bought a VGA game but you only had an EGA card, then the game would not work at all. As you said, some games would ask what you had and you had to know what the right answer was, otherwise the game would not work.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 677, "passed_quality_check": "True", "flesch_reading_ease": 71.94097721822544, "entropy": 2.9966758759134073}
Why is it "behead" and not "dehead"?
null
[]
We didn’t use de-head because we already had a verb behead by the time we started using de- to create verbs: behead was a verb in Old English, behéafdian. So behead was already used long before the de- privative prefix came to be used productively in English. That didn’t happen until Modern English with a few productive examples in the 17ᵗʰ century but most coming from the 19ᵗʰ century or after. As Janus mentions in comments, the de- word meaning the same thing, decapitate, was imported in full with the de- already there, from Latin via French, in the 17ᵗʰ century. There are many different possible senses of be- in verbs; the OED lists six different primary senses with subsenses. This here in behead is one of the rarer ones. Under be- sense 6c, it says that this privative sense of be- used to create behead is an ancient sense that means bereave of: Forming trans. verbs on substantives used in an instrumental relation; the primary idea being; * a. To surround, cover, or bedaub with, as in becloud, to put clouds about, cover with clouds, bedew. Thence, by extension, * b. To affect with in any way, as in benight, beguile, befriend. In both sets there is often an accompanying notion of ‘thoroughly, excessively,’ as in 2. * c. An ancient application, no longer in living use, was to express the sense of ‘bereave of,’ as in behead, belimb, etc., q.v. Cf. 3, above. Although 6a and 6b are still productive, 6c no longer is so in the living language. Another Old English verb formed using 6c was belandian, meaning to deprive of one’s land. However, this verb did not survive into Modern English. El destierro Apropos de nada, the Spanish equivalent of the obsolete verb beland still very much exists in the verb desterrar, which combines the privative des‑ prefix with the noun tierra meaning land then puts that into an infinitive verb form. This is normally translated as “exile” in English, but sometime as “expel” or as a noun “expulsion”. There is also a substantive version, destierro, is famously found in “Cantar del destierro”, which is the title of the first canto from that most ancient of Castilian epic poems, El Cantar de Mio Cid. Truly, el Cid was belanded of his lands by the King.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 30, "passed_quality_check": "False", "flesch_reading_ease": 90.95857142857145, "entropy": 0.36578281995807477}
Why do many vinyl albums of classical music have Sides 1 / 4 on the first record and 2 / 3 on the second? An example of this is the RCA Red Seal recording of Beethoven's 9th Symphony by the Boston Symphony Orchestra.
null
[]
Many phonographs were able to play multiple records in sequence with a mechanism that would hold one or more records on the turntable, and one or more additional records elevated on the center post. At the end of one record, the mechanism sensed the tone arm reaching close to the center of the record, and then lifted it, pulled it out beyond the edge of the records. The system then dropped the bottom record of those on the center post, leaving the rest of them. Then the tone arm mechanism moved the tone arm to the outside of the record and lowered it to the record. The mechanism was pretty ingenious, but it couldn't flip records over. So, to play a long piece, it would play one side of each record until the stack was exhausted. Then it was up to a person to flip the stack to play the opposite sides in sequence. So, when playing records 1A/1B, 2A/2B, 3A/3B, 4A/4B in such a mechanism, the play order would be 1A, 2A, 3A, 4A, (flip), 4B, 3B, 2B, 1B. The "B" sides would go the other way because flipping the whole stack would put them in the opposite order. Purists would take offense at the idea of letting records drop like that, but it was an irresistible convenience to people who could tolerance slightly quicker wear of their records.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 174, "passed_quality_check": "True", "flesch_reading_ease": 72.53969512195123, "entropy": 1.1140509029046335}
Why isn't the market dropping like a stone with all the bad news?
null
[]
Market reactions to information are not always timely, proportional, or rational. We don't know the full impact of our current situation; we're feeling it out. * Some people (bulls), believe that the initial dip was an over-reaction, that the government response will prevent further decline, and/or that things will go back to normal pretty quickly, so they are buying the dip. * On the other side you have people (bears) that believe the initial reaction was just a start but not enough to price-in the full impact, that the government can't prop up the economy, and/or that this will drag on for a long while, so they are betting on further decline. The problem with this idea of information being priced-in is that we all know there's a global pandemic, but there are very different opinions about how much that should affect the market. Consider unemployment levels: We have projections about unemployment rate potentially hitting a peak over 30%. Meanwhile, the current unemployment rate is 4.4% and projected to hit double digits in April. The only way all of that information could be appropriately priced in is if everyone agreed about the reasonableness of the projections and had the economic prowess to understand the actual impact of those figures. Instead, what happens is that some people will see the actual April unemployment numbers as surprising new information to react to, while others will see it as old information in line with their expectations. Add in thousands of other pieces of information about which people have conflicting opinions, and it becomes pretty much impossible to know in advance if that information was all priced in appropriately. The most recent comparable event is the subprime mortgage crash. Many people thought bottom was hit around November 2008 and there was a brief counter-trend rally before actual bottom was hit around March 2009. We don't know at this time if the market has bottomed out yet or not; nor do we know how long recovery could take.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 53, "passed_quality_check": "True", "flesch_reading_ease": 96.02461538461542, "entropy": 0.47878033891835015}
What are Null Pointer Exceptions (```java.lang.NullPointerException```) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
null
[]
There are two overarching types of variables in Java: 1. Primitives: variables that contain data. If you want to manipulate the data in a primitive variable you can manipulate that variable directly. By convention primitive types start with a lowercase letter. For example variables of type `int` or `char` are primitives. 2. References: variables that contain the memory address of an `Object` i.e. variables that refer to an `Object`. If you want to manipulate the `Object` that a reference variable refers to you must dereference it. Dereferencing usually entails using `.` to access a method or field, or using `[` to index an array. By convention reference types are usually denoted with a type that starts in uppercase. For example variables of type `Object` are references. Consider the following code where you declare a variable of primitive type `int` and don't initialize it: ``` int x; int y = x + x; ``` These two lines will crash the program because no value is specified for `x` and we are trying to use `x`'s value to specify `y`. All primitives have to be initialized to a usable value before they are manipulated. Now here is where things get interesting. Reference variables can be set to `null` which means "I am referencing nothing". You can get a `null` value in a reference variable if you explicitly set it that way, or a reference variable is uninitialized and the compiler does not catch it (Java will automatically set the variable to `null`). If a reference variable is set to null either explicitly by you or through Java automatically, and you attempt to dereference it you get a `NullPointerException`. The `NullPointerException` (NPE) typically occurs when you declare a variable but did not create an object and assign it to the variable before trying to use the contents of the variable. So you have a reference to something that does not actually exist. Take the following code: ``` Integer num; num = new Integer(10); ``` The first line declares a variable named `num`, but it does not actually contain a reference value yet. Since you have not yet said what to point to, Java sets it to `null`. In the second line, the `new` keyword is used to instantiate (or create) an object of type `Integer`, and the `reference` variable `num` is assigned to that `Integer` object. If you attempt to dereference `num` before creating the object you get a `NullPointerException`. In the most trivial cases, the compiler will catch the problem and let you know that "`num may not have been initialized`," but sometimes you may write code that does not directly create the object. For instance, you may have a method as follows: ``` public void doSomething(SomeObject obj) { // Do something to obj, assumes obj is not null obj.myMethod(); } ``` In which case, you are not creating the object `obj`, but rather assuming that it was created before the `doSomething()` method was called. Note, it is possible to call the method like this: ``` doSomething(null); ``` In which case, `obj` is `null`, and the statement `obj.myMethod()` will throw a `NullPointerException`. If the method is intended to do something to the passed-in object as the above method does, it is appropriate to throw the `NullPointerException` because it's a programmer error and the programmer will need that information for debugging purposes. In addition to `NullPointerException`'s thrown as a result of the method's logic, you can also check the method arguments for `null` values and throw NPEs explicitly by adding something like the following near the beginning of a method: ``` // Throws an NPE with a custom error message if obj is null Objects.requireNonNull(obj, "obj must not be null"); ``` Note that it's helpful to say in your error message clearly which object cannot be `null`. The advantage of validating this is that 1) you can return your own clearer error messages and 2) for the rest of the method you know that unless `obj` is reassigned, it is not null and can be dereferenced safely. Alternatively, there may be cases where the purpose of the method is not solely to operate on the passed in object, and therefore a null parameter may be acceptable. In this case, you would need to check for a null parameter and behave differently. You should also explain this in the documentation. For example, `doSomething()` could be written as: ``` /** * @param obj An optional foo for ____. May be null, in which case * the result will be ____. */ public void doSomething(SomeObject obj) { if(obj == null) { // Do something } else { // Do something else } } ``` Finally, how to pinpoint the exception & cause using Stack Trace: > What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? Sonar with find bugs can detect NPE. Can sonar catch null pointer exceptions caused by JVM Dynamically Now Java 14 has added a new language feature to show the root cause of NullPointerException. This language feature has been part of SAP commercial JVM since 2006. In Java 14, the following is a sample NullPointerException Exception message: > in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "list" is null
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 200, "passed_quality_check": "True", "flesch_reading_ease": 69.15845528455286, "entropy": 1.1019347773620645}
In Raiders of the Lost Ark, at the Ark opening ceremony the Nazi troops brings the Ark of the Covenant to the top of the mountain as Belloq said something before opening the Ark. Then they took the sand from the Ark and suddenly spirits coming out from the Ark and they're all killed (except Indy and Marion) by the freed-spirits which came from the Ark. Meanwhile, Indy asks Marion to keep her eyes shut. They didn't see the Ark when it was opened, so they're survived. In that scene what I don't understand is how did Indy know not to look into the Ark when it was opened?
null
[]
There was a deleted scene that explained it: A plot element involving the Ark of the Covenant was cut from the film and is only hinted at during the finale when the Ark is opened. Basically, there were 2 rules about the Ark not mentioned in the final cut of the film: * If you touch the Ark, you die * If you look at the Ark when it is opened, you die This is first explained in additional dialogue for the scene when Indy and Sallah visit Imam. Before translating the writings on the headpiece that give the height of the Staff of Ra, Imam warns Indy not to touch the Ark or look at it when it is opened. [Source] The next scene involving this Ark subplot is when Sallah and Indy remove the Ark from the Well of the Souls. When Sallah first sees it he reaches out to touch it. Indy stops him before he does and reminds him of Imam's warning. Then they insert long poles through each side of the Ark to lift it out of its crypt. [Source] Notice that nobody ever touches the Ark throughout the rest of the film until the finale. And from the Bible (King James Version): 1 Samuel 6:19: And he smote the men of Bethshemesh, because they had looked into the ark of the Lord, even he smote of the people fifty thousand and threescore and ten men... 2 Samuel 6:6-7 And when they came to Nachon's threshingfloor, Uzzah put forth his hand to the ark of God, and took hold of it; for the oxen shook it. And the anger of the Lord was kindled against Uzzah; and God smote him there for his error; and there he died by the ark of God.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 466, "passed_quality_check": "True", "flesch_reading_ease": 79.90863636363638, "entropy": 3.7762147136038404}
What is likely to happen when you plug two ends of a network cable to a single switch/router? Will this create problems on the network, or just be ignored?
null
[]
It depends on the router/switch. If it's "Managed" - Like decent Netgear, Cisco or HP Procurve, or has STP (Spanning Tree Protocol) or one of its variants enabled, there's a few seconds of absolute insanity, then the switch realises that there's a loop in the network topology, and blocks one of the ports. (I've only described the STP re-convergence as "absolute insanity" because if you're using old-style, slow, STP then re-convergence can take 30s or more, depending on network complexity. Vendor specific STP extensions such as BackboneFast and so on will decrease this, but you might still end up with a short period of a slightly unstable network. Rapid STP is a lot quicker to converge, due to a different algorithm) If it's "Unmanaged"- Like pretty much all SOHO grade gear, and a fair proportion of small 4-8 port switches, then all hell breaks loose, as you've just created a loop in a network, and all the traffic tends to just bounce about inside the loop. The reason this happens is because switches rely on a process of MAC address learning to map MAC addresses to physical ports. In a non-looped network, one MAC address will only be visible to the switch on a given physical port. If you have a loop, then the switch will see multiple paths to the same MAC address, and possibly multiple MAC addresses on multiple ports, so instead of the traffic being switched efficiently, it will be broadcast to wherever it sees the MACs. This is known as a "Broadcast Storm". This can quickly use up all of a switch's CPU power, fill the transmit and receive buffers, as well as polluting the MAC address table. Basically, if you create a loop in the network, you'll know about it, either through monitoring (detecting a change in the STP topology [you do have monitoring, right?]), or in everything falling over dramatically. If you look at a switch that has a broadcast storm on it, you tend to find that all of the port activity lights are blinking all at the same time.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 127, "passed_quality_check": "True", "flesch_reading_ease": 90.09000000000002, "entropy": 0.916212644335187}
What command do I use to find the size of all the files (recursively) in a Linux or Mac OS X directory?
null
[]
The BSD version of ```du``` used in OS X reports size with 512-byte blocks -- the sizes are essentially rounded up to the next 512-byte value. This tells you the space on disk, which is larger than the amount of data. If you have a lot of small files, the difference can be large. Here's an example. This is the value with regular ```du```. It's in 512-byte blocks: ```$ du -s 248 . ``` The ```-h``` flag results in a more readable number, in kilobytes. As expected, it's half the number of 512-byte blocks: ```$ du -hs 124K . ``` Finally, you can use ```find``` and ```awk``` to give you the sum of actual bytes in the files. This is kind of slow, but it works: ```$ find . -type f -exec ls -l {} \; | awk '{sum += $5} END {print sum}' 60527 ``` This value matches exactly the number reported by Finder's Get Info window. (There are no weird forks or xattrs in this set of files.) It's significantly smaller than the value reported by ```du```. Here's how it works: it gets a list of all the files, and passes them to ```ls -l```; then ```awk``` is used to count up the bytes. The ```-type f``` flag is there so that only files (and not directories) get sent to ```ls```. Without that flag, it'll also send directory names to ```ls```, and each file will be listed twice : once as an individual file, and once as an item in the directory. The GNU version of ```du``` can give values in actual bytes instead of blocks. It's unfortunate that the BSD version of ```du``` is not as flexible.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 82, "passed_quality_check": "True", "flesch_reading_ease": 80.67772727272727, "entropy": 0.7171375010080488}
I've been writing C and C++ code for almost twenty years, but there's one aspect of these languages that I've never really understood. I've obviously used regular casts i.e. ```MyClass *m = (MyClass *)ptr; ``` all over the place, but there seem to be two other types of casts, and I don't know the difference. What's the difference between the following lines of code? ```MyClass *m = (MyClass *)ptr; MyClass *m = static_cast(ptr); MyClass *m = dynamic_cast(ptr); ```
null
[]
## static_cast `static_cast` is used for cases where you basically want to reverse an implicit conversion, with a few restrictions and additions. `static_cast` performs no runtime checks. This should be used if you know that you refer to an object of a specific type, and thus a check would be unnecessary. Here is an example: ``` void func(void *data) { // Conversion from MyClass* -> void* is implicit MyClass *c = static_cast<MyClass*>(data); ... } int main() { MyClass c; start_thread(&func, &c) // func(&c) will be called .join(); } ``` In this example, you know that you passed a `MyClass` object, and thus there isn't any need for a runtime check to ensure this. ## dynamic_cast `dynamic_cast` is useful when you don't know what the dynamic type of the object is. It returns a null pointer if the object referred to doesn't contain the type casted to as a base class (when you cast to a reference, a `bad_cast` exception is thrown in that case). ``` if (JumpStm *j = dynamic_cast<JumpStm*>(&stm)) { ... } else if (ExprStm *e = dynamic_cast<ExprStm*>(&stm)) { ... } ``` An "up-cast" (cast to the base class) is always valid with both `static_cast` and `dynamic_cast`, and also without any cast, as an "up-cast" is an implicit conversion (assuming the base class is accessible, i.e. it's a `public` inheritance). ## Regular Cast These casts are also called C-style cast. A C-style cast is basically identical to trying out a range of sequences of C++ casts, and taking the first C++ cast that works, without ever considering `dynamic_cast`. Needless to say, this is much more powerful as it combines all of `const_cast`, `static_cast` and `reinterpret_cast`, but it's also unsafe, because it does not use `dynamic_cast`. In addition, C-style casts not only allow you to do this, but they also allow you to safely cast to a private base-class, while the "equivalent" `static_cast` sequence would give you a compile-time error for that. Some people prefer C-style casts because of their brevity. I use them for numeric casts only, and use the appropriate C++ casts when user defined types are involved, as they provide stricter checking.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 397, "passed_quality_check": "False", "flesch_reading_ease": 60.705964912280706, "entropy": 2.7581556481736134}
Why don't toilets use saltwater?
null
[]
The main answer is logistical. Building a network of pipes to convey water to houses is a major effort, and most places where that's been done found it extremely expensive. Providing a second set of pipes to bring salt water to houses would probably cost about the same. Except that cities go to considerable lengths to put their water reservoirs above the city as far as possible so they don't have to use as much energy for pumping. The few cities with seawater above them pay a lot to pump water out. A minor secondary problem is that sewage treatment plants are fairly heavily biological. They grow things in the sewage to break it down. But most of those things won't grow in salt water. It's already a challenge keeping toxic chemicals out of the sewage. For this to work it might be necessary to add a second set of sewer pipes to carry the water away, and develop new methods of treating that salty sewage (the treated sewage couldn't be spread on farmland, for example). It would be far simpler, cheaper and more reliable to simply buy everyone a composting toilet to replace each toilet they currently have. As a halfway measure, mandating more economical toilets would help, as would education campaigns like the ones encouraging people not to flush at all when they urinate. Even with a sensible cistern that has a 2 litre &quot;half flush&quot;, that's two litres wasted every time someone pees. Additionally, salt is not good for pipes. A lot of pipes, even today, are clay or concrete, and salt water is bad for both of these. It's not impossible to get around that, just expensive.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 28, "passed_quality_check": "False", "flesch_reading_ease": 83.32000000000004, "entropy": 0.10592961265502784}
How do I modify fields inside the new PostgreSQL JSON datatype?
null
[]
With Postgresql 9.5 it can be done by following- ```UPDATE test SET data = data - 'a' || '{"a":5}' WHERE data->>'b' = '2'; ``` OR ```UPDATE test SET data = jsonb_set(data, '{a}', '5'::jsonb); ``` Somebody asked how to update many fields in jsonb value at once. Suppose we create a table: ```CREATE TABLE testjsonb ( id SERIAL PRIMARY KEY, object JSONB ); ``` Then we INSERT a experimental row: ```INSERT INTO testjsonb VALUES (DEFAULT, '{"a":"one", "b":"two", "c":{"c1":"see1","c2":"see2","c3":"see3"}}'); ``` Then we UPDATE the row: ```UPDATE testjsonb SET object = object - 'b' || '{"a":1,"d":4}'; ``` Which does the following: * Updates the a field * Removes the b field * Add the d field Selecting the data: ```SELECT jsonb_pretty(object) FROM testjsonb; ``` Will result in: ``` jsonb_pretty ------------------------- { + "a": 1, + "c": { + "c1": "see1", + "c2": "see2", + "c3": "see3", + }, + "d": 4 + } (1 row) ``` To update field inside, Dont use the concat operator ```||```. Use jsonb_set instead. Which is not simple: ```UPDATE testjsonb SET object = jsonb_set(jsonb_set(object, '{c,c1}','"seeme"'),'{c,c2}','"seehim"'); ``` Using the concat operator for {c,c1} for example: ```UPDATE testjsonb SET object = object || '{"c":{"c1":"seedoctor"}}'; ``` Will remove {c,c2} and {c,c3}. For more power, seek power at postgresql json functions documentation. One might be interested in the ```#-``` operator, ```jsonb_set``` function and also ```jsonb_insert``` function.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 53, "passed_quality_check": "True", "flesch_reading_ease": 72.61545454545457, "entropy": 0.2574519238164745}
I find that the survivability and general performance of my party increases massively from levels 1 to 2. At times, level 1 feels like a completely different game from level 2. However, I can't fathom how or why. I think that the availability of healing has something to do with it. From a mechanical perspective, is there any deep reason why level 1 and level 2 seem so radically different? Furthermore, why I do find no similar differences between later levels, such as 6 and 7?
null
[]
Welcome to Rusty Dagger Shanktown! What you have noticed is very widely commented upon—1st level is often called “rusty dagger shanktown.” It’s hyper-lethal, rather than the kind of heroic fantasy Dungeons & Dragons pitches itself as. It is very, very difficult for 1st-level PCs to actually really adventure at all. Many, many groups avoid 1st for this reason (many skip 2nd too, even though it is already dramatically different). Personally, I’ll include 1st level often, but the PCs basically always level-up to 2nd almost entirely on roleplaying XP. Note that this isn’t unique to 3.5e; it goes back to the earliest days of D&D. Pathfinder, of course, inherited it from 3.5e (I don’t know about PF 2e). It’s also very much still true in 5e—after 4e actually managed to avoid it, which may mean that this is considered a “feature” by some, enough that Wizards of the Coast felt the need to restore it as part of 5e’s general “return to form” after the divisive fourth edition. Anyway, the primary causes of rusty dagger shanktown: Hit points Almost anyone can one-shot almost any 1st-level character. It’s very, very easy to have 6 hp in a world where a decent, but basic, weapon’s base damage averages 7. Even smaller weapons can easily deal that much damage, either through luck or skill. We expect 1st-level characters to often go down in one hit. A 2nd-level character can have nearly twice as much hp. Actually, could easily be twice as much, if they multiclass from a small-HD class to a large-HD class. That drastically changes the game, because suddenly you can feel reasonably confident that you aren’t going to just suddenly die before anyone can do anything. Healing actually becomes relevant, where at 1st it’s often too little, too late. Notably, this only has this effect because damage doesn’t grow at the same rate. The base damage of weapons is fixed, and ability scores start at double digits but grow very slowly from there. That’s the biggest chunk of early damage for most characters. Even beyond that, a lot of damage boosts—inspire courage, rage, sneak attack—come at 1st anyway. And monsters tend to kind of mirror these trends. So what ends up happening is that a 1st-level character can’t really take a chance in order to get something accomplished. A 2nd-level character can feel reasonably comfortable taking a chance at least once. That dramatically affects the style of play. At 2nd-level D&D literally feels like a different game. Really, it is a different game. Wealth Characters start with less than 200 gp worth of gear. That’s not enough for a masterwork weapon, not enough even for non-masterwork medium or heavy armors, definitely not enough for any kind of magic item beyond maybe an extremely basic consumable. No 1st-level character has even their complete basic kit yet. The expected wealth of a 2nd-level character is 900 gp. That can afford masterwork armor of anything short of full-plate, and for many armors leave enough left over for a masterwork weapon. Most importantly, that is enough money for a party of 4 to trivially afford a wand of cure light wounds. A wand of cure light wounds is a game-changer. It means you can easily start every fight at full hp. And with 2nd-level hp, that means you can actually take a few risks. 2nd-level features This varies considerably from one class to the next, but several classes get major class features at 2nd level. The paladin’s 2nd-level feature, divine grace, might be the single greatest class feature in the game (assuming we don’t count “spells” and the like as a singular feature). Rangers don’t get their combat style until 2nd. Bards get 1st-level spells at 2nd (though inspire courage from 1st level is probably more important). Outside of core, meldshapers don’t get any chakra binds until 2nd, which can leave them with zero offense at 1st. Swordsages don’t get Wis-to-AC until 2nd. But plenty of characters are fine from 1st, so this can vary a lot.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 395, "passed_quality_check": "True", "flesch_reading_ease": 74.24015503875972, "entropy": 3.0134921915678152}
In my table view I have to scroll to the top. But I cannot guarantee that the first object is going to be section 0, row 0. May be that my table view will start from section number 5. So I get an exception, when I call: ```[mainTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; ``` Is there another way to scroll to the top of table view?
null
[]
Possible Actions: 1 ```func scrollToFirstRow() { let indexPath = NSIndexPath(forRow: 0, inSection: 0) self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Top, animated: true) } ``` 2 ```func scrollToLastRow() { let indexPath = NSIndexPath(forRow: objects.count - 1, inSection: 0) self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: true) } ``` 3 ```func scrollToSelectedRow() { let selectedRows = self.tableView.indexPathsForSelectedRows if let selectedRow = selectedRows?[0] as? NSIndexPath { self.tableView.scrollToRowAtIndexPath(selectedRow, atScrollPosition: .Middle, animated: true) } } ``` 4 ```func scrollToHeader() { self.tableView.scrollRectToVisible(CGRect(x: 0, y: 0, width: 1, height: 1), animated: true) } ``` 5 ```func scrollToTop(){ self.tableView.setContentOffset(CGPointMake(0, UIApplication.sharedApplication().statusBarFrame.height ), animated: true) } ``` Disable Scroll To Top: ```func disableScrollsToTopPropertyOnAllSubviewsOf(view: UIView) { for subview in view.subviews { if let scrollView = subview as? UIScrollView { (scrollView as UIScrollView).scrollsToTop = false } self.disableScrollsToTopPropertyOnAllSubviewsOf(subview as UIView) } } ``` Modify and use it as per requirement. Swift 4 ``` func scrollToFirstRow() { let indexPath = IndexPath(row: 0, section: 0) self.tableView.scrollToRow(at: indexPath, at: .top, animated: true) } ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 364, "passed_quality_check": "True", "flesch_reading_ease": 61.2271153846154, "entropy": 2.434423778285457}
While in Phd I developed a lot of code that I want to turn into start-up. Can I do this?
null
[]
I'm not aware of any blanket prohibition, anywhere, that say that you can't use code developed during a PhD for a commercial venture - but most Universities in the US will have some kind of intellectual property agreement in place to state what the process is for doing this. You will need to check with officials at your University to see what agreements you are subject to - but you should go a step farther than this. Specifically, you should see what departments might exist that can actually help you. In the US at least - and I'm sure many other institutions around the world - there are departments specializing in intellectual property, "knowledge transfer", corporate spin-offs, start-ups, entrepreneurship, etc. These can be a rich source of support and networking, if they are available to you, even if you have intellectual property agreements that assign various rights to the University. Universities want to earn money for these projects, as I'm sure you do as well, and 100% of $0 is $0. Universities often heavily facilitate the process of converting this work into money, and it is not abnormal for even a place that has heavily restricted intellectual rights assignments agreements to assign use rights and royalty agreements that have zero cost for the first $200,000+ US dollars in income. There are often even startup grants available, accelerators (even if they are not called that - places that provide space and equipment to help starting businesses), introductions to investors, showcases, and more. You won't know until you ask and look for them, as where they are located tends to vary heavily by institution. For the exact nature of the agreements that apply to you, we can't say; I've seen everything from "the student owns their own work" to "anyone funded assigns all rights and ownership to the University", and I'm sure there are agreements everywhere in between. You are right to check them out in advance of a major decision, but this is so specific that you'll need to talk with multiple people are your specific institution to see what applies to you. You may also need to speak with an outside legal professional (lawyer experienced in this area, etc) to verify, but your local administrators are your best first point of contact to see how things work.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 69, "passed_quality_check": "False", "flesch_reading_ease": 103.52035714285715, "entropy": 0.8656646841967115}
I have heard multiple times in photography, the words Bokeh, and Gaussian Blur. To me, it seems that the words are used almost interchangeably, but in some instances, I have heard them contrasted. What's the difference, and what are the definitions of each of them?
null
[]
Bokeh is specifically the out-of-focus areas of an image. Gaussian blur is an algorithm to fog selected image areas, to hide details or make them look out of focus. The main differences: * bokeh is created optically, gaussian blur in post-production; * in bokeh, the amount of how wide an out-of-focus point will be smeared is determined by its relative distance from focal plane, whereas gaussian blur is applied to a two-dimensional image where no distance information is present, thus all points are smeared equally; * in bokeh, the smearing characteristics depend on configuration and aperture shape of the lens, whereas gaussian blur is always smooth; * a small light source will be rendered as an aperture-shaped figure with quite well-defined edges in bokeh; but gaussian blur renders it as a spot with fading edges; * in bokeh, noise is present at the same level as in in-focus parts of image with same luminance; gaussian blur kills noise, so there'll be less noise than in non-blurred parts of image; * in bokeh, light areas will dominate over dark ones, while gaussian blur gives preserves the ratio of dark-light areas. So, all in all, you can use one to fake another, but the result will be similar only for low-noise bokeh containing items on roughly a plane parallel to focal plane, not including any significantly lighter areas or light sources, and taken with a lens that has a smooth bokeh.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 221, "passed_quality_check": "True", "flesch_reading_ease": 76.93000000000002, "entropy": 2.282903783279869}
In 1969, NASA not only went to the moon, but broadcast the whole thing live on TV. How did they achieve the TV broadcast? What technology did they need to use to send a video and audio signal from the moon to earth? Was there much of a lag?
null
[]
Apollo 11 mission had two modules * Lunar module - which descent to moon carrying two astronauts * command / service module- CSM was designed to return astronauts from the lunar surface on a direct-descent mission to earth and splash down. Direct telecast from the Command service module is not possible but CSM stored the recording of conversation which is transmitted by LM (which occur once in a rotation because the LM is stationary while CSM is orbiting the moon) then CSM sents to earth. Regarding the actual camera used in Apollo > Originally, these slow-scan television (SSTV) cameras, running at 10 frames-per-second (fps), produced only black and white pictures and first flew on the Apollo 7 mission in October 1968. NASA states as > The equipment onboard the Apollo Command Module that was used to make the recordings was called the Data Storage Equipment (DSE). Its contents were transmitted to the ground periodically during the mission. Also, the Command Module DSE had the capability to record data live during certain periods from the Lunar Module as it flew separately in lunar orbit. The equipment used aboard the Lunar Module to make the recordings was called the Data Storage Electronics Assembly (DSEA). It made recordings onboard the Lunar Module, but the DSEA flown on the Eagle during Apollo 11 malfunctioned. As a result, many of its recordings are barely, if at all, audible, with a constant high-pitched background tone. In the attached database, the recordings that are virtually inaudible are highlighted, but they are available on the web to ensure a complete release of the recordings made during the mission. and > The portion of the broadcast spectrum traditionally used for video was sending vital ship data to Earth, and there was no room left for the standard black-and- white video format of the era: 525 scan lines of data at 30 frames per second, transmitted at 4.5 MHz. So Lebar helped devise a smaller "oddball format" – 320 scan lines at 10 fps, transmitted at a meager 500 kHz. Tracking stations back on Earth would take this so-called slow-scan footage, convert it for TV broadcast, and beam it to Mission Control, which would send it out for the world to see. Transmission stations > To ensure a direct transmission signal from the moon, NASA had to maintain stations in three continents – two in Australia (the Honeysuckle Creek Tracking Station near Canberra and the Parkes Radio Observatory surrounded by sheep paddocks west of Sydney); one at the Goldstone Deep Space Communications Complex in the Mojave Desert of California; and one at the Madrid Manned Flight Tracking Site in Spain........ the tracking stations with a direct line on the Apollo 's signal were the ones in Australia. The 200-foot-diameter radio dish at the Parkes facility manag to withstand freak 70 mph gusts of wind and successfully captured the footage, which was converted and relayed to Houston.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 193, "passed_quality_check": "True", "flesch_reading_ease": 99.3955, "entropy": 1.7311620722041643}
Why does "elite" rhyme with "beet" rather than "bite"?
null
[]
This has everything to do with the following: * The language of origin of the word and * The point at which the word entered the English language. The reason that the words &quot;light&quot; and &quot;might&quot; and &quot;site&quot; have a diphthong is because they were present in spoken English during the Great Vowel Shift, which started in the 1400s and continued for a few hundred years. So words that had already entered the English language underwent that change in pronunciation. Those words could be of Anglo-Saxon, Norman French, or Latin origin. We see it across the board. However, the word elite entered English towards the end of the period of the Great Vowel shift. The first attestation is in the mid 1700s (1738 in the OED). This is probably further complicated by the fact that French has long been the language of nobility, so there are certain pressures to maintain the pronunciation patterns of the origin language. &quot;Elite&quot; joined the party a little bit late, so its pronunciation remained rather stable. As Rjpond points out, elite is a modern borrowing. Words like crime, sublime, mime, etc. are older borrowings. To note: There are early occurrences of the word &quot;elite&quot; in around 1400, with the meaning of a &quot;bishop elect&quot;. This sense of the word died out and is now marked as archaic. So when &quot;elite&quot; was re-introduced (directly from French) in the 1700s, there was no existing pronunciation. Small addendum: Already existing in English is another word that already occupies the same lexical space that elite would occupy, if the pronunciation were analogized to bite: alight, which dates back to Old English. (It's a lovely word.) You might say that there is some linguistic pressure to avoid creating homophones: elite vs. alight.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 46, "passed_quality_check": "False", "flesch_reading_ease": 113.10000000000002, "entropy": 0.28209778307782535}
A lot of ShaderToy demos share the Ray Marching algorithm to render the scene, but they are often written with a very compact style and i can't find any straightforward examples or explanation. So what is Ray Marching? Some comments suggests that it is a variation of Sphere Tracing. What are the computational advantages of a such approach?
null
[]
## TL;DR They belong to the same family of solvers, where sphere tracing is one method of ray marching, which is the family name. ## Raymarching a definition Raymarching is a technique a bit like traditional raytracing where the surface function is not easy to solve (or impossible without numeric iterative methods). In raytracing you just look up the ray intersection, whereas in ray marching you march forward (or back and forth) until you find the intersection, have enough samples or whatever it is your trying to solve. Try to think of it like a newton-raphson method for surface finding, or summing for integrating a varying function. This can be useful if you: * Need to render volumetrics that arenot uniform * Rendering implicit functions, fractals * Rendering other kinds of parametric surfaces where intersection is not known ahead of time, like paralax mapping etc. ## Sphere tracing Sphere tracing is one possible Ray marching algorithm. Not all raymarching uses benefit form this method, as they can not be converted into this kind of scheme. Sphere tracing is used for rendering implicit surfaces. Implicit surfaces are formed at some level of a continuous function. In essence solving the equation ```F(X,Y,Z) = 0 ``` Because of how this function can be solved at each point, one can go ahead and estimate the biggest possible sphere that can fit the current march step (or if not exactly reasonably safely). You then know that next march distance is at least this big. This way you can have adaptive ray marching steps speeding up the process.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 285, "passed_quality_check": "True", "flesch_reading_ease": 72.85019067796611, "entropy": 1.8206240168820333}
Is martial arts training 'inadequate' for the real world?
null
[]
Yes, depending on your definitions of martial arts, inadequate, and real world. No, depending on your definitions of martial arts, inadequate, and real world. Surviving an attack (or combat) is all about stacking the deck in your favour: martial arts (arts of Mars, the God of War) do help, so do guns, team mates, artillery, the police, not being there, body armour, etc... There is no such thing as a typical real world violent attack. For example, urban warfare is not the same thing as a bar brawl and both require very different skill sets to survive. The no prior warning is utter rubbish. There are always signs that something is about to happen. Sure, one may not notice those and a skilled attacker will be trained in camouflaging those signs but they always are. Police officers, body guards, soldiers, etc... are all trained in recognise those signs. Making general sweeping statements about violence and how to survive it generally indicate either bad research or an agenda. For a good site about self defence, especially the section on martial arts, see MacYoung's no nonsense self defense. But this is about civilian self defence in a stable country. If you were in a civil war zone, the advise would be very different.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 49, "passed_quality_check": "True", "flesch_reading_ease": 75.50000000000003, "entropy": 0.19765496303651886}
Make a single page landscape in Google Documents
null
[]
Currently a single Google Document can only be either Landscape or Portrait not both. Changing page orientation is done by selecting File and then Page setup. It is currently recommended to separate the Landscape and Portrait pages into different documents. A good place to get more information that might help is at Google Products Forums. Note that an additional option might be to have three files in Google Docs. The Portrait, The Landscape, and Microsoft Word Doc which integrates the two layouts into the correct sequence (this document would be Read Only when viewed in Google Docs). A Microsoft Word document may allow multiple orientations of the Page Layout, but if it is converted to a Google Document the Page Layout for each page will revert to the first Orientation found in the document. Also, creating multiple Orientations in Word isn't as straight forward as one might want either. For those wanting to do this in Word: Use portrait and landscape orientation in the same document 1. Select the pages or paragraphs that you want to change to portrait or landscape orientation. NOTE: If you select some but not all of the text on a page to change to portrait or landscape orientation, Word places the selected text on its own page, and the surrounding text on separate pages. 2. On the Page Layout tab, in the Page Setup group, click Margins. 3. Click Custom Margins. (This is the important part) 4. On the Margins tab, click Portrait or Landscape. 5. In the Apply to list, click Selected text.. NOTE: Microsoft Word automatically inserts section breaks before and after the text that has the new page orientation. If your document is already divided into sections, you can click in a section (or select multiple sections), and then change the orientation for only the sections that you select.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 41, "passed_quality_check": "False", "flesch_reading_ease": 82.39000000000001, "entropy": 0.12667470172138268}
PHP is writing this error in the logs: "Notice: Use of undefined constant". Error in logs: ```PHP Notice: Use of undefined constant department - assumed 'department' (line 5) PHP Notice: Use of undefined constant name - assumed 'name' (line 6) PHP Notice: Use of undefined constant email - assumed 'email' (line 7) PHP Notice: Use of undefined constant message - assumed 'message' (line 8) ``` Relevant lines of code: ```$department = mysql_real_escape_string($_POST[department]); $name = mysql_real_escape_string($_POST[name]); $email = mysql_real_escape_string($_POST[email]); $message = mysql_real_escape_string($_POST[message]); ``` What does it mean and why am I seeing it?
null
[]
The error message is due to the unfortunate fact that PHP will implicitly declare an unknown token as a constant string of the same name. That is, it's trying to interpret this (note the missing quote marks): ```$_POST[department] ``` The only valid way this would be valid syntax in PHP is if there was previously a constant ```department``` defined. So sadly, rather than dying with a Fatal error at this point, it issues this Notice and acts as though a constant had been defined with the same name and value: ```// Implicit declaration of constant called department with value 'department' define('department', 'department'); ``` There are various ways you can get this error message, but they all have the same root cause - a token that could be a constant. Strings missing quotes: ```$my_array[bad_key]``` This is what the problem is in your case, and it's because you've got string array keys that haven't been quoted. Fixing the string keys will fix the bug: Change: ```$department = mysql_real_escape_string($_POST[department]); ...(etc)... ``` To: ```$department = mysql_real_escape_string($_POST['department']); ...(etc)... ``` Variable missing dollar sign: ```var_without_dollar``` Another reason you might see this error message is if you leave off the ```$``` from a variable, or ```$this->``` from a member. Eg, either of the following would cause a similar error message: ```my_local; // should be $my_local my_member; // should be $this->my_member ``` Invalid character in variable name: ```$bad-variable-name``` A similar but more subtle issue can result if you try to use a disallowed character in a variable name - a hyphen (```-```) instead of an underscore ```_``` would be a common case. For example, this is OK, since underscores are allowed in variable names: ```if (123 === $my_var) { do_something(); } ``` But this isn't: ```if (123 === $my-var) { do_something(); } ``` It'll be interpreted the same as this: ```if (123 === $my - var) { // variable $my minus constant 'var' do_something(); } ``` Referring to a class constant without specifying the class scope In order to refer to a class constant you need to specify the class scope with ```::```, if you miss this off PHP will think you're talking about a global ```define()```. Eg: ```class MyClass { const MY_CONST = 123; public function my_method() { return self::MY_CONST; // This is fine } public function my_method() { return MyClass::MY_CONST; // This is fine } public function my_bad_method() { return MY_CONST; // BUG - need to specify class scope } } ``` Using a constant that's not defined in this version of PHP, or is defined in an extension that's not installed There are some system-defined constants that only exist in newer versions of PHP, for example the mode option constants for ```round()``` such as ```PHP_ROUND_HALF_DOWN``` only exist in PHP 5.3 or later. So if you tried to use this feature in PHP 5.2, say: ```$rounded = round($my_var, 0, PHP_ROUND_HALF_DOWN); ``` You'd get this error message: Use of undefined constant PHP_ROUND_HALF_DOWN - assumed 'PHP_ROUND_HALF_DOWN' Warning (2): Wrong parameter count for round()
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 600, "passed_quality_check": "False", "flesch_reading_ease": 48.559887955182106, "entropy": 2.156697528171615}
I'm from a very rural area and love to garden, however, for work I just moved into an apartment in the city. I miss being able to grow vegetables and so I attempted to start some leaf lettuce indoors, however, almost every plant died quickly. I'm just curious, does anyone have experience growing vegetables indoors? What are the best ones for this? What sort of planter do you use? Do they need to be directly next to a window? How often should they be watered? I'm not used to not having Mother Nature help me out with my plants Any tips that can be provided would be much appreciated, thanks!
null
[]
Indoor gardening is a bit more difficult then the regular outdoor gardening, there are several factors but in most cases it boils down to: Temperature, Humidity, Light, The air in your apartment. You didn't mention exactly where your dying plants are being placed. Do you have a fan within the apartment? Plants need air whether it is natural or even if it is coming from a fan. What type of lighting is inside the apartment? Are you only using natural light? These are important factors to aide the growth of the plant as well. How is the temperature within the apartment? If you notice a lot of temp ups / downs in the area you are gardening than it is probably worth moving the garden or choosing another spot. With apartments that becomes all the more difficult. Your plant also probably came from some nice greenhouse, an english gardens, a ray weigands, etc etc...They have plenty of light, they also have plenty of means of water and the temperature well most of this is all outside, so they have the advantage of using mother nature. Your plant needs to adjust to these conditions. You should try to begin to place your plants in a very lit area with as much natural wind / fan as possible, these plants need to breath. If your plants are not conditioned for this type of environment you run the risk that they give up and die. When potting the plant ensure the actual pot is cleaned up to remove any unnecessary plant diseases from prior plants. Look on the bottom of the actual pot, are you getting drainage? If not drill a hole in the bottom of the pot if you can, if not toss that pot out and get you a pot that has a good amount of drainage. Overwatering plants will destroy them, and without nature (wind, temperature, etc) the water sitting there takes all the longer to dry out. When it comes to veggies Tomatoes need a ton of sunlight and humidity is great for them as well. Herbs are probably the simpliest to get going but I'm not sure if this is what you are after. Cucumbers and squash don't need as much sunlight as tomatoes.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 486, "passed_quality_check": "True", "flesch_reading_ease": 85.20602272727274, "entropy": 3.6308134863625723}
What are the advantages of studying words by their frequency?
null
[]
The main advantage is that by learning higher frequency words, you get a greater "bang for your buck" - that is, if you know the most frequent words of the language, you'll be able to understand more of the words you encounter, and therefore you gain the greatest benefit by studying those frequent words first. According to Nation & Waring (1997), text coverage in the Brown corpus is as follows: * Most frequent 1000 words: 72.0% * Most frequent 2000 words: 79.7% * Most frequent 3000 words: 84.0% * Most frequent 4000 words: 86.8%. So by learning the top 1000 words, you'll know 72% of the words in the average text you read. But after that, there are diminishing returns: the next 1000 words gives you another 7.7% of a typical text, and the next 1000 words allows you to understand just 4.3% more. After that, the returns on memorizing by frequency decrease even more, so learning from frequency lists becomes less useful. Note that text coverage (the percentage of words that you know in an average text) is important. We don't need to understand every single word in a text in order to understand the general meaning. Some research has investigated what percentage of words we do need to understand. Laufer and Sim (1985) suggested 65-70% should be understood as an absolute minimum for comprehension, but Laufer (1989) (as described in Hu and Nation (2000)) suggests 95% should be known for solid comprehension. Hu and Nation (2000) suggest that 98% of words should be known for unaided comprehension. Although learning high-frequency words is a good idea, especially when you first start learning a language, frequency is not the only consideration when choosing words to learn. Barker (2007) suggests that "cost" and "benefit" be the primary considerations when choosing words to learn; benefit is partially defined by frequency, but also on personal needs. So it's good to learn the "technical" vocabulary of your major or field, and it's also useful to learn words related to your interest. It's also beneficial to learn words with a lower "cost" - words that are familiar, that you've encountered a lot recently, or that just seem easy. Also, although memorizing words has benefits, it is best to combine this with real exposure to words, so that you learn them naturally in real contexts.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 52, "passed_quality_check": "True", "flesch_reading_ease": 78.24500000000002, "entropy": 0.24998931512504985}
I have heard many people saying, “Hah! I beat Stockfish,” and one saying, “I am the best chess player ever! I beat Stockfish.” So I wonder if it is possible, just to know whether I should try to beat it. I tried to play it once; I barely played 25 moves.
null
[]
The answer is that they either played it on some very handicapped mode, they took back A LOT of moves, or they are probably lying. Stockfish 11 is currently rated about 3607, and that is in standard chess. Computer programs are typically even HARDER to beat for humans at even faster controls. There is a reason elite humans have not played matches against computers for a long time: even the Carlsens of the world cannot beat them any more. According to the ELO winning expectancy calculator, there is currently a 745 point difference between Stockfish 11 and Carlsen, and per the chart, that gives the computer a 99.5439696% chance of winning. Note: The ratings used above are from different rating pools, and thus, are not truly directly comparable, but used as a rough estimate of what would happen between the computer and Carlsen.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 204, "passed_quality_check": "True", "flesch_reading_ease": 98.61141176470588, "entropy": 2.4123315247372727}
How to decrypt Jenkins passwords from credentials.xml?
null
[]
There is a `hudson.util.Secret.decrypt()` function which can be used for this, so: 1. In Jenkins, go to: `/script` page. 2. Run the following command: ```println(hudson.util.Secret.decrypt("{XXX=}")) ``` or ``` println(hudson.util.Secret.fromString("{XXX=}").getPlainText()) ``` where `{XXX=}` is your encrypted password. This will print the plain password. To do the opposite, you can run: ``` println(hudson.util.Secret.fromString("some_text").getEncryptedValue()) ``` Alternatively check the following scripts: `tweksteen/jenkins-decrypt`, `menski/jenkins-decrypt.py`.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 48, "passed_quality_check": "False", "flesch_reading_ease": 54.70142857142861, "entropy": 0.1314988644519236}
I'm pretty disappointed with my horse. He wasn't cheap -- 1000g -- but he just doesn't seem that fast. To make things worse, he's a bit of a wolf magnet and every time I get attacked I have to tediously dismount, blast the wolf, and then remount. Is the speed of a horse actually significantly faster than normal running speed? If so, how much faster?
null
[]
Don't forget that you can sprint with a horse. It might be that you know that you can sprint on your character, but not on your horse. Please note that your horse is also able to sprint using stamina. You can do this using the default Alt key. Horses are indeed faster, transportation was simplified. Since Oblivion, they took Acrobatics and Athletics skills away, thus you can't improve your speed in such way anymore that it would be faster than a horse. The speed improvements by not being Fatigued and not being overweight are not enough to be significant. All horses in Skyrim have the same speed and hardiness, they are all draft types that resemble a Clydesdale, and all cost 1000 septims. — Wikia - Elder Scrolls V: Skyrim - Horse All horses in Skyrim are the same, seems that they wanted to simplify the whole transportation idea. Restrictions apply on both your character and horse. Without mods, a horse can't be used inside a city. If you do a lot of role-playing within cities having a horse might not be useful. At the same time, characters are limited in Skyrim as Raven Dreamer noted; while you can get over some mountains by jumping left and right trying to get over a rock, a horse will be more superior in performing this task as it is less restricted by physics. You can however be smart enough to choose your path right, rather than trying to work against the physics...
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 288, "passed_quality_check": "True", "flesch_reading_ease": 88.52511764705883, "entropy": 2.5875550923180533}
Other than rust, corrosion, and other reactions with air that would make the use of a metal unfavorable, how do different metals affect the performance? Let's give Yagi an example: Let's say I use 4 different metals for the directors , reflector, and driven element. One antenna made out of copper, one made out of aluminum, and one made out of a higher resistance conductor, let's say graphite (I know it would snap, I'm just talking theoretical), and iron Other then the metal variations, the antennas are identical. So, do different metals with different conductivity and permiability affect the performance of an antenna including gain, efficiency, impedance, elevation, or any other characteristic other then mechanical strength, and chemical reliability in open air.
null
[]
Considering just electrical properties, the most significant parameter for your selection of antenna conductor is resistance. You want to keep the resistance to a minimum, because when current flows through a resistance, the electrical power is converted to heat, according to Joule heating: $$ P = I^2 R $$ Any energy you use to make heat is energy you aren't using to make electromagnetic waves. So first, you should consider the resistivity ($\rho$) of various metals. A lower resistivity means you will need less of a metal to reduce the resistance to an acceptable target. Here's a selection, ordered from lowest to highest resistivity in nano-ohm-meters (nΩm), of some metals you might consider using in an antenna: * Silver: 15.9 * Copper: 16.8 * Gold: 24.4 * Aluminium: 26.2 * Zinc: 59.0 * Nickel: 69.9 * Iron: 100 * Tin: 109 I'm not going to list stainless steel because there are so many kinds, but generally stainless steels are not great conductors, being over 100 on this scale. A high resistivity isn't bad in itself, because you can compensate by making the conductor thicker, and end up with the same resistance. Thus, you might think copper is the best choice (ruling out silver due to high cost), but when you start making mechanical and cost considerations, you may find aluminium is better. This is because for a sample of copper and another of aluminium of equal resistance, the aluminium sample will be bigger, but stiffer, lighter, and cheaper. There's another effect to consider here: with increasing frequency, currents like to flow on the surfaces of conductors. This is called the skin effect. The current flowing only on the skin of a conductor effectively reduces the cross-sectional area, and thus the conductance. Since most of the RF current is only on the surface, it often makes sense to build antennas from tubing for antennas requiring rigid elements (a 440 MHz Yagi), or copper-clad steel for wire antennas requiring tensile strength (a 40 meter dipole). This saves weight and cost for a negligible increase in loss. Magnetic permeability is a factor in skin depth. With increasing permeability, the skin depth decreases, increasing loss. Of the metals listed above, only iron and nickel have significantly higher permeability. Iron by a factor of about 5000, and nickel by 100 to 600. You could compensate for the reduced skin depth by increasing the surface area of the conductor, but when you consider cost and mechanics, it usually makes more sense to simply avoid iron and nickel and alloys containing them.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 657, "passed_quality_check": "True", "flesch_reading_ease": 40.73225000000002, "entropy": 5.040458869229667}
Windows in its earliest days was simply a shell that ran on top of MS-DOS, which means that Windows 3.1 itself was actually just a standard MS-DOS application like any other. Yet, MS-DOS is not a multitasking operating system, and at the same time, Windows applications were compiled native-code binaries that ran without any form of managed environment. So, how exactly was multitasking of Windows binaries achieved if Windows 3.1 was simply a regular old MS-DOS program itself? Are there any old technical documents still floating around that describe the early Windows architecture internally?
null
[]
For Win16 programs, Windows implemented co-operative multitasking. Its implementation was based upon the &quot;message loop&quot; architecture of every Windows program. The duty of every program was to endlessly run in a loop in which a call to the ```GetMessage``` function was performed. This function call looks whether a message to this process is in the queue. If there is one, it is retrieved (```GetMessage```), optionally translated (```TranslateMessage```, done to convert keyboard shortcuts into menu actions) and finally, passed to the window procedure (```DispatchMessage```). If there is no message available in the queue, Windows suspends the current task and gives the CPU to another task. This task will try to retrieve a message from its queue as well, yielding the CPU to another task if no message is present and so on. If a program needed to perform background tasks while there were no pending messages in its queue, it would call ```PeekMessage``` instead of ```GetMessage```. This didn't make the task relinquish the CPU, as ```PeekMessage``` would immediately return to the caller task to inform it whether a message is available or not. This was used to time-multiplex message processing with another time-consuming task (think of a 3D program rendering but letting the user cancel that render by pressing a &quot;Cancel&quot; button). If this time-consuming task was actually very time-consuming, a well-behaved program should call the ```Yield``` function from time to time, to relinquish the CPU and let other tasks run. A badly-behaved program could easily hog the CPU by not retrieving messages too often or by spending too much time in a window procedure function. The situation was quite different for MS-DOS boxes. They ran using the V8086 mode of the 80386 (if Windows was running in enhanced mode). Windows-aware programs ran in the so-called System VM (Virtual Machine 1). DOS boxes ran from VM 2 upwards. DOS programs usually were badly-behaved programs, so Windows assigned each DOS box a different virtual machine. Virtual machines used pre-emptive multitasking in Windows 3.1, so each DOS box could run concurrently to others and to any Windows-aware program.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 504, "passed_quality_check": "True", "flesch_reading_ease": 51.176000000000016, "entropy": 2.4875014511347993}
I'm working on 2 different branches: release and development. I noticed I still need to integrate some changes that were committed to the release branch back into the development branch. The problem is I don't need all of the commit, only some hunks in certain files, so a simple ```git cherry-pick bc66559 ``` does not do the trick. When I do a ```git show bc66559 ``` I can see the diff but don't really know a good way of applying that partially to my current working tree.
null
[]
The core thing you're going to want here is ```git add -p``` (```-p``` is a synonym for ```--patch```). This provides an interactive way to add in content, letting you decide whether each hunk should go in or not, and even letting you manually edit the patch if necessary. To use it in combination with cherry-pick: ```git cherry-pick -n # get your patch, but don't commit (-n = --no-commit) git reset # unstage the changes from the cherry-picked commit git add -p # make all your choices (add the changes you do want) git commit # make the commit! ``` ``git-cherry-pick``` has a ```--no-commit``` option, and you need to do ```git reset```. If you only want to leave a few things out of the commit, you could use ```git reset ...``` to unstage just those files.) You can provide specific paths to ```add -p``` if necessary. If you're starting with a patch you could replace the ```cherry-pick``` with ```apply```. If you really want to ```git cherry-pick -p ``` (that option does not exist), you can use ```git checkout -p ``` That will diff the current commit against the commit you specify, and allow you to apply hunks from that diff individually. This option may be more useful if the commit you're pulling in has merge conflicts in part of the commit you're not interested in. (Note, however, that ```checkout``` differs from ```cherry-pick```: ```checkout``` tries to apply ``````'s contents entirely, while ```cherry-pick``` applies the diff of the specified commit from it's parent. This means that ```checkout``` can apply more than just that commit, which might be more than you want.)
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 399, "passed_quality_check": "True", "flesch_reading_ease": 75.24666666666668, "entropy": 3.376221902961121}
In Civilization V, you attain a cultural victory by accumulating enough culture to purchase at least 36 social policies, and then building a wonder. The catch is that the more cities you build, the more culture you need to generate before you hit the next "plateau" of culture. What is the ideal number of cities for a cultural victory? Does it change over time?
null
[]
The question you're really asking is &quot;When does the combined culture / turn of an additional city outstrip the increase in social policy cost incurred by founding that city?&quot; The short answer is... We know that adding another city increases the culture costs by approximately 30% of the base cost (that of 1 city). Therefore: If your maximum potential culture / turn won't increase by at least 30% due to the new city, you are hurting, not helping, the time till your next social policy. (This may be slightly hard to calculate, and if you take too long to reach your &quot;maximum potential culture / turn&quot; you're actually wasting turns.) The long answer is... It depends To begin with, we need to make some assumptions: * When you found a new city, you can get its culture / turn maximized within a single turn by buying the necessary building improvements (monument, etc). * Ignore city-states, leader specific abilities, +culture social policies, and wonders. These all help produce culture, and will shift the &quot;ideal city count&quot; down, but do so inconsistently. To produce an &quot;ideal&quot; city count, we limit ourselves by era and improvements alone. * This list of social policy costs is accurate for the given parameters: medium map and normal speed. And now, some math. The 1st social policy costs 25 points with a single city. In the ancient era, your cities can generate 2 culture / turn due to the monument. (Remember, we're ignoring the palace for now) This means that it will take 13 turns (Ceiling(25/2) to enact the policy, or 9 turns (ceiling (45/4) with two cities. We can continue this extrapolation -- 8 turns with 3 cities, 7 turns with 4 cities, 6 turns with 5 cities, and we finally reach diminishing returns at city 6 (also 6 turns). For the second social policy, the ramifications of the # of cities gets magnified due to a larger starting value: One city takes 23 turns, two cities take 15 turns, three cities take 13 turns, four cities take 12, five cities take 10, and again, we run into diminishing returns cap out at at six cities (10 turns). It is not until the 4th social policy that this trend is broken and diminishing returns end at the NINTH! city. Remember -- this assumes that each city has a monument the minute it is founded. Now let's say we've reached the classical age, and have temples in addition to monuments. Each city is now generating 5 culture. The first policy takes 5 turns with a single city, 4 turns with two, and 3 with three. What (hopefully) becomes clear is that we reached diminishing returns (4 cities as opposed to 6 cities) much faster when each individual city's contribution is higher. The more culture any one city is capable of producing, the more incentive there is to produce more cities. Even if you don't manage to build every +culture improvement immediately, you're still likely to come out ahead (as long as you're pre-diminishing returns). So while the optimal number of cities changes due to any number of factors, you can probably safely not shoot yourself in the foot if you stay between three and six cities, with six being on the high end.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 300, "passed_quality_check": "True", "flesch_reading_ease": 69.29817307692309, "entropy": 2.3636802796088294}
How to find if a customer is logged in or not in Magento 2. If the customer is logged in then how to get customer data from a session?
null
[]
It is possible via ```Magento\Framework\App\Http\Context``` or via ```Magento\Customer\Model\Session```. However, the result may be different: * HTTP context is initialized earlier than the customer session (but it does not matter since both are initialized in action controllers) * When the ```PageCache``` module is on (probably always on production), keep in mind that as soon as layout generation started, the customer session will be cleared by ```\Magento\PageCache\Model\Layout\DepersonalizePlugin::afterGenerateXml``` on all cacheable pages. It means that if you now check if the customer is logged in via the HTTP context, it will still say 'yes, but customer data will not be available in customer sessions anymore. So double-check is necessary before trying to access data in customer sessions. This can easily happen in the block, while is unlikely in action controller since you are not expected to generate layout manually there, it will be generated after-action controller returns an instance of ```ResultInterface``` To eliminate any risk of described inconsistencies when PageCache is on, consider using customer session if it is already initialized (true for action controllers). Else use the HTTP context.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 107, "passed_quality_check": "True", "flesch_reading_ease": 72.04500000000002, "entropy": 0.9870379383669438}
I have a 9 year old daughter that has expressed some interest in manga, but I'm having trouble locating series that are appropriate for her age. No one at our local bookstore could offer any advice. Is there a kid-friendly imprint or other resource I could use to help her find something appropriate? My preference is for physical books but I'm willing to explore digital options.
null
[]
The content deemed acceptable for Japanese children generally differs from the concept in other countries; manga contains all genres of stories, so one cannot responsibly presume that just because a title was marketed at Japanese kids, that you would likewise consider it appropriate for your kid of the same age. As one example: The popular girl's series Sailor Moon was published in the manga magazine Nakayoshi, which was marketed toward elementary school-age girls (1st through 6th grade). This series includes strong language, bullying, violence, death, war, genocide, refugees, lovers' suicide (more than once), non-consensual kisses (forced while awake, while asleep, while drunk), a father fondling his adult daughter while brainwashed, human/animal romance, demonic-style alien possession of human bodies, nudity, cross-dressing, a non-monogamous lesbian couple, and non-graphic sex resulting in teen pregnancy (the 90s anime version, also marketed toward children, also added wrist/ankle restraints for a rape-like, pain-inducing entering of victims). There are many manga reviews on the web, including those that specifically for parents and teen/preteen/kid readers on what sort of possibly objectionable content is included in the title (such as strong language, violence, nudity, gender-bending, innuendo, sexual content, etc.) and what sort of general content you can expect (for example: horror, potty humor, serious themes like depression/body image/sexual orientation/prostitution/parental abandonment/bullying/suicide) and let you as the parent or the reader use your own judgment about whether a title fits what you deem appropriate at what age. Browsing reviews also allows you to seek out titles that reinforce and contribute to your family's values (such as traits of selflessness, generosity, celebration of uniqueness, etc.). Some good starting places are: * A Parent's Guide to Anime * Good Manga for Kids at Manga Bookshelf * Good Comics for Kids at School Library Journal * Kids Manga at No Flying No Tights Since you have a daughter, she may be especially interested in shoujo manga, which was written with the target audience of Japanese girls. Within shoujo, nearly all genres of stories are included; some titles are very cheerful and innocuous and teach a moral-of-the-day, others are dark and heavy. Good starting places to get informed are: * What is Shoujo Manga?, What Shoujo Manga Are and Are Not, and Recommended Shoujo Manga by Matt Thorn, a professor in the Faculty of Manga at Kyoto Seika University (one of the world's experts on shoujo manga) * What is Shoujo? at Energetic Heartbeats Some shoujo manga review sites are: * The Classics at Shoujo Corner * Emily's Random Shoujo Manga Page (despite its unassuming name, contains many detailed reviews) * Heart of Manga * Shoujo Savvy * Shoujo Manga Recommendations * Romance Manga Reviews * Shoujo Manga Reviews * Shoujo Manga with Anime at Anime Manga Reviews More general review websites include MangaBlog and Kuriousity, and a Google search will find you many more.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 315, "passed_quality_check": "True", "flesch_reading_ease": 68.61583955223882, "entropy": 1.8637017713488067}
I'm looking for a precise piece of information in a database which I have no knowledge about. The database is on a separate machine, but I can log into it, and launch a ```psql``` command line, with administrator rights. It's a third-party product, and they are slow to answer questions. I know the data is inside that database, so I want to do a little bit of reverse-engineering. Given a table name, is it possible to get a list of the names of the columns in that table? For example, in SQL Server, it's possible to dump a table into a reusable ```CREATE``` statement, which textually lists all the columns the table is composed of.
null
[]
The information schema is the slow and sure way: it is standardized and largely portable to other databases that support it. And it will keep working across major versions. However, views in the information schema often join many tables from the system catalogs to meet a strictly standardized format - many of which are just dead freight most of the time. This makes them slow. The Postgres developers aren't making promises, but basics (like what is needed here) aren't going to change across major versions. More detailed assessment: * Query to output names and data types of a query, table or view ```psql``` (the native command-line interface) takes the fast lane, of course, and queries the source directly. If you start ```psql``` with the parameter ```-E```, the SQL behind backslash commands like ```\d``` is displayed. Or ```\set ECHO_HIDDEN on``` from the psql command line. Starting from there you can build an answer to your question. Given one table, is it possible to have a list of the names of the columns for this table. ```SELECT attrelid::regclass AS tbl , attname AS col , atttypid::regtype AS datatype -- more attributes? FROM pg_attribute WHERE attrelid = 'myschema.mytable'::regclass -- table name optionally schema-qualified AND attnum > 0 AND NOT attisdropped ORDER BY attnum; ``` Faster than querying ```information_schema.columns```. Try ```EXPLAIN ANALYZE``` to see for yourself. Still hardly matters for a one-time look-up. But might make a difference if used in a query / function that's repeated many times. There are also subtle differences in visibility. The following artical has detailed comparison: * How to check if a table exists in a given schema
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 524, "passed_quality_check": "True", "flesch_reading_ease": 76.19136363636365, "entropy": 5.4358164843436025}
I am using Visual Studio Code and have a fairly common project structure: ```├── client/ │ ├── tsconfig.json ├── shared/ ├── server/ │ ├── tsconfig.json ├── project.json ``` The two tsconfig files have different settings (e.g. the one under ```client/``` targets ES5, the one under ```server/``` targets ES6). Note that there is no tsconfig in the root directory. The problem is that I want the shared directory to be included in both projects. I can't do this using tsconfig because the ```exclude``` option won't let me include a folder that is in a higher directory than the tsconfig.json, and using ```files``` I have to constantly keep the list of files up to date as it doesn't support globs. Note that I can compile fine by adding the shared folder into tsc, what I want is for the Visual Studio Code IDE to recognise the shared code for intellisense etc. Is the only option to wait for filesGlob?
null
[]
These days it is much easier as vscode has better support for this. You can use this directory structure so all the code is independent: ```├── frontend/ │ ├── src/ │ │ ├── │ ├── package.json │ ├── tsconfig.json ├── shared/ │ ├── package.json ├── backend/ │ ├── src/ │ │ ├── │ ├── package.json │ ├── tsconfig.json ``` Then in both the backend and frontend ```tsconfig.json```: ```{ &quot;compilerOptions&quot;: { &quot;paths&quot;: { &quot;~shared/*&quot;: [&quot;../shared/*&quot;] }, &quot;rootDirs&quot;: [ &quot;./src&quot;, &quot;../shared&quot; ] } } ``` To allow access to the shared code e.g.: ```import { Foo } from '~shared/foo'; ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 759, "passed_quality_check": "False", "flesch_reading_ease": 58.55271090047394, "entropy": 5.102190621145081}
I have the following method to save an Object to a file: ```// Save an object out to the disk public static void SerializeObject(this T toSerialize, String filename) { XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType()); TextWriter textWriter = new StreamWriter(filename); xmlSerializer.Serialize(textWriter, toSerialize); textWriter.Close(); } ``` I confess I did not write it (I only converted it to a extension method that took a type parameter). Now I need it to give the xml back to me as a string (rather than save it to a file).
null
[]
Use a `StringWriter` instead of a `StreamWriter`: ``` public static string SerializeObject<T>(this T toSerialize) { XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType()); using(StringWriter textWriter = new StringWriter()) { xmlSerializer.Serialize(textWriter, toSerialize); return textWriter.ToString(); } } ``` Note, it is important to use `toSerialize.GetType()` instead of `typeof(T)` in XmlSerializer constructor: if you use the first one the code covers all possible subclasses of `T` (which are valid for the method), while using the latter one will fail when passing a type derived from `T`. There is some example code on Ideone that motivates this statement, with XmlSerializer throwing an `Exception` when `typeof(T)` is used, because you pass an instance of a derived type to a method that calls SerializeObject that is defined in the derived type's base class. Also, Ideone uses Mono to execute code; the actual `Exception` you would get using the Microsoft .NET runtime has a different `Message` than the one shown on Ideone, but it fails just the same.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 481, "passed_quality_check": "False", "flesch_reading_ease": 55.56268564356438, "entropy": 3.5658154969916795}
I have a problem with the embedded bitcode term. What is embedded bitcode? When to enable, ```ENABLE_BITCODE``` in new Xcode? What happens to the binary when enabled, ```ENABLE_BITCODE``` in Xcode 7?
null
[]
> What is embedded bitcode? According to docs: > Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store. This phrase in "New Features in Xcode 7" made me to think for a long time that Bitcode is needed for Slicing to reduce app size: When you archive for submission to the App Store, Xcode will compile your app into an intermediate representation. The App Store will then compile the bitcode down into the 64 or 32 bit executables as necessary. However that's not true, Bitcode and Slicing work independently: Slicing is about reducing app size and generating app bundle variants, and Bitcode is about certain binary optimizations. I've verified this by checking included architectures in executables of non-bitcode apps and founding that they only include necessary ones. Bitcode allows other App Thinning component called Slicing to generate app bundle variants with particular executables for particular architectures, e.g. iPhone 5S variant will include only arm64 executable, iPad Mini armv7 and so on. > When to enable ENABLE_BITCODE in new Xcode? For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS and tvOS apps, bitcode is required. > What happens to the binary when ENABLE_BITCODE is enabled in the new Xcode? From Xcode 7 reference: > Activating this setting indicates that the target or project should generate bitcode during compilation for platforms and architectures which support it. For Archive builds, bitcode will be generated in the linked binary for submission to the app store. For other builds, the compiler and linker will check whether the code complies with the requirements for bitcode generation, but will not generate actual bitcode.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 172, "passed_quality_check": "False", "flesch_reading_ease": 79.33333333333336, "entropy": 1.3038563055817363}
In Dupire's local volatility model, the volatility is is a deterministic function of the underlying price and time, chosen to match observed European option prices. To be more specific, given a smooth surface $(K,T)\mapsto C(K,T)$ where K is the strike and T is time to maturity. Dupire equation implies that there exits an unique continuous function $\sigma_{loc}$ defined by $$\sigma_{loc}^{2}(K,T)=\frac{\partial_{T}C(K,T)+rK\partial_{K}C(K,T)}{\frac{1}{2}K^{2}\partial_{KK}C(K,T)}$$ for all $(K,T)\in(0,\infty)\times(0,\infty)$ such that the solution to the stochastic differential equation $dS_{t}/S_{t}=rdt+\sigma(t,S_{t})dW_{t}$ exactly generates the European call option prices. What do the dynamics of the local volatility mean? Are dynamics equivalent to the volatility surface? Why the dynamics of local volatility model is highly unrealistic?
null
[]
A general model (with continuous paths) can be written $$ \frac{dS_t}{S_t} = r_t dt + \sigma_t dW_t^S $$ where the short rate $r_t$ and spot volatility $\sigma_t$ are stochastic processes. In the Black-Scholes model both $r$ and $\sigma$ are deterministic functions of time (even constant in the original model). This produces a flat smile for any expiry $T$. And we have the closed form formula for option prices $$ C(t,S;T,K) = BS(S,T-t,K;\Sigma(T,K)) $$ where $BS$ is the BS formula and $\Sigma(T,K) = \sqrt{\frac{1}{T-t}\int_t^T \sigma(s)^2 ds}$. This is not consistent with the smile observed on the market. In order to match market prices, one needs to use a different volatility for each expiry and strike. This is the implied volatility surface $(T,K) \mapsto \Sigma(T,K)$. In the local volatility model, rates are deterministic, instant volatility is stochastic but there is only one source of randomness $$ \frac{dS_t}{S_t} = r(t) dt + \sigma_{Dup}(t,S_t) dW_t^S $$ this is a special case of the general model with $$ d\sigma_t = (\partial_t \sigma_{Dup}(t,S_t) + r(t)S_t\partial_S\sigma_{Dup}(t,S_t) + \frac{1}{2}S_t^2\partial_S^2\sigma_{Dup}(t,S_t)) dt + \frac{1}{2}S_t\partial_S\sigma_{Dup}(t,S_t)^2 dW_t^S $$ What is appealing with this model is that the function $\sigma_{Dup}$ can be perfectly calibrated to match all market vanilla prices (and quite easily too). The problem is that while correlated to the spot, statistical study show that the volatility also has its own source of randomness independent of that of the spot. Mathematically, this means the instant correlation between the spot and vol is not 1 contrary to what happens in the local volatility model. This can be seen in several ways: 1. The forward smile. Forward implied volatility is implied from prices of forward start options: ignoring interest rates, $$ C(t,S;T\to T+\theta,K) := E^Q[(\frac{S_{T+\theta}}{S_{T}}-K)_+] =: C_{BS}(S=1,\theta,K;\Sigma(t,S;T\to T+\theta,K)) $$ Alternatively, it is sometimes defined as the expectation of implied volatility at a forward date. In a LV model, as the maturity $T$ increases but $\theta$ is kept constant, the forward smile gets flatter and higher. This is not what we observe in the markets where the forward smile tends to be similar to the current smile. This is because the initial smile you calibrate the model too has decreasing skew: $$ \partial_K \Sigma(0,S;T,K) \xrightarrow[T\to +\infty]{} 0 $$ 2. Smile rolling. In a LV model, smile tends to move in the opposite direction of the spot and get higher independently of the direction of the spot. This is not consistent with what is observed on markets. See Hagan and al. Managing Smile Risk for the derivation. This means that $\partial_S \Sigma_{LV}(t,S;T,K)$ often has the wrong sign so your Delta will be wrong which can lead to a higher hedging error than using BS. 3. Barrier options. In FX markets, barrier options like Double No Touch are liquid but a LV model calibrated to vanilla prices does not reproduce these prices. This is a consequence of the previous point. The LV model is a static model. Its whole dynamic comes from the volatility surface at time 0. But the vol surface has a dynamic that is richer than that. There are alternatives using multiple factors like SV models, LSV models (parametric local vol like SABR or fully non parametric local vol), models of the joint dynamic of the spot and vol surface etc... but the LV model remains the default model in many cases due to its simplicity, its ability to calibrate the initial smile perfectly and its numerical efficiency.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 752, "passed_quality_check": "True", "flesch_reading_ease": 49.154329268292685, "entropy": 4.2901026378409615}
Can you explain why we need a large number of trees in random forest when the number of predictors is large? How can we determine the optimal number of trees?
null
[]
Random forest uses bagging (picking a sample of observations rather than all of them) and random subspace method (picking a sample of features rather than all of them, in other words - attribute bagging) to grow a tree. If the number of observations is large, but the number of trees is too small, then some observations will be predicted only once or even not at all. If the number of predictors is large but the number of trees is too small, then some features can (theoretically) be missed in all subspaces used. Both cases results in the decrease of random forest predictive power. But the last is a rather extreme case, since the selection of subspace is performed at each node. During classification the subspace dimensionality is $\sqrt{p}$ (rather small, $p$ is the total number of predictors) by default, but a tree contains many nodes. During regression the subspace dimensionality is $p/3$ (large enough) by default, though a tree contains fewer nodes. So the optimal number of trees in a random forest depends on the number of predictors only in extreme cases. The official page of the algorithm states that random forest does not overfit, and you can use as much trees as you want. But Mark R. Segal (April 14 2004. "Machine Learning Benchmarks and Random Forest Regression." Center for Bioinformatics & Molecular Biostatistics) has found that it overfits for some noisy datasets. So to obtain optimal number you can try training random forest at a grid of ```ntree``` parameter (simple, but more CPU-consuming) or build one random forest with many trees with ```keep.inbag```, calculate out-of-bag (OOB) error rates for first $n$ trees (where $n$ changes from $1$ to ```ntree```) and plot OOB error rate vs. number of trees (more complex, but less CPU-consuming).
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 129, "passed_quality_check": "True", "flesch_reading_ease": 76.48314516129035, "entropy": 0.7893728557117801}
I believe artificial intelligence (AI) term is overused nowadays. For example, people see that something is self-moving and they call it AI, even if it's on autopilot (like cars or planes) or there is some simple algorithm behind it. What are the minimum general requirements so that we can say something is AI?
null
[]
It's true that the term has become a buzzword, and is now widely used to a point of confusion - however if you look at the definition provided by Stuart Russell and Peter Norvig, they write it as follows: > We define AI as the study of agents that receive percepts from the environment and perform actions. Each such agent implements a function that maps percept sequences to actions, and we cover different ways to represent these functions, such as reactive agents, real-time planners, and decision-theoretic systems. We explain the role of learning as extending the reach of the designer into unknown environments, and we show how that role constrains agent design, favoring explicit knowledge representation and reasoning. Artificial Intelligence: A Modern Approach - Stuart Russell and Peter Norvig So the example you cite, "autopilot for cars/planes", is actually a (famous) form of AI as it has to use a form of knowledge representation to deal with unknown environments and circumstances. Ultimately, these systems also collect data so that the knowledge representation can be updated to deal with the new inputs that they have found. They do this with autopilot for cars all the time To answer your question, for something to be considered as "having AI", it needs to be able to deal with unknown environments/circumstances in order to achieve its objective/goal, and render knowledge in a manner that provides for new learning/information to be added easily. There are many different types of well defined knowledge representation methods, ranging from the popular neural net, through to probabilistic models like bayesian networks (belief networks) - but fundamentally actions by the system must be derived from whichever representation of knowledge you choose for it to be considered as AI.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 260, "passed_quality_check": "True", "flesch_reading_ease": 69.7866666666667, "entropy": 1.7377817489150165}
I have some questions regarding the usage and significance of the ```synchronized``` keyword. * What is the significance of the ```synchronized``` keyword? * When should methods be ```synchronized```? * What does it mean programmatically and logically?
null
[]
The ```synchronized``` keyword is all about different threads reading and writing to the same variables, objects and resources. This is not a trivial topic in Java, but here is a quote from Sun: > ```synchronized``` methods enable a simple strategy for preventing thread interference and memory consistency errors: if an object is visible to more than one thread, all reads or writes to that object's variables are done through synchronized methods. In a very, very small nutshell: When you have two threads that are reading and writing to the same 'resource', say a variable named ```foo```, you need to ensure that these threads access the variable in an atomic way. Without the ```synchronized``` keyword, your thread 1 may not see the change thread 2 made to ```foo```, or worse, it may only be half changed. This would not be what you logically expect. Again, this is a non-trivial topic in Java. To learn more, explore topics about: * Concurrency * Java Memory Model Keep exploring these topics until the name "Brian Goetz" becomes permanently associated with the term "concurrency" in your brain.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 221, "passed_quality_check": "False", "flesch_reading_ease": 72.49916666666671, "entropy": 1.3713319970472944}
I am using the ```$http``` service of AngularJS to make an Ajax request. How can a spinner GIF (or another type of busy indicator) be shown while the Ajax request is executing?
null
[]
This really depends on your specific use case, but a simple way would follow a pattern like this: ``` .controller('MainCtrl', function ( $scope, myService ) { $scope.loading = true; myService.get().then( function ( response ) { $scope.items = response.data; }, function ( response ) { // TODO: handle the error somehow }).finally(function() { // called no matter success or failure $scope.loading = false; }); }); ``` And then react to it in your template: ``` <div class="spinner" ng-show="loading"></div> <div ng-repeat="item in items>{{item.name}}</div> ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 146, "passed_quality_check": "True", "flesch_reading_ease": 70.21000000000004, "entropy": 0.9751998602465137}
Let's say that we have a gaseous or liquidus compound (I don't know if elements or compounds make a difference, take this as a thought experiment), and we have a tungsten or steel block that's 5cm (or less, you choose) thick. Is there any physical method for that gas or liquid to pass through that thick heavy metal block (not by drilling etc.)?
null
[]
Yes, some gases can diffuse into and through metal. It is the bane of the high-vacuum engineer's life. Hydrogen is the worst because it tends to dissociate into atoms at the surface and the nucleus, a single proton, can then leave its electron behind and wander through the metal lattice until it picks up another electron when it leaves. For example Mu-metal, favoured for some applications, typically has to be annealed in hydrogen at high temperature. Once that is over, it can take weeks or months for the residual hydrogen to diffuse out of the metal before a high enough vacuum can be achieved and the work proceed. A &quot;virtual leak&quot; occurs where a small bubble of gas is embedded in the material inside a vacuum chamber. The leak usually happens because a tiny hole exists for the gas to diffuse out through, but sometimes the &quot;hole&quot; is no more than an ultra-thin skin of metal (invisible to the frustrated technician) and the gas diffuses through it. These little horrors can keep going for months or even years and generally mean replacing suspected parts and pumping down over and over again until the dodgy one is finally stumbled on. Helium is both monatomic and the physically smallest atom. It can diffuse more easily than any other neutral atom or molecule, making certain metal foils unsuitable as say gas-tight liners for airships. As noted in another answer, in quantity it can also affect the bulk properties of the metal. On a more energetic scale, hydrogen and helium nuclei (protons and alpha particles) can pass through thin metal foils if fired with sufficient energy, and this has been used to establish the crystalline structures of some metals and alloys (where, for whatever reason, electrons were unsuitable). Other gases have much larger atoms (neon and other noble gases) or molecules (nitrogen and other diatomic molecules, water and other hydrides), but they can still diffuse extremely slowly through some metals. This can limit the lifetime of some microchips. A related phenomenon occurs where there is a defect in the lattice at the surface, such as a grain boundary, and a gas atom attaches to it. Defects are sometimes quite mobile and can migrate through the lattice; the gas atom will stabilise the defect and may be able to hitch a ride. Quantum processes such as tunnelling are not really relevant, as they work over distances smaller than the atomic wavelength, which in turn is typically far smaller than the thickness of any metal atom or foil. The probability of a gas atom tunnelling across is so infinitesimal as to be effectively zero.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 284, "passed_quality_check": "True", "flesch_reading_ease": 69.92687500000002, "entropy": 2.1340606623733454}
Once, I boarded a plane, went to my designated seat and tried to put my bag in the overhead bin. However, it was full, and other adjacent overhead bins were full too. Because I had a seat next to the emergency exit, which I paid for, I had to hand over my bag to someone else in order to take off. Do I have any rights over the overhead bin above my seat? Could I ask the flight attendant to remove some of the bags to make room for me? I cannot imagine that the bins were full because there was not enough space. I think this happened because some people were ignorant enough to bring more bags than is allowed inside the airplane instead of sending them to cargo. If this is the case why doesn't the airline enforce the bag limit inside the airplane?
null
[]
You have no right to the bin above your seat. For those exit rows where you cannot put anything beneath the seat in front of you, flight attendants will generally try to help find some space somewhere for at least your small personal item, but any passenger may be required to check their bags rather than put them in the overhead bin. It is entirely possible that the airline didn't enforce the bag limit, but the overhead bins can easily fill up even when the limit is strictly enforced. If every passenger, or even most passengers, brings a regulation sized carry-on on a full flight, it is obvious that many of the bags will not fit in the bins and will have to be checked. In some cases, overhead bins may be marked as reserved for first class or premium economy passengers (or safety equipment, or pillows and blankets). Even in such cases, cabin crew may fill these bins with other bags in an attempt to accommodate as many passengers as possible, and a late-boarding passenger may be caught out with no space. It is hard to imagine that they are likely to remove and check someone's bag so you may have that space. Overhead bin space is typically first-come first served, and at some point, they will declare the bins full and start checking bags (sometimes even before the bins are actually full). Note that if your bag must be checked, you should ensure you remove any essential items (medication, passports, keys, etc...) and any valuables, along with any hazardous material that cannot be checked, namely spare (uninstalled) lithium batteries including external power packs. Boarding as early as possible (which, on some airlines, could require frequent flyer status or paying an extra fee) will help secure you overhead bin space.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 610, "passed_quality_check": "True", "flesch_reading_ease": 86.28375000000001, "entropy": 5.60140101335539}
The Canon EF 40mm f/2.8 has a designation of STM on the lens. What does this mean? What are the advantages of having it and does it replace an older technology?
null
[]
STM stands for Stepper Motor and is a applied to a new range of Canon lenses which feature a new design of focus motors which, along with a new iris mechanism are designed to eliminate (auditory) noise during video recording. Canon haven't revealed any information about how the new design works but it's probably the same type of motor used in mirrorless camera lenses. It's a more precise version of a regular DC motor but still has the same direct connection to the lens focus group, which means manual focus has to be implemented using a focus-by-wire arrangement whereby moving the focus ring by hand sends a signal to the motor to move the focus group. In comparison an ultrasonic motor (like Canon's USM) consists of a pair of concentric rings which vibrate at high frequency to rotate back and forth, an arrangement which permits the user to move the focus ring to directly move the lens element, achieving full time manual focus without damaging the motor. Stepper motors are better at producing smooth, precise incremental movements, such as those required by contrast detect AF, and AF during video. Ultrasonic motors are better at jumping to the right focus point as part of a phase detection system.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 131, "passed_quality_check": "True", "flesch_reading_ease": 85.4336363636364, "entropy": 0.9631917175692921}
I'm trying to set get id of all elements in an ```HTMLCollectionOf```. I wrote the following code: ```var list = document.getElementsByClassName("events"); console.log(list[0].id); for (key in list) { console.log(key.id); } ``` But I got the following output in console: ```event1 undefined ``` which is not what I expected. Why is the second console output ```undefined``` but the first console output is ```event1```?
null
[]
You can't use ```for```/```in``` on ```NodeList```s or ```HTMLCollection```s. However, you can use some ```Array.prototype``` methods, as long as you ```.call()``` them and pass in the ```NodeList``` or ```HTMLCollection``` as ```this```. So consider the following as an alternative to jfriend00's ```for``` loop: ```var list= document.getElementsByClassName("events"); [].forEach.call(list, function(el) { console.log(el.id); }); ``` There's a good article on MDN that covers this technique. Note their warning about browser compatibility though: [...] passing a host object (like a ```NodeList```) as ```this``` to a native method (such as ```forEach```) is not guaranteed to work in all browsers and is known to fail in some. So while this approach is convenient, a ```for``` loop may be the most browser-compatible solution. Update (Aug 30, 2014): Eventually you'll be able to use ES6 ```for```/```of```! ```var list = document.getElementsByClassName("events"); for (const el of list) console.log(el.id); ``` It's already supported in recent versions of Chrome and Firefox.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 370, "passed_quality_check": "False", "flesch_reading_ease": 58.8309090909091, "entropy": 2.0969154609947473}
I am 21 years old and living in a large city in Germany where smalltalk in local markets is not a common thing. A new cashier joined my local food shop. She’s always at the checkout and never doing stuff like sorting products or cleaning the floor where I could actually ask her out. I am quite new to relationships, but the signs she gave me are promising. My question is how I can ask for her number, or ask her out for coffee while she is only sitting at the checkout? I mean there are always like 5 people before and after me, and I think it would be awkward if we are changing numbers while customers are waiting behind us. Or even worse if I read the signs wrong and she rejects me? Since the store is just 5 min away from my place I visit regularly and don't want to leave a bad impression there.
null
[]
Asking her out directly seems like a bad idea. Instead, in these situations, I've found something that works much better for both of you. During your conversation with her, mention some place you're planning to be in the future so she can find you there if she chooses. For example: &quot;I like to grab lunch here before going to [Public Event You Enjoy]&quot; This could be almost anything, but here are some examples: * A place your band plays * A public dance * A painting/pottery class * A wine tasting This should be something you actually enjoy, so be sure to let your excitement about your hobby be apparent when you mention it. Ex: &quot;I enjoy that they let you try lots of different wines from all around the world!&quot; If she expresses interest in the activity as well, tell her more about it so she can attend: &quot;Yeah, it's really fun. They do it every Tuesday and Thursday at 7pm - the admission fee is 5 Euro. You should check it out sometime!&quot; If she is interested in you and has time, she will probably arrange to come to the event some time and you will see her there. This is preferable because she is not under obligation to behave professionally for her work and you can spend some time chatting as equals. And if that goes well, then you have created a good opportunity to ask her on a real date. And if she doesn't come, well, you were planning to go there anyways so it's not a real loss on your part - you just spent an afternoon/evening doing something you already enjoy.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 648, "passed_quality_check": "True", "flesch_reading_ease": 83.0591442374051, "entropy": 4.777992042488788}
You start with the number 1536. Your mission is to get to 1 in as few steps as possible. At each step, you may either multiply or divide the number you have, by either 2 or 3; but, only if the result is a whole number whose first digit is 1, 3, 4, or 9. That is all.
null
[]
As Jo has already shown, this can be accomplished in 28 steps. This is minimal, and it can be proven. To help visualize this problem, we can imagine: A two-dimensional grid/chart where each point is a number of the form $3^x2^y$, with $(x,y)$ as the relevant co-ordinates. We want to find a path from $(1,9)$ to $(0,0)$ while making only one step up/down/left/right at a time, and ensuring that the numbers we step on have their most significant digit in the set {1,3,4,9}. Here is what the chart looks like for the range $(0,0)$ to $(10,10)$. The dashes represent numbers that do not begin with {1,3,4,9}, and so are unusable in our path. ```1024 3072 9216 ---- ---- ---- ---- ---- ---- ---- ---- .``` ```---- 1536 4608 13824 41472 124416 373248 1119744 3359232 10077696 30233088 .``` ```---- ---- ---- ---- ---- ---- 186624 ---- 1679616 ---- 15116544 .``` ```128 384 1152 3456 10368 31104 93312 ---- ---- ---- ---- .``` ```---- 192 ---- 1728 ---- 15552 46656 139968 419904 1259712 3779136 .``` ```32 96 ---- ---- ---- ---- ---- ---- ---- ---- 1889568 .``` ```16 48 144 432 1296 3888 11664 34992 104976 314928 944784 .``` ```---- ---- ---- ---- ---- 1944 ---- 17496 ---- 157464 472392 .``` ```4 12 36 108 324 972 ---- ---- ---- ---- ---- .``` ```---- ---- 18 ---- 162 486 1458 4374 13122 39366 118098 .``` ```1 3 9 ---- ---- ---- ---- ---- ---- 19683 ---- .``` From here, we can see two different routes of 28 steps each: (1536->373248->93312->384->48->3888->972->36->9->1) and (1536->373248->46656->3779136->944784->3888->972->36->9->1). Proving minimality: Since a path of length 28 exists (we've found two), we can rule out anything that's too far away to be used in a shortest path. Moving from (1,9) to (0,0) must take at least ten steps on its own, so we can move at most nine steps completely out of the way (and nine steps back) in a shortest route. That limits us to only considering x-coordinates up to 10; any further would require making at least ten '*3' steps, eleven '÷3' steps, and at least nine '÷2' steps, putting the route definitely longer than 28. With our x-coordinate limited to [0,10], we now look at the bottlenecks. It should be clear that any shortest route must start by going from 1536 to 93312 in seven steps, and must end by going from 3888 to 1 in nine steps. These are both forced by unique bottlenecks; there is only one way to step from $(x,7)$ to $(x,6)$ and only one way to step from $(x,3)$ to $(x,2)$ in this range. This leaves at most twelve steps to go from 93312 to 3888. Either by observation or by pointing out that there are only two ways to go from $(x,6)$ to $(x,5)$, we can see that there are exactly two shortest routes from 93312 to 3888, and both require all twelve steps. Therefore, the shortest route is 28 steps, and there are exactly two ways to do so, both of which are described in Jo's solution and below the chart.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 209, "passed_quality_check": "True", "flesch_reading_ease": 94.38991379310346, "entropy": 2.4860677809945733}
I want to create a simple bit of JS code that creates an image element in the background and doesn't display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 = ```var oImg = document.createElement("img"); oImg.setAttribute('src', 'http://www.testtrackinglink.com'); oImg.setAttribute('alt', 'na'); oImg.setAttribute('height', '1px'); oImg.setAttribute('width', '1px'); document.body.appendChild(oImg); ``` Is this the simplest but most robust (error free) way to do it?
null
[]
```oImg.setAttribute('width', '1px'); ``` ```px``` is for CSS only. Use either: ```oImg.width = '1'; ``` to set a width through HTML, or: ```oImg.style.width = '1px'; ``` to set it through CSS. Note that old versions of IE don't create a proper image with ```document.createElement()```, and old versions of KHTML don't create a proper DOM Node with ```new Image()```, so if you want to be fully backwards compatible use something like: ```// IEWIN boolean previously sniffed through eg. conditional comments function img_create(src, alt, title) { var img = IEWIN ? new Image() : document.createElement('img'); img.src = src; if ( alt != null ) img.alt = alt; if ( title != null ) img.title = title; return img; } ``` Also be slightly wary of ```document.body.appendChild``` if the script may execute as the page is in the middle of loading. You can end up with the image in an unexpected place, or a weird JavaScript error on IE. If you need to be able to add it at load-time (but after the `````` element has started), you could try inserting it at the start of the body using ```body.insertBefore(body.firstChild)```. To do this invisibly but still have the image actually load in all browsers, you could insert an absolutely-positioned-off-the-page `````` as the body's first child and put any tracking/preload images you don't want to be visible in there.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 471, "passed_quality_check": "False", "flesch_reading_ease": 56.098918918918926, "entropy": 2.557902889850831}
Why is %s better than + for concatenation in python?
null
[]
There are several benefits of using ```%s``` over ```+``` for string concatenation in Python: * Readability. The format string syntax is more readable, as it separates style from the data. Also, in Python, ```%s``` syntax will automatically coerce any non ```str``` types to ```str```; while concatenation only works with ```str```, and you can't concatenate ```str``` with ```int```. * Performance. In Python ```str``` is immutable, so the left and right string have to be copied into the new string for every pair of concatenation. If you concatenate four strings of length 10, you will be copying (10+10) + ((10+10)+10) + (((10+10)+10)+10) = 90 characters, instead of just 40 characters. And things gets quadratically worse as the number and size of the string increases. Java optimizes this case some of the times by transforming the series of concatenation to use ```StringBuilder```, but CPython doesn't. * For some use cases, the logging library provide an API that uses format string to create the log entry string lazily (```logging.info("blah: %s", 4)```). This is great for improved performance if the logging library decided that the current log entry will be discarded by a log filter, so it doesn't need to format the string.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 43, "passed_quality_check": "True", "flesch_reading_ease": 61.32500000000002, "entropy": 0.19047329799647691}
I had an interview with an employer working on a software-based vehicle solution. Before going further in the interview process, he gave me a task to find out if a potential customer (automotive OEMs) is interested. My question is, how can I approach a potential customer and arrange some time together to present to them the solution?. I'm intending to use Linkedin, but I'm not sure how to proceed. * Who to contact (I mean the person position in the company) * How to formulate the request?
null
[]
Run (and run fast) - here are just a few points to consider: * That's a very unorthodox task for somebody still in the interviewing stage. * How you going to present a solution you aren't familiar with? * Since you aren't an employee of said company yet you have no grounds to represent them or even hustle their products. * You aren't on their payroll yet so why should you waste your time looking for customers? * There are a bunch of legal issues arising from such a 'task' (think NDA etc..). * How will your potential employer determine if your task has been carried out successfully? * Any CEO/CTO or even higher management of any automotive company will NOT engage in such a conversation with a random stranger. * Such an unprofessional approach is extremely disrespectful of the prospective customer's time. These are all major red flags and should lead any mentally sane person to the conclusion that the person asked for such tasks is unreasonable and has no clue about business in general. Additionally - what kind of impression do you think they will have of you or your potential, future employer considering the above mentioned points? Thank them for their time and continue applying elsewhere because this company is a nut-house.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 413, "passed_quality_check": "True", "flesch_reading_ease": 68.13450549450552, "entropy": 3.701790239226539}
When an expendable booster rocket stage nears the end of its burn, does the guidance computer shut the engine(s) off at a certain velocity/altitude for the mission, or does the stage completely exhaust its propellants?
null
[]
First stages are generally run to depletion (though not complete depletion). First stage ascents often use a preprogrammed, open loop guidance system to get out of the atmosphere with a good chunk of downrange velocity. Because winds aloft and other factors may vary, first stage performance also varies somewhat. Upper stage guidance is almost always closed loop, targeting a specific position and velocity combination. As a result, upper stages of boosters are shut down when that target is reached, with some amount of reserve propellants left to cover dispersions during ascent and a disposal burn. Liquid fueled first stages are not run dry. Cutoff is triggered with some amount left in the tank. This is because the turbopumps operate at ridiculous velocities and need something to pump, at a specific inlet pressure. The heat source (gas generator, expander, or preburner) that drives the pump is downstream of the inlet in the flow path, so cutoff has to happen by cutting off the drive force to the pump before the inlet loses pressure or runs dry. If that pressure drops below minimum specifications or if the inlet goes dry, you will get cavitation and/or overspeed conditions, both of which would result in a violent reconfiguration of the hardware. Solid lower stages are much simpler in this regard. At some point, the thrust will tail off until the booster no longer supports its own weight. At that point, it is jettisoned.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 184, "passed_quality_check": "True", "flesch_reading_ease": 48.09500000000003, "entropy": 1.071644672281826}
Is &quot;ima&quot; an informal spelling of &quot;I must&quot;? MegaCharizardZord Replying to @nytimes about COVID-19 vaccine: i just hope when i take it don't die lol. i trust the government in Canada, but if I do get something ima sue the shit out of em lol. Source: Twitter
null
[]
Ima is an informal contraction of I'm going to when it's used in going-to future construction - not in sentences like I'm going to London etc. It's also written i'ma or imma in informal conversations. How did I'm going to come to be pronounced/spelt that way? In casual speech, we tend to drop consonants that require more effort to articulate, assimilate nearby consonants, drop weak vowels etc., for the ease of articulation. Grammatical words that don't have any meaning on their own (function words?) like have to, going to (not present continuous), has, is, was, will etc., are highly susceptible to these sound changes. For instance, have to is often pronounced hafta, trying to is pronounced tryna, want to is wanna etc etc. The same thing happened to the phrase I'm going to. There are a few processes involved in the reduction of I'm going to to ima. * I'm going to → I'm gonna: the consonant t is often dropped in many other clusters and grammatical constructions as well (as in tryna, wanna etc). Here it's dropped and the vowel of to—which is usually a schwa [ə]—is linked with the preceding word; going to → gonna: [ˈɡəʊɪ̃ŋtə] → [ˈgə̃nə] * Deletion of the /g/: plosives (/g t d k/ etc) require great effort to articulate (the air is completely blocked and then released), so people dropped the plosive /g/ to make its articulation easier: [aɪ̃m gə̃nə] → [aɪ̃m ə̃nə] (i'm ana) * linking I'm and gonna: In causal and connected speech, consonants and vowels are often linked by a process called liaison, so both I'm and gonna join together and become [aɪ̃mə̃nə] (i'mana). * Syncope of the vowel in the second syllable: Unstressed schwas are often lost through syncope (for example, 'chocolate' is choc.late for most speakers). If we removed the schwa from the second syllable, we'd get [aɪmnə] (i'mna). * Deletion of /n/: It's simple cluster reduction. In English, two nasals that are next to each other are often reduced to a single nasal (as in damn), so the /n/ is deleted, yielding in this case [aɪ̃mə] (i'ma). Or people dropped the /n/ for the sake of ease. Some people further reduce the diphthong [aɪ] it to something like [a], which results in [ãmə] (ama) That's why people spell it that way. It's highly informal and as TypeIA pointed out in a comment, it's mostly a verbal thing and is not usually found in written form. It's commonly found in chatspeak or lolspeak. You shouldn't write it in any kind of writing.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 236, "passed_quality_check": "True", "flesch_reading_ease": 88.28238636363638, "entropy": 1.5731654662455614}
How to prevent "Delhi Belly" from eating/drinking locally?
null
[]
Basically, you can't. The world is full of gastrointestinal (GI) diseases, even in developed, First World nations. There are some decent steps to trying to minimize your exposure: * Properly cooked foods. Everything heated to a proper internal temperature (depends on the dish, check the USDA's site for guidelines), no sampling the raw chicken dish, etc. * For fruits and veg, if you can't peel it, don't eat it. A tremendous number of GI outbreaks are due to fruit and veg, rather than meat. This includes things like salads - since you can't really peel lettuce, avoid it. * Check if the local water is safe. When in doubt, assume it isn't. You can stick to bottled water, though there's always the distinct chance its being bottled from a contaminated source. Coke/Pepsi etc., and beer are good alternatives. Little known fact, the Coca-Cola company is hugely involved in clean water programs worldwide, because they need it for their product. * Ice. Ice is bad. Its probably made using the local tap-water, and there are many beasties that can survive an encounter with an ice machine. But when it comes down to it, nearly every traveller makes some sort of safe-eating "mistake" fairly frequently, whether they realize it or not. At the end of the day, your best bet is to talk to your travel physician, and see if you can get a prescription for an antibiotic. Using that in combination with something like Imodium will probably keep your trip mostly on track - shutting down the problem long enough for the antibiotics to treat the source. Unless of course its viral - norovirus, rotavirus etc. In that event, best of luck. And if it does happen? Stay hydrated. You're losing salts and water, they need to be replaced.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 51, "passed_quality_check": "False", "flesch_reading_ease": 66.10000000000002, "entropy": 0.20012961844355595}
I'm working at my first programming job. My boss is a very smart software engineer, and I feel like I have very little to offer compared to him. Problem is, he is always busy, and needs someone to help him out. I feel like I'm not good enough, but I still want to succeed. I want to be a great programmer. What can I do to impress him? Thank you.
null
[]
Remember the scene in Aladdin where Aladdin wants to impress Jasmine, and the genie tells him he'd do better to just focus on being himself? Same principle here. If the boss is that much better than you and you know it, he probably knows it too. He isn't expecting any great feats of programming rock-stardom out of you. Since this is your first job, he most likely hired you because he saw the potential to become a good coder in you. So if you really want to impress him, learn. Learn the language, learn the system you're working on, learn the ins and outs and dark corners. Focus on learning correct principles, learning them well and learning them quickly, in that order. And remember that part of learning is copying knowledge that other people already have. Don't be afraid to ask questions, either of your coworkers or on StackOverflow, or research things on Google. Whatever you do, don't pretend you know something when you really don't, in an effort to avoid seeming dumb. Any good developer will notice quickly, and that will make you look even stupider in their eyes. Humility tends to still be considered a virtue among engineers. Do a good job at that and it'll impress the boss.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 280, "passed_quality_check": "True", "flesch_reading_ease": 95.42534246575342, "entropy": 3.469710456977119}
Can I pass variables to a GNU Makefile as command line arguments? In other words, I want to pass some arguments which will eventually become variables in the Makefile.
null
[]
You have several options to set up variables from outside your makefile: * From environment - each environment variable is transformed into a makefile variable with the same name and value. You may also want to set ```-e``` option (aka ```--environments-override```) on, and your environment variables will override assignments made into makefile (unless these assignments themselves use the ```override``` directive . However, it's not recommended, and it's much better and flexible to use ```?=``` assignment (the conditional variable assignment operator, it only has an effect if the variable is not yet defined): ```FOO?=default_value_if_not_set_in_environment ``` Note that certain variables are not inherited from environment: * ```MAKE``` is gotten from name of the script * ```SHELL``` is either set within a makefile, or defaults to ```/bin/sh``` (rationale: commands are specified within the makefile, and they're shell-specific). * From command line - ```make``` can take variable assignments as part of his command line, mingled with targets: ```make target FOO=bar ``` But then all assignments to ```FOO``` variable within the makefile will be ignored unless you use the ```override``` directive in assignment. (The effect is the same as with ```-e``` option for environment variables). * Exporting from the parent Make - if you call Make from a Makefile, you usually shouldn't explicitly write variable assignments like this: ```# Don't do this! target: $(MAKE) -C target CC=$(CC) CFLAGS=$(CFLAGS) ``` Instead, better solution might be to export these variables. Exporting a variable makes it into the environment of every shell invocation, and Make calls from these commands pick these environment variable as specified above. ```# Do like this CFLAGS=-g export CFLAGS target: $(MAKE) -C target ``` You can also export all variables by using ```export``` without arguments.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 139, "passed_quality_check": "True", "flesch_reading_ease": 69.59336206896553, "entropy": 0.9271271823069669}
I have noticed that some games quote the requirement for "pixel shader 3.0 or better". What is a pixel shader and is it some software requirements or hardware requirements?
null
[]
Simple answer Pixel shaders are tiny programs that can do operations on a single pixel on the screen, as opposed to geometry shaders and vertex shaders which work on the geometrical primitives (triangles) that make up everything you see on the screen. The most common use for pixel shaders is 'shading', approximation to real world lighting. Commonly used shading model is Phong. Pixel shaders are executed on your video card, so your video card needs to support them. Each new version provides more capabilities, so an older video card will not run newer shaders. A new version of the pixel shader specification (e.g. Pixel Shader 3.0) is usually released for each new version of DirectX (more accurately, Direct3D). Software Requirements You need to have the correct version of Direct3D (or OpenGL) installed in order to use the shaders. For example, Pixel Shader 4.0 requires at least Direct3D 10. Normally you don't have to worry about this, every game that uses Direct3D will install the correct version for you when you install the game. The only exceptions are Direct3D 10 and later, which will not run on Windows XP or earlier. You will need at least Windows Vista in order to play a game that uses Direct3D 10 or 11. Wikipedia provides a nice list of Pixel Shader versions, the version of Direct3D you need, and the types of graphics cards that work with them. Technical answer The 'standard' stages of a 3D rendering pipeline are as follows (somewhat simplified): * Transformation (Moving, rotating and scaling all the objects in the scene) * Lighting * Projection ('Squashing' the 3D world into a 2D plane) * Clipping (Removing anything outside the field of view) * Rasterising (Converting the vector graphics (triangles, etc) into raster graphics (pixels)) * Texturing * Display Pixel Shaders are used as an alternative to the standard texturing phase. During rasterisation, each triangle is converted into pixels. These pixels do not have their final colour yet, but the do have a bunch of parameters associated with them. These include base colour, texture coordinates, lighting information, etc. The Pixel Shader is a small program that takes these parameters and uses them to calculate the final colour as it is displayed on the screen. The Pixel Shader has access to all texture data, and can use them to do interesting things such as blending two textures (to create a 'dirty' look), using a texture as a bump map (to simulate a relief), or to simulate reflections. Hardware On the hardware side, Pixel Shaders are executed on 'Shader Units', small processors on your GPU. Each Shader Unit is basically a very simple CPU, but a modern video card may contain thousands of these things (an AMD Radeon HD6990 contains over 3000). Older GPUs had different Shader Units for different tasks: Pixel Shaders were executed on different parts of the system than Vertex Shaders. Modern GPUs have so called 'unified shader units' which can perform all of these operations.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 145, "passed_quality_check": "True", "flesch_reading_ease": 78.81000000000003, "entropy": 0.9438471013377241}
Red light facing forwards? It was nighttime in Manhattan. Isn't more always better when it comes to being seen?
null
[]
No. You should always ride with a white light facing forward and a red light facing backwards. If you want additional illumination, you can add multiple white/red lights in the appropriate direction. Amber/yellow lights can be used facing any direction for additional visibility. The first reason is that it's the law: (a) Every bicycle when in use during the period from one-half hour after sunset to one-half hour before sunrise shall be equipped with a lamp on the front which shall emit a white light visible during hours of darkness from a distance of at least five hundred feet to the front and with a red or amber light visible to the rear for three hundred feet. Effective July first, nineteen hundred seventy-six, at least one of these lights shall be visible for two hundred feet from each side. More importantly for your safety though, the color of a light conveys a certain meaning. Drivers, pedestrians, and other cyclists associate the color red with a taillight and the color white with a headlight. If you put the wrong color facing the wrong direction, people may think you are traveling the opposite direction. Imagine a car is pulling out of a driveway and sees a red bike light flashing to their left. They may assume that means a bike is moving away from them on the left. If they then pull out of the driveway and you're really moving towards them, you could get hit.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 93, "passed_quality_check": "True", "flesch_reading_ease": 80.18561403508772, "entropy": 0.521861638720221}
If water is not a good conductor, why are we advised to avoid water near electricity (no wet hands near circuits etc.)?
null
[]
&quot;Pure&quot; water is a very poor conductor (resistivity is actually used as a measure of purity). &quot;Real&quot; water is not pure - it contains electrolytes and is quite conductive. Also - when your skin is wet, its resistivity is significantly lower. For example - &quot;pure&quot; water has a resistivity of (about) 18.2 M$\Omega\cdot\rm{cm}$. With 10 ppm of dissolved NaCl (&quot;very good quality tap water&quot; would have less than 50 ppm), the resistivity drops to about $43~\rm{k\Omega\cdot cm}$ A lot of detail can be found in &quot;Conduction of Electrical Current to and Through the Human Body: A Review&quot; (Fish and Geddes, ePlasty 2009, 9, e44). > Why immersion in water can be fatal with very low voltages * Immersion wets the skin very effectively and great lowers skin resistance per unit area * Contact area is a large percentage of the entire body surface area * Electric current may also enter the body through mucous membranes, such as the mouth and throat * The human body is very sensitive to electricity. Very small amounts of current can cause loss of ability to swim, respiratory arrest and cardiac arrest
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 98, "passed_quality_check": "True", "flesch_reading_ease": 69.14136363636365, "entropy": 0.6520766426693382}
What is the difference between cohesion and coupling? How can coupling and cohesion lead to either good or poor software design? What are some examples that outline the difference between the two, and their impact on overall code quality?
null
[]
Cohesion refers to what the class (or module) can do. Low cohesion would mean that the class does a great variety of actions - it is broad, unfocused on what it should do. High cohesion means that the class is focused on what it should be doing, i.e. only methods relating to the intention of the class. Example of Low Cohesion: ```------------------- | Staff | ------------------- | checkEmail() | | sendEmail() | | emailValidate() | | PrintLetter() | ------------------- ``` Example of High Cohesion: ```---------------------------- | Staff | ---------------------------- | -salary | | -emailAddr | ---------------------------- | setSalary(newSalary) | | getSalary() | | setEmailAddr(newEmail) | | getEmailAddr() | ---------------------------- ``` As for coupling, it refers to how related or dependent two classes/modules are toward each other. For low coupled classes, changing something major in one class should not affect the other. High coupling would make it difficult to change and maintain your code; since classes are closely knit together, making a change could require an entire system revamp. Good software design has ***high cohesion*** and ***low coupling***.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 202, "passed_quality_check": "True", "flesch_reading_ease": 75.3486991869919, "entropy": 1.090037727198707}
Can Romex (NM-B) cable be run through conduit?
null
[]
Yes, NM (Romex) cable can be in conduit. In fact, National Electrical Code (NEC() calls for it to be in conduit, when protection from physical damage is required. But it really isn't worth it. ## It's a nightmare to pull NM (Romex) is already solid wire except in the large sizes, and now you have 3-4 wires bound together. You are trying to pull this around maybe 14" radius elbows, and if the NM gets twists in it (it always does), it really drags in those places. It's just a stiff, miserable pull - enough to "put you off conduit forever" - which is a shame, because conduit is wonderful when using easy-to-pull stranded wire. Pulling this stiff cable increases the risk of damaging the cable. What's more, "cable in conduit" is often a newbie who chooses cable simply because he is unaware that wire comes in any other forms. Which leads to more risk of damage still. ## It requires ridiculously large conduit You still have to calculate and respect conduit fill rules, and those are very punishing toward cable. Most cable is oblong, and the rules say you use the largest dimension and treat it as a circular wire of that dimension. * For a single "wire", you are allowed 53% conduit fill. That means the conduit ID must be at least 137% of the large cross-section of the cable. That's not so bad, but... * For two "wires", you're only allowed 31% fill. That's to protect the wires from binding. That means the conduit ID must be at least 2.54 times the cable large dimension. * For three "wires", you're allowed 40% fill. That means the conduit must be at least 2.74 times the cable width (at 3 wires), larger for more wires. For instance, someone wanted to squeeze three #6 cables through a 1" conduit. Now this is "easy peasy" with 6 individual #6 THHN wires and 3 bare #10 grounds. However, with three #6 UF cables, the conduit size needed to be 3" instead of 1". Whoa. You are certainly allowed to do it, but you will be using rather enormous conduit, and you will have a hard time pulling.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 39, "passed_quality_check": "False", "flesch_reading_ease": 103.70000000000002, "entropy": 0.13846909895765722}
Let's say I have a function which takes an ```std::function```: ```void callFunction(std::function x) { x(); } ``` Should I pass ```x``` by const-reference instead?: ```void callFunction(const std::function& x) { x(); } ``` Does the answer to this question change depending on what the function does with it? For example if it is a class member function or constructor which stores or initializes the ```std::function``` into a member variable.
null
[]
If you want performance, pass by value if you are storing it. Suppose you have a function called "run this in the UI thread". ```std::future run_in_ui_thread( std::function ) ``` which runs some code in the "ui" thread, then signals the ```future``` when done. (Useful in UI frameworks where the UI thread is where you are supposed to mess with UI elements) We have two signatures we are considering: ```std::future run_in_ui_thread( std::function ) // (A) std::future run_in_ui_thread( std::function const& ) // (B) ``` Now, we are likely to use these as follows: ```run_in_ui_thread( [=]{ // code goes here } ).wait(); ``` which will create an anonymous closure (a lambda), construct a ```std::function``` out of it, pass it to the ```run_in_ui_thread``` function, then wait for it to finish running in the main thread. In case (A), the ```std::function``` is directly constructed from our lambda, which is then used within the ```run_in_ui_thread```. The lambda is ```move```d into the ```std::function```, so any movable state is efficiently carried into it. In the second case, a temporary ```std::function``` is created, the lambda is ```move```d into it, then that temporary ```std::function``` is used by reference within the ```run_in_ui_thread```. So far, so good -- the two of them perform identically. Except the ```run_in_ui_thread``` is going to make a copy of its function argument to send to the ui thread to execute! (it will return before it is done with it, so it cannot just use a reference to it). For case (A), we simply ```move``` the ```std::function``` into its long-term storage. In case (B), we are forced to copy the ```std::function```. That store makes passing by value more optimal. If there is any possibility you are storing a copy of the ```std::function```, pass by value. Otherwise, either way is roughly equivalent: the only downside to by-value is if you are taking the same bulky ```std::function``` and having one sub method after another use it. Barring that, a ```move``` will be as efficient as a ```const&```. Now, there are some other differences between the two that mostly kick in if we have persistent state within the ```std::function```. Assume that the ```std::function``` stores some object with a ```operator() const```, but it also has some ```mutable``` data members which it modifies (how rude!). In the ```std::function const&``` case, the ```mutable``` data members modified will propagate out of the function call. In the ```std::function``` case, they won't. This is a relatively strange corner case. You want to treat ```std::function``` like you would any other possibly heavy-weight, cheaply movable type. Moving is cheap, copying can be expensive.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 389, "passed_quality_check": "False", "flesch_reading_ease": 43.16464285714288, "entropy": 1.847317092853382}
I have an Eloquent model which has a related model: ```public function option() { return $this->hasOne('RepairOption', 'repair_item_id'); } public function setOptionArrayAttribute($values) { $this->option->update($values); } ``` When I create the model, it does not necessarily have a related model. When I update it, I might add an option, or not. So I need to check if the related model exists, to either update it, or create it, respectively: ```$model = RepairItem::find($id); if (Input::has('option')) { if () { $option = new RepairOption(Input::get('option')); $option->repairItem()->associate($model); $option->save(); $model->fill(Input::except('option'); } else { $model->update(Input::all()); } }; ``` Where `````` is the code I am looking for.
null
[]
A Relation object passes unknown method calls through to an Eloquent query Builder, which is set up to only select the related objects. That Builder in turn passes unknown method calls through to its underlying query Builder. This means you can use the ```exists()``` or ```count()``` methods directly from a relation object: ```$model->relation()->exists(); // bool: true if there is at least one row $model->relation()->count(); // int: number of related rows ``` Note the parentheses after ```relation```: ```->relation()``` is a function call (getting the relation object), as opposed to ```->relation``` which a magic property getter set up for you by Laravel (getting the related object/objects). Using the ```count``` method on the relation object (that is, using the parentheses) will be much faster than doing ```$model->relation->count()``` or ```count($model->relation)``` (unless the relation has already been eager-loaded) since it runs a count query rather than pulling all of the data for any related objects from the database, just to count them. Likewise, using ```exists``` doesn't need to pull model data either. Both ```exists()``` and ```count()``` work on all relation types I've tried, so at least ```belongsTo```, ```hasOne```, ```hasMany```, and ```belongsToMany```.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 679, "passed_quality_check": "False", "flesch_reading_ease": 47.59826923076926, "entropy": 3.8775569588525896}
NASA is hiring a new 'planetary protection officer' to defend Earth from alien matter, and the pay is a six-figure salary: as much as $187,000 a year. When we are not sure whether aliens exist, why are we still hiring staff for protecting Earth? I do understand we have to take precautions. But when we don't have any proof why spend $187,000 a year? Source: Nasa [sic] hiring new 'planetary protection officer' to defend Earth from alien matter - Times of India, Aug 3, 2017
null
[]
You're observing shamefully bad journalism. The &quot;protect Earth from aliens&quot; bullet point in the &quot;Highlights&quot; section of the article was put there by an editor who either ignorantly or willfully distorted the actual role of the Planetary Protection Officer. The first paragraph of the story gets a little closer: The full-time role of &quot;planetary protection officer&quot; will involve ensuring that humans in space do not contaminate planets and moons, as well as ensuring that alien matter does not infect Earth. &quot;Planetary Protection Officer&quot; isn't a new position; the current one is retiring. The primary focus of the planetary protection office is sterilizing probes that are going to other planets and moons. This is done both to preserve any existing life elsewhere in the solar system from Terran competition, and so that if and when we find life on other bodies, we will know we didn't bring it ourselves. Preventing microbes from other worlds reaching Earth is also a concern, for similar reasons. Developing and implementing the policies of the planetary protection office is a complex job requiring a broad array of both technical and human skills, and so a $187K salary is not remarkable for it: Candidates will be required to travel frequently — but like any job, there will be a significant amount of emails, proposals and other reading. Candidates must have at least one year's experience as a top-level civilian government employee, and an advanced degree in physical science, engineering or mathematics. They must also have &quot;advanced knowledge&quot; of planetary protection. The position also requires &quot;demonstrated skills in diplomacy that resulted in win-win solutions during extremely difficult and complex multilateral discussions&quot;. The new hire will also receive &quot;secret&quot; security clearance. Only US citizens and US nationals can apply.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 393, "passed_quality_check": "False", "flesch_reading_ease": 75.65114606741574, "entropy": 2.436935664404549}
Traditional advice for making megadungeons in older versions of D&D is in addition to any rooms with Monsters, Treasure, Traps, or "Tricks", there should also be at least 50 to 60 percent "Empty" rooms, which contain nothing overtly threatening or valuable. Now, there's several arguments for including these empty rooms that I buy, so I'm not going to accept any answer which primarily says, "Don't include empty rooms". The main issue I run into with empty rooms, however, is that they're boring in the way that I've been including them. They don't do their job of increasing tension, and the set dressing included around them hasn't been sufficiently interesting to my players either. My question is this: How can I make empty rooms interesting, by increasing tension or simply being interesting in and of themselves?
null
[]
By definition, nothing's going to happen in an empty room (though see below). There are no hidden doors to find, no puzzles to solve, no enemies to fight. So what's their purpose? ## Bringing the dungeon to life While all the orcs may sit around in a guard room waiting for PCs to show up, where do they sleep, what do they eat, what happens to their trash? Think of a dungeon not just as a place to have fights in, but as an actual place that serves a purpose. Once you do, the dungeon will start making sense. &quot;Empty&quot; rooms will increase immersion for the players, and force you to consider things you may not have otherwise. Should there be a pet otyugh that eats the trash? Are the orcs demanding cows from the local farmers for &quot;protection&quot;? Do they keep a famed halfling cook enslaved, to make them rare steaks? ## Foreshadowing Once the dungeon makes sense, you can use that to place clues for things that dwell deeper within. Has a horde of zombies marched through to guard the necromancer's abode within, and left a few rotten body parts here and there? Has a malevolent force been summoned and spoiled all the meat and milk in the dungeon? Is there a golem maintenance station, with oil to grease them, rags to polish them, and a mad goblin mechanic? These may be vital clues PCs need to prepare for a tough fight, or they can simply let them form theories and feel smart about being right once they do come upon a golem or three. #Currently empty These rooms are empty now, but they don't have to stay that way. PCs may choose to fortify a room and bring the enemy to them - such tactical choices could be an important part of dungeoncrawling. Orcs may chase PCs through the dungeon, or randomly come across them in a kitchen because they were feeling peckish. Note that some of these ideas would introduce creatures or things into rooms that PCs may choose to interact with, which would make them non-empty. In a way that's fine: you started with an empty room but found something interesting to put inside after all. If that's not your intention, well, don't put goblins or halflings or otyughs in. Stick to body parts and greasy pots and shadowy portraits and bloodstains and scent of brimstone and fresh flowers and broken mirrors and... Tell a story with your empty rooms, or offer tactical choices. Preferably both.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 686, "passed_quality_check": "True", "flesch_reading_ease": 59.32591366906476, "entropy": 4.8991687245434825}
Laravel - Eloquent "Has", "With", "WhereHas" - What do they mean? explain in the context of an example
null
[]
With ```with()``` is for eager loading. That basically means, along the main model, Laravel will preload the relationship(s) you specify. This is especially helpful if you have a collection of models and you want to load a relation for all of them. Because with eager loading you run only one additional DB query instead of one for every model in the collection. Example: ```User > hasMany > Post``` ```$users = User::with('posts')->get(); foreach($users as $user){ $users->posts; // posts is already loaded and no additional DB query is run } ``` Has ```has()``` is to filter the selecting model based on a relationship. So it acts very similarly to a normal WHERE condition. If you just use ```has('relation')``` that means you only want to get the models that have at least one related model in this relation. Example: ```User > hasMany > Post``` ```$users = User::has('posts')->get(); // only users that have at least one post are contained in the collection ``` WhereHas ```whereHas()``` works basically the same as ```has()``` but allows you to specify additional filters for the related model to check. Example: ```User > hasMany > Post``` ```$users = User::whereHas('posts', function($q){ $q->where('created_at', '>=', '2015-01-01 00:00:00'); })->get(); // only users that have posts from 2015 on forward are returned ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 85, "passed_quality_check": "False", "flesch_reading_ease": 82.39000000000001, "entropy": 0.7808049474602257}
What are some of the advantages of using one over the other?
null
[]
ASP.NET Web Forms and MVC are two web frameworks developed by Microsoft - they are both good choices. Neither of the web frameworks are to be replaced by the other nor are there plans to have them 'merged' into a single framework. Continued support and development are done in parallel by Microsoft and neither will be 'going away'. Each of these web frameworks offers advantages/disadvantages - some of which need to be considered when developing a web application. A web application can be developed using either technology - it might make development for a particular application easier selecting one technology versus the other and vice versa. ASP.NET Web Forms: * Development supports state • Gives the illusion that a web application is aware of what the user has been doing, similar to Windows applications. I.e. Makes 'wizard' functionality a little bit easier to implement. Web forms does a great job at hiding a lot of that complexity from the developer. * Rapid Application Development (RAD) • The ability to just 'jump in' and start delivering web forms. This is disputed by some of the MVC community, but pushed by Microsoft. In the end, it comes down to the level of expertise of the developer and what they are comfortable with. The web forms model probably has less of a learning curve to less experienced developers. * Larger control toolbox • ASP.NET Web Forms offers a much greater and more robust toolbox (web controls) whereas MVC offers a more primitive control set relying more on rich client-side controls via jQuery (Javascript). * Mature • It's been around since 2002 and there is an abundance of information with regards to questions, problems, etc. Offers more third-party control - need to consider your existing toolkits. ASP.NET MVC: * Separation of concerns (SoC) • From a technical standpoint, the organization of code within MVC is very clean, organized and granular, making it easier (hopefully) for a web application to scale in terms of functionality. Promotes great design from a development standpoint. * Easier integration with client side tools (rich user interface tools) • More than ever, web applications are increasingly becoming as rich as the applications you see on your desktops. With MVC, it gives you the ability to integrate with such toolkits (such as jQuery) with greater ease and more seamless than in Web Forms. * Search Engine Optimization (SEO) Friendly / Stateless • URL's are more friendly to search engines (i.e. mywebapplication.com/users/ 1 - retrieve user with an ID of 1 vs mywebapplication/users/getuser.aspx (id passed in session)). Similarly, since MVC is stateless, this removes the headache of users who spawn multiple web browsers from the same window (session collisions). Along those same lines, MVC adheres to the stateless web protocol rather than 'battling' against it. * Works well with developers who need high degree of control • Many controls in ASP.NET web forms automatically generate much of the raw HTML you see when an page is rendered. This can cause headaches for developers. With MVC, it lends itself better towards having complete control with what is rendered and there are no surprises. Even more important, is that the HTML forms typically are much smaller than the Web forms which can equate to a performance boost - something to seriously consider. * Test Driven Development (TDD) • With MVC, you can more easily create tests for the web side of things. An additional layer of testing will provide yet another layer of defense against unexpected behavior. Authentication, authorization, configuration, compilation and deployment are all features that are shared between the two web frameworks.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 49, "passed_quality_check": "True", "flesch_reading_ease": 81.85500000000002, "entropy": 0.43452272303753114}
What factors determine the maximum altitude for a plane? Is it limited by wing design, engine thrust, and so on? Is there a formula by which one can calculate the maximum altitude a plane can reach?
null
[]
The higher you get, the lower the density of the air becomes. This lower density results in a lower lift being generated for the same airspeed and angle of attack. Effectively, the higher you fly the higher your minimum speed becomes. So while climbing, your speed needs to increase to compensate for the lower air density. As long a you can fly faster, the lower density at altitude can be compensated for. Basically there are two things that limit your maximum speed: thrust and speed of sound and with that your maximum altitude. First is thrust; the higher you get, the lower the thrust your engines deliver. You might note that drag goes down with the air density as well but since you are flying faster and faster during the climb the drag doesn't decrease at all. If your maximum altitude is limited by thrust then at some point during the climb the thrust and drag are getting close to equal and that is where the climb stops. When you can no longer climb with more than 100ft per minute (for propeller aircraft) or 500ft per minute (for jet / turbofan aircraft) you have reached your service ceiling. If the aircraft maximum altitude is determined by thrust, the absolute ceiling will take very long to reach. At high altitudes air breathing engines will get difficulties eventually. Due to the lower air density the mass flow through the engine is reduced up to a point where it causes a flame out. The other limitation is the speed of sound, at least for subsonic aircraft. In the process of generating lift, air flowing over the top of the wing is accelerated. At one point, when the aircraft is still flying below the speed of sound, shock waves will start to form over the wing. This results in increase of drag and reduces the lift. So provided you have enough engine power at your disposal you can climb to an altitude where your minimum speed is also your maximum speed. This is called the coffin corner. In the coffin corner: * if you fly any faster, you will exceed the maximum Mach number ($M_{mo}$) of your aircraft, resulting in high speed buffet, vibrations and possible loss of control. * if you fly any slower, the maximum lift that the wing can provide will be insufficient to maintain altitude. Descent or the aircraft will stall. * if you fly any higher and you will be too fast and too slow at the same time. * if you turn, you increase the wing loading, thereby increasing the minimum speed needed to create the required lift. Also the outer wing will easily exceed the maximum speed while at the same time the inner wing is below stall speed. This can quickly develop into a spin. Since accurate knowledge of engine performance, drag and wing characteristics of the aircraft is needed, there is not a simple formula to derive the maximum altitude for an aircraft. Apart from the aircraft performance related limitations above there is a certified maximum operating altitude for the pressurized cabin. This takes into account the structural properties of the hull (pressure difference between inside and outside) and the achievable emergency descent rate in case of a depressurization event.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 165, "passed_quality_check": "True", "flesch_reading_ease": 80.43622807017547, "entropy": 1.0927852025920772}
Why did the Typescript folks create the ```infer``` keyword? According to the documents, this is an example of how you would use it: ```type ReturnType = T extends (...args: any[]) => infer R ? R : any; ``` I don't understand why this is needed. Why can't it just be: ```type ReturnType = T extends (...args: any[]) => R ? R : any; ``` Why doesn't this work? Why is the ```infer``` keyword necessary ?
null
[]
With ```infer```, the compiler ensures that you have declared all type variables explicitly: ```type MyType = T extends infer R ? R : never; type T1 = MyType // T1 is { b: string; } ``` Here we declare a new type variable ```R``` in ```MyType```, which gets inferred from ```T```. (Note, that ```infer``` is always used within the ```extends``` clause of a conditional type.) Usage of undeclared type parameters now can result in a compile error: ```type MyType2 = T extends R2 ? R2 : never; // error, R2 undeclared ``` Without ```infer```, the compiler wouldn't know, if you wanted to introduce an additional type variable ```R2``` that is to be inferred (see first case), or if ```R2``` is just an accidental typing error/typo. ```infer``` exists to remove this ambiguity. More precisely the compiler checks, if ```T``` is assignable to ```R``` , when ```infer``` is omitted: ```type R = { a: number } type MyType3 = T extends R ? R : never; // compare T with type R type T3 = MyType3 // T3 is never ``` Note, that ```infer R``` shadows type references of an equally-named type declaration ```R```: ```type R = { a: number } type MyType4 = T extends infer R ? R : never; type T4 = MyType4 // { b: string; } ```
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 334, "passed_quality_check": "False", "flesch_reading_ease": 89.23431518151817, "entropy": 2.1820045043605445}
Which is more widely supported: ```window.onload``` or ```document.onload```?
null
[]
When do they fire? ```window.onload``` * By default, it is fired when the entire page loads, including its content (images, CSS, scripts, etc.). In some browsers it now takes over the role of ```document.onload``` and fires when the DOM is ready as well. ```document.onload``` * It is called when the DOM is ready which can be prior to images and other external content is loaded. How well are they supported? ```window.onload``` appears to be the most widely supported. In fact, some of the most modern browsers have in a sense replaced ```document.onload``` with ```window.onload```. Browser support issues are most likely the reason why many people are starting to use libraries such as jQuery to handle the checking for the document being ready, like so: ```$(document).ready(function() { /* code here */ }); $(function() { /* code here */ }); ``` For the purpose of history. ```window.onload``` vs ```body.onload```: A similar question was asked on codingforums a while back regarding the usage of ```window.onload``` over ```body.onload```. The result seemed to be that you should use ```window.onload``` because it is good to separate your structure from the action.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 70, "passed_quality_check": "False", "flesch_reading_ease": 72.32500000000003, "entropy": 0.135811090598515}
I was surprised to learn that Puerto Ricans, despite living in a US territory, were not entitled to vote in the presidential elections. I was even more surprised to learn that US citizens are allowed to vote for president from anywhere in the world - EXCEPT if they happen to live in Puerto Rico. What is the legal/political rationale behind this? What is it about Puerto Rico that magically removes one's right to vote? Has anyone ever challenged this?
null
[]
This is a peculiarity as a result of the federal nature of the USA and the exceptional position of Puerto Rico as a territory but not a state. Within the States and Territories of the USA, your voting rights depend on residence. If you leave the States and Territories your voting rights depend on former residence or inheritance. In general most citizens of the USA are also citizens of a state of the USA. Since states don't issue their own passports, your citizenship of a state is determined by residence. If a New Yorker moves to Florida, they become Floridians, and so can vote in state elections in Florida, but can't now vote in elections in New York. Now if our New Yorker moves to Timbuktu, this is treated slightly differently. They remain a US citizen and a citizen of New York, and so retain the right to vote in New York elections. Their children could also claim New York citizenship. But Puerto Rico is both part of the USA but not a State or part of a State of the USA. When our New Yorker moves to Puerto Rico, they can vote in Puerto Rican elections but not elections in New York. Now the nature of elections in the US is that there are no national elections There are statewide elections of Senators, Governors and Presidential electors. There are district elections of Representatives and there are local elections of many kinds. Our New Yorker has lost the right to vote in New York elections (just as they would have done if they had moved to Florida) but not gained the right to vote in Puerto Rican elections for Presidential electors (because there are none). This is odd, but something similar is true if the New Yorker moves to DC. They cease to have the right to vote in elections to the Senate.
{ "type": null, "score": null, "agent": null }
null
{"n_characters": 377, "passed_quality_check": "True", "flesch_reading_ease": 72.36977777777778, "entropy": 2.5937398330064405}