message
stringlengths 2
17.7k
| message_type
stringclasses 2
values | message_id
int64 0
19
| conversation_id
int64 0
1.03k
|
---|---|---|---|
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?
|
instruction
| 0 | 100 |
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.
|
output
| 1 | 100 |
What does strength refer to in mathematics? Is it a formal idea?
|
instruction
| 0 | 101 |
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.
|
output
| 1 | 101 |
Does vegetarianism affect life expectancy?
Is an average vegetarian supposed to live longer just because of their diet?
|
instruction
| 0 | 102 |
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)
|
output
| 1 | 102 |
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?
|
instruction
| 0 | 103 |
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.
|
output
| 1 | 103 |
I've rooted my phone. Now what? What do I gain from rooting?
|
instruction
| 0 | 104 |
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.
|
output
| 1 | 104 |
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.
|
instruction
| 0 | 105 |
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
```
|
output
| 1 | 105 |
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)?
|
instruction
| 0 | 106 |
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.
|
output
| 1 | 106 |
Why isn't Sectumsempra an Unforgivable Curse?
|
instruction
| 0 | 107 |
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.
|
output
| 1 | 107 |
How can I add a delay to a program in C#?
|
instruction
| 0 | 108 |
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.
|
output
| 1 | 108 |
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```.
|
instruction
| 0 | 109 |
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).
|
output
| 1 | 109 |
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?
|
instruction
| 0 | 110 |
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
|
output
| 1 | 110 |
Reasons for being vegetarian or vegan other than ethical reasons?
|
instruction
| 0 | 111 |
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)
|
output
| 1 | 111 |
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?
|
instruction
| 0 | 112 |
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.
|
output
| 1 | 112 |
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?
|
instruction
| 0 | 113 |
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.
|
output
| 1 | 113 |
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'));
});
```
|
instruction
| 0 | 114 |
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.
|
output
| 1 | 114 |
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?
|
instruction
| 0 | 115 |
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.
|
output
| 1 | 115 |
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/```
|
instruction
| 0 | 116 |
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
```
|
output
| 1 | 116 |
Did Aztecs know how many continents there are on earth?
|
instruction
| 0 | 117 |
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.
|
output
| 1 | 117 |
What did the Soviet Union and Russia bring to the ISS?
|
instruction
| 0 | 118 |
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.
|
output
| 1 | 118 |
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.
|
instruction
| 0 | 119 |
## 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.
|
output
| 1 | 119 |
What's the difference between ASCII and Unicode?
|
instruction
| 0 | 120 |
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.
|
output
| 1 | 120 |
Reasons why healthy people would intentionally want to get infected?
|
instruction
| 0 | 121 |
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.
|
output
| 1 | 121 |
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?
|
instruction
| 0 | 122 |
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
|
output
| 1 | 122 |
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?.
|
instruction
| 0 | 123 |
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.
|
output
| 1 | 123 |
How do I add Git submodule to a sub-directory?
|
instruction
| 0 | 124 |
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.
|
output
| 1 | 124 |
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?
|
instruction
| 0 | 125 |
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.
|
output
| 1 | 125 |
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?
|
instruction
| 0 | 126 |
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.
|
output
| 1 | 126 |
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 "call" your hand determines the winner:
For example, you have an Ace, King, Queen, Jack, and Ten. You call your hand and say, "I have a Straight!"
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?
|
instruction
| 0 | 127 |
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.
|
output
| 1 | 127 |
How to get the first item from an associative PHP array?
|
instruction
| 0 | 128 |
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 = "Array is empty"; // An error should be handled here
} else {
$value = $array[$firstKey];
}
```
|
output
| 1 | 128 |
Why do people write #!/usr/bin/env python on the first line of a Python script?
|
instruction
| 0 | 129 |
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 "grawity,"
> 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.)
|
output
| 1 | 129 |
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?
|
instruction
| 0 | 130 |
> 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.
|
output
| 1 | 130 |
Why is it "behead" and not "dehead"?
|
instruction
| 0 | 131 |
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.
|
output
| 1 | 131 |
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.
|
instruction
| 0 | 132 |
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.
|
output
| 1 | 132 |
Why isn't the market dropping like a stone with all the bad news?
|
instruction
| 0 | 133 |
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.
|
output
| 1 | 133 |
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?
|
instruction
| 0 | 134 |
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
|
output
| 1 | 134 |
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?
|
instruction
| 0 | 135 |
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.
|
output
| 1 | 135 |
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?
|
instruction
| 0 | 136 |
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.
|
output
| 1 | 136 |
What command do I use to find the size of all the files (recursively) in a Linux or Mac OS X directory?
|
instruction
| 0 | 137 |
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.
|
output
| 1 | 137 |
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);
```
|
instruction
| 0 | 138 |
## 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.
|
output
| 1 | 138 |
Why don't toilets use saltwater?
|
instruction
| 0 | 139 |
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 "half flush", 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.
|
output
| 1 | 139 |
How do I modify fields inside the new PostgreSQL JSON datatype?
|
instruction
| 0 | 140 |
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.
|
output
| 1 | 140 |
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?
|
instruction
| 0 | 141 |
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.
|
output
| 1 | 141 |
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?
|
instruction
| 0 | 142 |
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)
}
```
|
output
| 1 | 142 |
While in Phd I developed a lot of code that I want to turn into start-up. Can I do this?
|
instruction
| 0 | 143 |
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.
|
output
| 1 | 143 |
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?
|
instruction
| 0 | 144 |
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.
|
output
| 1 | 144 |
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?
|
instruction
| 0 | 145 |
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.
|
output
| 1 | 145 |
Why does "elite" rhyme with "beet" rather than "bite"?
|
instruction
| 0 | 146 |
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 "light" and "might" and "site" 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.
"Elite" 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 "elite" in around 1400, with the meaning of a "bishop elect". This sense of the word died out and is now marked as archaic. So when "elite" 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.
|
output
| 1 | 146 |
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?
|
instruction
| 0 | 147 |
## 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.
|
output
| 1 | 147 |
Is martial arts training 'inadequate' for the real world?
|
instruction
| 0 | 148 |
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.
|
output
| 1 | 148 |
Make a single page landscape in Google Documents
|
instruction
| 0 | 149 |
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.
|
output
| 1 | 149 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.