Calibration of Cox regression survival analysis

Question:
To perform calibration of a Cox regression model (i.e. assessing for the agreement between the predicted and the observed outcome), what is the best method to present the accuracy of the model in predicting the actual event?
As far as I understand, we can calculate the actual outcome probability by observing the number of events that occurred in a number of subjects with similar/same predicted probability from the Cox model. To perform the above calculation, do we stratify the predicted risk into several groups (<15%, 15-30%, 30-45% etc.), and within each risk group we use the number of subjects as the denominator for the calculation of actual outcome?
What method do we use to compare the predicted outcome with the actual outcome? Is it good enough if we simply present the predicted and actual risk% in each risk group in table format? Can rms package in R do all calibrations for you?
Can we use pec::predictSurvProb() to give the absolute risk of event for each individual? Can we specify the time point for the risk/hazard function for each individual to be at the ENDPOINT of follow up?
When interpreting the results, do we use the mean follow up period (in years) as the time point on which the predicted risk and actual risk are based? (E.g. Individual A has 30% risk of event at 6.5 years (mean follow up period))
Is the goodness-of-fit test for Cox regression (Gronnesby and Borgan test) simply a means for calibration for cox regression? Or does it mean something else?
To compare models with net reclassification, how many subjects and outcomes do we need for such method to become valid?
Answer:
Cox models do not predict outcomes! "Best" methods depend on whether you obtain a risk score (as with Framingham) or absolute risk (as with Gail Breast Cancer Risk). You need to tell us exactly what you're fitting
With absolute risk prediction, you can split groups according to their risk deciles and calculate proportions of observed vs. expected outcome frequencies. This is basically the Hosmer Lemeshow test. But, in order to use this test, you need to have an absolute risk prediction! You cannot, say, split the groups by risk score deciles and use the empirical risk as the risk prediction, this strips off too much information and leads to some counter intuitive results.
The bioconductor package has a suite of tools related to ROC analyses, predictiveness curves, etc.
Nowhere in Ulla's package is mention made of estimating smoothed baseline hazard estimates. This is necessary to obtain risk prediction from survival models... because of censoring! Here's an example of that method being applied. I would accept no less from the package.
No, don't use mean follow up. You should report total person years follow-up, along with censoring rate, and event rate. The Kaplan Meier curve kinda shows you all of that.
I'm sure Sir David Cox is not fond of G&B's test. The power of the Cox model is that it can give consistent inference without necessarily having predictive accuracy: a tough concept for many to grasp. Tsiatis' book "semiparametric inference" has a lot to say about this. However, if you aim to take the Cox model one step further and create predictions from it, then I think the G&B test is very good for that purpose.
Reclassification indices are proportions of individuals being shuffled into different (more discriminating) risk categories comparing two competing risk prediction models (see Pencina). It's important to realize (Kerr 2011) that you can calculate confidence intervals for this value... not using the bootstrap (or any limit theory treating the model as fixed) but using the double bootstrap (bootstrap sample, refit model, bootstrap sample again, calibrate models).
Comment: (+1) Nice answer.
Comment: @ AdamO - (b) Any R packages would allow the performing of Hosmer Lemeshow test or G&B's test for Cox regression?
Comment: @ AdamO - (a) I am trying to assess the incremental value of a biomarker in risk modelling by fitting models with that biomarker and models without that biomarker and compare the predicted ABSOLUTE RISK(%) of developing adverse cardiovascular outcomes in models with and without the biomarker (in a cohort with a mean follow up period of 6.5 years).
Comment: Do read the article I linked from Gail. Getting absolute risk from Cox models requires a smoothed estimate of the [BL hazard, as done here](http://rss.acs.unt.edu/Rdoc/library/gbm/html/basehaz.gbm.html). With that, [HL test code popped up in R forums long ago](https://stat.ethz.ch/pipermail/r-help/2008-September/174044.html). Also see the work done by [Janes and Pepe](http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3091826/) which I think is very insightful. I haven't seen the G&B test elsewhere. Any chance you can write it up on your own?
Comment: Re #6: to test calibration in survival models you can use modified Hosmer-Lemeshow test (called GND test in the paper). Here is the code with the reference (https://ncook.bwh.harvard.edu/assets/code101316_GND_test_replicable_example.R).
Answer: @ AdamO is more knowledgeable than me, but if what you are trying to do is see if adding a biomarker to a model improves the model then this is a case of "nested" models.  What's needed is:

Define the null hypothesis as  H0: No improvement in risk prediction
Apply the likelihood ratio test to calculate twice the change in the log-likelihood statistic (D).
This difference D follows a chi-squared distribution with n degree of freedom (n=1 in this case if you are adding just 1 biomarker). You look up D in a chi-squared table to find a p value.

I've played with assessing the added value of a biomarker risk to a logistic regression model.  If you are interested in there are some new statistical metrics (including net reclassification - often poorly applied) and a way of visualising them that are far more informative than merely comparing AUCs (c stats).  See my paper Pickering, J. W., & Endre, Z. H. (2012). New Metrics for Assessing Diagnostic Potential of Candidate Biomarkers. Clinical Journal Of The American Society Of Nephrology, 7, 1355–1364. doi:10.2215/CJN.09590911


Is PMKID same for a specific client when it is roaming from AP1 to AP2 using WPA2-Enterprise?

Question: I have two access points (APs) setup with the same SSID name and using the same freeRADIUS server for station authentication. I have read Cisco documentation about fast roaming. So I have this doubt in my mind. Is PMKID same for a specific client when it is roaming from AP1 to AP2 using WPA2-Enterprise?
Answer: The answer is no.
PMKID is an unique value as a result of hash function combines the PMK with Access Point's MAC address and Client's MAC address.
Comment: Isn't it the combination of `authenticator's address (aa)` and `supplicant's address (spa)` as per hostapd documentation? And here authenticator is RADIUS server. In this case, PMKID supposed to be the same right?
Comment: @NayabBashaSayed These terms mean: Authenticator = AP, Supplicant = Client and Authentication Server = Radius. You can check again the docs from hostapd (https://w1.fi/hostapd/) and from CWNP (https://www.cwnp.com/uploads/802-11i_key_management.pdf)


Nissan Altima Intermittent Emergency brake warning light

Question: Every morning when I release the emergency brake, the light on the dashboard stays on.  At times I apply and release as hard as I can and the light goes off.  During the day, there is no issue with the light. I'm guessing there is a loose connection.  If so, where do I go about checking the connection?  If not, what else could be wrong?
Comment: The light can come on if the brake fluid is low or where the front brakes need to be done ... all the fluid is sitting in the calipers, which will refill the reservoir once new brake pads are installed.
Comment: As Paulster2 said, this can happen if your brake fluid is just starting to get low. Mine would come on intermittently...but only when slowing down at stoplights. You can check your car's user manual (or look online) to confirm if your dashboard brake light will come on as a "low fluid" indicator.
Answer: The first port of call should be your brake fluid reservoir. The emergency brake light will stay on if the brake fluid level is low (which could happen if your brake pads are wearing thin).


Altas with rules on different layer than the cover layer

Question: I need to generate an atlas based on a polygon shapefile, but I'd like to see just what is inside the polygon itself. Maybe with rules that involves other shape's attributes. Any suggestion?
Answer: You can do as described below. But I strongly recommend to do this only on small(er) datasets, as this will need a lot of calculation. If you want to do this with a bigger dataset, I suggest to first join attributes by location, so you don't need to perform an intersection by expression for every single feature and perform the rule based selection based on the joined attributes.
Create a rule based symbology for your polygon layer using this expression: @atlas_featureid = $id

Now create a rule based symbology on your other layers. Use within() for point layers and intersects() for line and polygon layers:  intersects( geometry( get_feature_by_id( 'polygonlayername', @atlas_featureid)),$geometry)

When you now preview your atlas only features are displayed that fall within or intersect with the current atlas polygon feature.

Addition to show surrounding features:
You can also build a buffer around your polygon. Just use this expression for it:  intersects(  buffer( geometry( get_feature_by_id( 'polygon', @atlas_featureid)),100),$geometry)
100 is the buffer size in meters. Be aware you will need a projected CRS (like UTM) to use this properly. The result:
Comment: @RicccardoLeuci Updated my answer so surrounding features nearby will also be displayed.
Answer: If your polygons are square or rectangular, you can size the map extent to suit and select 0% as the margin around the feature.
If you polygons are some other shape (possibly irregular), I would make a new layer that is supersized to cover all your Atlas polygons.  Then find the difference between the two layers (which will give you a copy of the supersized polygon but with holes in it where your Atlas polygons are.  Add this at the top of your layers and colour it either opaque white or semi transparent (to fade out the surrounding area but still let people see the wider context of the map).
I've used this method both with Atlas and with other maps where I want to focus attention on a specific area.


View remaining stamina

Question: So we know that as when you sprint the stamina 'amount' decreases, what I'd like to know is if there's a way to see the amount of stamina they have left before they hit their 'limit' and it starts deducting health? Is there anything the character does to give a clue it might be getting low?
Comment: Well they start breathing heavily but other than that I don't know. I think they should have replaced the air bar with a stamina one and made an air bar pop up when underwater
Comment: There's an air bar? Where's that? My understanding is it's: Green - Health, Blue - Armour, Yellow - Special.
Comment: Oh. Never mind then. Armor would make sense. I thought the blue bar would go down underwater. So there is neither a stamina nor an air bar. That's pretty lame
Comment: There is a stamina bar, but only when you're doing the Triathlon.
Comment: @Nolonar Oh right, I haven't done one of those yet. I thought of this when I had to race a girl near the beach and I had no idea how what my stamina level was.
Answer: There's no stamina bar, the only exception is when you do the Triathlon race.
One way to find out when you are running low on stamina before starting losing health during "normal" activities it's by looking at the health bar, it starts flashing before starting draining your health.
Comment: Thanks, that was driving me absolutely mad. Being colour blind does NOT help with this at all. Ramming the 2/3 bars together is very confusing for me.

View remaining stamina


What would be an algorithm for calculating the ideal column widths of a table to show on-screen, to minimize the table's height?

Question: I've you've ever had a table of text like in Word or Google Docs, you'd know that there are ideal widths for each table column to minimize the height of the table and fit the most text, here's an example. I've tried thinking about how I could implement that myself, but have no ideas. I wonder if this would be some sort of optimization math equation, but I haven't touched math in forever. If it was, how would it optimize all the column widths? I did some looking up, as well as asking both GPT 3.5 and 4 to write a Python script for this, but they both had issues.
Comment: Shouldn't the first word of the post body be *If*? *minimize the height of the table* shouldn't be the only criterion - else make every column a mile and half. To find an approach, start with a simplified problem: How to size columns if texts weren't made up of words/"non-divisible" chunks - say, of repetitions of a single narrow glyph.
Answer: There is a reasonably efficient algorithm for this.  I will assume that you have a value $w$ that is the maximum possible width for the table, and you want to find column widths that sum  to at most $w$, that minimize the table height.  For instance, $w$ might be the width of the page or of the text region on the page.
The solution will be to use binary search repeatedly.  In particular, we'll do binary search on the height $h$ of the table.
I assume the text for each column is given.  Therefore, given any proposed width $w_i$ for a column, you can compute the height required for that column (by formatting the text into a box of width $w_i$).
Now I suggest you use binary search on $h$, the height of the table, to find the minimum achievable height, given that the total table width must be no greater than $w$.  Suppose we have a particular $h$.  For each column, say the $i$th column, find the minimum width $w_i$ for that column that ensures its height will be at most $h$ (this can be done using binary search over $w_i$ combined with the fact from the prior paragraph).  This gives a minimum width $w_i$ for each column.  Now compute the sum $w_1+\dots+w_k$; if this is greater than $w$, then conclude that height $h$ is not attainable (within the constraint on max table width); otherwise conclude that height $h$ is attainable.  Continue using binary search on $h$ to find the smallest $h$ that is attainable.
The total running time will be at most something like $O(n^2 \lg^2 n)$, where $n$ is the size of the input.  There are probably optimizations to significantly improve this.


Recover Time Machine Photo Library Without a Mac

Question: I'm trying to help a friend and looking for the best solution. I have an external hard drive that was his time machine backup on his old mac, which he no longer has. I can mount this drive on Ubuntu and see the many backups and directories. What is the easiest way to recover the Photo Library without a mac? It appears they are spread all over the drive in different backup folders and I'm hoping there might be an easy way to get the photos without having to go into each backup directory.
Answer: You will need a Mac to make sense of the database and choices made. Also, sign into iCloud photos from a modern browser and check what data if any was synced to Apple servers.
See about borrowing or renting one from a library or friend in the community. It is very easy to install macOS on an external drive and migrate everything back to a live album and then export the best version of the photos and avoid all the thumbnails, optimized (full resolution is in iCloud) and other photos and videos.
Can you tell how much space is in the latest photos library folder and estimate the size of one full size photo based on which camera your friend used? We might be able to estimate time to import and the export for you in that case.
Comment: Thank you this helps a lot. I'll try to find a mac to get those photos exported.


Can I enter Colombia with an expired passport if I possess a second nationality?

Question: Hi i have tried on several occasions to get in touch with the colombian consulate in london and to no avail. My british passport is an electronic passport but my colombian one is not. I plan to travel to colombia in a months time. Is it possible to travel with my british passport to colombia and my non electronical colombian passport which states it expires on the 2017? i have my colombian cedula identity card up to date. Will i have problems entering Colombia?? please someone help and advise
Comment: I think you should only show them your Colombian documents and I can't really imagine they would not allow their citizen in.  I would think that even an expired passport should be good enough to enter your country, so that you can apply for a new one "from home".
Comment: It is now 2016.  Your passport expires in 2017.  Your passport is therefore valid.  Am I missing something?
Comment: phoog  its not an electronic or has the barcode to scan. its just a standard Colombian passport they say on the consulate website its now void. Im wondering if i can travel with my electronic British passport surely that should be ok right? Ive heard that the Colombian authorities can be quite funny even send you back  if you enter with your British passport or any other passport  being a Colombian citizen. Im based in London and the majority of my family live in Colombia i must travel due to bereavement in the family.
Comment: Grzenio i don't think any country would allow you in their country even if you are a citizen with an invalid passport but i have booked an appt to get an electronically Colombian one with the london consulate which is in June the dates are ridiculous there is nothing available sooner. i could ask if i could get it done in colombia but its still no guarantee they will let me in.
Comment: @Grzenio Not all countries allow citizens to re-enter with expired or invalid documentation. For instance, India is (in)famous for refusing to allow citizens with expired passports to enter the country.
Comment: Vanessa: Is your passport machine readable?  That is, does it look like [this](https://upload.wikimedia.org/wikipedia/commons/3/32/ColombianBiometricPassportInside.jpg), with two rows of data at the bottom of the ID page? If so, it is still valid even if it is not an e-passport. See http://bu.com.co/en/newsandpublications/300.
Comment: Please check this question: http://travel.stackexchange.com/questions/45265/colombian-entering-colombia-on-day-of-colombian-passport-expiry-date-could-i-be?rq=1
Answer: Colombia has a law requiring dual nationals to enter Colombia with their Colombian passports:

Nota: De conformidad con el Artículo 22 de la Ley 43 de 1993, el ciudadano  colombiano que posea doble nacionalidad, en el territorio colombiano, se someterá a la Constitución Política y a las leyes de la República. En consecuencia, su ingreso y permanencia en el territorio, así como su salida, deberán hacerse siempre en calidad de colombiano, por lo tanto deberá tener pasaporte colombiano para el ingreso y la salida del territorio colombiano.

Source: http://www.cancilleria.gov.co/tramites_servicios/pasaportes

Annotation: In accordance to Article 22 of Law No. 43 of 1993, Colombian citizens with dual nationality will be subject, in Colombian territory, to the Constitution and Laws of the Republic. Therefore the inmigration and emigration processes must always be done in his/her status as Colombian citizens and a current valid Colombian Passport is required.

Source: http://www.cancilleria.gov.co/en/procedures_services/passports
To comply with this law, then it seems that your only option is to be persistent in trying to make contact with the Colombian consulate.  If you don't have enough time for an ordinary application, you might be able to file an emergency application.
Or, depending on your passport, it may not actually be invalid.  Machine-readable passports continue to be valid, according to http://bu.com.co/en/newsandpublications/300.
It is interesting to note that the English translation says "current valid" but as far as my limited Spanish skills can ascertain, there is no such condition in the Spanish text.
Comment: What is immigration going to do if the citizen's passport is expired? Deport them?
Comment: @JonathanReez I do not know.  See [Michael Hampton's comment about India](http://travel.stackexchange.com/questions/61914/can-i-enter-colombia-with-an-expired-passport-if-i-possess-a-second-nationality/61933?noredirect=1#comment129666_61914).
Comment: but India doesn't allow double citizenship, while Colombia does. It's therefore illegal to travel to India with a passport from a different country, which is a whole different issue.
Comment: @JonathanReez but it's not necessarily illegal to travel to India with an expired Indian passport.  The UK allows British citizens to travel to the UK with expired UK passports, for example.


nonce usage in authentication

Question: In digest based authentication, nonce is generated by server. However in OAuth based authentication, nonce is generated by client. I want to know if anyone knows the reason for the difference?
Answer: Nonces are used to make a request unique.  In an authentication scheme without a nonce, a malicious client could generate a request ONCE and replay it MANY times, even if the computation is expensive.  If the authentication schema requires the client to perform expensive computation for every single request, as the request is made unique by using a nonce, the replay attack is folded, as its speed just went from O(1) to O(N).
The reason to have a client nonce is to prevent malicious clients do replay attacks.
The reason to have a server nonce is to prevent a Man-in-the-Middle attacks, in case an attacker captures a valid server response, and tries to replay it to a client.
http://en.wikipedia.org/wiki/Cryptographic_nonce has a nice explanation and diagram for how to use a nonce.
http://en.wikipedia.org/wiki/Digest_access_authentication has a nice example of how nonces are used in the real world.
Comment: I don't understand. What prevents a malicious client to send many times a `nonce` he has generated once? Is a request supposed to be turned down when the server receives a `nonce` already used?
Comment: Nothing, malicious clients can do that no problem.  That's not the scenario that nonces protect.  They protect non-malicious users from having their login replayed by a malicious snooper.
Answer: Firstly, sometimes clients do provide a nonce in digest auth, but mainly it relies on the server (see RFC2617)
Secondly, because if you think of the authentication procedure in terms of a handshake, then with Oauth when you already have a token you've been through half of the handshake, you've already spoken with the server, so your next move is to contact the server with your service request. This needs to be protected by a nonce too, so you provide it.
Or, the converse. I already have the token, so why would I contact the server to get a nonce so that I could then contact the server again with my service request? I might make a 1000 service requests, by producing my own nonces it cuts down on 2000 bits of network traffic that were unneeded.

nonce usage in authentication


How can I use rsync to backup personal files to an external hard drive or network drive without having permission related issues?

Question: Background
What is the "correct" method to use rsync to backup data? The reason why I ask for the "correct" method is because my past experience of using rsync has resulted in permissions, file/folder mask, and timestamp related issues. Therefore, this question seeks to understand how can I use rsync to backup data without running into any permission, file/folder mask, or timestamp related issues, primarily when rsync is being used on a Windows system.
Another motivation for this question is to ensure that I don't into my previous issue where I was unable to access any files on my external drive which was backed up with rsync via cygwin. This was a nightmare because I had actually lost data on my main PC and was trying to restore it from the backup.
Below are similar issues I have ran into when using rysnc:

Unable to access any files on external drive that was backed up using rsync Rsync and Cygwin based backup on Windows gives permission denied errors
Unable to preserve timestamp https://unix.stackexchange.com/questions/61586/how-to-tell-rsync-to-preserve-time-stamp-on-files-when-source-tree-has-a-mounted
rsync - mkstemp failed issue https://stackoverflow.com/questions/11039559/rsync-mkstemp-failed-permission-denied-13

My understanding of rsync usage is intermediate and I have referred to the guides listed below. However, my biggest confusion of rsync usage comes from permissions, file/folder masking, Posix, etc.

The Non-Beginner's Guide to Syncing Data with Rsync
Rsync man page

Requirements/Assumptions

I want to use rsync in the context of "backup" and NOT in the conext of "sync". Often other users asking questions related to rsync may be interested in "syncing" data to ensure they have a working copy of files on another PC in sync. However, my intention is not for "syncing" but simply "backing up", such that if anything happens to my PC, I can get a last backup copy and restore it.
The original files that need to be backed up could exist on any operating system (ex: Windows, Ubuntu, MacOS), but primarily on Windows.
On Windows, rsync is used using Windows Subsystem for Linux (WSL) and NOT through cygwin
The destination for the backup could be an external drive formatted as NTFS, FAT32, or exFAT or it can be a network drive (ex: Samba share).
This is not required, but destination could be connected to using SSH

My current method & issues
I am using rsync through Windows Subsystem for Linux (WSL) on Windows 10. Below are example example issues I have run into:
Example 1: Not working
rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup

This method results in files NOT being transferred and errors like below:
rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)

and
rsync: mkstemp "/mnt/my_usb_mount/ProjectA/src/.mydata.json.6cfTCf" failed: Operation not permitted (1)

Example 2: Partially working
rsync -avhP --no-p --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup

or
rsync -avhP --no-p --chmod=ugo=rwX --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup

This method of using rysnc results in files being transferred but the timestamp (created, modified, accessed) are all set to the time of the transfer. If I run the rsync command again, all the files will be detected as modified and get re-transferred because of the incorrect timestamp. In addition I get errors like below:
rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)

Example 3: Correctly working.
sudo rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup

This method work perfectly, however, I don't understand why I have to use sudo? Is it because I am using rsync on Windows through WSL? Would I have to use sudo if I were backing up files from a Linux PC (ex: Ubuntu)?
Although example 3 is a working solution, I still have many questions:

How do I know when sudo is required?
When do I use --no-p or --chmod=ugo=rwX
What if I don't have permissions to use sudo?
Will it work if I were backing up files to a network drive?
What if I am using SSH?
When using rsync from Windows through WSL, will I ever run into weird permission or file/folder mask issues as I previously have?
Comment: You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access.   SSH won't directly help you, although rsync can (and often does)  run over ssh.     You would typically use sudo if backing up files you do not own in Linux.
Comment: The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own.   If you back up on a network drive then the permissions are limited by what the network drive supports.  You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
Answer: Ntfs and fat don't care about linux permission, you must make you're backup on a partition ext4
or make a backup and compress it into tar.gz and then decompress it on a linux system file and restore it


What's up with these new high energy neutrinos?

Question: A bunch of pop science articles just popped up talking about new high-energy neutrino detection. See this article, published today, for example. The answer to this question says that the source of high-energy neutrinos is still an open question, however, these news articles seem to be saying that there was a breakthrough in understanding where they come from. A comprehensive summary of the results and their implications, plus a link to an arXiv post, would be superb.
Comment: You may find some interest in the [*Science* article](http://science.sciencemag.org/content/early/2018/07/11/science.aat2890.full).
Answer: High energy Neutrinos also sometimes referred to as astrophysical neutrinos have previously been observed, but a source has never been well localized. For reference on some useful past work, this article talks about the relevant detection mechanisms and implications as well as some of the predictions: https://arxiv.org/pdf/1801.01551.pdf.
The newest observations (outlined in this paper but not on arxiv right now: http://science.sciencemag.org/content/early/2018/07/11/science.aat2890) are showing strong evidence that the event detected by IceCube in September 2017 is localized to a certain Blazar, Blazar TXS 0506+056. Blazars are very compact quasars (quasi-stellar radio source) that are associated with supermassive black holes at the center of giant galaxies.
Blazars are amongst the most energetic phenomena in the universe and as such have been hypothesized to be a source of astrophysical neutrinos for a long time. Blazars are formed in the same way that all active galactic nuclei (AGNs) are formed at the center of a galaxy around a super massive black hole (SMBH). As gas, dust and occasionally stars spiral inwards towards the SMBH, a hot accretion disk is formed which releases a large amount of energy in the form of photons, electrons, positrons and other elementary particles.
Perpendicular to the plane of the disc, a pair of jets transport energetic plasma away from the AGN. The jet is formed due to large winds and turbulence as well as magnetic fields near the center of the AGN. This jet is where it is hypothesized that we see these astrophysical neutrinos. These jets move at very high velocities with much of the plasma reaching speeds of 95-99% the speed of light.
The new observations which combined multiple wavelengths and many observational devices, have successfully localized the detection to an area of $\sim 1\ \text{arcmin}^2$ and therefore successfully isolates the observation to within the area of influence of a single blazar.
The next questions that must be asked are how the source is creating these neutrinos, primarily whether it is from a relativistic jet and whether or not the jet is baryonic. Now that we know what to observe to find them, it will be easier to continue the search for more information about their origin.
Comment: A better description of a blazar would be useful, particularly the orientation.
Comment: AGN = active galactic nuclei
Comment: I added some more info on blazars. Feel free to comment, submit and edit or start a new answer if you have more input on useful information I am missing. I am not an expert on this subject but I work with researchers who are in this field so I have a decent idea of the big picture but am probably missing some specifics.
Comment: The whole point is that a blazar is an AGN where the jet is basically directed towards us.


Good one-way sync program for Windows?

Question: I need a program that can do one-way synchronization of directories in Windows. The only feature I absolutely need is the ability to exclude certain files and/or folders from the sync (wildcard support here is a must). Any suggestions?
Answer: I would highly advise you use Microsoft SyncToy, you can setup one way partnerships and it can do exactly what you want!
Comment: Can it exclude subdirectories, though? I'm using it right now but I see no option to exclude certain file types or subdirectories.
Comment: Never mind, I see it...d'oh! I don't know how I missed that. :) As a bonus question, is there a way to have it run on a schedule through the program, or do I have to create a Windows scheduled task for that?
Comment: I've used Sync Toy but unfortunately I found it to be unbearably slow for me to take backups of admittedly very large numbers of large image files, using XCOPY with parameters set to copy newly updated files worked a lot better. My two cents.
Answer: Robocopy is good -
e.g. to synchronize folders,
robocopy <source> <dest> /MIR

to see other options run robocopy /?
There's also a UI wrapper called RichCopy - doesn't seem to have much of a home, closest thing. More Info. Blog updates.
Comment: If you use robocopy then don't forget `/copy:DAT /dcopy:T` otherwise all your timestamps and file attributes will be messed up.
Answer: As Wil mentioned, SyncToy is a great GUI tool for this. If you'd rather a command line program which you could use in batch files and schedules tasks, take a look at robocopy. It is a command line robust copying tool and is built into Windows 7. It will only copy files which have changed, works over the network or locally, has wildcard support, can exclude specific filetypes, individual files, or directories, and can run in restartable mode for if it gets interrupted. A very powerful tool, and not too difficult to use. Run robocopy /? in the command line for documentation.
Answer: I have been using GoodSync to do bi-directional synchronization between two computers, so I am sure it could be used for one-way sync as well.  Perhaps overkill for what you are trying to do, but a nice program to have around.  Supports wildcards, and has many automation features.  I have no connection with the company (they're the same one that markets RoboForm); I'm just a happy user.
Comment: Yes, I did take a brief look at their product, and it looks pretty good (no pun intended). I may install the trial and test it out, but it sounds like I can just stick with SyncToy unless GoodSync has some feature(s) that will blow me away. Thanks for mentioning it, though. :)
Answer: Depending on how much your wanting to sync... syncplicity is really good at syncing files. You can exclude subdirectories, and even files.  it also does two way syncing or just one way (backup).  It saves all the files online, and to any other pc you install it on. However in order to use the free option, you have to keep it under 2 gigs.
http://www.syncplicity.com/
Comment: I'm not a fan of cloud-based sync tools; otherwise I'd just use Dropbox. Thanks though.

Good one-way sync program for Windows?


iBGP running only between BGP border routers?

Question: I was studying about the BGP protocol and I had this question:
Let's say we have an AS having both BGP border routers and internal routers . I know that the border routers should form a full mesh to have iBGP sessions and exchange external routes (learned by eBGP).
I was wondering how the internal routers are going to learn about these external routes.
Do the internal routers also establish iBGP sessions?; do the border routers redistribute the external routes through IGP protocol?; do the internal routes have static (or not static) default routes to border routers (but how to choose which one)?
Does anyone have an idea how the current network operators deal with this issue?
Answer: Typically (but this is not always the case), the border routers inject a default route into the IGP.  This can be done either by redistributing a route from BGP into the IGP, or redistributing a static default route.
It's also possible to inject a few summary routes into the IGP if it is necessary to steer certain traffic to a particular border router.
Comment: So let's assume we have injected a default route with final hop to a border router, and anything with a destination beyond our AS will be sent to this router. If this border router has learned through iBGP that another border router is "closer"  to the destination AS, it should send this traffic back into our AS to reach this preferred router, right? But then doesn't this create a loop?
Comment: As I said in the second paragraph, if you have multiple exit points, and you need to steer certain traffic to a particular border router, then you would inject the required routes into the IGP.


Music deleted from my iPhone 4

Question: So I have the iTunes app on my iPhone 4 and I used it to purchase songs onto my phone. I went to my music app a while back a deleted some songs I didn't want anymore ( i just went to the song swiped my finger across the screen and the delete button apeared) but now I want them again and I don't know how get them back on my phone with out debuting them?
Answer: If you bought it on the same Apple ID, then the iTunes on your computer should see that you purchased those songs already. Therefore, you should be able to simply sync music back to iPhone.
Perhaps I'm not understanding your question though. So I'll cover both sides.
Transferring Music from iPhone to Computer
If you purchased songs and you bought them on the same Apple ID, you can simply transfer purchases back onto your iPhone. See the picture below.
Just go to File => Devices => Transfer Purchases

Transferring Music from Computer to iPhone
First of all, you can see what content you purchased (make sure you sign in to the iTunes store first). Take a look at the picture below. You should see it under the Quick Links section:

However, to automatically transfer these purchases from the computer to the iPhone, you need to follow these instructions:
On the iPhone Side:
You need to use Automatic Downloads. Make sure it's on by following the directions in the picture below.

On the Computer Side:
Make sure that iTunes has the preference that is mentioned in this picture enabled.
Answer: There's a purchased section on the iTunes app. If you tap it you can view the song you have purchased.

Music deleted from my iPhone 4


Why do tokamaks have so few toroidal field magnets?

Question: From the ITER webpage itself, the tokamak has only eighteen toroidal field magnets. If the magnetic field is directly and linearly dependant on the number of coils around the torus, then why did the best plasma physicists choose to have so few? Wouldn't many problems, such as the maximum current density of the coils, or the systems necessary to keep these coils cooled be solved by having many more, thinner coils? What qualities made fewer superconducting coils more attractive than many?
Comment: What makes you think that thinner coils would have a better maximum current density? The critical current density of a superconductor is largely an intrinsic property, meaning that the maximum _total current_ that can be carried by the coil increases with coil thickness (remember that the magnetic field depends mainly on the total current through the coil). See e.g. https://physics.stackexchange.com/questions/1060/can-a-superconducting-wire-conduct-unlimited-current
Comment: @probably_someone I suppose I didn't make myself clear. Yeah, the critical current density IS intrinsic, and wouldn't change, and the critical current itself would be lower for a given coil, but with more coils, the amount of current necessary for a given magnetic field is lower. Then, one wouldn't need to find exotic materials with high critical current densities and the like.
Answer: Intensive optimization routines go into planning the number of toroidal field magnets. Technically, groups of thin coils like the ones you propose are actually what tokamaks use, but you may be thinking from a purely physical (i.e. not practical) perspective.
Groups of ideally thin conducting coils grow considerably in size by the need for (often central) cooling channels and insulating tapes and covers. The size of every coil unit is further increased by tensile stress considerations which demand thick stainless steel cases and robust support structures. If you take a look at resulting toroidal field coils in their cases, the thickness of each unit is easily above 1 meter and significantly more when support structures are included for attachment in the tokamak vessel.
Consider a very large reactor like ITER has a mid-plane circumference below 40 meters. You can imagine a spatial limit in the number of such coil cases that you can stack toroidally side by side toward the center of the tokamak.
From early optimization calculations for ITER focused purely on the magnetic field, 24 toroidal field coils were required. I assume that would have made use of the entire space to stack coil cases. In practice, the number of coils has to be further reduced for access considerations: the space has to be shared with a multiplicity of large heating systems (NBI, ECRH, ICRF, etc.), fueling systems and even more diagnostic systems. So the number of coils was subsequently reduced for ITER to 20 and, finally, to 18.
All in all, I wouldn't say plasma physicists oppose the idea of a large number of thin conducting coils to increase the toroidal field in tokamaks. I would say they embrace the method, but real world considerations get in the way.
Comment: Great sources and a well-written, straightforward answer. I would give many more points if I could. Thank you!
Comment: @trytryagain You're very welcome! I saw this today, if you have access to this paper: https://iopscience.iop.org/article/10.1088/1741-4326/ab0e27/pdf The Chinese CFETR future test reactor will have as "little" as 16 TF coil units, but you can see in page 10 how crowded the space already is with that configuration.


View local PHP files in the browser on OS X

Question: is there a way to view local PHP files in my browser without running Apache or anything? I'm using Snow Leopard.
Comment: Do you want to see the native PHP code in your local browser or do you want to the rendered HTML equivalent?
Comment: Do you want to see the actual PHP code or you want to run the scripts and see the output (in a browser or CLI)?
Answer: A browser can not show you the output of a PHP file. This is because a PHP file needs to be run by an interpreter (the php interpreter). A browser has no means to do this, it just expect HTML code or in the best cases it will show you the content of .php file as a text.
However, there are a few ways you can see the output of a PHP file. You can run any PHP file from Terminal. cd into the folder where your php file is, and run it like this php ./my_file.php You will see the output in the Terminal window. The output will be the HTML code if your PHP generates HTML code. If this is the case, you can php ./my_file.php > output.html and open the output.html file in your browser.

Please note, there is no way you can interact with your PHP files. You have no way to fill in HTML forms and click HTML buttons.
These rules are general for all operating systems, not just MacOS.
Answer: If you don't want to argue with apache configuration (which is shipped with snowleopard), you can install MAMP(the free version) ! I've a very easy to use Apache + MySQL solution, that will allow you to run php pages locally.
Answer: If you only see code in a browser window with web sharing turned on, you may not have PHP turned on, and therefor need to edit httpd.conf located here: hard drive/private/ect/apache2/httpd.conf
It's hidden, but you can open with bbedit. Do a search for 'PHP'. Uncomment (remove hash from) the first instance you find to turn on PHP and save. The line looks like this:
LoadModule php5_module libexec/apache2/libphp5.so

Be sure to restart Apache as the last step (turning web sharing off and on again will do it)
To test that PHP is now working, create a PHP test file in your new user level web root (~/Sites) with the following command:
printf "<?php phpinfo(); ?>" > ~/Sites/phpinfo.php

to perform this in Terminal, use this guide:
https://ole.michelsen.dk/blog/setup-local-web-server-apache-php-macos-x-mavericks.html
Comment: Please read the question again carefully. Your answer does **not** answer the original question. This is the opposite of what the OP asked for.


What is the difference between AISI 1015 and SAE 1015 steel? Are they the same?

Question: I've been trying to understand the differences between the AISI and SAE naming systems, but haven't been able to completely figure it out yet. It seems like sometimes they are considered the same, but sometimes they are not? They both have 4 digit codes and seem to overlap fairly well based on my reading of this article .
Answer: Here is a brief mention of the history of the coding system, which may clear the confusion.
"The early 1940's witnessed the development of a coding system for the classification of different types of steels. Designers, heat treaters, draftsmen, and engineers were able to obtain specific information on the types of steel along with its grades. The coding system is known for its efficient classification of steels as it uses the standards from the American Iron and Steel Institute (A.I.S.I.) and the Society of Automotive Engineers (S.A.E.)."
"For many years, certain grades of carbon and alloy steels have been designated by a four-digit AISI/SAE numerical index system that identified the grades according to standard chemical compositions. Since the American Iron and Steel Institute (AISI) ceased writing material specifications (in 2017?), the relationship between AISI and grade designations has been discontinued. From point of edition of the 1995 Iron and Steel Society (ISS) Strip Steel Manual, the four-digit designations are referred to solely as SAE Designations."
So, in general, the standards are the same when the 4 (or 5) digit designations are identical (AISI 1015 = SAE 1015), but it is prudent to check both.


List of Actors playing Chris Kelvin (Protagonist in 'Solaris' by Stanislaw Lem)

Question: Kindly provide a list with the names of Actors that have played Chris Kelvin from the book Solaris.
Please add the year in which the Movie in which the Actor played Chris Kelvin was produced.
Comment: What have you got so far? Didn't IMDB or Wikipedia have anything useful?
Comment: http://www.imdb.com/character/ch0009253/
Answer: Chris Kelvin (AKA Kris Kelvin) has been portrayed by 6 actors in three live-action films;
Solaris (2002)

George Clooney (as Chris Kelvin)

Solaris (AKA Solyaris) (1972)

V. Statsinskiy (as Kris Kelvin v yunosti)
Donatas Banionis (as Kris Kelvin, psikholog)
Vladimir Zamanskiy (as Kris Kelvin, psikholog)
Raimundas Banionis (as Kris Kelvin v otrochestve)

Solaris (AKA Solyaris) (1968) (Made-for-TV)

Vasiliy Lanovoy (as Kris Kelvon)

You can find a complete listing on IMDB here

The book has also been converted into a play and opera. The following actors have played the leading role:

Charles Church
Dietrich Henschel
Roero Arneis
Zlatko Slavenski
Ron Cook
Comment: It appears that Banionis is listed double. And unless he played as double I did not see anyone but Banionis play Chris Kelvin the 1972 Solaris, but at least I found another Actor playing him (in the 1968 TV Mr. Lanovoy.)
Comment: Banionis isn't double-listed. The elder Donatas Banionis was born in 1923, the younger Raimundas Banionis was born in 1957 (making him approximately 14 at the time of filming). They're two different people albeit presumably related.
Comment: Then the younger one must have been the boy that was running around in the first act of the movie. That would fit. And the description then possibly says Chris Kelvins Son (which is only guesswork as google doesnt recognize the word otrochestve, yunosti und psikholog, though I would say the last one means psychologist.)
Comment: yunosti seems to mean "young/adolescent", otrochestve is "adolescent (middle-teens)", psikholog is "psychologist"


In what order should headers be included?

Question: What order should headers be declared in a header / cpp file? Obviously those that are required by subsequent headers should be earlier and class specific headers should be in cpp scope not header scope, but is there a set order convention / best practice?
Answer: In a header file you have to include ALL the headers to make it compilable. And don't forget to use forward declarations instead of some headers.
In a source file:

corresponded header file
necessary project headers
3rd party libraries headers
standard libraries headers
system headers

In that order you will not miss any of your header files that forgot to include libraries by their own.
Comment: I think "necessary project headers" should be separate on two items:
- project headers from the same lib;
- headers from other project libs (in order where most common project libs headers follow below than some special project libs headers)
Comment: I really like your ordering. This way headers do not rely on other headers to include their dependecies.
Comment: And order alphabetically within each group to prevent duplicating include statements.
Comment: precompiled header should be the first one.
Answer: Good practice: every .h file should have a .cpp that includes that .h first before anything else. This proves that any .h file can be put first.
Even if the header requires no implementation, you make a .cpp that just includes that .h file and nothing else.
This then means that you can answer your question any way you like. It doesn't matter what order you include them in.
For further great tips, try this book: Large-Scale C++ Software Design - it's a shame it's so expensive, but it is practically a survival guide for C++ source code layout.
Comment: An easier to automate test: just compile (-c) each header file (yes, g++ -c blah.h) and make sure it compiles.

You can then throw the object files away.
Comment: You can do it with VC++ too: cl.exe /EHsc /TP /c blah.h
Comment: I do this in my unit tests instead.
Comment: +1, there's a lot that's left unsaid in that answer. Great tip!
Comment: @VadimFerderer Unfortunately that would not work for header that's part of a complex project with a lot of additional paths (includes, libs etc). Is there any easy way to make cl.exe aware about these paths (they are set up in project file).
Answer: In header files, I tend to put standard headers first, then my own headers (both lists being ordered alphabetically). In implementation files, I put first the header corresponding (if any), then standards headers and other dependency headers.
Order is of little importance, except if you make a great use of macros and #define ; in that case, you must checked that a macro you defined doesn't replace a previously included one (except if that's what you want, of course).
Concerning this statement

those that are required by subsequent headers should be earlier

A header shouldn't rely on other headers being included before it! If it requires headers, it just includes them. Header guards will prevent multiple inclusion:
#ifndef FOO_HEADER_H
#define FOO_HEADER_H
...
#endif

EDIT
Since I wrote this answer, I changed my way of ordering the include directives in my code. Now, I try to always put headers in increasing order of standardization, so the headers of my project come first, followed by 3rd party libraries headers, followed by standard headers.
For instance, if one of my file uses a library I wrote, Qt, Boost and the standard library, I will order the includes as follow:
//foo.cpp
#include "foo.hpp"

#include <my_library.hpp>
// other headers related to my_library

#include <QtCore/qalgorithms.h>
// other Qt headers

#include <boost/format.hpp> // Boost is arguably more standard than Qt
// other boost headers

#include <algorithms>
// other standard algorithms

The reason why I do that is to detect missing dependencies in my own headers: let's assume for instance that my_library.hpp uses std::copy, but doesn't include <algorithm>. If I include it after <algorithm> in foo.cpp, this missing dependency will go unnoticed. On the contrary, with the order I just presented, the compiler will complain that std::copy has not been declared, allowing me to correct my_library.hpp.
In each "library" group, I try to keep the include directives ordered alphabetically, to find them more easily.
On a sidenote, a good practice is also to limit at a maximum the dependency between header files. Files should include as little headers as possible, especially headers file. Indeed, the more headers you include, the more code needs to be recompiled when something changes. A good way to limit these dependencies is to use forward declaration, which is very often sufficient in header files (see When can I use a forward declaration?).
Answer: Google C++ Style Guide, Names and Order of Includes :

In dir/foo.cc, whose main purpose is to implement or test the stuff in dir2/foo2.h, order your includes as follows:

dir2/foo2.h (preferred location — see details below).
C system files.
C++ system files.
Other libraries' .h files.
Your project's .h files.
Comment: yeah but ggl style guide has some nasty things in it :)
Answer: I used to order them in alphabetical order (easier to find)
Comment: This is how Epic does it too, in their Unreal Engine 4 style doc.
Answer: The "how" is not obvious, but the "what" is.
Your goal is to make sure that the order in which you include header files never matters (and i mean "NEVER !").
A good help is to test whether header files compile when building cpp files (one for each header file) that only include one of them.
Answer: For .cpp files, you should include the header of the class or whatever you are implementing first, so you catch the case where this header is missing some includes. After that, most coding guidelines tend to include system headers first, project headers second, for example the Google C++ Style Guide.
Answer: If a header needs other headers then it just includes them in that header.
Try to structure your code so you pass pointers or references and forward declare where you can.
In the implementation then the header that defines it should be listed first (except in Visual Studio if you are using pch then stdafx would go first).
I generally list them as I need.
Answer: I've found the following convention the most useful:
module.cpp:
// this is the header used to trigger inclusion of precompiled headers
#include <precompiled.h>
// this ensures that anything that includes "module.h" works
#include "module.h"
// other headers, usually system headers, the project

The important thing is to put the module's header as the first non-precompiled header. This ensures "module.h" has no unexpected dependencies.
If you're working on a large project with slow disk access times, I've seen this style used to decrease build times:
module.cpp:
// this is the header used to trigger inclusion of precompiled headers
#include <precompiled.h>
// this ensures that anything that includes "module.h" works
#include "module.h"
// other headers, usually system headers, the project
#if !defined _OTHER_MODULE_GUARD_
#include "other_module.h"
#endif

#if !defined _ANOTHER_MODULE_GUARD_
#include "another_module.h"
#endif

It's a bit verbose but does save on disk seeking since the header won't be searched for / opened if it's already been included. Without the guard check, the compiler will seek for and open the header file, parse the whole file to end up #ifdefing the whole file out.
Answer: It's a dependency thing and it depends largely on what you put in our headers. A fact is that you can be really notorious about this and minimize to keep your includes strict but you'll eventually run into a scenario where you'll wanna use inclusion guards.
#ifndef MY_HEADER_H
#define MY_HEADER_H
//...
#endif

The problem isn't that apparent in the beginning, but as the complexity of your software grows so does your dependencies. You can do well, and be smart about it but larger C++ projects are generally riddled with includes. You can try, but you can only do so much. So be diligent and think about your includes, YES! But you'll most certainly have cyclic dependencies at some point and that is why you need inclusion guards.
Comment: Is this not the same as calling '#pragma once' ?
Comment: Yes it (more or less) the same, but #pragma once is not standard.
Comment: For the record #pragma once is a Microsoft extension. If I'm working on a multi-platform project I use it as well as include guards because #pragma once actually prevents parsing of the file.
Comment: #pragma once works just fine in most C++ compilers, including G++.


How does the energy we get from food transform into mechanical motion at the cellular level?

Question: I am curious how, food broken down into glucose powers the movement of proteins in our cells (e.g., in muscle fibers for example).
Is the thermal energy converted to kinetic energy somehow?
As a mechanical engineer, I am just trying to visualize how the energy is converted to mechanical motion at the cellular level.
Comment: https://biology.stackexchange.com/questions/31323/how-is-atp-involved-in-muscle-contraction
Answer: Scope of this Answer
This answer attempts to summarize the principles involved in biological energetics, with only the most minimal reference to particular molecules or systems. It is directed at those approaching the subject for the first time, particularly from a physical science or engineering background.
Energetic processes in biology
Energetic processes in biology involve chemical energy — essentially the energy embodied in the chemical bonds between the atoms of molecules.
In considering biological processes involving energy transfer, it is usual to adopt a thermodynamic approach in which the change in (Gibbs) Free Energy is considered. Chemical reactions are energetically unfavourable if they involve an increase in free energy, but are energetically favourable if they involve a decrease in free energy. In reactions of the latter type occurring in isolation, the chemical bond energy is converted to thermal energy (heat). In biological chemistry, however, processes that involve an increase in free energy are made possible by 'combining' them with such energetically favourable processes so that, rather than being released (lost†) as heat, the free energy is used to achieve an overall negative free energy change.
Such a 'combination' of two reactions (generally termed 'coupling') is, in effect, a different reaction (or succession of reactions), although the overall free energy change is the same as the sum of the separate ones. The coupling  requires specialized protein macromolecules (enzymes), which actually participate in the reaction (naïvely speaking, direct the flow of electrons from one bond to another) and help lower the activation energy of the reaction that prevents it occurring spontaneously at ambient temperature.
The process of acquiring energy from food consists of a series of energetically favourable oxidation reactions that eventually result in the bond energy of the initial food molecule (carbohydrate, fat etc.) being used to form bonds in a 'form' that is useful to the cell for driving energetic processes. This 'form' is predominantly the phosphodiester bonds of a molecule entitled ATP, which not only has a high negative free energy of hydrolysis (which breaks these bonds), but for which a plethora of enzymes (and other proteins) have evolved that can facilitate the transfer of this bond energy to form bonds in other molecules.
This explains in principle how the energy from oxidation of foodstuffs can be used to sythesize other complex molecules required by the cell — chemical energy being both donor and recipient. What about the conversion of chemical energy to mechanical energy?¶ In general in these cases the hydrolysis of ATP is coupled to a change in conformation of a protein and its points of interaction with other proteins, resulting in their relative movement, as in the case of the actin and myosin components of muscle fibres. Proteins are molecules with three-dimensional conformations determined by the most energetically favourable combination of many non-covalent chemical interactions (mainly hydrogen bonds and hydrophobic interactions). Often there exist alternative structures with only small difference in free energy, so that a change in structure (or the point of interaction with another protein) can be effected by coupling this (although energetically unfavourable) to the hydrolysis of ATP.

† Thermal energy generated by metabolic processes can not be used in the directed manner implied in the question. Its only use for the organism would be to maintain body temperature (and indeed the specialized brown fat cells exist for that purpose).
¶ The question refers to kinetic energy, a term that is not much used in biochemical energetics, except in relation to the random movement of molecules. Although a protein moving along a filament will, I suppose, possess kinetic energy (à la billiard ball) this is a consequence of the changes in interaction of molecules, rather than from a direct 'cue stroke' from ATP hydrolysis.

Beyond the Principles
To go beyond the principles, one must read the book, as it were, and get to grips with the molecules. In my original answer I gave links below to some relevant sections of Biochemistry by Berg et al. the fifth edition of which was then available on NCBI Bookshelf. This is no longer the case, presumably because the edition is 20 years old. However as a basic introduction for the cash-strapped student who is not going to specialize in biochemistry, a second-hand copy of this edition is generally to be had on ebay for the price of two cups of coffee. The relevant sections are:

Free Energy, chemical reactions and ATP
Thermodynamics of redox reactions
Enzymes
Glycolysis, the Citric Acid Cycle and ATP synthesis
Motor Proteins
Comment: I think the question is far too broad to answer in detail — the poster needs to read a book on biochemistry to understand the problem properly. But by confining this answer to principles, I hope to provide something of some general use. Suggestions for improvement are welcome.
Answer: I agree with a comment that your question is broad, but I think a good answer can be given anyway. That answer is essentially: ATP, Adenosine Triphosphate, also known as "the energy currency of the cell".
https://en.wikipedia.org/wiki/Adenosine_triphosphate
This small molecule has three phosphate groups, hence the name, and energy is released when one or two of those are separated from the molecule (creating ADP or AMP, Adenosine Diphosphate and Adenosine Monophosphate). This energy is what thermodynamically allows most endergonic reactions in the organism. The phosphate groups can then easily be added back, recycling the components back to ATP. This mediator, "currency" allows energy to be transferred from chemical reaction to chemical reaction: a reaction that "creates energy for the cell" really regenerates ATP, which goes wherever and is broken down in reactions that "use energy".
See for example this textbook describing how the breakdown of carbohydrates produces ATP:
https://opentextbc.ca/anatomyandphysiology/chapter/24-2-carbohydrate-metabolism/
And I will recycle Bryan Krause's link in comments to a question about how ATP is used in muscle contractions, which I believe is the final step of answering your question:
How is ATP involved in muscle contraction?


The second law of thermodynamics and life on Earth

Question: The second law of thermodynamics says that order always decreases in a system. The appearance of life seems to contradict that law, but if we invoke the Sun, everything falls into place again. But what if humans create order (which is obvious as we take a look around), what does that mean for the Natural order (biodiversity)? If we consider only the closed system of the Earth, this means that the increase of human-made order must be compensated by a decrease of order in Nature, which means a decrease of biodiversity. Does what I write makes sense?
Comment: The second law of thermodynamics says that *entropy cannot decrease* in a closed system. The relation to "biodiversity" or the claim that "humans create order" is entirely non-obvious.
Comment: A person tidying their room may feel like they're making the universe more orderly, but the high-entropy waste heat given off by their body tells a different story. Any "order" created by humans is far outweighed by the amount of neg-entropy we burn to do so. There are accessible explanations of this concept on the internet, [such as this blog post](http://lesswrong.com/lw/o5/the_second_law_of_thermodynamics_and_engines_of/), which might help you understand. But if you want to *really* understand, that involves learning physics and doing the math.
Comment: It's a very simple experiment, really. Get into an airtight box of 2x2x2m and a puzzle with 1000 pieces. We will open the box and see if you have been able to decrease the entropy of the puzzle a week from now. Are you willing to do this simple experiment? Why not?
Comment: related question : [Entropy is…disorder?](http://physics.stackexchange.com/questions/230249/entropy-is-disorder)
Comment: @CraigGidney- You write: "Any "order" created by humans is far outweighed by the amount of neg-entropy we burn to do so." This holds also for the order we create with machines. The order we create with them is far outweighed by the disorder created by the machines. A disorder that is conveyed to Natural Biodiversity.
Comment: And besides, doesn't all the order we create on Earth takes the place of the Natural order, which simply vanishes?
Answer: As mentioned in a comment, entropy cannot decrease in a closed system.  When you are considered life on Earth, it is not a closed system.  Energy comes into the earth from the sun and radiates away from the earth as heat.
In thermodynamics, we normally consider mostly engines because they are really simple in comparison to other systems.  If we ignore the fact that we had to put in energy Q_h and exhaust head Q_c then yes it seems like we not only violate the second law, but also the first law.  This approach to engines is analogous to trying to understand the Earth as a closed system.
Comment: Welcome to Physics.SE, tdoughty84!
Answer:
The second law of thermodynamics says that order always decreases in a system.

This is incorrect. My air conditioner alone proves that this statement of the second law of thermodynamics is incorrect. I live in Houston, TX; I rely on my air conditioner for about six months of the year. My air conditioner does not violate the second law of thermodynamics. Nor does life, nor does humans building roads and bridges.
There are two things with this statement. One is removing the caveat isolated that qualifies the systems for which this simplified version of the second law of thermodynamics applies. The other is the equating entropy and disorder. Defining what "order" vs "disorder" means is hard. Quantifying it is harder yet. On the other hand, whether energy is concentrated or dispersed is quantifiable. Entropy is a measure of whether energy is concentrated (low entropy) or widely dispersed (high entropy).
With these corrections, the second law of thermodynamics in its simplest form says that entropy cannot decrease in an isolated system.
Some take this to mean that the second law of thermodynamics only applies to isolated systems. Were that the case, the second law of thermodynamics would be rather useless. The only known isolated system is the universe as a whole. However, the second law can be recast as various mathematical expressions that apply to closed systems (systems that exchange energy but not mass with their surroundings), open systems (systems that exchange energy and mass with their surroundings), and even systems that are far removed from thermodynamic equilibrium.
The second law of thermodynamics places constraints on how efficiently systems can operate. In the billions of years that Earth has supported life, not one biological organism has yet managed to violate the second law of thermodynamics. Evolution is a powerful mechanism. If the second law was not valid, life would have found a way to violate it.
The second law also places constraints on humanity's construction of apparently orderly roads, buildings, dams, etc. Building such constructs requires a good amount of energy. That consumed energy is shortly dispersed to the surroundings, and then radiated out into space. After accounting for that dispersed energy, building a building does not decrease the entropy of the universe. It increases it.
Answer: Of course the order in an open system always decreases. Locally, like on the Earth, beautifull orderly structures can evolve (wich wouldn´t be possible if the Earth always had one side directed to the Sun), and nonetheless the total order of the system Sun-Earth would decrease. But human activity, by wich I mean the changing of the surface of the Earth by humans, doesn´t involve the Sun. We generate energy and that energy gets converted to order, wich is not so difficult to see if we look around us. And that increase in order can only be compensated by an bigger amount of loss in order in the Natural world (decrease in biodiversity, wich is also very obvious to see) to compensate for the man-made order. It would have been better for the bidiversity if we just would have let all the fossil fuels burn, than making use of that energy and built the Earth full of human structures.


Is DC modulated with a sine wave actually AC?

Question: So we have a DC level that, for example, varies between 0VDC and 10VDC in sinusoidal fashion. Is that classified as alternating current even though it does not go negative?
Comment: @Trevor Thanks - it bugged me when I first started EE more than 40 years ago! I know what it will do, but its classification always eluded me, not that it really matters.
Comment: As the answers show, you look at nothing at all "absolutely" but only "relatively." This even goes to magnetic fields. To Sue, who is observing a moving charge, there is a resulting magnetic field. To Bob, who is traveling at the same frame of reference as the moving charge, there is no magnetic field at all.
Comment: it does go negative if you hang out in the middle...
Comment: good question.....
Comment: It is DC-coupled AC.
Comment: "bugged me when I first started EE more than 40 years ago" LOL yup a have a list of those too....
Comment: related: [Answer with two definitions of DC](https://electronics.stackexchange.com/a/90817/7036)
Answer: It's all a matter of perspective and relativity. What you have is really a 10V  Pk-Pk AC level superimposed on a 5V DC level. So the answer is yes. But I agree the term alternating is muddy in this case.
However, when we remember that voltage is a relative term it makes more sense.
If we think of AC like the classic point on a wheel spinning round the sinusoidal AC part is easy to imagine. But if we extend that and mount that wheel on top of a moving trolley we get your scenario. If you are standing on the trolley you see the dot going backwards, if you stand on the ground, you don't.
The term "Modulation-Current" might be more appropriate..
Which brings up a another question...
Why do we say alternating current not alternating volts.. which is the units we are usually quoting? e.g 110V AC
Comment: Ah. But from the point of view of some other point sitting at 5 V DC, it's just 10 V AC and no DC at all. Or from the point of view of yet another point that is in-phase 10 V AC but centered on the ground reference point, it's just 5 V DC and that's all. So I like your "perspective and relativity" preface.
Comment: @jonk yup..answer was a work in progress
Comment: The *current* may actually be changing direction even when the voltage is not changing polarity.
Comment: Good point @ChrisStratton.. and just to make it even more confusing... current can be AC even on a DC source.
Answer: AC with DC offset - So you have a 10V AC signal with a +5V DC offset
Comment: Or a 5V DC with a 10-volt AC component riding on it. Take your pick. Generally the choice depends on which component is more useful to you, or which has the larger value.
Comment: Or some weird signal riding on a square wave.. :)
Comment: Fair point - I tend to think AC first but that's clearly just my brain and the fact we commonly encounter it that-way-around in the industry I work in (Thin Films and Vacuum Deposition)... But yes if it was 2V Pk-Pk on 5V DC I would think about it in the reverse
Comment: Thinking about it further its interesting that we would attribute AC  to a sine but we would likely, at least in my experience, not mention 'AC' unless the polarity was indeed switching, when its triangular or square wave - (i.e. 'and we applied a DC signal with a triangular waveform', or we applied 'pulsed DC', etc...)


Is there a wristband-like controller for the wii?

Question: We've been playing Just Dance and Wii Fit quite a bit lately and I was thinking a small wrist-band or watch type controller would be handy.  The wiimote gets heavy for my 5-year-old and you really just need the motion sensor for these games and maybe "A" and "B" buttons to advance through menus.
Does this exist already?
Comment: Not sure but the "heavy controller" fits the Wii fit very well :D.
Comment: I would suggest that if your 5 year old is finding the unit to be too heavy, you should use this as a time-limit factor.  Children that age should have their screen time limited anyway.  I would not limit them to the draconian limits set by the American Academy of Pediatrics, but the amount of time it takes for them to tire of holding a wiimote is probably a good built-in limit.
Answer: There is no such controller for Wii or Wii-U currently (but nobody knows what Nintendo is cooking up)
This is pretty much a technology/cost barrier. as the motion detection hardware is quite large (although it has been getting smaller if you notice wii-motes now come with motion+ and are the same size as original wii-motes). Hardware that small that stil works effectively in a gaming environment is also probably quite expensive even if it does exist,
If you want to play motion games without the weight of a bulky controller, try investing in the Kinect. Now that the Xbox One is out you could probably find a cheap Xbox 360+Kinect bundle or something.
Answer: No. There is only the regular controller.


Plants turning purple and red?

Question: I recently transplanted a bunch of corn flowers and they are turning purple and red. I also have lupins, tomatoes, and sun flowers turning red and purple. When I transplanted them i dug the hole twice as deep and filled the difference with soil, 3 in 1 and 1/8 of a teaspoon of organic 4-4-4 fertilizer and lightly watered it before placing in the seedlings. They were all hardened off prior and had not been fertilized in ten days. Last fertilizer i used was a 2-2-2 fish emulsion at half strength. I thought I might have over fertilized but I have some that haven't been transplanted that look the same. What could the problem be and what can I do?
Comment: Can you please post some pictures Jennifer?
Comment: Yes we need that photo.  Generically one possible cause is excessive watering.  Half an hour after you water, is there any water in the tray?  Best if the answer is no.
Comment: Please send pictures and the dates of fertilizing.  I don't think you overfertilized.  Formulas should be just fine. What do you mean 3:1?  For the soil?  Are you transplanting starts into the garden?
Comment: I did have a picture up im not sure how to post from here. My bed was low it soil so i added 3:1 (3 garden soil, 1 three in one: manure hummus and peat). Yes they have gone into the ground. So last tuesday the 6th) i fertilized them with half strength fish emulsion. About 30 mins after fertilizing i dump out whatever drained into the tray then lightly watered. This tuesday (the 13th) i transplanted. I dug holes twice as deep if not 3 times deeper then necessary. In the holes i put about a 1/4 cup 3 in 1 mix 1/8 teaspoon of 4-4-4 jobes organic fertilizer then filled the hole to seedling level.
Comment: Ivw been watering as needed weve had hot humid days as well as rainy.
Answer: I'm posting this comment, not really an answer, in hopes of closing the question.  For plant species and varieties that normally are green, red leaves are a sign of stress.  I've seen it mostly in overwatered plants and occasionally in dry ones.  But red leaves can come from any kind of stress.  That's why the comments all ask for more information.  People are trying to help you diagnose what kind of stress your plant is suffering.
Here are two plagiarized comments, with sources:  "Fluctuations in the soil and air around plants upset nutrients and cause red pigments. Cool spring air and cold soil often produces red and purple foliage tints. ... High soil salts draw water away from plant roots and create droughtlike conditions that cause red leaves as surely as true drought.  https://www.hunker.com/13406045/why-are-my-plant-leaves-turning-red-during-summer
"Red geranium leaves signal the plant is stressed in some way. This may be because the plant is receiving too much water or too much sunshine, or has been planted outdoors too early or in mineral-deficient soil. Geraniums that are planted too close together also tend to develop red leaves."  https://www.gardenguides.com/about_6538075_geranium-leaves-turning-red_.html
Comment: I definitely agree with your comments! The act of transplanting can also stress a plant.

Plants turning purple and red?


external USB drive via VirtualBox says it's busy

Question: When I try to access an external USB flash drive with my running Ubuntu in Virtualbox, by going to the Devices -> USB section in the Virtualbox menu, it complains that the device is busy with a previous request (gives me a UUID number and some more details). Not sure if this is because it's automatically mounted by Wwindows and I need to do something with it before being able to access it with
Answer: This error indicates that the drive can not be unmounted from the host, most likely because it is accessed from an application there, or any file operation to the flash drive is pending.
Since your host OS is Windows we can not really tell what might be the cause in your case, and how to resolve it (virus scanner?).
Answer: Workaround: add a filter in the "Ports" tab of the virtual machine settings, then unplug the disk, start the virtual machine, and plug it in again once the VM has booted.
Answer: I just had the same problem. When I unplugged the device from the (blue) USB 3 port and plugged it into the (black) USB 2 port, it worked. Seems like VirtualBox doesn't like USB 3...


Simulation of t copula in Python

Question: I am trying to simulate a t-copula using Python, but my code yields strange results (is not well-behaving):
I followed the approach suggested by Demarta & McNeil (2004) in "The t Copula and Related Copulas", which states:

By intuition, I know that the higher the degrees of freedom parameter, the more the t copula should resemble the Gaussian one (and hence the lower the tail dependency). However, given that I sample from scipy.stats.invgamma.rvs or alternatively from scipy.stats.chi2.rvs, yields higher values for my parameter s the higher my parameter df. This does not made any sense, as I found multiple papers stating that for df--> inf, t-copula --> Gaussian copula.
Here is my code, what am I doing wrong? (I'm a beginner in Python fyi).
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import invgamma, chi2, t

#Define number of sampling points
n_samples = 1000
df = 10

calib_correl_matrix = np.array([[1,0.8,],[0.8,1]]) #I just took a bivariate correlation matrix here
mu = np.zeros(len(calib_correl_matrix))
s = chi2.rvs(df)
#s = invgamma.pdf(df/2,df/2)
Z = np.random.multivariate_normal(mu, calib_correl_matrix,n_samples)
X = np.sqrt(df/s)*Z #chi-square method
#X = np.sqrt(s)*Z #inverse gamma method

U = t.cdf(X,df)

My outcomes behave exactly oppisite to what I am (should be) expecting:
Higher df create much higher tail-dependency, here also visually:
 U_pd = pd.DataFrame(U)
 fig = plt.gcf()
 fig.set_size_inches(14.5, 10.5)
 pd.plotting.scatter_matrix(U_pd, figsize=(14,10), diagonal = 'kde')
 plt.show()

df=4:

df=100:

It gets especially worse when using the invgamma.rvs directly, even though they should yield the same. For dfs>=30 I often receive a ValueError ("ValueError: array must not contain infs or NaNs")
Thank you very much for your help, much appreciated!
Answer: As this is a cross-posted question, I am not sure it makes sense to cross-post the corresponding answer as well. I'll just add the link to it on StackOverflow.

Simulation of t copula in Python


When does password expire when unchecking "Password never expires"

Question: On a Windows Server 2008 R2 AD, if you uncheck the account option "Password never expires" on a User Account, does the password expire instantly, or does it get set to the period defined in the Password Policy?
Answer: The expiration date should be inherited from the domain's policy. The last password modification date is being stored in the attribute pwdLastSet
So if you uncheck the box there's a slight chance that this user's password is older then your policy defines. Therefore the password might expire.
But you can check password expiration with
<code>net user username
</code>
Edit: I think I just found the solution you are looking for. Just set pwdLastSet to -1 and it will store today's date.
Source with a decent VBS script:
https://stackoverflow.com/questions/5556806/change-password-expiration-date-in-active-directory-using-vbs
Answer: You could also use Powershell as well as dism for this purpose.
https://www.itechtics.com/set-windows-local-user-account-passwords-to-never-expire/
And yes the option will take effect immediately. If you uncheck the option, it will abide by the group policy no. of days before the password expires.


How can I mount in Linux a filesystem for one process or user only

Question: I want to have different mounts that are seen only by a specific process or user. One use case I am thinking about is when I want to mount a unionfs or aufs that will be available for one user. So I can have multiple mounts on the same mount point that are different for different users.
Comment: I don't care to look it up right now, but I think the pam_namespace can do this...also something with cgroups should be possible but I haven't done this yet.
Comment: Based on your answer I've found an article about mount namespaces: http://www.ibm.com/developerworks/linux/library/l-mount-namespaces/index.html and the man page: http://manpages.ubuntu.com/manpages/hardy/man8/pam_namespace.8.html
Comment: I don't consider that info much of an answer. But If you provide some outline on how to do it I'll upvote yours. Answering your own question seems perfectly fine to me (*and* I still don't have to look it up) :)
Answer: Here is how to enable per user mount namespaces in Ubuntu 12.10 using pam_namespace:
Edit /etc/security/namespace.conf
Uncomment the last lines. For safety, add your current user to the list of exclusions.
/tmp     /tmp-inst/            level      root,adm,myuser
/var/tmp /var/tmp/tmp-inst/     level      root,adm,myuser

Edit /etc/security/namespace.init and change #!/bin/sh -p to #!/bin/bash --noprofile or to #!/bin/sh This is because sh is actually dash.
For testing edit /etc/pam.d/su and append at the end of file:
session required pam_namespace.so

Test on a test user:
su - testuser

As test user run:
echo diff '<(sort /proc/'$$'/mounts) <(sort /proc/mounts)'

This will generate a command like:
diff <(sort /proc/31987/mounts) <(sort /proc/mounts)

Run the generated diff from test user shell and from root. From the test user you will have no output, but from the root you will see something like:
4,7d3
< /dev/sda1 /tmp ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
< /dev/sda1 /tmp/tmp-inst ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
< /dev/sda1 /var/tmp ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
< /dev/sda1 /var/tmp/tmp-inst ext4 rw,relatime,errors=remount-ro,data=ordered 0 0

The test_user /tmp folder will be mapped as /tmp/tmp-inst/test_user and it will be accessible only to this user.
Answer: Why not just mount at ~/specificmountpoint. Set the permissions accordingly. Every user will have the same (almost) mout point.
Answer: It looks like nowadays it's possible:

You should create new User Namespace, which gives your process root permissions and all capabilities (only inside that namespace).
You should create new Mount Namespace, to isolate mounts inside your namespace from global mounts.
Mount what you need.
Drop privileges back to normal user and run your application.

At least, in theory. Check this article for more details: http://lwn.net/Articles/531114/


What are some Common 3D Game Patterns?

Question: What are some of the more common design patterns used when developing 3D games? Are there any high-level architectural design patterns that are commonly used? What about general software patterns within the architecture?
Answer:
Composite for doing everything per update step (eg. rendering) (And indeed common amongst all UI libraries).
Flyweight for drawing many of the same item type on the screen (trees/bushes/bullets)
Observer for a lot of UI libraries (again, not game specific)
State for transitioning between game/menu/console/pause/etc. states
Abstract factory in some beat-em-up type of games for creating mobs/NPCs (the games with ridiculous amounts of AI characters at a time - ie. Left 4 Dead).
Strategy for the swapping heuristics in path finding algorithms like A*
edit> Command for games like MMO's that have an actionbar with interchangeable buttons that you can click to cast spells and whatnot.

That's all that I can think of seeing right now.
Answer: I don't think there are any particularly game-specific software design patterns. Games use the same languages, libraries, platforms as everybody else and face pretty much exactly the same problems at the software level.
There are certain methods or approaches that seem to be popular, but which aren't formalised at code level in the way that classic design patterns are. One example is component-based actors, often not even aggregated in the same object but via sharing an ID, communicating   via a signals/slots type mechanism. Another would be the embedding of a second language for scripting purposes, such as Lua, Python, or Javascript.
Comment: They don't exist, I'm afraid! This sort of question comes up again and again over on GameDev.net but there is actually no standard approach or anything resembling one. Everything has an input-update-render/output loop, and often there is a game state system similar to that described by Matt Olenik, but beyond that, it's an ad-hoc arrangement of various small-scale systems and patterns. I could give some advice, but I'd be lying if I claimed my suggestions were "common".
Comment: I'm really looking for some general architectural patterns - like how to organize all the different components of the game into something that is understandable and maintainable from a high level. Something like the game development equivalent of an MVC type architecture or a layered architecture.
Answer: I found this PDF detailing possible game architectures. Although, it might be 'disagreeable to readers who are more inclined to think in terms of object-oriented design.'
Answer: Variations on the state pattern are useful for modeling game state. The Enginuity series of articles is a good overview of some of the low level aspects of game engine design. It is incomplete, but good. The Guff framework's designers outlined the use of state hierarchies for handling game state. The hierarchy concept is good, although their view of a game state is limited (it encompasses the entire game loop instead of just state). They also have a paper on real-time game loops.
When implementing scripting, is is extremely useful and powerful to use a scripting language that supports some kind of cooperative multithreading. Stackless Python offers this. Since Mono 2.6, you can do this in C# using continuations, but only on the Mono platform (not .NET), as it required changes to the VM.
There are common solutions for 2D and 3D graphics, animation, input, etc. Many of them are handled by DirectX, SDL or similar frameworks.

What are some Common 3D Game Patterns?


How do Bit Torrent search engines work?

Question: For a normal search engine, I understand that it regularly travel across the internet to gather web page information, and sometimes the web page can voluntarily submit to engines their latest updates. But how about BT search engines? These torrents cannot be simply find through viewing web pages. Then how do they work? User submit?
Answer: A publisher submits their torrent to a tracker, and then distributes a link to the file on that tracker. Users in turn use that file to connect to the specified tracker and download that file; the tracker then gives a list of users who are sharing that file. The torrent search sites just list what trackers are available and what files can be found on what trackers, which are submitted by publishers.
However, I think this may be better suited to something like the superuser rather than stackoverflow...
Answer: No, users do not submit torrents. As we made with our torrent search site http://tornado.li/, we've created different robots that scan all added torrent sites for new torrents and add them to database. The whole process is fully automated, only in this way it's possible to give a good choise of torrents.

How do Bit Torrent search engines work?


How do I install older PostgreSQL (8.4) in Ubuntu 12.04?

Question: Well, it's the whole question. I installed 9.1 before, but I need older version now and I haven't yet found out how to do that.
Answer: sudo apt-get install postgresql-8.4

Seems to do the trick (well, not really a trick).
Comment: `E: Package 'postgresql-8.4' has no installation candidate` says my Ubuntu 13.04(06.18.2013)
Answer: If the old version of PostgreSQL is not available in Ubuntu repositories see PostgreSQL Apt Repository:

This repository will integrate with your normal systems and patch management, and provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL.
Answer: If you want to install PostgreSQL 8.4 in ubuntu in specific version like ubuntu 12 then Follow the steps:

Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository :

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main"> /etc/apt/sources.list.d/pgdg.list'

Import the repository signing key, and update the package lists :
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update

sudo apt-get install postgresql-8.4
Answer: It's 2019 and (at least with my actual Ubuntu 16 config) PG versions prior to 9.3 are not available to instal with apt-get. I've followed the instructions provided in this site and now I have PG 10.10 and 8.4 installed. Required steps are (extracted from the previous link):
1. Create and edit the PostgreSQL repository by running the command below:
~$ sudo vi /etc/apt/sources.list.d/pgdg.list
Press I on keyboard and add the below line into the file:
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Press Esc on keyboard and followed by :wq to save the file.
2. Download & import the repository key:
~$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
3. Update your system:
~$ sudo apt-get update
4. Now you're able to install PostgreSQL via below command:
~$ sudo apt-get install postgresql-8.4 pgadmin3
NOTE: I've omitted pgadmin3 because I had it installed before.
NOTE 2: The link doesn't mention but if you have another PG version installed, remember you'll have to change port in one of your installations:
~$ sudo updatedb
~$ locate postgresql.conf
/etc/postgresql/10/main/postgresql.conf
/etc/postgresql/8.4/main/postgresql.conf
~$ cp /etc/postgresql/8.4/main/postgresql.conf /etc/postgresql/8.4/main/postgresql.conf_yyyymmdd
~$ sudo vi /etc/postgresql/8.4/main/postgresql.conf

Find the entry that says:
port = 5433 and change port number to new value. Save file (:wq) and restart your postgres.


How to get apropos to show only executable programs/shell commands?

Question: Most of the times when I use apropos I don't care about system calls, library calls etc — I'm just trying to find a command I forgot the name of. Is there a way to trim down the output of apropos to show only executables and commands (section 1 of the manual) and filter out everything else?
Answer: Assuming you're using the man-db version of apropos, you can specify the section you're interested in with the -s option:
apropos -s 1 read

If you want to include administrative commands,
apropos -s 1,8 read

From man apropos:

-s list, --sections=list, --section=list

Search  only  the  given  manual sections.  list is a colon- or
comma-separated list of sections.  If an entry  in  list  is  a
simple section, for example "3", then the displayed list of descriptions will include pages in sections "3",  "3perl",  "3x",
and  so on; while if an entry in list has an extension, for example "3perl", then the list will only include  pages  in  that
exact part of the manual section.

With other versions of apropos, you can grep the results:
apropos read | grep '(1)'

or
apropos read | grep -E '\((1|8))'

Comment: Thanks a lot. It turns out the `apropos` shipping with macOS doesn't have any option whatsoever... and here I was wondering if I was missing something super obvious.
Comment: Ah, right, so my assumption is wrong ;-).


how to clean up black paint that spilled on exterior bricks

Question: My upstairs neighbor (well she said her cat did it) spilled black paint on her deck/patio last summer.  It dripped for 10 minutes down the side of my exterior wall of my unit (outside).  It's spilled all over the light fixture and on the bricks.  We've had power washers try and get it off, but they weren't able to clean it up.  What are my options for cleaning this up?  The condo association is responsible for the exterior of the building, but they are not too diligent about cleaning this up.  I'm more concerned about the bricks.  The glass/metal light fixture can be replaced.  What are my options for getting this cleaned up correctly?
Comment: Do you know what type of paint it is? Your options will be different if it's gloss or emulsion (for example).
Comment: I do not, but I will ask her.
Comment: Have you seen & read through these? http://diy.stackexchange.com/q/3706/3138 & http://diy.stackexchange.com/q/181/3138 & http://diy.stackexchange.com/q/3087/3138
Comment: it was latex paint
Answer: You might consider soda blasting.  It's like sand blasting but uses industrial baking soda.  One of the suggested uses is for removing graffiti from brick.
Comment: corn products are good for this too
Comment: what do you mean by corn?  I'm a programmer, so I only know what corn bread is.  Haha.
Comment: Not sure how they cleaned it up, but if you need the same thing done, call them up: Nate Zellner or Nick Bellino @ DUCTZ/HOODZ of Greater Madison Area @ 608-849-5308 .. it was under $200 to clean up the brick wall.
Comment: it was latex paint btw..


Rails ActiveRecord equivalent to Hibernate load()?

Question: I'm new to Rails, from a Java background.
I have some troubles on many-to-many (through 3rd join table) associations.
class Physician < ActiveRecord::Base
  has_many :appointments
  has_many :patients, :through => :appointments
end

class Appointment < ActiveRecord::Base
  belongs_to :physician
  belongs_to :patient
end

class Patient < ActiveRecord::Base
  has_many :appointments
  has_many :physicians, :through => :appointments
end

In my rest method, i will past Physician id and Patient id. To setup Physician and Patient connection I use
py = Physician.find(params[:physician_id])
pa = Patient.find(params[:patient_id])
py.patients<<pa

I mean, here, two select and one insert seems too costy for me.
Is there anyway just trigger one insert since i already know physician and patient exist in db.
In hibernate, there is load() function which create the proxy object of loaded model without hitting DB.
Physician py = session.load(1);
Patient pa = session.load(2);
AppointmentDao.save(new Appointment(py,pa));

Thanks for any answer. And any suggestions on Rails philosophy.
Answer: You can just do Appointment.create physician_id: 1, parient_id: 2