source stringclasses 5
values | query stringlengths 12 7.84k | response stringlengths 15 17.7k |
|---|---|---|
stackexchange | 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.
Althou... | 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 po... |
stackexchange | What does strength refer to in mathematics? Is it a formal idea? | 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 ... |
stackexchange | Does vegetarianism affect life expectancy?
Is an average vegetarian supposed to live longer just because of their diet? | 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 n... |
stackexchange | 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 rela... | 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(o... |
stackexchange | I've rooted my phone. Now what? What do I gain from rooting? | 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 cust... |
stackexchange | 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. | 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 p... |
stackexchange | 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)? | 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 \Rightarro... |
stackexchange | Why isn't Sectumsempra an Unforgivable Curse? | 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 ... |
stackexchange | How can I add a delay to a program in C#? | 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 in... |
stackexchange | 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```. Th... | 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 `... |
stackexchange | 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 repopulati... | 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 procr... |
stackexchange | Reasons for being vegetarian or vegan other than ethical reasons? | 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 pro... |
stackexchange | 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? | 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 R... |
stackexchange | 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? | 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 translati... |
stackexchange | 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``` ... | 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 h... |
stackexchange | 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? | 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... |
stackexchange | 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/al... | 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 -e... |
stackexchange | Did Aztecs know how many continents there are on earth? | 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 se... |
stackexchange | What did the Soviet Union and Russia bring to the ISS? | 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 m... |
stackexchange | 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. | ## 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 cre... |
stackexchange | What's the difference between ASCII and Unicode? | 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.
... |
stackexchange | 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. ... |
stackexchange | 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.
... |
stackexchange | 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... |
stackexchange | 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. |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | Why isn't the market dropping like a stone with all the bad news? | 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 g... |
stackexchange | 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? | 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 primitiv... |
stackexchange | 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... |
stackexchange | 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 ... |
stackexchange | 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... |
stackexchange | 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... | ## 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 e... |
stackexchange | 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 ... |
stackexchange | 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 ... |
stackexchange | 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 the... | 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. Man... |
stackexchange | 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... |
stackexchange | While in Phd I developed a lot of code that I want to turn into start-up. Can I do this? | 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 you... |
stackexchange | 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... |
stackexchange | 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? | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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 ... |
stackexchange | 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... |
stackexchange | 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 ... |
stackexchange | 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... |
stackexchange | I'm pretty disappointed with my horse. He wasn't cheap -- 1000g -- but he just doesn't seem that fast. To make things worse, he's a bit of a wolf magnet and every time I get attacked I have to tediously dismount, blast the wolf, and then remount.
Is the speed of a horse actually significantly faster than normal runni... | Don't forget that you can sprint with a horse. It might be that you know that you can sprint on your character, but not on your horse. Please note that your horse is also able to sprint using stamina. You can do this using the default Alt key.
Horses are indeed faster, transportation was simplified.
Since Oblivion, th... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | How to find if a customer is logged in or not in Magento 2.
If the customer is logged in then how to get customer data from a session? | It is possible via ```Magento\Framework\App\Http\Context``` or via ```Magento\Customer\Model\Session```. However, the result may be different:
* HTTP context is initialized earlier than the customer session (but it does not matter since both are initialized in action controllers)
* When the ```PageCache``` module is o... |
stackexchange | I have a 9 year old daughter that has expressed some interest in manga, but I'm having trouble locating series that are appropriate for her age. No one at our local bookstore could offer any advice. Is there a kid-friendly imprint or other resource I could use to help her find something appropriate? My preference is fo... | The content deemed acceptable for Japanese children generally differs from the concept in other countries; manga contains all genres of stories, so one cannot responsibly presume that just because a title was marketed at Japanese kids, that you would likewise consider it appropriate for your kid of the same age.
As on... |
stackexchange | 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... |
stackexchange | 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
│ ... |
stackexchange | I have the following method to save an Object to a file:
```// Save an object out to the disk
public static void SerializeObject(this T toSerialize, String filename)
{
XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());
TextWriter textWriter = new StreamWriter(filename);
xmlSerializer.Se... | Use a `StringWriter` instead of a `StreamWriter`:
```
public static string SerializeObject<T>(this T toSerialize)
{
XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());
using(StringWriter textWriter = new StringWriter())
{
xmlSerializer.Serialize(textWriter, toSerialize);
... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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 ... |
stackexchange | Let's say that we have a gaseous or liquidus compound (I don't know if elements or compounds make a difference, take this as a thought experiment), and we have a tungsten or steel block that's 5cm (or less, you choose) thick. Is there any physical method for that gas or liquid to pass through that thick heavy metal blo... | Yes, some gases can diffuse into and through metal. It is the bane of the high-vacuum engineer's life. Hydrogen is the worst because it tends to dissociate into atoms at the surface and the nucleus, a single proton, can then leave its electron behind and wander through the metal lattice until it picks up another electr... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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)... |
stackexchange | 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 ... |
stackexchange | 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... |
stackexchange | I had an interview with an employer working on a software-based vehicle solution.
Before going further in the interview process, he gave me a task to find out if a potential customer (automotive OEMs) is interested.
My question is, how can I approach a potential customer and arrange some time together to present to the... | Run (and run fast) - here are just a few points to consider:
* That's a very unorthodox task for somebody still in the interviewing stage.
* How you going to present a solution you aren't familiar with?
* Since you aren't an employee of said company yet you have no grounds to represent them or even hustle their produc... |
stackexchange | 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 ... |
stackexchange | Is "ima" an informal spelling of "I must"?
MegaCharizardZord Replying to @nytimes about COVID-19 vaccine:
i just hope when i take it don't die lol. i trust the government in Canada, but if I do get something ima sue the shit out of em lol.
Source: Twitter
| Ima is an informal contraction of I'm going to when it's used in going-to future construction - not in sentences like I'm going to London etc. It's also written i'ma or imma in informal conversations.
How did I'm going to come to be pronounced/spelt that way?
In casual speech, we tend to drop consonants that require mo... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | Red light facing forwards? It was nighttime in Manhattan. Isn't more always better when it comes to being seen? | No. You should always ride with a white light facing forward and a red light facing backwards. If you want additional illumination, you can add multiple white/red lights in the appropriate direction. Amber/yellow lights can be used facing any direction for additional visibility.
The first reason is that it's the law:
... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | 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 ... |
stackexchange | 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... |
stackexchange | 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... |
stackexchange | What factors determine the maximum altitude for a plane?
Is it limited by wing design, engine thrust, and so on?
Is there a formula by which one can calculate the maximum altitude a plane can reach? | The higher you get, the lower the density of the air becomes. This lower density results in a lower lift being generated for the same airspeed and angle of attack. Effectively, the higher you fly the higher your minimum speed becomes. So while climbing, your speed needs to increase to compensate for the lower air densi... |
stackexchange | 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 ... |
stackexchange | 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... |
stackexchange | 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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.