instruction stringlengths 17 7.84k | response stringlengths 15 13.7k |
|---|---|
Reasons why healthy people would intentionally want to get infected? | 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. ... |
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 ... |
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.
... |
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?. | 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 defau... |
How do I add Git submodule to a sub-directory? | 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. |
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? | 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 p... |
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/bac... | 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 plugg... |
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 Straigh... | 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... |
How to get the first item from an associative PHP array? | 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);
```
T... |
Why do people write #!/usr/bin/env python on the first line of a Python script? | 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 sc... |
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 engin... | > 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... |
Why is it "behead" and not "dehead"? | 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 product... |
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. | 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 i... |
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 free... | 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 y... |
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? | 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 ... |
What command do I use to find the size of all the files (recursively) in a Linux or Mac OS X directory? | 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 wi... |
Why don't toilets use saltwater? | 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 ... |
How do I modify fields inside the new PostgreSQL JSON datatype? | 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 ... |
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] atScrollPositio... | 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)
se... |
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? | 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 sme... |
Why does "elite" rhyme with "beet" rather than "bite"? | 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 Vow... |
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 advantage... | ## 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). I... |
Is martial arts training 'inadequate' for the real world? | 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, arti... |
Make a single page landscape in Google Documents | 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 Go... |
PHP is writing this error in the logs: "Notice: Use of undefined constant".
Error in logs:
```PHP Notice: Use of undefined constant department - assumed 'department' (line 5)
PHP Notice: Use of undefined constant name - assumed 'name' (line 6)
PHP Notice: Use of undefined constant email - assumed 'email' (line 7)
PH... | The error message is due to the unfortunate fact that PHP will implicitly declare an unknown token as a constant string of the same name.
That is, it's trying to interpret this (note the missing quote marks):
```$_POST[department]
```
The only valid way this would be valid syntax in PHP is if there was previously a co... |
I'm from a very rural area and love to garden, however, for work I just moved into an apartment in the city. I miss being able to grow vegetables and so I attempted to start some leaf lettuce indoors, however, almost every plant died quickly. I'm just curious, does anyone have experience growing vegetables indoors? Wha... | Indoor gardening is a bit more difficult then the regular outdoor gardening, there are several factors but in most cases it boils down to: Temperature, Humidity, Light, The air in your apartment.
You didn't mention exactly where your dying plants are being placed. Do you have a fan within the apartment? Plants need ... |
What are the advantages of studying words by their frequency? | The main advantage is that by learning higher frequency words, you get a greater "bang for your buck" - that is, if you know the most frequent words of the language, you'll be able to understand more of the words you encounter, and therefore you gain the greatest benefit by studying those frequent words first.
Accordin... |
I have heard many people saying, “Hah! I beat Stockfish,” and one saying, “I am the best chess player ever! I beat Stockfish.” So I wonder if it is possible, just to know whether I should try to beat it. I tried to play it once; I barely played 25 moves. | The answer is that they either played it on some very handicapped mode, they took back A LOT of moves, or they are probably lying.
Stockfish 11 is currently rated about 3607, and that is in standard chess. Computer programs are typically even HARDER to beat for humans at even faster controls.
There is a reason elite ... |
How to decrypt Jenkins passwords from credentials.xml? | There is a `hudson.util.Secret.decrypt()` function which can be used for this, so:
1. In Jenkins, go to: `/script` page.
2. Run the following command:
```println(hudson.util.Secret.decrypt("{XXX=}"))
```
or
```
println(hudson.util.Secret.fromString("{XXX=}").getPlainText())
```
where `{XXX=}` is your encrypted passwor... |
Other than rust, corrosion, and other reactions with air that would make the use of a metal unfavorable, how do different metals affect the performance?
Let's give Yagi an example:
Let's say I use 4 different metals for the directors
, reflector, and driven element.
One antenna made out of copper, one made out of alumi... | Considering just electrical properties, the most significant parameter for your selection of antenna conductor is resistance. You want to keep the resistance to a minimum, because when current flows through a resistance, the electrical power is converted to heat, according to Joule heating:
$$ P = I^2 R $$
Any energy y... |
Windows in its earliest days was simply a shell that ran on top of MS-DOS, which means that Windows 3.1 itself was actually just a standard MS-DOS application like any other.
Yet, MS-DOS is not a multitasking operating system, and at the same time, Windows applications were compiled native-code binaries that ran withou... | For Win16 programs, Windows implemented co-operative multitasking. Its implementation was based upon the "message loop" architecture of every Windows program.
The duty of every program was to endlessly run in a loop in which a call to the ```GetMessage``` function was performed. This function call looks whet... |
I'm working on 2 different branches: release and development.
I noticed I still need to integrate some changes that were committed to the release branch back into the development branch.
The problem is I don't need all of the commit, only some hunks in certain files, so a simple
```git cherry-pick bc66559
```
does... | The core thing you're going to want here is ```git add -p``` (```-p``` is a synonym for ```--patch```). This provides an interactive way to add in content, letting you decide whether each hunk should go in or not, and even letting you manually edit the patch if necessary.
To use it in combination with cherry-pick:
```g... |
In Civilization V, you attain a cultural victory by accumulating enough culture to purchase at least 36 social policies, and then building a wonder. The catch is that the more cities you build, the more culture you need to generate before you hit the next "plateau" of culture.
What is the ideal number of cities for a c... | The question you're really asking is "When does the combined culture / turn of an additional city outstrip the increase in social policy cost incurred by founding that city?"
The short answer is...
We know that adding another city increases the culture costs by approximately 30% of the base cost (that of 1 ci... |
I'm looking for a precise piece of information in a database which I have no knowledge about. The database is on a separate machine, but I can log into it, and launch a ```psql``` command line, with administrator rights.
It's a third-party product, and they are slow to answer questions. I know the data is inside that d... | The information schema is the slow and sure way: it is standardized and largely portable to other databases that support it. And it will keep working across major versions.
However, views in the information schema often join many tables from the system catalogs to meet a strictly standardized format - many of which are... |
I am using Visual Studio Code and have a fairly common project structure:
```├── client/
│ ├── tsconfig.json
├── shared/
├── server/
│ ├── tsconfig.json
├── project.json
```
The two tsconfig files have different settings (e.g. the one under ```client/``` targets ES5, the one under ```server/``` targets ES6). Note t... | These days it is much easier as vscode has better support for this.
You can use this directory structure so all the code is independent:
```├── frontend/
│ ├── src/
│ │ ├──
│ ├── package.json
│ ├── tsconfig.json
├── shared/
│ ├── package.json
├── backend/
│ ├── src/
│ │ ├──
│ ├── package.json
│ ... |
I have a problem with the embedded bitcode term.
What is embedded bitcode?
When to enable, ```ENABLE_BITCODE``` in new Xcode?
What happens to the binary when enabled, ```ENABLE_BITCODE``` in Xcode 7? | > What is embedded bitcode?
According to docs:
> Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to subm... |
In Dupire's local volatility model, the volatility is is a deterministic function of the underlying price and time, chosen to match observed European option prices.
To be more specific, given a smooth surface $(K,T)\mapsto C(K,T)$ where K is the strike and T is time to maturity. Dupire equation implies that there exits... | A general model (with continuous paths) can be written
$$
\frac{dS_t}{S_t} = r_t dt + \sigma_t dW_t^S
$$
where the short rate $r_t$ and spot volatility $\sigma_t$ are stochastic processes.
In the Black-Scholes model both $r$ and $\sigma$ are deterministic functions of time (even constant in the original model). This... |
Can you explain why we need a large number of trees in random forest when the number of predictors is large? How can we determine the optimal number of trees? | Random forest uses bagging (picking a sample of observations rather than all of them) and random subspace method (picking a sample of features rather than all of them, in other words - attribute bagging) to grow a tree. If the number of observations is large, but the number of trees is too small, then some observations... |
I believe artificial intelligence (AI) term is overused nowadays. For example, people see that something is self-moving and they call it AI, even if it's on autopilot (like cars or planes) or there is some simple algorithm behind it.
What are the minimum general requirements so that we can say something is AI? | It's true that the term has become a buzzword, and is now widely used to a point of confusion - however if you look at the definition provided by Stuart Russell and Peter Norvig, they write it as follows:
> We define AI as the study of agents that receive percepts from the environment and perform actions. Each such ag... |
I have some questions regarding the usage and significance of the ```synchronized``` keyword.
* What is the significance of the ```synchronized``` keyword?
* When should methods be ```synchronized```?
* What does it mean programmatically and logically? | The ```synchronized``` keyword is all about different threads reading and writing to the same variables, objects and resources. This is not a trivial topic in Java, but here is a quote from Sun:
> ```synchronized``` methods enable a simple strategy for preventing thread interference and memory consistency errors: if a... |
I am using the ```$http``` service of AngularJS to make an Ajax request.
How can a spinner GIF (or another type of busy indicator) be shown while the Ajax request is executing? | This really depends on your specific use case, but a simple way would follow a pattern like this:
```
.controller('MainCtrl', function ( $scope, myService ) {
$scope.loading = true;
myService.get().then( function ( response ) {
$scope.items = response.data;
}, function ( response ) {
// TODO: handle the ... |
Once, I boarded a plane, went to my designated seat and tried to put my bag in the overhead bin. However, it was full, and other adjacent overhead bins were full too. Because I had a seat next to the emergency exit, which I paid for, I had to hand over my bag to someone else in order to take off.
Do I have any rights ... | You have no right to the bin above your seat. For those exit rows where you cannot put anything beneath the seat in front of you, flight attendants will generally try to help find some space somewhere for at least your small personal item, but any passenger may be required to check their bags rather than put them in th... |
The Canon EF 40mm f/2.8 has a designation of STM on the lens. What does this mean? What are the advantages of having it and does it replace an older technology?
| STM stands for Stepper Motor and is a applied to a new range of Canon lenses which feature a new design of focus motors which, along with a new iris mechanism are designed to eliminate (auditory) noise during video recording.
Canon haven't revealed any information about how the new design works but it's probably the s... |
I'm trying to set get id of all elements in an ```HTMLCollectionOf```. I wrote the following code:
```var list = document.getElementsByClassName("events");
console.log(list[0].id);
for (key in list) {
console.log(key.id);
}
```
But I got the following output in console:
```event1
undefined
```
which is not what I e... | You can't use ```for```/```in``` on ```NodeList```s or ```HTMLCollection```s. However, you can use some ```Array.prototype``` methods, as long as you ```.call()``` them and pass in the ```NodeList``` or ```HTMLCollection``` as ```this```.
So consider the following as an alternative to jfriend00's ```for``` loop:
```var... |
I am 21 years old and living in a large city in Germany where smalltalk in local markets is not a common thing.
A new cashier joined my local food shop. She’s always at the checkout and never doing stuff like sorting products or cleaning the floor where I could actually ask her out. I am quite new to relationships, but... | Asking her out directly seems like a bad idea.
Instead, in these situations, I've found something that works much better for both of you. During your conversation with her, mention some place you're planning to be in the future so she can find you there if she chooses.
For example: "I like to grab lunch here befor... |
You start with the number 1536. Your mission is to get to 1 in as few steps as possible. At each step, you may either multiply or divide the number you have, by either 2 or 3; but, only if the result is a whole number whose first digit is 1, 3, 4, or 9. That is all. | As Jo has already shown, this can be accomplished in
28 steps. This is minimal, and it can be proven.
To help visualize this problem, we can imagine:
A two-dimensional grid/chart where each point is a number of the form $3^x2^y$, with $(x,y)$ as the relevant co-ordinates. We want to find a path from $(1,9)... |
I want to create a simple bit of JS code that creates an image element in the background and doesn't display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 = ```var oImg = document.createElement("img"); oImg.setAttribute('src', 'http://www.test... | ```oImg.setAttribute('width', '1px');
```
```px``` is for CSS only. Use either:
```oImg.width = '1';
```
to set a width through HTML, or:
```oImg.style.width = '1px';
```
to set it through CSS.
Note that old versions of IE don't create a proper image with ```document.createElement()```, and old versions of KHTML don't ... |
Why is %s better than + for concatenation in python? | There are several benefits of using ```%s``` over ```+``` for string concatenation in Python:
* Readability. The format string syntax is more readable, as it separates style from the data. Also, in Python, ```%s``` syntax will automatically coerce any non ```str``` types to ```str```; while concatenation only works wit... |
When an expendable booster rocket stage nears the end of its burn, does the guidance computer shut the engine(s) off at a certain velocity/altitude for the mission, or does the stage completely exhaust its propellants? | First stages are generally run to depletion (though not complete depletion). First stage ascents often use a preprogrammed, open loop guidance system to get out of the atmosphere with a good chunk of downrange velocity. Because winds aloft and other factors may vary, first stage performance also varies somewhat.
Upper ... |
How to prevent "Delhi Belly" from eating/drinking locally? | Basically, you can't.
The world is full of gastrointestinal (GI) diseases, even in developed, First World nations. There are some decent steps to trying to minimize your exposure:
* Properly cooked foods. Everything heated to a proper internal temperature (depends on the dish, check the USDA's site for guidelines), no... |
I'm working at my first programming job. My boss is a very smart software engineer, and I feel
like I have very little to offer compared to him. Problem is, he is always busy, and needs someone to help him out. I feel like I'm not good enough, but I still want to succeed. I want to be a great programmer.
What can I do ... | Remember the scene in Aladdin where Aladdin wants to impress Jasmine, and the genie tells him he'd do better to just focus on being himself? Same principle here.
If the boss is that much better than you and you know it, he probably knows it too. He isn't expecting any great feats of programming rock-stardom out of you... |
Can I pass variables to a GNU Makefile as command line arguments? In other words, I want to pass some arguments which will eventually become variables in the Makefile. | You have several options to set up variables from outside your makefile:
* From environment - each environment variable is transformed into a makefile variable with the same name and value.
You may also want to set ```-e``` option (aka ```--environments-override```) on, and your environment variables will override ass... |
I have noticed that some games quote the requirement for "pixel shader 3.0 or better".
What is a pixel shader and is it some software requirements or hardware requirements? | Simple answer
Pixel shaders are tiny programs that can do operations on a single pixel on the screen, as opposed to geometry shaders and vertex shaders which work on the geometrical primitives (triangles) that make up everything you see on the screen. The most common use for pixel shaders is 'shading', approximation to... |
If water is not a good conductor, why are we advised to avoid water near electricity (no wet hands near circuits etc.)? | "Pure" water is a very poor conductor (resistivity is actually used as a measure of purity).
"Real" water is not pure - it contains electrolytes and is quite conductive. Also - when your skin is wet, its resistivity is significantly lower.
For example - "pure" water has a resistivity of (a... |
What is the difference between cohesion and coupling?
How can coupling and cohesion lead to either good or poor software design?
What are some examples that outline the difference between the two, and their impact on overall code quality? | Cohesion refers to what the class (or module) can do. Low cohesion would mean that the class does a great variety of actions - it is broad, unfocused on what it should do. High cohesion means that the class is focused on what it should be doing, i.e. only methods relating to the intention of the class.
Example of Low C... |
Can Romex (NM-B) cable be run through conduit? | Yes, NM (Romex) cable can be in conduit. In fact, National Electrical Code (NEC() calls for it to be in conduit, when protection from physical damage is required. But it really isn't worth it.
## It's a nightmare to pull
NM (Romex) is already solid wire except in the large sizes, and now you have 3-4 wires bound toget... |
Let's say I have a function which takes an ```std::function```:
```void callFunction(std::function x)
{
x();
}
```
Should I pass ```x``` by const-reference instead?:
```void callFunction(const std::function& x)
{
x();
}
```
Does the answer to this question change depending on what the function does with it? For... | If you want performance, pass by value if you are storing it.
Suppose you have a function called "run this in the UI thread".
```std::future run_in_ui_thread( std::function )
```
which runs some code in the "ui" thread, then signals the ```future``` when done. (Useful in UI frameworks where the UI thread is where you... |
I have an Eloquent model which has a related model:
```public function option() {
return $this->hasOne('RepairOption', 'repair_item_id');
}
public function setOptionArrayAttribute($values)
{
$this->option->update($values);
}
```
When I create the model, it does not necessarily have a related model. When I updat... | A Relation object passes unknown method calls through to an Eloquent query Builder, which is set up to only select the related objects. That Builder in turn passes unknown method calls through to its underlying query Builder.
This means you can use the ```exists()``` or ```count()``` methods directly from a relation ob... |
NASA is hiring a new 'planetary protection officer' to defend Earth from alien matter, and the pay is a six-figure salary: as much as $187,000 a year.
When we are not sure whether aliens exist, why are we still hiring staff for protecting Earth? I do understand we have to take precautions. But when we don't have any pr... | You're observing shamefully bad journalism. The "protect Earth from aliens" bullet point in the "Highlights" section of the article was put there by an editor who either ignorantly or willfully distorted the actual role of the Planetary Protection Officer.
The first paragraph of the story gets a lit... |
Traditional advice for making megadungeons in older versions of D&D is in addition to any rooms with Monsters, Treasure, Traps, or "Tricks", there should also be at least 50 to 60 percent "Empty" rooms, which contain nothing overtly threatening or valuable. Now, there's several arguments for including these empty room... | By definition, nothing's going to happen in an empty room (though see below). There are no hidden doors to find, no puzzles to solve, no enemies to fight. So what's their purpose?
## Bringing the dungeon to life
While all the orcs may sit around in a guard room waiting for PCs to show up, where do they sleep, what do ... |
Laravel - Eloquent "Has", "With", "WhereHas" - What do they mean? explain in the context of an example | With
```with()``` is for eager loading. That basically means, along the main model, Laravel will preload the relationship(s) you specify. This is especially helpful if you have a collection of models and you want to load a relation for all of them. Because with eager loading you run only one additional DB query instead... |
What are some of the advantages of using one over the other? | ASP.NET Web Forms and MVC are two web frameworks developed by Microsoft - they are both good choices. Neither of the web frameworks are to be replaced by the other nor are there plans to have them 'merged' into a single framework. Continued support and development are done in parallel by Microsoft and neither will be... |
Why did the Typescript folks create the ```infer``` keyword?
According to the documents, this is an example of how you would use it:
```type ReturnType = T extends (...args: any[]) => infer R ? R : any;
```
I don't understand why this is needed. Why can't it just be:
```type ReturnType = T extends (...args: any[]) => R... | With ```infer```, the compiler ensures that you have declared all type variables explicitly:
```type MyType = T extends infer R ? R : never;
type T1 = MyType // T1 is { b: string; }
```
Here we declare a new type variable ```R``` in ```MyType```, which gets inferred from ```T```.
(Note, that ```infer``` is always used ... |
Which is more widely supported: ```window.onload``` or ```document.onload```? | When do they fire?
```window.onload```
* By default, it is fired when the entire page loads, including its content (images, CSS, scripts, etc.).
In some browsers it now takes over the role of ```document.onload``` and fires when the DOM is ready as well.
```document.onload```
* It is called when the DOM is ready whi... |
I was surprised to learn that Puerto Ricans, despite living in a US territory, were not entitled to vote in the presidential elections.
I was even more surprised to learn that US citizens are allowed to vote for president from anywhere in the world - EXCEPT if they happen to live in Puerto Rico.
What is the legal/polit... | This is a peculiarity as a result of the federal nature of the USA and the exceptional position of Puerto Rico as a territory but not a state. Within the States and Territories of the USA, your voting rights depend on residence. If you leave the States and Territories your voting rights depend on former residence or ... |
Suppose I wrote that I will be killed by a UFO falling from space in the year 2315 while I am lifting.
Will the Note increase my lifespan? In other words, will I still be alive by then? | No. There are some rules that prevent this. From the Rules of the Death Note wiki:
1. The 23-days rule
How to use: XXVII
* [...]
* If you write, “die of disease” for the cause of death, but only write a specific time of death without the actual name of disease, the human will die from an adequate disease. Bu... |
I have an Affa Protector enchanted with Unhallowed Pact ... My opponent kills my Affa with Dread Slaver ...
Who will take control of the creature at the end? This is taking into consideration that my aura spell was cast 5 turns ago. Meaning my aura spell is NOT on the stack. | It depends on whose turn it is.
Both abilities trigger at the same time, and so will be put on the stack together. Abilities are put on the stack in APNAP (Active Player, Non-Active Player) order.* This means that the player whose turn it is puts their ability on the stack, then the other player does. That second playe... |
I've found that some people call JavaScript a "dynamically, weakly typed" language, but some even say "untyped"? Which is it really? | strong/weak can be thought of in relation to how the compiler, if applicable, handles typing.
* Weakly typed means the compiler, if applicable, doesn't enforce correct typing. Without implicit compiler interjection, the instruction will error during run-time.
```"12345" * 1 === 12345 // string * number => number
```... |
I was fixing my laptop, and as you may know, laptops have a lot of small screws to take out when you are fixing it. One of the screws fell into the floor (the floor has carpet on it), and I was unable to follow the screw with my sight. If I don't follow the screw with my sight when it falls, there is a high chance that... | This is why you should always have spare screws on hand. Fortunately, there is a way:
## Light Method
Most screws are silver. Shine a flashlight into the carpet and look for little silvery glints. This may take some time, but you'll probably find it. If your carpet is unnaturally thick...
## Magnet Method
Take a powe... |
What is the difference between mutex and critical section? Please explain from Linux, Windows perspectives?
I am programming in C#, would these two terms make a difference. Please post as much as you can, with examples and such....
Thanks | From a theoretical perspective, a critical section is a piece of code that must not be run by multiple threads at once because the code accesses shared resources.
* A mutex is an algorithm (and sometimes the name of a data structure) that is used to protect critical sections.
* Semaphores and Monitors are common imple... |
What is the purpose of the single underscore "_" variable in Python? What is the meaning of ```_``` after ```for``` in this code?
```if tbh.bag:
n = 0
for _ in tbh.bag.atom_set():
n += 1
``` | ```_``` has 3 main conventional uses in Python:
1. To hold the result of the last executed expression in an interactive interpreter session (see docs). This precedent was set by the standard CPython interpreter, and other interpreters have followed suit.
2. For translation lookup in i18n (see the gettext documentatio... |
What is the difference between doing:
```ptr = malloc (MAXELEMS * sizeof(char *));
```
or:
```ptr = calloc (MAXELEMS, sizeof(char*));
```
When is it a good idea to use calloc over malloc or vice versa? | ```calloc()``` gives you a zero-initialized buffer, while ```malloc()``` leaves the memory uninitialized.
For large allocations, most ```calloc``` implementations under mainstream OSes will get known-zeroed pages from the OS (e.g. via POSIX ```mmap(MAP_ANONYMOUS)``` or Windows ```VirtualAlloc```) so it doesn't need to ... |
I've looked in the Apex developer's guide and a saw the Naming Conventions section which has basically only has this:
We recommend following Java standards for naming, that is, classes start with a capital letter, methods start with a lowercase verb, and variable names should be meaningful.
I'm looking for something... | Follow the CamelCase Java conventions, except for VF pages and components start with a lower case letter.
Triggers:
* <ObjectName>Trigger - The trigger itself. One per object.
* <ObjectName>TriggerHandler - Class that handles all functionality of the trigger
* <ObjectName>TriggerTest
Controllers:
* <ClassName>Control... |
When learning some basic French, I was somewhat surprised to learn that phrases of the form "I have found the cat" generally translate almost word-for-word from English (J'ai trouvé le chat). To me, it's not immediately obvious that possession ("I have"/"J'ai") has a correspondence with past tense, although if I think ... | This is what's called a "Sprachbund" feature: it's a trait shared by a bunch of languages in an area, even ones that aren't genetically related. In particular, this one is a feature of the "Standard Average European" Sprachbund, a group of languages centered in Western Europe, and it's one of the features that was orig... |
I'm building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don't, however, have the absolute path to the directory where the templates are stored. I do have a relative path from the script but when I call the script it treats that as a path relati... | Python have already evolve to the ```__future__``` long time ago. So how about using the amazing ```pathlib``` coming with Python 3.4 to accomplish the task instead of struggling with ```os```, ```os.path```, ```glob ```, ```shutil```, etc.
So we have 3 paths here (possibly duplicated):
* ```mod_path```: which is the ... |
How to send HTML-formatted email in C#? | Setting isBodyHtml to true allows you to use HTML tags in the message body:
```
msg = new MailMessage("xxxx@gmail.com",
"yyyy@gmail.com", "Message from PSSP System",
"This email sent by the PSSP system<br />" +
"<b>this is bold text!</b>");
msg.IsBodyHtml = true;
``` |
I want to sum a list of Integers. It works as follows, but the syntax does not feel right. Could the code be optimized?
```Map integers;
integers.values().stream().mapToInt(i -> i).sum();
``` | This will work, but the `i -> i` is doing some automatic unboxing which is why it "feels" strange. `mapToInt` converts the stream to an `IntStream` "of primitive int-valued elements". Either of the following will work and better explain what the compiler is doing under the hood with your original syntax:
```
integers.v... |
I am beginner of LaTeX. From many examples I found, I notice that it's very common to use command ```\leavevmode```. I can't find any information about this command. Could anyone tell me what's the function of it and how to use it? | The ```\leavevmode``` is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.
For example ```\mbox{..}``` is defined as ```\leavevmode\hbox{... |
In Python specifically, how do variables get shared between threads?
Although I have used ```threading.Thread``` before I never really understood or saw examples of how variables got shared. Are they shared between the main thread and the children or only among the children? When would I need to use thread local stora... | In Python, everything is shared, except for function-local variables (because each function call gets its own set of locals, and threads are always separate function calls.) And even then, only the variables themselves (the names that refer to objects) are local to the function; objects themselves are always global, an... |
Why can't we kill ourselves by holding our breath? | ## Short answer
Healthy people cannot hold their breaths until unconsciousness sets in, let alone commit suicide.
## Background
According to Parkes (2005), a normal person cannot even hold their breath to unconsciousness, let alone death. Parkes says:
Breath‐holding is a voluntary act, but normal subjects appear un... |
Sometimes while driving in the traffic, I come across a car or two which would be dripping water-like drops from its exhaust steadily in 4-5 second intervals. I tried to ask a couple of people at the local workshops; they say, and I quote, "The car is giving an amazing mileage".
And I am like, what does that ... | It signifies that the car is running absolutely correct. Here is the reason why:
A gasoline (petrol) molecule is made up as such:
C8H18 (or 8 Carbon atoms and 18 Hydrogen atoms)
Energy is obtained from the combustion of it by the conversion of a hydrocarbon to carbon dioxide and water. The combustion of octane follo... |
Why can't MX records point to an IP address? | The whole idea behind the mail exchange (MX) record is to specify a host or hosts which can accept mail for a domain. As specified in RFC 1035, the MX record contains a domain name. It must therefore point to a host which itself can be resolved in the DNS. An IP address could not be used as it would be interpreted as a... |
Why is ```SELECT *``` bad practice? Wouldn't it mean less code to change if you added a new column you wanted?
I understand that ```SELECT COUNT(*)``` is a performance problem on some DBs, but what if you really wanted every column? | The asterisk character, "*", in the SELECT statement is shorthand for all the columns in the table(s) involved in the query.
Performance
The ```*``` shorthand can be slower because:
* Not all the fields are indexed, forcing a full table scan - less efficient
* What you save to send ```SELECT *``` over the wire risks ... |
I did my training around the Seattle area, and was told that landing at SeaTac Airport (the region's major International/Commercial airport), while not strictly forbidden, was definitely frowned upon because it can slow down and interfere with the big planes on schedules. To discourage GA aircraft from using the big ai... | Can you? Absolutely, and air traffic control will treat you (almost) like any other airplane. You are supposedly handled on a first-come-first-serve basis (reality is slightly different with different aircraft speeds, etc.). Do the airlines like it if you slow them down? No, but it's part of the system and the way tha... |
Given the following code:
```var arr = [1,2,3,4,5];
var results: number[] = await arr.map(async (item): Promise => {
await callAsynchronousOperation(item);
return item + 1;
});
```
which produces the following error:
TS2322: Type 'Promise[]' is not assignable to type 'number[]'.
Type 'Promise i... | The problem here is that you are trying to ```await``` an array of promises rather than a Promise. This doesn't do what you expect.
When the object passed to ```await``` is not a Promise, ```await``` simply returns the value as-is immediately instead of trying to resolve it. So since you passed ```await``` an array (of... |
Why don't helicopters use reaction wheels to counter the main rotor? | You're talking about a device (in helicopters the tail fan imparting horizontal thrust) that counteracts the torque imparted on the main rotor (and therefore on the helicopter) by the surrounding air as the main rotor is dragged through the air.
You propose instead to impart an opposite torque through a reaction wheel... |
When configuring cron to run a command every other day using the "Day of Month" field, like so:
```1 22 */2 * * COMMAND
```
it runs every time the day of month is odd: 1,3,5,7,9 and so on.
How can I configure cron to run on days of month that are even like 2,6,8,10 and so on (without specifying it literally, which is ... | The syntax you tried is actually ambiguous. Depending on how many days are in the month, some months it will run on odd days and some on even. This is because the way it is calculated takes the total number of possibilities and divides them up. You can override this strage-ish behavior by manually specifying the day ra... |
Can I spend the night alone in a tent in a forest outside Stockholm in -20°C without risking my life?
The backstory
From the end of January, I'm starting my studies in a suburb of Stockholm. I've decided to, if it turns out plausible, not rent an apartment, but live in a tent. (This is not out of frugality, but out of... | Yes, it is definitely doable. -20°C is only -4°F. The real question is whether it is doable by you at the level of discomfort and hassle you are willing to put up with. Only you can answer that. At best we can point out what the hassles and discomforts will be.
First, your fear of dying of cold in your sleep i... |
Why is the volt not identical to the full name Volta, unlike the other electrical units ohm, ampere, coulomb, tesla, weber and henry? Is there a historical explanation, was the volt introduced at a different time? | The volt, ohm and farad were introduced by the same person, Latimer Clark, a cable engineer, in a paper in 1861. He started the tradition of naming units after scientists. He initially distorted all names: the unit names ohma, volt, galvat (from Galvani), and farad (from Faraday). In his words, he "neglected etymologic... |
We can define cross products mathematically like if we take two vectors, we can find another vector with certain properties but why do we use it in physics, if we consider a hypothetical physical quantity like force which is equal to cross product of certain vectors?
For example, the force exerted on a charge in mot... | This is a great question. The dot and cross products seem very mysterious when they are first introduced to a new student. For example, why does the scalar (dot) product have a cosine in it and the vector (cross) product have a sine, rather than vice versa? And why do these same two very non-obvious ways of "multiplyin... |
I have a web project in my solution file that is "unavailable" when I open the solution. When I right-click on the web project and reload the project, I get the following error:
```
The Web Application Project mycompany.myapp.mywebproject is configured to use IIS. The Web Server 'http://localhost/MyWebApp could not be ... | When this happens the easiest solution is to make the virtual directory manually.
First of all, you need to make sure you have the right version of ASP.Net installed and that you have installed the IIS extensions.
To do this, go to the relevant .net version's folder in C:\(Windows)\Microsoft.NET\Framework\(dotnetver)\... |
Why is it hard to draw people running in animes? | The walk cycle is considered to be one of the most basic aspects of animation. American animators and animation enthusiasts often times scorn the Japanese styles and methods of animation as lazy, while Japanese anime enthusiasts deride the American style as clunky or too comical.
Why is that you ask? The answer lies i... |
Malachi 4:5:
I will send you the prophet Elijah. He will come before the day of the Lord arrives. It will be a great and terrifying day
Jesus says in Matthew 11:14
"and if you are willing to believe their message, John is Elijah, whose coming was predicted"
Jesus says in Mathew 17:12
But I tell you, Elijah ... | Faulty Premise #1: John the Baptist was a reincarnation of Elijah
When Jesus asked Peter who people said he was, he answered that some people thought that Jesus was Elijah come back. Peter knew better and said Jesus was the Christ. In any event, John the Baptist himself directly denied the claim (see John 1:19-21).
W... |
I see hugely varied performance depending on how many newlines there are in the file I'm visiting.
Here's an example. I have two JSON files:
```$ wget https://github.com/Wilfred/ReVo-utilities/blob/a4bdc40dd2656c496defc461fc19c403c8306d9f/revo-export/dictionary.json?raw=true -O one_line.json
$ python -m json.tool prett... | Emacs' handling of long lines is not very well optimized. For a number of operations, Emacs has to scan the whole line repeatedly. For example, to display a line, Emacs has to figure out the height of the line, which requires scanning the whole line to find the tallest glyph. Additionally, scanning for bidirectional di... |
Sooner or later we come across a task in our project, with which we are totally unfamiliar ('we' as in PM, but also possibly the staff assigned to do this particular task).
How can we estimate amount of time/work/resources needed to complete such a task? What margins of error should we assume? | Don't place too much confidence on your first guess just because you've used a sophisticated formula to derive your estimate. Do your best, move on, plan to revise your estimate, don't let bad estimates linger and destroy the discipline of your project schedule ... errors in time estimates are likely to be lognormally... |
If we fold a paper and then apply pressure on the newly formed crease, it seems that the paper's surface gets a permanent deformation but what exactly has happened to the paper at a molecular scale? | Basically, a fold or crease in paper will remain because the structure of the fibers in the paper have become irreversibly damaged. This happens because the paper is bent/compressed beyond its elastic limit.
Chemically, paper is mainly composed of cellulose from plant fibers. Cellulose is an organic polymer, which ha... |
What are the differences between the Strategy design pattern and the State design pattern? please explain the difference in layman's terms? | The difference simply lies in that they solve different problems:
* The State pattern deals with what (state or type) an object is (in) -- it encapsulates state-dependent behavior, whereas
* the Strategy pattern deals with how an object performs a certain task -- it encapsulates an algorithm.
The constructs for... |
I remember when the Muslim holy book was the Koran when I was in middle school, but now it's the Quran. But it's always been Qatar and Iraq (but still Kuwait.)
Who decided that 'Q' was going to be represent that sound instead of 'K', and why? | In Arabic, in fact, they've always been separate sounds! The sound we write "K" is spelled with the letter ك in Arabic, and is pronounced a little bit further forward in the mouth; the sound we write "Q" is spelled with the letter ق and pronounced a little bit farther back. In phonetic terms, "K" is a velar sound, and ... |
How do you add Boost libraries in CMakeLists.txt? | Put this in your `CMakeLists.txt` file (change any options from OFF to ON if you want):
```
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost VERSION COMPONENTS *boost libraries here*)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})... |
Quando devo fazer essa gravação direto no banco?
Quais as situações?
Eu sei que posso gravar no banco o caminho da imagem. | Além do custo ser mais alto como mencionado, deve-se levar em conta vários fatores:
* Volume de dados: para um baixo volume de dados pode não haver problema. Por outro lado, para armazenamento de grande massa de dados o banco de dados é praticamente inviável. Pergunte ao Facebook ou ao Google se eles usariam banco. O ... |
I need a regular expression that validates a number, but doesn't require a digit after the decimal. ie. ```123 123. 123.4 ``` would all be valid ```123.. ``` would be invalid | Here is the regular expression you can use:
```
/^\d*\.?\d*$/
```
* `^` - Beginning of the line;
* `\d*` - 0 or more digits;
* `\.?` - An optional dot (escaped, because in regex, . is a special character);
* `\d*` - 0 or more digits (the decimal part);
* `$` - End of the line.
This allows for .5 decimal rather than ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.