Bruteforce Veracrypt

Question: I forgot my Veracrypt password, I have around 1000-2000 possible password combination and I need a software to bruteforce the password on Windows.
What software would that be?
Comment: Problem is retry delay in the case of VC is very high. One try can take quite a few seconds, so it won't be a quick process.
Comment: We have a sister site for [software recommendations](https://softwarerecs.stackexchange.com/)
Answer: You don't mention how quickly you need this done.
If time is not a concern and you only have a limited pool of possible passwords, you could easily script the mount operation to try every possible password inline and look for a success message. No guarantees this works, but something like:
<code>veracrypt /v your_volume_name_here.tc /l x /a /p MyP@$$w0rd! /e /b
</code>
Loop this and rotate the password on each attempt. Stop when the mount was successful, and for god's sake make sure you log the found password somewhere so you don't have to do it all over again (bitter experience).
I've done this successfully with a GELI-encrypted drive (twice); it took a few days to complete each time, but I also had a smaller pool of candidates to work with than you do.
Comment: Thanks a few days would be fine. Do I write this in the Windows command prompt? and do I have to write each password manually or can I use a txt file with all possible passwords to do it automatically and how? thanks again
Comment: Apologies for laughing at your bitter experience - it''s just the sort of thing that I would do (upvote)
Answer: I would redirect you to either hashcat or johntheripper (google). And whether bruteforcing in your situation is feasible or not depends purely on strength of your password.
Comment: This answer could use some serious fleshing out.
Comment: I'd reccomend looking at this page: https://www.veracrypt.fr/en/Encryption%20Algorithms.html and adjusting your answer in order to suggest how to extract data or part of the disk in order to check if OP has the correct password. Maybe if you dig deeper into the docs or source code you can find something about how OP can check a password against the data
Answer: Just forgot my password too.
I made a simple batch script (Windows):
<code>@echo off
for /f "tokens=*" %%a in (word.list) do (
  echo ---[new check]---
  veracrypt /v {{full path to the encrypted file}} /l Q /a /p %%a /e /b /q /s
  echo Tring password:%%a
  if exist Q:\ ( echo PasswordWorks!!! ) else ( echo Wrong password...)
  veracrypt /d Q /s /q
)
 echo ---[Done]---
</code>
VeraCrypt Brute-force cracker
This is a very simple file that will help you recover a forgotten password for your VeraCrypt encrypted file.
it works on windows only (I'm sure that with a some basic Bash knowladge you can translate it to linux too)
Instructions:

Put the above script in VeraCrypt folder (name it VcCrack.cmd)
Create a word list file (name it word.list) and put it in VeraCrypt folder
Fill up the word.list with optional passwords (you can generate it if there are too many)
Edit VcCrack.cmd:
a. Make sure that Drive Q: isn't mounted already (or change the Q in lines 4,6,7 to a different drive)
b. replace the {{full path to the encrypted file}} with the relevant full path
run this command (in elevated command prompt):
VcCrack.cmd >brute.log
Go to do some stuff - the results will be in the log file when we finish trying all the options (about 5 seconds for an option - depends on the machine)

Example for output brute.log:
<code>---[new check]---
TRY=123456789
Wrong password...
---[new check]---
TRY=foobar123456
PasswordWorks!!!
---[new check]---
TRY=abcdabcd
PasswordWorks!!!
---[new check]---
TRY=password6
Wrong password...
---[Done]---
</code>
Gist link: https://gist.github.com/YossiCohen/4336cc4e905ad3534f681082962377e8

Bruteforce Veracrypt


Possibility to print via printer dot matrix with PHP

Question: Is there any possibility so we can print bill with printer dot/jet matrix in PHP? And also, can PHP detect for barcode reader ? or just simple method, I only provide input text then if I scan with barcode reader, directly fill to input text automatically ?
Answer: On the client side you could use jzebra plugin (https://code.google.com/p/jzebra/) which detects all installed printers and provides escp javascript methods to send hexadecimal esc commands along with the text you want to print, while the actual printing is performed by a java applet.


How do I cite this apparently unpublished paper?

Question: How do I cite the paper The fundamental distinction between brains and turing machines, by Andrew Friedman?
Comment: I believe that you may want to add more context. Are you adding references by hand or are you using bibtex or the like? You can always add author, title and so on fields by hand if you do not find the database entry online.
Comment: Could well be that it is published. You may find here someone who knows the answer to the question whether or not this journal is reliable, but IMHO this is not necessarily a LaTeX question.
Answer: If you want to cite something you found online that does not seem to be published elsewhere (in a journal, as part of a collection/book/conference proceedings, ...) you can always fall back to @online.
From the PDF alone you already have the author, a title and you can infer the year. Naturally you have a URL and the access date, so you could have
@online{friedman,
  author  = {Friedman, Andrew},
  title   = {The Fundamental Distinction Between Brains and Turing Machines},
  year    = {2002},
  url     = {http://web.mit.edu/asf/www/PopularScience/Friedman_BrainsAndTuringMachines_2002.pdf},
  urldate = {2019-06-19},
}

According to Andrew Friedman's web page http://web.mit.edu/asf/www/popular_science.shtml and his CV https://asfriedman.physics.ucsd.edu/MITResume/AndrewFriedmanCV.pdf this article was published in the Berkeley Scientific Journal, Vol. 6, Issue 1, Spring 2002, p. 28-33. The cover image of the journal in question available at http://afriedman.org/AndysWebPage/BSJ/Spring2002Cover.html as well as the short summary of the contents of the Spring 2002 issue at https://bsj.berkeley.edu/read-the-bsj/past-issues/ seem to corroborate that story.
Unfortunately, older volumes of the BSJ are not digitally available in their entirety. See also https://bsj.berkeley.edu/read-the-bsj/past-issues/. Newer versions can be found at https://escholarship.org/uc/our_bsj.
One may feel a bit uneasy about citing a publication with data that one could not verify completely and that is not particularly helpful to the reader (the BSJ issue in question is not available online and I doubt that a lot of people have access to the journal through their libraries), but if that is not an issue for you, you could also cite this entry as an @article
@article{friedman,
  author  = {Friedman, Andrew},
  title   = {The Fundamental Distinction Between Brains and Turing Machines},
  year    = {2002},
  journal = {Berkeley Scientific Journal},
  volume  = {6},
  number  = {1},
  issue   = {Spring},
  url     = {http://web.mit.edu/asf/www/PopularScience/Friedman_BrainsAndTuringMachines_2002.pdf},
  urldate = {2019-06-19},
}

Comment: I'm not quite sure if this is what you had in mind. And the question does not seem to be about (La)TeX/BibTeX an awful lot, but maybe it helps.
Comment: Hey, moewe, congrats on the 100k landmark! Cheers!
Comment: @gusbrs Thanks!
Answer: Cite it as @Misc, and give as much detail as you can get (e.g., URL where to find it, where it is cited, ...).


Float a control over a CView

Question: I've got an app that uses several CView-derived classes (actually CScrollView) to display document data. For one particular view, I want to add a fly-out edit box to add notes. That is, you'd see a tab at the bottom of the window labeled "Page Notes", and clicking on that would bring up the edit box. Clicking the tab while the edit box is visible would reduce it back to just the tab.
I thought I could use a one-tab CTabCtrl holding an edit box and just position it so that only the tab is visible initially. Capture the tab click notification and move the entire control, with edit box, into view. Clicking the tab again would move it back down so only the tab is visible.
Hosting the CTabCtrl on the CView is fine, and I can get it positioned correctly. The problem is that if the view is scrolled, the tab control is scrolled along with it, whereas I need it to "float" over the view and not be affected by any scrolling. I can move it back into place after the scroll, but the flickering is unsightly.
Is there a straightforward way to accomplish the "floating" effect? I mainly want the tab embedded in the view for maintenance, since it's the only view class out of the several in use that needs the "Page Notes" feature.
Should I just buckle down and put the tab in the view's parent window instead? I know it won't be affected by scrolling there, but I like the idea of keeping the tab as part of the view if possible.
Comment: If it's not supposed to scroll, shouldn't it be "outside" the scroll view, just like you have said? Perhaps, you need to split your view into two views?
Answer: It sound like the tab is functioning like a button. You click the tab and a fly out edit box appears. You could use a modeless dialog.
Select the "Page Note" and the modeless dialog comes up to edit your notes allowing you to scroll your view under the dialog.

Float a control over a CView


How was kernel written?

Question: Running a program in kernel mode forbids using standard C library because the only thing your program linked to is kernel itself. So I'm allowed to use functions defined in kernel. But kernel itself is a program written in C and compiled for some particular architecture. And it shouldn't use C standard library, but it also shouldn't use any drivers since drivers are loadable modules. So my question is what actual C functions are used when writing a kernel? How can you interact with hardware not through kernel? Don't say me to look at sources it's too next level for me, TY.
Answer: The Unix kernel has traditionally included some assembly language code.
I haven't looked at its source code recently,
but I suspect that that's still true.
See How does a driver actually communicate with a hardware device?
for an overview of that topic.
The answers to that question discuss two kinds of computer architecture.
On a system that uses port-mapped I/O (PMIO),
the kernel must be written partly in assembly language —
although you may be able to get by with a couple very short routines.
On a system that uses memory-mapped I/O (MMIO),
even device drivers can be written entirely in C.
All they need to do is declare a pointer,
set it equal to the virtual address of the device,
and then use it to manipulate the device as if it were accessing memory.
Answer: Not all drivers are loadable modules, being loadable is simply an option but some crucial drivers are not dynamically loaded, they are part of the kernel.
Comment: With `vi`, likely.
Comment: So then the question is how drivers were written
Answer: The kernel reproduces a whole bunch of the functionality provided by libc statically, within itself.
Just like in user-mode C programming, a function can be defined in one compilation unit and another unit can simply reference it (usually via a header file), the compiler will make it an undefined reference, and the linker will link it with the compilation unit that actually provides the symbol.
Loading kernel modules works on the same principle as dynamic loading and it's described here:
http://www.tldp.org/LDP/tlk/modules/modules.html
Comment: It's all just C, you see.
Comment: I mean, is there any functions in C which are not implemented neither in kernel nor in standard library? What is the most "naked"(assembly-like) C only compiler knows what to do with ?
Comment: @user30167 You can use any standard types known by the compiler to implement functions to manipulate data (all the basic operators like: +,-,*,/,=,^,|,&,...).  In order to do useful stuff with the data, you need the drivers implemented by the kernel which are also accessible by libc (which uses syscalls to the kernel).  There is also bare metal programming, but that will typically require some assembly language or a specific compiler.

How was kernel written?


T20 cricket winning probability

Question: Given that an opponent Team A has scored X runs (in the first innings), what is the probability that Team B will beat this score? Also, what is the expected score of the chasing Team B? Suppose I have a lot of past match data for both teams but let us just keep it simple and use only data of the form $(x_i,y_i)$ where $x_i$ was an opponent team's score and $y_i$ was Team B's final score in matches when Team B batted second. Alternatively, we could have only opponent score and match result (win/loss/toss) data for Team B. e.g. (212,lost);(163,won) etc
I have noticed that the batting scores are normally distributed. Using this I have built a simple, untruncated model that gives a probability for a particular team scoring X runs in first innings, based on its past first innings scores. However, I am unable to build a good model for giving a probability of beating a particular score. What to do? Should I post my approach? I haven't done so yet so to avoid priming others with a particular approach.
Background:
A T20 (Twenty 20) cricket match is a game in which a toss win allows a team to choose whether to bat first or bowl first. The team batting first gets to play 20 overs (sets of 6 balls thrown by an individual bowler in one go), or "first innings", and score runs. Zero is the minimum possible score in a ball and also the game. After 20 over are over or after ten batters are out, the other team gets to bat and beat the score. So, in the data above $y_i>x_i$ implies a win, $y_i=x_i$ implies a tie and $y_i<x_i$ implies a loss, for the chasing Team B.
Answer: I was using Bayes theorem along with Gaussian distribution but logistic regression is what I needed. The formula I got for a particular strong chaser team was:
<code>p(win_x)=1/e^(-19.12506+0.09340*x)
</code>

T20 cricket winning probability


Testing significance of cross-correlated series

Question: I want to prove that, overall, signal B is correlated to signal A. I was thinking of using cross-correlation (in R) to measure this.
Essentially I have two kinds of signals: signal A is a series of single-valued data describing a particular song; signal B is a series of single-valued data for a user. There are many songs and many users per song, but I do not have the same number of users for every song.
For example:
<code>Signal A (song data), for song 1
0.994
0.986
0.955
0.890
0.795
0.650
...

Signal A (song data), for song 2
0.763
0.788
0.787
0.908
0.854
0.901
...

Signal B (user data), for user 1 listening to song 1
75
74.4
73.7
73
72.3
72
...

Signal B (user data), for user 1 listening to song 2
71
72.3
74.9
73
72.5
72.9

Signal B (user data), for user 2 listening to song 2
60.6
60.2
61
60.7
61
59.3
...

Etc.
</code>
The series are obviously truncated for this illustration. Again, there are many songs, and not every user listened to every song.
I am interested in whether I can draw conclusions about how well all song data (signal A) can predict all user response (signal B).
Ideally, I would like to capture the cross-correlation in one number (one test statistic for each song), so that I may easily quantify whether there is an overall correlation between the two signals.
Using ccf (in R) gives me a value for each lag. For example:
<code>> print(ccf(x,y))
Autocorrelations of series 'X', by lag
-6     -5     -4     -3     -2     -1      0      1      2      3      4
-0.242 -0.090  0.057  0.197  0.466  0.699  0.896  0.436  0.221 -0.018 -0.116
</code>
(Are these values the cross-correlation coefficients?)
Also, my data are not stationary. Is there any way (another function?) to test whether signals A and B are correlated across users and songs?
One approach would be to average signal B (take the mean user response) for each song, but because there are a different number of users for each song, working with means might be problematic.
So, my main questions again are:

If I perform a cross-correlation for one user data/song data pair, how do I test for significance? Will R give me a correlation coefficient at each lag, or does it only tell me which lag is significant (but not provide any test statistic)? If the latter is the case, will I need to adjust one series of data (to account for the lag) before running a normal Pearson's correlation?
What test may I use when the data are not stationary?
There are a different number of users for each song. For this reason, I can't simply take the average of all users' data for each song (to correlate the mean user data with the song data) - is that correct? Is there a way to test the correlation between signals A and B for each song (across existing users), or must I try to calculate the correlation for each user/song pair individually?

I hope my intent is clear. Thanks for any insight.
Comment: So basically do you have just a pair of single-valued variables observed over time? Or is one of the variables vector-valued? Or are both of them vector-valued? For starters we could consider the simplest case, and then move on to develop the full case. I think there have been a few similar questions before, at least where variables are single-valued (not vector-valued); have you tried looking for relevant threads at here Cross Validated?
Comment: Hi Richard Hardy, the values are single-valued time series over time. The questions I have seen here don't answer all of the issues I have. For instance, could I use one value that belong to a lag for cross correlation (is this the correlation coefficient for this lag?). And can I do it when my data is non stationary? Maybe there are better metrics I could use such as coherence?
Comment: I am still wondering about your data structure. Your second paragraph does not seem to indicate a simple pair of single-valued time series... How does your data look like?
Comment: There are basically two time series per user per song. A time series is just a list of decimal values over time here.
Comment: Related to [this](http://stats.stackexchange.com/questions/194130/cross-correlation-of-two-autocorrelated-signals-removing-acf-with-arima).
Answer:
I want to prove that, overall, signal B is correlated to signal A.

If you want to prove that, you could calculate the empirical correlation and estimate its statistical significance under the assumption of $i.i.d.$ observations. However, time series data is notorious for not satisfying the $i.i.d.$ assumption; the conditional means and/or variances of time series usually change with time. Hence, you need some model to describe the relation between A and B and their time development (including possibly the time development of the relationship itself). Once you have built a model and validated its assumptions, you may proceed to model-based inference. For example, you may test the model's overall significance or significance of particular coefficients or their combinations. That way you may establish (or fail to establish) significant relationships between A and B. (You may think of the $i.i.d.$ case as being a very simple model that reflects constancy of means and variances (and higher order moments) and also constancy of the relationship between A and B.)
This may be too general to be directly useful, but it should provide a framework to think and develop a further discussion within. Unfortunately, I do not yet understand your problem sufficiently well to suggest a concrete model to work with.
Comment: Yes, I am specifically expecting the conditional means to change over time, and the samples are not independent (being heart rate data). I have updated the question to be more clear.
When you say, "Hence, you need some model to describe the relation between A and B and their time development (including possibly the time development of the relationship itself)."
What kind of model are you referring to? How does one set up a model describing the relationship between two time series that are not stationary?
Comment: @dorien, sorry, I am a little busy these days and might not be able to come back to this as the question is nontrivial for me.
Answer: A possible way to estimate the significance of the cross-correlation function (CCF) could be to simulate two uncorrelated time series with similar variability properties (i.e. same power spectrum) and then cross-correlate them. This will give you the estimate of the CCF if the two time series were completely uncorrelated. The distribution of the values of the CCF for large N will be Gaussian centred in 0. At this point you can compare the sigma from the Gaussian and the value of your CCF and see if the CCF is significant or not.


android camera error 1001 - what the heck is that?

Question: I've searched all over on the web and I can't find out what that 1001 error is. A few seconds after that I get the camera 100 error but I can't find out what the first error is. Does anyone have any ideas?
Comment: What ever it was my rollback to an earlier version of my code fixed it but I would still like to know wtf that 1001 error is so I can avoid it in the future.
Answer: I encountered this error as well on my S3.  I believe I tracked it down to how the camera preview surface was used by the MediaRecorder.  In my case the preview display was getting reset when I was attempting to start recording.  I solved it by cleaning out my code and just used the calls to set, start and stop the preview display in the SurfaceView implementation below (from the Android Camera developer guide):
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;

public CameraPreview(Context context, Camera camera) {
    super(context);
    mCamera = camera;

    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed.
    mHolder = getHolder();
    mHolder.addCallback(this);
    // deprecated setting, but required on Android versions prior to 3.0
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

public void surfaceCreated(SurfaceHolder holder) {
    // The Surface has been created, now tell the camera where to draw the preview.
    try {
        mCamera.setPreviewDisplay(holder);
        mCamera.startPreview();
    } catch (IOException e) {
        Log.d(TAG, "Error setting camera preview: " + e.getMessage());
    }
}

public void surfaceDestroyed(SurfaceHolder holder) {
    // empty. Take care of releasing the Camera preview in your activity.
}

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    // If your preview can change or rotate, take care of those events here.
    // Make sure to stop the preview before resizing or reformatting it.

    if (mHolder.getSurface() == null){
      // preview surface does not exist
      return;
    }

    // stop preview before making changes
    try {
        mCamera.stopPreview();
    } catch (Exception e){
      // ignore: tried to stop a non-existent preview
    }

    // set preview size and make any resize, rotate or
    // reformatting changes here

    // start preview with new settings
    try {
        mCamera.setPreviewDisplay(mHolder);
        mCamera.startPreview();

    } catch (Exception e){
        Log.d(TAG, "Error starting camera preview: " + e.getMessage());
    }
}
}

Answer: Just thought I would add a post here for future reference. This issue bothered me for a long time.
It turns out that my problem was caused by an incorrect preview size, although the resolution set was obtained from the getSupportedPictureSize method.
So for example you can get the sizes as follows:
//first entry in list is 1392x1392 for front facing camera on an S3
List<Camera.Size> supportedPictureSizes = params.getSupportedPictureSizes();

Setting this resolution or neglecting to set a picture size alltogether will cause the dreaded error 1001.
If you encounter this on any other device I would recommend trying different picture sizes.
Answer: So there was another reason for why I got it on my Galaxy S3. I was using a TextureView to show my camera preview and got this dreaded error when pressing the home button after a successful preview and then entering the app again. In the onResume() function I started up the preview again and found that I had not released the SurfaceTexture instance variable in the onSurfaceTextureDestroyed() function.
I added the release line to this function and it now looks like this and works perfectly:
@Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
    mSurfaceTexture = null; //This was the offending culprit.

    releaseMediaPlayer();
    releaseVideoRecorder();
    releaseCamera();

    return false;
}

Answer: In my case, in Samsung S3, the video-size parameter was not set and this led to the 1001 error. Setting the video size on the media recorder using preview size fixed the issue. However, this change may fail on other devices since the parameter may or may not be available/set in all devices. The following code addresses most of the devices:
if(params.get("video-size") != null && params.get("video-size").isEmpty()) {
    int videoWidth = params.getPreviewSize().width;
    int videoHeight = params.getPreviewSize().height;
    mediaRecorder.setVideoSize(videoWidth, videoHeight);
} else {
    mediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
}


How to use Raspberry PI4 as a device to play movies from my NAS on my TV using my smartphone?

Question: I'm new to the Raspberry technology so I wondered if it can be used to solve my 'use case'.  I have a Synology NAS with photos and videos and I have an old flatscreen TV which is not a smart TV (no internet/browser technology).  What I'd like to do is use my smartphone to see these photos and play these videos on my TV.  I assume I need to connect a Raspberry to my TV (HDMI) on one hand and via wifi with the NAS on the other hand, and use the smartphone to connect to the Raspberry to control and manage this all using the screen if my TV.
Is this at all possible and if so what would be the best way to get this going ?
Comment: You should learn to problem solve. First connect to your NAS. Solve subsequent problems later. The smartphone is a red herring.
Answer:
Is this at all possible?

Yes.  The only complicated part is communication between the phone and the Pi, the rest is trivial.  If you have experience developing smartphone or web apps, then you are probably good to go.
If not, unless one of those is something you wanted to start learning anyway, you probably do not want to start learning it just for this.  There are some Pi oriented apps in the Google play store (and elsewhere), I do not know how adaptable they will be to this -- although since you are not making any special use of the Pi hardware, something more general might be easier, that either pairs with Windows IoT or has a client/server architecture part of which can be deployed on Linux (and not proprietary, since unless it is in the repos you will need to compile specifically for the pi).  There may even be something, eg., python based, that is easily portable (does not require compiling, etc.).
If those last few sentences involved some gobbledygook for you, you could get by without any specialized app: There are SSH clients available for any smartphone, and you can use those to login to the Pi and do what you want via the commandline.  To make it easier, it is just a matter of writing (very simple) short form alias commands or shell scripts to do your tasks.  This is really only a matter of shortening something that might be sentence length down to something that is one or two words, again very simple, any literate person could do it given a few hours of study (and online resources like this one).
Even if I were planning on writing a custom application, that is the way I would start initially anyway.  If it turns out to be good enough, then hurrah.
Answer: kodi as a "Media Center Software" on the Pi and yatse on the smartphone for remote controlling kodi is a simple way using readily available software and without additional programming.

install kodi on your favourite Raspberry Pi OS, e.g. see here and yes, connect to Pi to the TV using the HDMI port
configure access to the NAS on the Pi via whatever means the Synology NAS supports, e.g. nfs or samba
install yatse (or look for an equivalent app) on your phone
enable remote access in kodi, look for something like "Allow remote control via HTTP", e.g. see here

Should be fairly straight forward, assuming the Pi, the NAS and the Phone are on the same network.


Is there a frequency converting amplifier?

Question: Frequency conversion means output of the amplifier is at a frequency different from that of the input.
Comment: Also, (if you made the question more clear), would you get a better answer on [Electrical Engineering Stackexchange](http://electronics.stackexchange.com) instead of Physics?
Comment: What problem are you trying to solve? Why wouldn't a simple oscillator at the desired output frequency solve the problem? (How do you want the characteristics of the input signal to affect the output signal)? What kind of signal are you trying to amplify (electrical, electromagnetic, sonic, optical, ...)?
Comment: Radio receivers quite often have a mixing stage to bring the received signal up or down into another frequency range to amplify/filter/whatnot. Is that what you mean?
Answer: Yes there is. The circuit is called a heterodyne and is used in radio communications receivers to downconvert the high frequency radio signals to lower intermediate frequencies which are easier to process. The heterodyne principle starts by mixing the radio frequency signal with that of a lower frequency local oscillator which produces a spread of frequencies consisting of the original, the local oscillator frequency, and sum and difference frequencies. Everything except the difference frequencies is then filtered out. Radios in which only one heterodyne stage is used are called single-conversion receivers and up to three stages are used in triple conversion receivers.
Within each stage, frequency-selective circuits are used to focus on a narrow band of passed signals so the radio exhibits good selectivity or rejection of adjacent signals which would otherwise interfere with the signal frequency of interest. The tuning of each stage is synchronized so the bandpass of all the stages coincide throughout the heterodyning process regardless of what frequency the radio is tuned to receive.


Is Internet required to activate Kinect?

Question: Do you have to have Internet on your Xbox 360 to activate the Kinect?
Comment: Well it directly had to get an update, so I figure you need internet regardless of activation
Comment: I was able to play on my parent's unconnected Xbox on Christmas morning. Not sure if the update came from the Kinect Adventures game or from the device itself, but it definitely installed an update and worked just fine.
Answer: No, Kinect comes with an update on it for drivers and stuff it needs to work.
Once you connect to the internet it does take a new update, but you don't need the internet (or that update) to use Kinect right out of the box.
Comment: @Bora what do you mean? IIRC if you don't have the latest system update you can't get online, regardless of whether you have Kinect or not.
Comment: I'm pretty sure that some time in the future Microsoft will not allow Kinect users with a depreciated software through XBox Live because they are becoming a security threat.
Comment: I wasn't talking about activating Kinect, but also playing with it online. That's why only as a comment.
Answer: The Kinect games all have the required updates on the discs.  It will prompt you to download the update (from the disc) when you try to play the game.  I believe future titles will require you to download updates from their discs as well.
There are plenty of people who play kinect without an internet connection, so I wouldn't worry about it.  Assuming you have the newest version of Xbox (unofficially called the "slim"), you can turn on wifi and try to connect to a neighbors connection just for updates, but of course this is frowned upon. :)


What is dependent typing?

Question: Can someone explain dependent typing to me?  I have little experience in Haskell, Cayenne, Epigram, or other functional languages, so the simpler of terms you can use, the more I will appreciate it!
Comment: Well, the article opens with lambda cubes, which sound like some type of sheep meat to me.  Then it goes on to discuss λΠ2 systems, and as I don't speak alien I skipped that section.  Then I read about the calculus of inductive constructions, which incidentally seems to have little to do with calculus, heat transfer, or construction.  After giving a language comparison table, the article ends, and I am left more confused than when I got to the page.
Comment: @Nick That's a general problem with Wikipedia. I saw your comment a few years ago, and I've remembered it since. I'm bookmarking it now.
Comment: Wikipedia has no sense of "knowledge dependencies" for its articles, and so no means of notating dependencies, let alone detecting *circular* dependencies. This means that 90% of its math and computer science articles are literally impossible to understand, *ever*, from simply reading the other articles linked in a given article.
Comment: the Wikipedia page is actually really nice: https://en.wikipedia.org/wiki/Dependent_type#Formal_definition
Comment: see this too https://www.quora.com/What-are-dependent-types
Answer: Consider this: in all decent programming languages you can write functions, e.g.
def f(arg) = result

Here, f takes a value arg and computes a value result. It is a function from values to values.
Now, some languages allow you to define polymorphic (aka generic) values:
def empty<T> = new List<T>()

Here, empty takes a type T and computes a value. It is a function from types to values.
Usually, you can also have generic type definitions:
type Matrix<T> = List<List<T>>

This definition takes a type and it returns a type. It can be viewed as a function from types to types.
So much for what ordinary languages offer. A language is called dependently typed if it also offers the 4th possibility, namely defining functions from values to types. Or in other words, parameterizing a type definition over a value:
type BoundedInt(n) = {i:Int | i<=n}

Some mainstream languages have some fake form of this that is not to be confused. E.g. in C++, templates can take values as parameters, but they have to be compile-time constants when applied. Not so in a truly dependently-typed language. For example, I could use the type above like this:
def min(i : Int, j : Int) : BoundedInt(j) =
  if i < j then i else j

Here, the function's result type depends on the actual argument value j, thus the terminology.
Comment: @Noein, refinement types indeed are a simple form of dependent types.
Comment: @mczarnek, these kinds of types *are* checked at compile time. Otherwise they wouldn't be types.
Comment: @TheAbelo2, in C++, they have to be compile-time _constants_, i.e., their value has to be fully known. They cannot depend on real _variables_, like the function parameters in the `min` example. Yet, certain conditions can still be derived or proved about them at compile-time, see again the `min` example and its result type.
Comment: I can see it being kind of nice and a way of letting the programmer know that i has to be less than j. But why does it really make that much of a difference vs just checking "if i>j {throw error}"?  This kind of type can't be checked at compile-time so effectively it's doing the same thing and I'm just not sure what the advantage is.
Comment: Isn't the `BoundedInt` example actually a Refinement Type, though? That's 'pretty close' but not exactly the kind of 'dependent types' that, e.g., Idris mentions first in a tutorial about dep.typing.
Comment: @AndreasRossberg I'm not sure I understand - you say C++ templates don't count because they have to be compile-time, yet how can dependant types be checked at compile time if they're dependent on runtime values?
Answer: Dependent types enable larger set of logic errors to be eliminated at compile time. To illustrate this consider the following specification on function f:

Function f must take only even integers as input.

Without dependent types you might do something like this:
def f(n: Integer) := {
  if  n mod 2 != 0 then
    throw RuntimeException
  else
    // do something with n
}

Here the compiler cannot detect if n is indeed even, that is, from the compiler's perspective the following expression is ok:
f(1)    // compiles OK despite being a logic error!

This program would run and then throw exception at runtime, that is, your program has a logic error.
Now, dependent types enable you to be much more expressive and would enable you to write something like this:
def f(n: {n: Integer | n mod 2 == 0}) := {
  // do something with n
}

Here n is of dependent type {n: Integer | n mod 2 == 0}. It might help to read this out loud as

n is a member of a set of integers such that each integer is divisible by
2.

In this case the compiler would detect at compile time a logic error where you have passed an odd number to f and would prevent the program to be executed in the first place:
f(1)    // compiler error

Here is an illustrative example using Scala path-dependent types of how we might attempt implementing function f satisfying such a requirement:
case class Integer(v: Int) {
  object IsEven { require(v % 2 == 0) }
  object IsOdd { require(v % 2 != 0) }
}

def f(n: Integer)(implicit proof: n.IsEven.type) =  {
  // do something with n safe in the knowledge it is even
}

val `42` = Integer(42)
implicit val proof42IsEven = `42`.IsEven

val `1` = Integer(1)
implicit val proof1IsOdd = `1`.IsOdd

f(`42`) // OK
f(`1`)  // compile-time error

The key is to notice how value n appears in the type of value proof namely n.IsEven.type:
def f(n: Integer)(implicit proof: n.IsEven.type)
      ^                           ^
      |                           |
    value                       value

We say type n.IsEven.type depends on the value n hence the term dependent-types.

As a further example let us define a dependently typed function where the return type will depend on the value argument.
Using Scala 3 facilities, consider the following heterogeneous list which maintains the precise type of each of its elements (as opposed to deducing a common least upper bound)
val hlist: (Int, List[Int], String)  = 42 *: List(42) *: "foo" *: Tuple()

The objective is that indexing should not lose any compile-time type information, for example, after indexing the third element the compiler should know it is exactly a String
val i: Int = index(hlist)(0)           // type Int depends on value 0
val l: List[Int] = index(hlist)(1)     // type List[Int] depends on value 1
val s: String = index(hlist)(2)        // type String depends on value 2

Here is the signature of dependently typed function index
type DTF = [L <: Tuple] => L => (idx: Int) => Elem[L, idx.type]
                                  |                     |
                                 value           return type depends on value

or in other words

for all heterogeneous lists of type L, and for all (value) indices
idx of type Int, the return type is Elem[L, idx.type]

where again we note how the return type depends on the value idx.
Here is the full implementation for reference, which makes use of literal-based singleton types, Peano implementation of integers at type-level, match types, and dependent functions types, however the exact details on how this Scala-specific implementation works are not important for the purposes of this answer which is mearly trying to illustrate two key concepts regarding dependent types

a type can depend on a value
which allows a wider set of errors to be eliminated at compile-time

// Bring in scope Peano numbers which are integers lifted to type-level
import compiletime.ops.int._

// Match type which reduces to the exact type of an HList element at index IDX
type Elem[L <: Tuple, IDX <: Int] = L match {
  case head *: tail =>
    IDX match {
      case 0 => head
      case S[nextIdx] => Elem[tail, nextIdx]
    }
}

// type of dependently typed function index
type DTF = [L <: Tuple] => L => (idx: Int) => Elem[L, idx.type]

// implementation of DTF index
val index: DTF = [L <: Tuple] => (hlist: L) => (idx: Int) => {
  hlist.productElement(idx).asInstanceOf[Elem[L, idx.type]]
}

Given dependent type DFT compiler is now able to catch at compile-time the following error
val a: String = (42 :: "foo" :: Nil)(0).asInstanceOf[String] // run-time error
val b: String = index(42 *: "foo" *: Tuple())(0)             // compile-time error

scastie
Comment: How does it deals with random value?  For example, will `f(random())` result in compile error?
Comment: Applying `f` to some expression would require the compiler (with or without your help) to provide that the expression is always even, and no such proof exists for `random()` (since it may in fact be odd), therefore `f(random())` would fail to compile.
Comment: -1. The code shown here illustrates refinement typing, which is related, but not identical to dependent typing. In fact, refinement typing is less expressive than dependent typing.
Comment: @Xwtek Thank you for feedback. Please see edited answer which hopeful now provides example of [Pi types in Scala](https://stackoverflow.com/a/12937819/5205022).
Comment: @MarioGalic: But wouldn't the presence of dependent types (and even refinement types) in a language require the evaluation at compilation time of many expressions that otherwise would get evaluated at run time, thus significantly increasing compilation time?
Comment: @AlexM., yes, typically compile times go up as it takes work to check the proofs. This is typical as type systems get stronger (a Rust program takes longer to compile than an equivalent Python program). This compile time duration vs runtime safety tradeoff suggests different programs should receive different amounts of compile time checking and safety. High assurance code (where e.g. security and physical safety are critical) takes longer to develop and compile and always has done.
Answer:
If you happen to know C++ it's easy to provide a motivating example:
Let's say we have some container type and two instances thereof
typedef std::map<int,int> IIMap;
IIMap foo;
IIMap bar;

and consider this code fragment (you may assume foo is non-empty):
IIMap::iterator i = foo.begin();
bar.erase(i);

This is obvious garbage (and probably corrupts the data structures), but it'll type-check just fine since "iterator into foo" and "iterator into bar" are the same type, IIMap::iterator, even though they are wholly incompatible semantically.
The issue is that an iterator type shouldn't depend just on the container type but in fact on the container object, i.e. it ought to be a "non-static member type":
foo.iterator i = foo.begin();
bar.erase(i);  // ERROR: bar.iterator argument expected

Such a feature, the ability to express a type (foo.iterator) which depends on a term (foo), is exactly what dependent typing means.
The reason you don't often see this feature is because it opens up a big can of worms: you suddenly end up in situations where, to check at compile-time whether two types are the same, you end up having to prove two expressions are equivalent (will always yield the same value at runtime). As a result, if you compare wikipedia's list of dependently typed languages with its list of theorem provers you may notice a suspicious similarity. ;-)
Answer: Quoting the book Types and Programming Languages (30.5):

Much of this book has been concerned with formalizing abstraction
  mechanisms of various sorts. In the simply typed lambda-calculus, we
  formalized the operation of taking a term and abstracting out a
  subterm, yielding a function that can later be instantiated by
  applying it to different terms. In SystemF, we considered the
  operation of taking a term and abstracting out a type, yielding a term
  that can be instantiated by applying it to various types. Inλω, we
  recapitulated the mechanisms of the simply typed lambda-calculus "one
  level up," taking a type and abstracting out a subexpression to obtain
  a type operator that can later be instantiated by applying it to
  different types. A convenient way of thinking of all these forms of
  abstraction is in terms of families of expressions, indexed by other
  expressions. An ordinary lambda abstraction λx:T1.t2 is a family of
  terms [x -> s]t1 indexed by terms s. Similarly, a type abstraction
  λX::K1.t2 is a family of terms indexed by types, and a type operator
  is a family of types indexed by types.

λx:T1.t2  family of terms indexed by terms
λX::K1.t2 family of terms indexed by types
λX::K1.T2 family of types indexed by types

Looking at this list, it is clear that there is one possibility that
  we have not considered yet: families of types indexed by terms. This
  form of abstraction has also been studied extensively, under the
  rubric of dependent types.
Answer: I will try to provide an answer that goes straight to the chase.
A dependent type is the label used to indicate that the output's type (i.e. the type of the co-domain) depends on the actual input value/argument passed to the (dependent) function. e.g. F:forall a:A, Y(A) means the input type of F is A and that depending on the specific value of a the output type will be Y(a). So the output type depends on the input argument.
For a normal function we usually write f: A -> B which means that function f, any input of type A (informally \forall a \in A or a:A) returns some element of type B (informally some a \in B or b:A). That is a "normal" function type. However, a dependent type indicates that the output type of the (dependent) function F depends on the argument. Similarly, the output type is indexed (i.e. "depends") by the value of the argument. E.g. the notation I like (that nobody else uses afaik) is F: a:A -> Y(a) or the common notation F: forall a:A, Y(a). These notations simply say F takes some element a in A (i.e. of type A) and returns some element y of type Y(a) (or if you like index sets more use Y_a). It just means that the output type of F changes depending on the input value a to F.
A common example is a function F: forall n:Nat, Vector n which explicitly specifies the size of the array returned/outputed. So if you call F(a) then the output is of type Vector n which means it can only return a vector of size n denoted F(a):Y(a). As you can guess, if you always somehow guarantee this return type is respected, you make it harder to make out of bound errors (which is good for security).
I actually really like the Wikipedia article section on product types and think it's very thorough. If some part of it doesn't make sense of that small section ask me here I'm happy to clarify in the comments section https://en.wikipedia.org/wiki/Dependent_type#Formal_definition. Hope to explain in more detail what the article says in the future -- especially the what a product type means and it's relation to Cartesian products.
Answer: An expression is said to be a dependent type if its type depends on a value.
Lets take C++. The expression "int" is of integer type. Its type doesn't depend on anything and is always
the same. Lets define another type called "int(x)", where x is a number. Lets define the purpose of the type int(x) as
helping us to have an integer with only "x" number of digits. Thus, the type of int(x) depends on the value of x, where the value of x
can be determined at runtime. For example, we can have a function that contains a statement that has the expression "int(x)" where the value
of x is passed as an argument to the function. What we are saying is that, for example, int(2) and int(3) are of different data types, i.e. how they behave
during computation is different.

What is dependent typing?


How long did Adam stay in Eden?

Question: Are there hints in the Bible or are there any hypotheses about the period of time Adam and Eve sojourned in Eden after their creation?
Answer: How long did Adam stay in Eden?
Ultimately we do not know this with any accuracy; some speculate one day or one week. We have no why to know for sure. Some Catholic mystics, such as Catherine Emmerich state that Adam (and Eve) were in the Earthly Paradise for about three (3) hours. The best response in my humble opinion is that they were in Eden for a relatively short period of time, with much leaning towards a single day or less.

How long were Adam and Eve in the Garden of Eden?
The answer is that we do not know. But, based on other biblical evidence, we can assume that their time in the garden was relatively short. The couple did not have their first child until after they were banished from the garden (Genesis 3:23—4:2). Since Romans 5:12 tells us that "sin entered the world through one man, and death through sin, and in this way death came to all people, because all sinned," Adam must have been childless at the moment he chose to sin. Any child born before Adam's sin would not have inherited Adam's sinful nature. There is no reason to believe that the man and woman abstained from sexual relations in the garden, but we can assume that Eve did not conceive her first child prior to their sin. It seems, then, that the serpent tempted Eve to eat the forbidden fruit and the couple were expelled from the garden quite early on (Genesis 3:1–7).
In their sin, Adam and Eve decided that the Lord would not be their Lord in this situation. They would be their own gods and choose for themselves what was right for them. The world has been reaping the consequences ever since. God had given them everything they needed to thrive and enjoy life, but they soon chose to disobey Him, and they lost paradise. Immediately upon sinning, Adam and Eve realized they were naked, and they felt ashamed (Genesis 2:25; 3:7). They made coverings for themselves out of fig leaves. But God provided them with garments of skin (Genesis 3:21), demonstrating that sin leads to death, as He had said, and that "without the shedding of blood there is no forgiveness" (Hebrews 9:22). God's action was a foreshadowing of the sacrificial death of Jesus Christ, whose blood would ultimately cover the sins of all who put their faith in Him (Hebrews 10:1–18). Also in the garden, God promised a Savior, one who would crush the serpent (Genesis 3:15)—that Savior is Jesus.
Then God drove Adam and Eve from the Garden of Eden and placed an angel with a flaming sword to guard it so they could not return (Genesis 3:24). But God never forsook them. In fact, He had a plan for redemption before He even called the world into existence (Isaiah 46:10; John 1:1–5; Revelation 13:8). For now, the world persists in sin, marred by its consequences (Romans 1:18–32; 8:18–25). But those who have put their faith in Jesus Christ have been forgiven of sin (2 Corinthians 5:21; Colossians 2:13–15). We have new life now (2 Corinthians 5:17; John 10:10) and will live with God for all eternity (Luke 23:43; John 3:16–18). One day God will make new heavens and a new earth (2 Peter 3:8–13; Revelation 21—22). The tree of life, lost to Adam and Eve, will be available to all who are a part of God's restored creation (Revelation 2:7; 22:1–2).
Though Adam and Eve's time in the Garden of Eden was short-lived, all is not lost. God offers us true life in Him. He is patient with this world, allowing it to continue on, because He wants all to repent and come to Him (2 Peter 3:9). He will one day bring judgment, and we must be ready (2 Peter 3:10)—we must turn from being the gods of our own lives and instead trust in the one, true God. By His grace, through faith, we can be saved (Ephesians 2:1–10). Choose life in Jesus Christ today!

Some Jewish traditions favours the opinion that Adam was in Paradise one day.

Talmud: The day on which Adam was created consisted of twelve hours. During the first hour his dust was gathered; the second hour it was made into a shapeless mass; the third hour his limbs were stretched out; the fourth hour a soul was placed in him; the fifth hour he stood on his feet; the sixth hour he named the animals; the seventh hour he was paired with Chava; the eighth hour they had two children; the ninth hour he was commanded not to eat from the Tree of Knowledge; the tenth hour he sinned; the eleventh hour he was judged; and the twelfth hour he was banished from the Garden of Eden and went on his way (Sanhedrin 38b).

Regardless of how we interpret the bible and any historical evidence, there will be be some who claim the Adam and Eve lived in Eden's Garden for many years. Personally, this does not add up, but so be it.

While not inspired, The Book of Jubilees was written in the second century BC and claims that Adam and Eve were in the Garden for seven years [pp. 46-48]. If they entered the Garden with the appearance of being 12 years of age, as suggested above, it poses the following question: We have two nubile teenagers, naked and in an earthly paradise with God's first commandment – "to be fruitful and multiply" – ringing in their ears [Genesis 1:28]. After seven years, why were there no children and Eve not even pregnant? The answer seemingly resides in the extreme longevity of pre-flood mankind. From the record in Genesis chapter five, we can deduce that the average longevity of the father [Enoch excluded] was 907 years, while the average age of the father for his first or principal son was 117 years. The Book of Jubilees maintains that Eve was aged between 64 and 70 years when she gave birth to Cain, her first child [p. 51]. - How Long were Adam and Eve in the Garden of Eden?

Notwithstanding the lack of historical evidence, many hold that both Adam and Eve were in Eden a relatively short time, perhaps a day or less.
Answer: Some things to consider in relation to this question
Genesis 2:19-20 tells us that before Eve was created, Adam was given the assignment to name all the land animals and birds. These verses say (NWT)

19 Now Jehovah God had been forming from the ground every wild animal
of the field and every flying creature of the heavens, and he began
bringing them to the man to see what he would call each one; and
whatever the man would call each living creature, that became its
name. 20 So the man named all the domestic animals and the flying
creatures of the heavens and every wild animal of the field, but for
man there was no helper as a complement of him.

A Watchtower article from 1976 on this states the following (emphasis added)

The brevity of the Genesis account surely does not require our
thinking that God simply gathered all the animals and birds into a big
group and then had them file past Adam while he quickly called off
names for them, one by one.
[...]
But even so, we cannot rule out the possibility that God's "bringing"
these creatures to Adam may have involved their moving in sufficiently
close to allow Adam to study them for a time, observing their
distinctive habits and makeup, and then select a name that would be
especially fitting for each. This could mean the passing of a
considerable amount of time.

If Adam had spent merely a week in observing a single species, he would have named about 52 of them in a year.
Another point is that Genesis 5:3 says that Adam was 130 years old when his 3rd son, Seth, was born. According to Eve's statement in Genesis 4:25, the birth of Seth happened after Cain had killed Abel. Of course there are quite a few unknowns here, for example that we do not know how old Cain was when he killed Abel. However it would seem reasonable that Adam and Eve had their first children sometime soon after leaving the garden. For that reason this factor, and the possible time it took to name the animals, could indicate that Adam was at least several decades old at the time he was expelled from the garden.
Comment: Yeah it is one of those we can't really know questions
Comment: How long was Adam alone in the Garden?
Comment: hi @User14, the Bible does not say. But judging from that he named the birds and land-animals (meaning, apparently, animal species) before Eve was created, it could have been decades. The narrative would work, logically speaking, even if Adam was 120 years old and Eve, say, 60 years old when they were expelled. But since the Bible does not say, this is just speculation and guesswork.
Comment: https://wol.jw.org/en/wol/d/r1/lp-e/1968324?q=%22seventh+period%22&p=par

Or it could have been a very brief time
Comment: hi @User14, you are correct that that is a possibility as well, as that article (from 1968) brings out. Throughout the years there has been different ideas about that duration like what can be seen in [this article from 1955](https://wol.jw.org/en/wol/d/r1/lp-e/1955089?p=par#h=18) and in [this article from 2019](https://wol.jw.org/en/wol/d/r1/lp-e/2019166?p=par#h=9-10). This is not a subject that we have any strong beliefs in either way.

How long did Adam stay in Eden?


Migrate from rails 2.1.1 to 2.2.2

Question: I am working on a project using rails 2.1.1.  With the new release of 2.2.2 I want to migrate to the new version.  Is there anything I need to change to migrate my 2.1.1 controllers, views, and models?
Answer: Don't forget to run the update Rake task
rake rails:update

That will go ahead and make sure it updates any scripts and configs to reflect 2.2.
Once you have 2.2 installed, issue:
rake -T

to view the available tasks, double check it's there and go ahead and fire it off and you'll be up and running.
Good luck!
Answer: There aren't any major changes in the way things are done.  Here is the list of deprecations
Of course the best way to quickly discover changes is to have a good test suite in place.  If you don't have that, I suggest dropping 2.2 into vendor/rails and clicking around the site by hand.
Answer: If you have any plugins that break, check GitHub. I had a bunch of plugins break with no official fixes. I searched GitHub and people had already patched them. Made the upgrade much better then it could have been.
Answer: Not really. I would have to agree with @dasil003 and say to check deprecations, and run your tests accordingly after updating. However, you'll need rubygems 1.3.1 in order to upgrade, so don't forget to do so, or your app server won't start.
Answer: You will also need to blow away your existing /vendor/plugins/activescaffold directory, and replace it with one that is compatible with rails 2.2. Otherwise you'll get the dreaded (and poorly documented) "no method 'pick_template' error".
To do this, you'll need to run the following in your app base directory:
script/plugin install git://github.com/activescaffold/active_scaffold.git -r 'rails-2.2' # add --force if necessary
Next, add:
script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.2
I ran into this migrating from 2.1 to 2.3 but I've read elsewhere that the issue is rampant going from 2.1 to 2.2 as well. Adding to save others the hassle.

Migrate from rails 2.1.1 to 2.2.2


Why can't my friend text me on my iPad mini 2 from her phone which is not and iPhone?

Question: I cannot receive nor send texts to my friend on her phone, which is not an iPhone. The error message is "This phone number is not registered with iMessage".
Answer: iPad can only send and receive iMessages. If your friend don't have any device from Apple (iPod, iPad, Mac, iPhone), he can't send you a message through iMessage. Use another chat service.
(Like Messenger from Facebook or WhatsApp)


Has a party that won an election ever lost its leader in the process?

Question: In a Parliamentary democracy, general elections appoint constituency representatives. Most such appointees are members of parties with internally determined leaders. One or more parties then form a government, with one of these party leaders the head of government.
However, it's theoretically possible that a party that enters or stays in government due to its electoral performance has to change leader, due to that individual losing their seat. (Party leaders typically come from safe seats to prevent this.)
Has this ever actually happened? I'd be interested if this happened in the UK, or failing that in any nation with a Westminster system.
Comment: Your question assumes district based elections - maybe it should be tagged as such (but which tag should be used? Maybe tag it "UK"). When using proportional voting, the first on the list - the leader - will be elected.
Comment: @J.G. Yes, Israel has pure PR at the national level. You're elected to represent the country as a whole (not only formally but also practically). If you are familiar with multi-seat constituencies like those in Ireland, you can think of this as one giant constituency covering the whole country. Another example would be the Netherlands, although it does technically have separate constituencies (but the parties typically submit the same candidates to all constituencies and the seats are apportioned at the national level).
Comment: @Sjoerd  It could also use Single Transferable Voting (STV).  That doesn't have districts, but a party leader is not guaranteed to win like in a party list system.
Comment: One thing to note is that the system of clearly designated party leaders, all of whom have seats in the Commons is relatively modern in the UK (at least compared to the age of the parliament). The government was last lead from the Lords by the Marquess of Salisbury in 1902.
Comment: @origimbo  Lord Home was technically Prime Minister while in the House of Lords as well.  He resigned his peerage and moved to the House of Commons *after* being chosen as Prime Minister (1963-1964).
Comment: Actually, in many parliamentary democracies, MP do *not* represent constituencies.
Comment: @Relaxed In such systems, how are MPs appointed? Could you give an example?
Comment: Another reason why this Q is specific to the westminster system is the unspoken assumption that government members sit in parliament. In most systems, parliament and government are distinct, often even by (constitutional) law.
Answer: That's incredibly rare as you mentioned, but it has happened before twice in Canada to the same Prime Minister though he remained Prime Minister.
Prime Minister William Lyon Mackenzie King lost his seat in York North in 1925 and his seat in Prince Albert in 1945 but went on to be Prime Minister on both occasions. However, his party lost their majority in Parliament on both occasions, though they won the by-election in 1925 and was the largest party in 1945.

Usually, leaders would only lose their seat if their party loses too, in which has occurred twice in Australia and once in the UK.
John Howard lost his seat, Bennelong, in the 2007 Australian federal election while Stanley Bruce lost his seat, Flinders, in the 1929 Australian federal election.
In the UK, Arthur Balfour lost his seat in Manchester East after the Conservative landslide defeat in 1906.
These examples are referenced from The Guardian.
Comment: Goddammit Panda you type faster than me
Comment: Might be worth adding that, on both occasions, King returned to Parliament shortly thereafter by persuading a member of his party in a safe seat to resign so that King could stand there instead. (Ditto for @SleepingGod's answer).
Comment: @SteveMelnikoff As evidenced by the 2nd loss of seat, maybe not safe enough.
Comment: @SleepingGod Lol :P
Comment: @Yakk indeed! :-)
Comment: Gave you thumbs up. I may be mis-remembering, but I seem to recall that this has happened to at least one other Canadian PM. But I don't have the citation. I also seem to recall it happening to the leader of the party that came second in at least one election in Canada. So the leader of the official opposition had to stand in a by-election to get a seat in parliament. Again, I don't have a cite.
Answer: In 2007 the Prime Minister of Australia John Howard lost his seat, but his party also lost the election. He is the second Australian Prime Minister to lose his sear in an election after Stanley Bruce in 1929.
In Britain Prime Minister Arthur Balfour lost his seat of Manchester East in the 1906 general election, but remained Conservative party leader, without a seat.
The best example of a Prime Minister who lost his seat but remained prime minister is William Lyon Mackenzie King who lost his seat in in the 1925 Canadian general election and in the 1945 Canadian general election, but still kept the job as Prime Minister of Canada. He returned  to parliament shortly after each of these elections by persuading a member of his own party to resign from a safe seat (which triggered a by-election) where he stood in turn and won.
Credit to Steve Melnikoff for point regarding how King returned to parliament in Canada
Answer: In the 2013 British Columbia provincial election, Christy Clark, the premier, lost her own seat to David Eby, even though the BC Liberal Party won a majority of 49 of the 85 seats in the legislature.
As a result, Ben Stewart resigned from his safe Liberal riding of Westside-Kelowna, effectively yielding his seat to her via a by-election.  Clark resumed her role as premier, then appointed Stewart as a provincial representative to Beijing.
Answer: Something like nearly happened in North-Rhine-Westphalia in Germany recently, where the candidate for prime minister of the winning party, Armin Laschet, won his seat by only a slim margin (article in German).
If he had lost it, the party would have had to do some shenanigans to get him into parliament (e.g. some other winning candidate would have had to renounce his seat) since he must be a member of parliament to become prime minister.
Answer: You could make the case that this "almost" happened to the Scottish National Party in the recent UK general election, and the situation would have been even closer to the OP's criterion if the SNP had become part of a coalition government.
The SNP remains the party with the largest number of Westminster MPs in Scotland (though reduced from 53 to 35 MPs in the 2017 election), but its former leader in Westminster, Angus Robertson, lost his seat to the Conservative candidate. The former party leader, Alex Salmond, also lost his Westminster seat.
Note, the current SNP party leader (Nicola Sturgeon) is an MSP in the Scottish Parliament, not at Westminster, and was therefore not a candidate in the Westminster election.
Answer: I'd like to point out the answer about Canada was wrong. Sitting Prime Ministers have lost their seats four times. The first time was in 1921 when Arthur Meighen lost his seat and the Conservatives, who had been in power since 1911, lost the election to William Lyon Mackenzie King. He had to run in another safe seat to sit in Parliament. Meighen then became the only sitting PM to lose his seat and the election a second time, in the 1926 election.
Meighen won the election of 1925, since he won the most seats, but could not form a government. King became PM when he formed a coalition with the Progressive party. Scandal forced him to resign, and a constitutional crisis was triggered when the Governor-General, Lord Byng, refused to allow a new election and invited Meighen to try to form a government. It lasted 88 days, and Meighen lost his seat in the next election and King and the Liberals formed the government again.
King lost his seat in the 1925 election, so he was the 2nd sitting PM to lose his seat, but still put together a coalition to form a government and was elected in a by-election in a safe seat after a resignation.
The 3rd time was Meighen's loss in the 1926 election, and the fourth was King's 1945 loss.
Comment: Please add references add references to support your answer.
Answer: While not Parliamentary, this is close enough. Newt Gingrich, who was the US Speaker of the House, lost his position 1998 after his party lost only 5 seats. While that was not enough to cost them the majority (i.e. they still won overall), it was enough to spark a revolt within the party against a weak election showing they blamed him for. Gingrich, rather than lose an election for Speaker, resigned.
Also, Eric Cantor, House Majority Leader, neglected working hard in the primaries and wound up losing to a political newcomer, who then went on to win Cantor's seat in the 2014 Republican landslide.
Comment: Though the title isn't clear on this, the question is specifically about the leader of a party losing his seat in an election. Gingrich didn't lose his seat in the 1998 election.
Comment: No, I don't believe they are close enough. The only US Speaker I know of who would conceivably qualify was [Speaker Galusha Grow](https://en.wikipedia.org/wiki/Galusha_A._Grow) in the election of 1862. But I believe this question was phrased to make it implicit that it is only talking about parliamentary systems.
Comment: @SteveMelnikoff Neither of these fit exactly, but are close enough. Gingrich won his seat, but he still resigned it after it became obvious he could not stay Speaker. I added Eric Cantor, which fits better (although still not Parliamentary)
Answer: In the US, Tom Foley was Speaker of the House and lost his race for reelection in 1994.  However, his party also lost (so he would not have been Speaker if he had won).
More directly, Galusha A. Grow lost his bid for reelection in 1862.  His party (Republicans) kept the House and he was replaced by another Republican, Schuyler Colfax.
Grow had replaced William Pennington as Speaker after Pennington lost his seat.
Comment: in all fairness, in US, party leader is typically the President, not Speaker.
Answer: While this is not a  Westminster system (but it is mostly a parliamentary one), Romania has suffered a similar process just in the recent years:

in 2016 the Social Democrats won the Parliamentary elections and formed the Goverment. Their leader (Liviu Dragnea) wanted to be the PM, but this was prevented by having been convicted of election rigging. However, he remained head of the Chamber of Deputies (part of the Parliament) which virtually means the 3rd person of the state (after the President and the head of Senate). He was de facto running the Government
in May 2019, Dragnea was sentenced to jail and had to leave all positions (party leader, head of Chamber of Deputies).
as a bonus the subsequent PM (who also became the party leader) and her government has not managed to survive a motion of trust (no-confidence vote).


How can I find where an app's files are stored?

Question: Besides the app's package, is there a way to find where it stores its other files from during installation?  Are they only allowed to install into the "Library" folders, or are there other places?  I want to wipe my drive and do a fresh install when I upgrade to Mountain Lion.
Answer: Deleting the files from an individual app and doing a clean install of Mountain Lion are two different things. As per mckeed's answer, you can use AppZapper to delete an individual app, other alternatives being AppDelete or Clean my mac, although the latter could be a bit overkill for what you want.
Fresh install for ML is a different story though, I did a fresh install the other day and I'm super glad I did - I'm one of those people who just collects apps and files they don't need and everything gets a bit clogged after a while. Simple instructions to do so are:

Start off by backing up whatever you need (I know this ones a bit
obvious), save anything you want to keep to an external harddrive.
You'll need to get your hands on another external harddrive or usb stick at least 8gb, and it has to be empty as we're going to use this to make a mountain lion boot disk. If it's not empty, don't worry we'll erase it in step 7.
Download mountain lion from the app store, but don't install it otherwise the app disappears and you'll have to re download it.
Secondary click (right click, whatever you want to call it) the install icon and choose "show package contents" from the menu.
When the contents of the install file are displayed you'll see a folder called "SharedSupport", open this up and you'll find a file called "installESD.dmg". Copy this file somewhere so you know where to find it.
Open "utilities" in your applications folder and open "Disk Utility"
Plug in your blank USB drive from step 2. You'll now see it in the left pane of the disk utility window, click on it to select it.
Click on the "Erase" tab in the main disk utility pane. Change the "format" dropdown to MAC OS Extended (Journaled) and then name your disk something that makes sense to you like "Mountain Lion Install". Click erase.
Click on the "Restore" tab in the main disk utility pane. In the "source" section, you'll need to navigate to and select the "InstallESD.dmg" file we copied earlier. In the destination tab you'll need to select your now clean drive. Click Restore.

The drive and your mac will now make whirry and buzzy noises for a while. When it's done cooking it will tell you. You now have a Mountain Lion boot disk.

Restart your computer with the new Mountain Lion drive plugged in still and immediately hold down the option key when it starts back up. If you've done this right, instead of booting OSX you'll see a picture of your drive to select. Click on the disk you created earlier to boot from it.
Now the scary part. You don't want to install just yet, somewhere on the screen there is an option for utilities, I think from memory it's in the top bar. Click utilities and select "disk utility" which looks alot like (actually exactly like) the disk utility app you used to make the disk earlier. This time, select your macs harddrive in the left pane and click the erase tab, make sure the format is set to MAC OS Extended again and click erase.
You've now erased your harddrive. Close out of the utilities window and continue the installation as normal installing Mountain Lion onto your newly clean Harddrive!

Hope all this helps, best of luck!
Answer:
Search for the application's name or bundle identifier with mdfind
Open fseventer before installing an application or opening it for the first time
lsbom -fls /var/db/receipts/somefile.bom
Press command-I after opening a package file or look at the bom file inside it with lsbom
Comment: Do you know how to output absolute paths when using `lsbom`?
Answer: Unfortunately there are many places apps typically put files, and there are no restrictions to where they can (other than folder permissions).
The easiest solution is the third-party uninstaller AppZapper, which searches for related files, though nothing would be guaranteed to find everything.


Can I use SearchKit to display a specific Contact Tag on a public directory?

Question: I am building a membership directory and want to display information on each member that is contained in the form of Contact Tags. I can obviously display the full list of Tags, but we use some for back office purposes.
I am using SearchKit to build the dataset for the directory, as the requirements go beyond the capabilities of other Civi searches.
So for instance, I would like to display (on a public directory / form) the Tag "Founding Contributor" (which identifies a category of donor) whilst excluding other Tags associated with that Contact.
I have Tags grouped in Tag Sets, which helpfully distinguish "back office" Tags from others.
Answer: You should be able to if you add 'Contact Tags' as a required or optional entity and then limit to the specific tag you want to include.
Comment: Thank you so much Rebecca - problem solved!
Comment: I have a supplementary question. I want to display more than one Contact Tag in the Directory. How can this be achieved with Searchkit? I guess it might be difficult to filter Tags in a record to show only those I wish to publish within the one Contact.Tag column, and I can't see how I could add a line to the query to show a different Tag in a separate column of the table.
Answer: I have found that I can specify a second Contact.Tag as an optional entity to show a second Tag in a separate Column...


How to make a fake DOC file containing only images

Question: I want to convert a PDF file to a DOC/DOCX file. I do not want the fomatting of file be affected in this conversion. Is there any tool to put every page in the pdf file as image in a DOC file. So when you open it in MS-Word, you think it is a regular word file (apparently you can not edit it, because it only contains images.)
Answer: ImageMagick will let you take a PDF and export a set of images, from there you could select all and drop into a Word document and do a group resize on all the images so that each image fits on one page neatly.
Alternatively you could get ImageMagick to do the image resizing but that may need a little trial and error to get the correct size.
Comment: If you can get the images the correct size to fit on one page of the document without needing changed inside Word why is doing a multi select from Windows Explorer and dragging them into the empty document a problem?
Comment: Thanks. Exporting PDF to a set of images is not the main problem. Inserting each image in each MS-Word pages is time-consuming. The PDF has more than 100 pages.


Exterior plateau problem with planar ends

Question: Considering a Jordan curve $\Gamma\subset \mathbb{R}^3$, we know from Douglas and Rado that there exists a unique minimal disk which bounds $\Gamma$. We also know that there exists exterior solutions, for example graph over $\mathbb{R}^2\setminus \Omega$ where $\Omega$ is the interior of the projection of $\Gamma$ over $\mathbb{R}^2\times\{0\}$ when the projection is one to one. Moreover we know that these surfaces are asymptotic to a plane or a catenoid. My question is about condition over Γ for existence of such minimal surface asymptotic to a plane? and do we know some curve for which there exits several solutions?
Comment: This was crossposted at math.SE: http://math.stackexchange.com/questions/35170 . Raphael, in general, posting the same question in multiple places at once is discouraged - you don't want to make someone work hard to giving you a great answer just to hear "thanks, but I've already got it from another forum". I'm unable to judge whether this question is appropriate for MathOverflow (since this isn't my area), but you should probably close one of the two versions you've posted.
Comment: The question has been removed from math.stackexchange. I agree that this is not, at first sight, an unreasonable question for MO.
Comment: Zev, I ask to math.SE for deleting the other post since I think this is more appropriate for MO.
Answer: Evidently what you want is Friedrich Tomi and Rugang Ye, "The Exterior Plateau Problem," Mathematische Zeitschrift, vol. 205 (1990), pages 233-245. I have only the first page available, but it appears that, once a normal direction to the surface at infinity is specified, so is the surface they construct. So there are, at least, infinitely many solutions. I should think their surfaces are planar at infinity, since a sufficently symmetric curve $$ x =  \cos \theta, y = \sin \theta, z = \sin 4 \theta  $$
with a catenoidal exterior minimal surface that faces "up" would have a second  catenoidal surface that faces "down." I imagine they discuss uniqueness for planar solutions.
Actually, that shows me how to give a $\Gamma$ with three answers. Draw some very non-symmetric curve around the neck of the catenoid. This curve has two existing catenoidal exterior minimal surfaces, the upper end of the catenoid and the lower end. If Tomi and Ye's solution with the same normal at infinity is planar, that gives a third solution. Of course, this is not very different from saying that the catenoid and the plane give three solutions exterior to the unit circle in the $xy$ plane.
Note that, by the Meeks-Hoffman strong half space theorem, a properly immersed minimal surface in $R^3$ that lies between two parallel planes is itself a plane. This is a comment only on the situation when an exterior solution and an interior solution match up to give a complete surface.
Comment: I will read attentively the paper of Ye and Tomi. But my question was about the uniqueness of solution with planar ends. Of course if $\Gamma$ is planar  then the only solution should be the exterior of the plane. But if $\Gamma$ is not planar does their exists exterior solutions with different planar ends and how is characterize the normal direction at infinity?
Comment: ...Anyway, Thank you for your answer
Comment: You might also want to have a look to this other paper (specially section 3) of Tomi & Jorge: Tomi, F., and L. P. Jorge. "The exterior Plateau problem in higher codimension." Journal of Mathematical Sciences 149.6 (2008): 1741-1754.


How can I find out what I did wrong?

Question: I logged in this morning, to find that I had somehow accumulated 8 down votes on a single question.  The activity page says that the question has been deleted.
I am new to this site, and eager to learn, but I can't figure out how to see what it was that I did to cause the problems. I have included a snip of the activity below.
Can someone explain to me what happened, or how to find out what happened?  I certainly would not want to repeat whatever the offense was, but I have no clue as to what I did...
Comment: Could you leave me a link to the question, so I could substantiate my answer?
Comment: @IͶΔ: http://ell.stackexchange.com/questions/80066/is-this-grammatically-correct
Comment: D'oh, people actually do use the tools tab? :P
Comment: @IͶΔ: Apparently! :P
Answer: This wasn't your question. It was someone else's, and you answered it; you got one upvote (+10) and one downvote (-2) for a net of +8... which was removed when the question was deleted, for -8, which is what you saw.
The question was deleted by the roomba automatically 9 days after closing; it was a straightforward proofreading question, which are generally only going to be of any value to one person, and won't usually teach them anything either.
In general, questions that should be closed for simple reasons like this should not be answered, as some effort is made by myself and others to delete the questions eventually, and that will usually take all rep gains. (If you provide a good enough answer to a terrible question — score of 3 or up — and the question lasts for at least 60 days after you post it, you'll keep the rep.)
Comment: You didn't do anything bad; but I'd recommend not answering questions that are likely to be closed in the future @Msf, to keep the quality of the acceptable ELL question high.
Comment: @DanBron: Hmm. I'm not sure that's the best test; relying on the existing close reasons (proofreading, dictionary, etc) is likely to be more specific and more useful.
Comment: @DanB - That's a good litmus test for ELU. For ELL, a more appropriate litmus test might be: _Would a general native speaker, a man on the street, know the answer to the question, while non-native speakers would have trouble figuring out this answer on their own?_ That said, proofreading questions are considered off-topic, even though they would pass that litmus test. We don't want ELL to become a free proofreading service, inundated with request for touching up resumes, cover letters, homework assignments, advertisements, and the like.
Comment: Okay, thank you for the explanation!  What a relief.  I thought I had done something really bad...  Apparently, I am just clueless, instead.  ;-)
Comment: @Msfolly: There's a lot of subtleties to Stack Exchange, yeah. Just try to do the best you can at answering the most useful questions and you shouldn't see this very often.
Comment: I will certainly try.  I am just now getting a feeling for how the system works, and what is acceptable, and what is not.
Comment: @Msfolly A good litmus test is: would a general native speaker, a man on the street, know the answer to the question immediately? If so, the question is likely to be closed, unless the OP specifically asked for the linguistic or grammatical mechanisms underlying the situation, and has demonstrated that's he's done some research of his own.
Comment: @NathanTuggy You're right, somehow I got mixed up and thought this was EL&U meta.

How can I find out what I did wrong?


How do I delete / remove icons in Windows 8.1 for programs already uninstalled?

Question: In Windows 8.1, when you click on the Start Menu, there is a down arrow to see the complete set of program icons, instead of just the ones pinned on the Start Menu. I found some for an old application I had already uninstalled that did not clean up after itself. The right-click uninstall context menu option only opened the Control Panel -> Programs -> Programs and Features selection, which no longer had the app in question.
Answer: What I found was that if I chose the right-click, Open file location on the icon, it brought me to the place where shortcut icons are kept.
On my installation of Windows 8.1, it was in

C:\Users*MYUSERLOGINID*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\

folder, where MYUSERLOGINID is my actual user login ID.
After I deleted the folders with the old program names, the icons were gone.


Looking for a verse like "if all the Jews repented at once the world would be saved"

Question: I grew up as a Christian and vaguely remember from those years a verse like "if all the Jews repented at once the world would be saved". It might have been "all the Christians" or another group; it might have been "they would see God" or another concept than the "world" being "saved". I'd love pointers to where this might have come from.
Comment: Wherever it is from, this is not from the Bible.
Comment: Is there a particular Bible translation which you used in your childhood that it would have come from?
Comment: we used NIV but I don't remember it well enough for more than a paraphrase
Answer: The Jerusalem Talmud, also called the Palestinian Talmud, not to be confused with the Babylonian Talmud, is a collection of rabbinic writings. It includes a statement  by the fourth century AD Rabbi Aha:

If Israel repents for one day, forthwith the son of David [the Messiah] will come.

According to some Jewish thought, in every generation there is someone ready to become messiah. if the circumstances of the time are right, God will appoint him, otherwise not. Another similar expression is that if Israel kept one or two Sabbaths properly, the Messiah would come.
The Christian Biblical version of this is in the second epistle of St. Peter.  Christians believe that the Messiah has already come, but will return. We read in  chapter 3. verse 9:

The Lord is not slack concerning his promise, as some men count slackness; but is longsuffering to us-ward, not willing that any should perish, but that all should come to repentance.

This verse is in the context of the delay in the Second Coming (v 4), and explains the delay as due to patience, a desire to give more time for repentance. If God is procrastinating to give more time for repentance, what would happen if everybody did repent? There would then be no further need to delay the Second Coming. This verse, then, may suggest that if everyone repented the Second Coming would happen immediately.  However, some Christians  see this as merely a hypothetical inference since they believe that, in fact,it is predestined that not everybody will repent.
Reference - see When will the Mashiach come? or for more detail on Rabbi Aha's discourse see Messiah in Routledge's dictionary of Judaism
Comment: I don't think 2 Peter 3:9 is discussing a day where everyone will repent. Verse 7 says it will be a day of destruction for the ungodly people.


Inverses of Modulo N

Question: It's easy to show that relatively prime numbers have inverse mod n via the Euclidian Algorithm-How do you show that they don't necessarily have an inverse if they aren't relatively prime? I would think you would start by pulling out a common factor, then maybe showing that if that factor isn't one, you'll always have some number greater than one time an integer for any power of the number, so there wouldn't be an inverse... but I think I'm wrong.
Answer: $$mm'\equiv 1\pmod{n} \Leftrightarrow mm'-1 = kn \Leftrightarrow mm'-kn = 1\Leftrightarrow \gcd(m, n) = 1$$
Answer: Fix some n, such as 6. Take a number not coprime to $n$, then take its sequence of multiples.

Inverses of Modulo N


Was there a fight during the filming of Caddyshack?

Question: During the filming of Caddyshack it's said that Bill Murray and Chevy Chase had a fight. Ever since then they refuse to work together. I'm wondering if it's known if there is any truth to this or is it an Urban myth? I am especially looking for interviews or statements that show this conflict between two great comedy actors that both started out on SNL and have the same friends.
Comment: -1.  Sorry, doesn't show a lot of research.  It took me a short time to find sources for the fight at SNL, not Caddyshack.   The answer is good though.
Comment: No problem. I wasn't sure where to look for actual sources rather than rumors. I had heard that it actually started on SNL but that didn't make sense to me since they have the scene in Caddyshack. The part I missed was Harold Ramis making it happen. Also they haven't worked together since and I've always heard references going back to the fight between them.
Comment: No problem from my side either, I just don't like to downvote without leaving a reason. I liked the question in principle, and you've got a good answer, and a few upvotes - so maybe i'm wrong :-)
Answer: It wasn't during the filming of Caddyshack but during Saturday Night Live.  Murray started on Saturday Night Live in the fall of 1977.  Chevy Chase had left the show at the end of the 1977 season and his movie "Foul Play" was due to be released in mid 1978.  The fight took place February 18, 1978. According to the excerpt from the book "Live from New York", on this blog, Bill Murray states:

"I got into a fight with Chevy (Chase) the night he came back to host. That was because I was the new guy, and it was sort of like it was my job to do that. It would have been too petty for someone else to do that. Its almost like I was goaded into that. I did sense that. I think they resented Chevy for leaving, and leaving and making his own career go. Everybody else was from the improvisational world, where you don't make it about you. You were an ensemble, you were a company. So when he left, there was resentment about that. It was a shock.
"At the same time, Chevy was the big potato on the stew. He got the most sketches, he had the most influence, he got the publicity -- all of those things. So they didn't miss that part of it. But there was still hangover feelings that he shouldn't have left until everybody had that. You make sure everybody else is there and then you do it.
"It did leave a big vacuum, because he was really heavy in those shows. You look at those early shows and he's heavy. And so you had a whole year when the writers ended up writing, like writers do -- they write for the guys who can get it done, who can get it on the air -- and Chevy's sketches got on the air because he was "the man," you know. The other actors had to start from scratch and teach the writers how to write for them ... When you become famous, you've got a year or two where you act like an asshole. You can't help yourself. It happens to everybody. You've got, like, two years to pull it together -- or it's permanent.

According to cast member Laraine Newman

"It seems that there was a tension between Chevy and Bill all along during the week. I don't know why. I don't know if Chevy provoked it or not. But it culminated with Billy saying to Chevy, 'why don't you fuck your wife once in a while?' And I don't even remember who threw the first punch, Billy or Chevy. But it was ugly. I'd never seen guys fighting like that, let alone people I knew. And, you know, I don't know how he did it, but Chevy went out and did the monologue a few minutes later. Watching from the floor, he seemed shattered.

According to the IMDB Caddyshack Trivia Section the scene with Murray and Chase's character in the greenskeeper shed were not in the original script.  Harold Ramis realized that the two had no scenes together in the entire movie so he sat down with Murray and Chase and worked out the scene.
Comment: Good answer and thanks for clarifying when the actual fight happened. Though it does look as though in the book "Live from New York" there are a few differences on the way it happened (which happens with witnesses) it does explain the basic start of the fight.


Does hardening reduce the ductility of a metal?

Question: Is hardening equivalent with reducing the ductility of a metal and improving the yield strength of it?
Comment: Hi, I listed a short answer below, but no offence meant, Wikipedia seems to cover the subject pretty well in a general sense.
Answer: From Wikipedia:

Hardening is a metallurgical and metalworking process used to increase
  the hardness of a metal. The hardness of a metal is directly
  proportional to the uniaxial yield stress at the location of the
  imposed strain. A harder metal will have a higher resistance to plastic
  deformation than a less hard metal.

Link to original reference: Hardening Metal
Ductility is reduced after hardening, but you don't say which metal or alloy you have in mind and, because of the varying crystal structure, it's a property that varies with the metal.
Again from Wiki:

There are several ways in which crystalline and amorphous materials
  can be engineered to increase their yield strength. By altering
  dislocation density, impurity levels, grain size (in crystalline
  materials), the yield strength of the material can be fine tuned. This
  occurs typically by introducing defects such as impurities
  dislocations in the material. To move this defect (plastically
  deforming or yielding the material), a larger stress must be applied.
  This thus causes a higher yield stress in the material. While many
  material properties depend only on the composition of the bulk
  material, yield strength is extremely sensitive to the materials
  processing as well for this reason.

Yield Strength Factors From Wikipedia
Comment: Thank you! The reason why I posted this question is that I didn't found a site that combined hardening and his influence on ductility and yield strength. So if hardness is directly proportional to yield strength, is yield strength, unlike ductility, then independent on the crystal structure?
Comment: I have edited my answer as  it seems other factors, including introducing other elements, can improve yield strength. If you think about it, bronze for example is improved by the addition of tin into pure (weak strength) copper.  This is not really my field, could I suggest, just to make sure you get the correct answer, that you read the wiki links in my post and then  you submit the question about yield strength again after looking through  the tags (there are lots of them) to see is there one more specific to your question.
Answer:
The image shows the stress-strain curve for a structural steel (not to scale).   The steel has a ductility, i.e it has a failure strain, of just over $\epsilon_y$, after which it breaks.
Start loading from the origin and you initially go up the straight line of slope $E$.   Up to the initial yield stress of $^0\sigma_y$, the material is elastic and, if unloaded, will return down the same line to the origin.
If you reload from the origin, you go up back up the line until $^0\sigma_y$ then, if loading continues, you follow the curved line.   If you unload from $\sigma_y$ say, you come back down the second straight line with slope (approximately) $E$ to $(\epsilon_p,0)$.   Now you have induced a permanent plastic strain of $\epsilon_p$ in the material and you recover an elastic strain of $\epsilon_e$.
If you now reload from $(\epsilon_p,0)$, you  will go back up the second straight line but further yielding will not occur until the current yield stress of $\sigma_y$.   You have then raised the yield stress and, in this sense, hardened the material.
However, the original failure strain of just over $\epsilon_y$ doesn't change so, on reaching the point $(\sigma_y,\epsilon_y)$, there is very little strain left until the material breaks.   In this sense, the material is less ductile than it was at the start.
Whether this work hardening is an improvement or not depends on what you want the steel to do.   If you want high yield stress and ductility, you have to alloy the steel.
Just to confuse matters, work hardening raises the yield stress but it isn't the same thing as what is commonly called the hardness of the material.   The latter is more complicated, is usually measured by an indenter test, and depends on a number of factors such as yield stress, work hardening rate, etc.