How exactly does Hawking radiation decrease the mass of black holes?

Question: From what I understand so far, when one of virtual particles crosses the event horizon and the other does not, they can not annihilate each other. The latter wanders off into the universe (btw, is it still virtual at this point, and what does 'virtual' mean at this point, if so?), while the other gets consumed by the black hole. I don't see how this event contributes to evaporation of the black hole (since the particles do not originate from the black hole). Shouldn't the consumed particle actually add-up to the black hole mass?
The closest question to mine is Does Hawking radiation in fact bring mass into the universe?, but I don't find the answers satisfactory.
I.e. "the escaped virtual particle is 'boosted' by black hole's gravitational field into becoming a real particle", rather adds to the question then answer it.
EDIT: I am humbled by the knowledge presented in the answers and feel incompetent to mark any as the most suitable. I hope this is okay.
Comment: Forget about virtual particle pairs, that's more like a metaphor. The thing is, black holes emit radiation, regardless of how they do that. Radiation carries energy, which must come from somewhere, there's no free lunch here. But energy equals mass. It all comes out of the black hole's "bank account" of mass, because that's the only thing nearby.
Comment: @Marko36 It's not that virtual particles are a metaphor in general (although in a sense they are, all particles, virtual or otherwise are just a way of viewing some aspects of the underlying fields), but they are not really a very good explanation of Hawking Radiation. This, however, doesn't answer your question. I look forward to seeing an answer.
Comment: This question on physics (and its accepted answer come the closest I have yet found to addressing this question) but they still don't answer it completely. https://physics.stackexchange.com/questions/251385/an-explanation-of-hawking-radiation.
Comment: @Marko36 "virtual particles" are internal lines in Feynman diagrams and should not be reified more than that.  QFT never assigns a *state* to a "virtual particle". They are *entirely* metaphorical. See the answer by Arnold Neumaier (https://physics.stackexchange.com/a/252183/) and his links.
Comment: You might like to check out http://math.ucr.edu/home/baez/physics/Quantum/virtual_particles.html and https://physics.stackexchange.com/questions/185110/do-virtual-particles-actually-physically-exist and other related questions on Physics about virtual particles.
Comment: Ok, thanks @Florin Andrei, but virtual particles are commonly accepted as a real thing, so how (much) are they metaphorical? Why?
Also, black hole radiation is explicitly explained by them. Should they be a metaphorical concept, what is this black hole radiation, you mentioned, really?
Also assuming that "nothing can escape the black hole, not even EM radiation".
Comment: Matt Strassler has an interesting explanation of virtual particles here: https://profmattstrassler.com/articles-and-posts/particle-physics-basics/virtual-particles-what-are-they/
Answer: I'm going to give you an intuitive answer. Keep in mind, this is not the "actual" answer, as the Hawking radiation is quite a bit more complex than the typical pop-sci explanation with virtual particles. But some intuitive justification is possible nevertheless.

I don't see how this event contributes to evaporation of the black
  hole (, since the particles do not originate from the black hole).

You're missing a key point here.
When the pair was generated, those were virtual particles. After one side of the pair was absorbed by the black hole, and the other side was released, the released part is a real particle. Huge difference there - virtual vs real.
Virtual particles don't really exist the same way that you and me exist. They seem to exist for a very short time; the more energetic they are, the shorter the interval of their virtual "existence", per the Heisenberg equation. In many ways they are just a mathematical trick.
Think of the vacuum, where no real particles exist. Before, it's just vacuum. Right now, a virtual pair flickers briefly, then it's gone. In the future, it's vacuum again.
What was the energy before? Zero. What is the energy in the future? Zero. What's the energy during the flicker? Well, it basically zero, within the limits permitted by Heisenberg's equations. Bottom line is, virtual particles come and go, and they do not contribute to the energy balance of some empty chunk of space.
(I am ignoring here the concept of vacuum energy, for the sake of an intuitive explanation.)
But let's say one of the virtual particles gets trapped by the black hole, so it cannot annihilate with its counterpart. The other particle flies off in the opposite direction and escapes the black hole. What's worse, this is now a real particle - we've exceeded the duration permitted by the Heisenberg equations, so the one that escapes is not virtual anymore.
How did that particle become real?
This is a big issue, because virtual particles don't require an energy budget to briefly exist, while real particles do carry energy forever. Something prevented the virtual pair from annihilating itself, and boosted one of the components to the status of real particle. The virtual pair has zero energy. The real particle that gets away has non-zero energy. That energy has to come from somewhere.
It comes from the black hole. The black hole gives up some of its mass / energy (same thing) to boost one particle from virtual to real. The other particle is captured - but being virtual anyway, it doesn't really matter.
What this intuitive explanation doesn't say is how the boost actually happens. I dunno, magic. Somehow one of the virtual particles gets a chunk of energy from the black hole and becomes real.
Again, this is not the actual process. The actual process is more complex. This is just a pop-sci fairy tale.

EDIT: To hit closer to home, Hawking radiation is more like a close relative to the Unruh effect. Say an inertial observer sees empty space here in this chunk of volume. An accelerating observer would not see empty space in the same volume, but instead would see blackbody radiation. That's the Unruh effect.
Well, gravity and acceleration are the same thing, per general relativity. So the strong gravity near a black hole is equivalent to strong acceleration. Something similar to the Unruh effect must happen there. That's the Hawking radiation.
http://backreaction.blogspot.com/2015/12/hawking-radiation-is-not-produced-at.html
EDIT2: The other answers currently on this page provide useful alternative points, so check them out too.
Comment: This "pop-sci fairytale", as you called it yourself, is quite a pleasant read, I even laughed. Thanks. But it is this "I dunno magic" I am after: how does the virtual particle get it's real state (besides magic) and how does this contribute to BH evaporation, having that nothing can escape the black hole..
Comment: @Marko Also see http://math.ucr.edu/home/baez/physics/Relativity/BlackHoles/hawking.html
Comment: I'm struggling with one part of the intuition - why is the particle which escapes converted to "real" while the one which is captured (and thus doesn't annihilate any more than the escaping one) remains "virtual"? I think the answer needs to address what is meant by real vs virtual. My intuition tells me that the escaping particle and the captured particle are just as real as each other, and thus the black hole may have lost mass/energy allowing one to escape, but it has gained the mass/energy of the captured one, resulting in an overall loss of zero.
Comment: Indeed [the "Heisenberg/virtual-particle" explanation is false](https://www.physicsforums.com/insights/vacuum-fluctuation-myth/). [Uhruh radiation is a better analogy given the Bogoliubov transformations' use.](https://math.ucr.edu/home/baez/physics/Relativity/BlackHoles/hawking.html). But a simplified, **accurate** explanation of why mass decreases is still missing from this site.
Comment: Do you get particles and anti-particles in equal proportion?
Comment: @JBentley It's just a story anyway.
Comment: @FlorinAndrei I got that. I just would like the missing piece for it to make sense :) ([obligatory xkcd](https://xkcd.com/895/))
Comment: @JBentley The pair retain the relationship that they combine to have (approximately) zero energy.  But there are no "real" particles in the universe that have non-positive energy.  Therefore any particle which escapes must have positive energy, and to preserve the relation the infalling one (which disappears from the universe and past the horizon) must have negative energy.  So the black hole loses from it's mass-energy in the exchange, every single time.
Comment: @StevenGubkin Yes, the proportions should be equal or very nearly equal.  Most of the particles are photons, which are their own anti-particle or neutrinos, which may be their own anti particle, so it's not always relevant, but when relevant, it's equal amounts.    Also, I feel I should point, not to you, but in general that anti matter and virtual particles are entirely different things.  I've seen people get that mixed up.
Answer: These lecture notes address the issues to some degree, especially on slides 33-35.

Because in the strongly warped spacetime near the
   horizon, virtual particles made from vacuum fluctuations
   turn out to have negative energy density.
Energy density = energy per unit volume.
These particles indeed have positive mass -- look at the
   one that escaped! -- but their mass is distributed very
   strangely over spacetime. (Quantum-mechanically
   speaking, particles have nonzero volume; this is an aspect
   of the wave-particle duality.)
Matter with negative energy density is generally called
  exotic matter

and, a bit later:

Quantum mechanical vacuum fluctuations in flat
   spacetime - far from any strong gravitational field -
   always have zero net energy density; they can never be
   exotic.
However, in warped spacetime, vacuum fluctuations are
   in general exotic: their net energy density is negative,
   according to a distant observer measuring the energy
   density by observation of the deflection of light by the
   ensemble of fluctuations. The stronger the curvature, the
   more negative the energy density looks.

This is the best explanation I have seen so far.
Comment: I don't mind, but if people keep copy-pasting different bits of the lecture, soon we will have the whole thing on here. :) I would encourage interested people to go read the lecture notes, they're really interesting.
Comment: This is a complex phenomenon. I think the question would benefit from having a diversity of answers.
Comment: This is great !
Comment: I like the explanation in this lecture as well. Which is why I linked it in my answer hours ago...
Comment: @jakub_d. Oops sorry. Would you like me to delete mine?
Comment: Thinking about this. I came up with an alternative interesting way of thinking about it   1 -- just as an electron, in vacuum is surrounded by a cloud of virtual photons and electrons (https://www.newscientist.com/article/mg15320662-300-science-more-to-electrons-than-meets-the-eye/) a BH is shielded by a cloud of virttual particles which make its mass seem a little smaller to a distant observer. Occassioanlly some of this shield is consumed by the event horizon, making its mass actually smaller, and resulting in emission of a particle. Disclaimer, I am not an expert and this is just a story.
Comment: The exam satistics at the start of those lecture notes is almost more interesting to me.  It basically seems to say "three people didn't take the test, one person got a zero on both the test and the practice test, and scores on the exam were almost directly correlated to the binary 'did you take the practice exam?'."  That last bit is kind of weird.
Answer: Heisenberg's principle allows you to temporarily violate energy conservation laws (e.g. create pairs of particles out of nothing) as long as you repay everything in time. The larger the particle-antiparticle pair, the quicker it has to be repaid. Converting a virtual pair to a real pair can be seen as generating a bit of negative-energy "exotic matter" (whatever that is) to represent the unpaid debt. Its energy is equal in size to the pair with the opposite sign. This then falls into the black hole along with one of the particles, decreasing the mass of the black hole overall.
The horizon of the black hole gets in the way of recombining some virtual pairs, so these conversions virtual->real will happen.
I found this lecture with the same idea (more detailed and less butchered):
http://teacher.pas.rochester.edu/Ast102/LectureNotes/Lecture19/Lecture19.pdf
Comment: @Sidney antimatter still has positive mass, when a positron meets an electron, we call it annihilation, but the result is not zero, it is two gamma photons of equivalent relativistic mass.
Comment: @KellyS.French If you want to harvest some negative energy density stuff, you would be better off playing with flying mirrors and conductive plates (see Casimir effect). It won't work either, but at least you don't need a black hole for it. :)
Comment: Pop-sci theorizing here, but is "exotic matter" actually necessary to balance this equation? If a virtual matter-antimatter pair self-instantiates and the anti-matter particle falls into the black hole while a regular-matter-particle escapes, shouldn't it annihilate a "particle's" (yes, I know black holes are weird™ and black hole particles aren't really a thing, that's why it's in quotes) worth of matter from the black hole, or has the black hole essentially forgot that it's constituent mass used to be composed of matter?
Comment: This answer triggered a thought I couldn't help but share.  The concept of an Alcubierre warp drive requires said 'exotic matter', so is it theoretically possible to take advantage of this to jump-start a warp drive?  Or is this not the same type of exotic matter / energy?
Comment: Why this should happen as such that the negative whatever it is fall inside?  By this picture one would expect an average null effect.
Comment: [The "Heisenberg/virtual-particle" explanation is completely false](https://www.physicsforums.com/insights/vacuum-fluctuation-myth/). [It was made up for pop-sci](https://math.ucr.edu/home/baez/physics/Relativity/BlackHoles/hawking.html), and has no correspondence at all to the underlying math/physics.
Answer: I don't know if the experts will agree with this description, but here is how I understand it:
Both space and the event horizon are in constant quantum fluctuation. Essentially, the event horizon has tiny ripples. At points where the event horizon ripples up (above the average radius of the black hole), it has an above average amount of local energy. The intense gravity rapidly pulls that local bump back down, the falling bump sends that local energy concentration back across the rest of the event horizon.
Now let's consider possible virtual particle-pairs near the hole. If a stationary virtual particle-pair appears just above the event horizon, it will either recombine and vanish or the entire thing gets pulled into the hole and vanishes in zero. We need a virtual particle-pair that has an apparent motion away from the black hole, at nearly the speed of light. If that that virtual particle-pair is going fast enough to completely escape, they recombine and vanish. Zero net effect. We need a virtual particle-pair that is moving away from the black hole at nearly the speed of light, and we need a ripple in horizon which only catches one virtual particle. I believe the ripple must be under extreme downwards acceleration for it to pull away from the second virtual particle, to avoid catching both. And here's the key part: The energy-debt between the particle pair intensely pulls them towards each other. The trapped particle is being pulled upwards, effectively pulling upwards on the horizon that trapped it. This slows the fall of horizon-ripple, diminishing the energy that the falling ripple returns to the rest of the black hole.
The energy required to pull the two virtual particles apart equals the combined energy of the two non-virtual particles. So the falling ripple loses energy equal to two particles, and the hole eats one particle. Everything balances out with the one escaped particle.
I believe it works the same, regardless of whether the virtual particles are photons or a matter-antimatter pair.
Answer: Here's an analogy to Quantum Mechanics. A particle in QM can tunnel through an impossible barrier, which is how elements heavier than lead can have some of their neutrons "tunnel" out of the nucleus escaping the bonds of the Strong Force.

A small Black Hole is like a quantum barrier that a particle can be tunnel through to escape. The smaller the barrier (Event Horizon), the more likely it is to be able to tunnel out. So a micro black hole with a mass of 228 tons and a Event Horizon of 3.4 x 10^-7 femtometers (literally less than 1 millionth the size of a proton) won't hold on to it's particles for very long and at all. In fact it will explode in a burst of Hawking Radiation after exactly 1 second.
A larger Earth Mass black hole with a radius of a whole centimeter, will last much longer: 8 x 10^50 years because it's much less likely for a particle to tunnel through a whole centimeter to get to freedom.

Source: Quantum tunneling from three-dimensional black holes: https://arxiv.org/abs/1306.6380
Source: Hawking Radiation modelled as a Quantum Effect: http://cscanada.net/index.php/ans/article/view/j.ans.1715787020120502.1817


Codecs, Premiere Pro & Quicktime: Import or Play Error

Question: Original Question
I've been using a FS-H200 (not the Pro variant) recorder with a JVC ProHD camera. I have been shooting with the DTE FORMAT to Quicktime (.mov). I copied the files to an external hard drive and am now trying to edit.
The files will play back in VLC, as they would be expected to. However they will not import into Adobe Premiere CS5.5, instead giving an error:

Unsupported format or damaged file.

Quicktime gives the following error when attempting to play the files:

Error -2002: a bad public movie atom was found in the movie (Filename)

To try and fix this, I have installed the following codec packs:

K-Lite Codec Pack 64-bit Full (version 5.9, latest)
K-Lite Codec Pack 32-bit Full (version 8.4, latest)
MainConcept Codec Suite (Broadcast) v5.1 for Adobe CS5
Reinstalled Quicktime with new download from Apple

The same errors and problems still exist.
From this I can assume that there is an issue with Quicktime and that is what Premiere is using as an encoder/decoder for the codec. Is there any way to fix this?

From looking at the "Codec Information" from VLC:

Stream 0

Type: Video
Codec: MPEG-1/2 (mpgv)
Language: English
Resolution: 1280 x 720
Frame Rate: 25

Stream 1

Type: Audio
Codec: PCM S16 BE (twos)
Language: English
Channels: Stereo
Sample Rate: 48000 Hz
Bits per sample: 16

Other computer specs:

Windows 7 Professional 64-bit (SP1)
Gigabyte Z68X-UD3-B3
Intel i7-2600K
16GB DDR3
2TB WD 7200RPM SATA 6Gb/s
LaCie d2 Quadra 2TB v3 7200RPM (External HDD)
NVIDIA GeForce GTX 560 Ti Golden Sample

Updates
2012-03-11 @ 2050 AEDT
MPEG Steamclip doesn't recognise, play or convert the footage.

File open error: unrecognised file type.
[Open Anyway]
File open error: can't find video or audio tracks.

2012-03-24 @ 1920 AEDT
Had to transcode the footage. :(
Answer: You should try using Camatasia Studio with a lower resolution.
You could also try installing these codecs.


Careers: give me a place to list my proficiencies and years of experience

Question: I don't have a formal education so to overcompensate on my traditional resume I have a section at the top that lists out all my proficiencies along with how many years of experience I have with that skill. I have been frequently complimented on this because it gives hiring managers a good overview of my skill set. It would be nice to have a similar feature on Careers. For the skills you could use SO tags.
Answer: They may institute that, but it doesn't seem likely.


How to install skinny cylinder surface mount ceiling light?

Question: I, located in Canada, bought UL-listed surface mount ceiling spotlights with diameter of about 6.5cm from Italy. My builder says it is illegal to install the cylinder body directly to the ceiling surface like indicated in the instruction. My ceiling is prepared with regular junction box. Could anybody help me with this please.
Comment: When you say that your "ceiling is prepared with regular junction box", what do you mean exactly? Line-voltage wire connections must be made inside of an approved enclosure like a round/octagonal ceiling electrical box, so ceiling lights are typically attached to those boxes with the wire connections inside. Are you saying that you have ceiling boxes available... but you do not intend to mount the fixtures to those boxes?
Comment: I meant those octagonal ceiling electrical box is prepared. The problem is that the size of my light fixture is way too smaller than the electrical box.
Answer: The one thing you cannot do in the US (Canada's electrical code is very similar to the US's and I'd imagine is 100% in agreement on this), is to install this without an electrical box by putting some sort of wall anchor in the ceiling as shown in the instructions. Your electrician was 100% correct on that statement.

To install this fixture, you'll need 2 things:

A way to hold the light onto the ceiling. Often, a cross bar that you will attach to the screw holes on the back of the fixture then mount the bar to the two screws on opposite corners of the box is supplied with lights designed to go on US boxes.

A rose or cover plate that will cover the parts of the junction box that are not covered by the light fixture itself. If the manufacturer doesn't supply them you'll have to come up with something that will work.

Something like one of these might work:

All images courtesy of Lowes.com. No endorsement intended or implied.
One of these would be great. It's plastic and would be easy to drill the right size hole through. However, I don't believe you're allowed to modify it and still have it be within code

This one might be your best bet. You can knock out the knockout to run your wiring through, then drill the appropriate mounting holes to actually mount the fixture to this, then use the mounting screws on the box to mount the cover & fixture to the box. It would, in effect, cover requirements 1 & 2 at the same time. You can modify metal boxes for mounting like this (see the 5th paragraph of this answer).

Of course, any of these could be painted to match the ceiling or fixture.
Comment: In comparison, recessed "puck" or "pot"-style lights *are* mounted directly to the ceiling (drywall) not to the junction box. The electrical connection is made in a supplied junction box either as part of the pot, or place loose on the ceiling near the puck. I thought it would be up to the manufacturer, not the NEC/CEC, thus allowing this if the manufacturer specifies it. If they are not cUL listed then they cannot be used regardless.
Comment: These lights are made in Italy, @P2000, so they're probably not made to US/Canadian specs.
Comment: Well, OP writes "UL listed". I saw no proof in linked instructions but let's take that at face value. Aside from it not being cUL, does that not allow installation *per instructions*, directly into ceiling material?
Comment: The puck lights you mention have a "box" built in or at the end of an armored cable allowing it to be remotely mounted. This light seems to have neither. I'll leave it for the more experienced/knowledgeable to quote exact code citations, but I'm 99.99% sure this cannot be mounted following the instructions. And yes, I agree that we're taking the OP's word that these are "UL Listed".


Uploading File in parts using XMLHttpRequest and auth digest

Question: I am trying to upload a local mp4/movie file with XMLHttpRequest() on a server. This is written with react-native and in a final version user would be able to upload any big files from his/her IOS/Android device to the server.
My test file is about 1 GB (it could potentially be from 100 mb to 10 GB).
With files below 70 mb I could easily use this code (below) to load the blob then slice it and put on server using : https://github.com/inorganik/digest-auth-request
sendRequest = new digestAuthRequest('PUT', uri, usernameVal, passwordVal);
        sendRequest.request(function (data) {
let oReq = new XMLHttpRequest();
oReq.open("GET", obj['path'], true);
oReq.responseType = "blob";
oReq.onload = function (oEvent) {
let blob = oReq.response;
console.log(blob);
sendBloblPart()
};

Then this is sendBlobPart function stripped away from all handling on callback (not important here) :
function sendBloblPart() {
    sendRequest = new digestAuthRequest('PUT', uri, usernameVal, passwordVal);
    sendRequest.request(function (data) {
    }, mainThis.fileUploadErrorHandler, blob.slice(startB, endB), true);
}

I am reconstructing the file on server from all the parts and this works just fine with the blob created by XMLHttpRequest(), but it seems XMLHttpRequest is loading whole file into memory so for example when trying to load 1 GB file as blob I get out of memory error. I looked for several solutions however nothing worked so far.  I found promising feature of : https://github.com/joltup/react-native-fetch-blob
so creating Blob from 1 GB file now takes about 100 ms and doesn't consume memory:
const Blob = RNFetchBlob.polyfill.Blob
let newBlob = new Blob(RNFetchBlob.wrap(obj['path']), {type: obj['mime']});

This however has a challenge in that the new blob has a different structure then previous one (previous one meaning from XMLHttpRequest) where I was able to simply pass the sliced blob as data to send and it worked just fine. Now no matter what I do with new blob I am not able to send any data to the server, all requests appear to work just fine, but 0 bytes are received on server end.
Are there any hints/solutions or ideas on how to better approach this problem?
Below I will add structure of both blobs, I can see they are quite different (I used 1.2 mb file for this example so XML request will work just fine and won't crash as with my 1GB desired file) :

While I thought about using readStream and similar solutions, I couldn't find an option for stream to wait while upload is done or start from 50% of the file for example.
Answer: I have a couple ideas. What happens if you wait for the blob slice to be created before making the upload call?
const firstBlob = await new Promise(resolve => {
  newBlob.slice(0, 262144).onCreated(resolve)
});

// send request with blob

firstBlob.safeClose();

const secondBlob = await new Promise(resolve => {
  newBlob.slice(262144, 262144 * 2).onCreated(resolve)
});

// etc

It looks like the rn-fetch-blob package has a polyfill for XHR that considers the onCreated callback. If you use that XHR instead it could also work.
const XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;

Answer: I'm a little confused about your codes.
As you said,'User would be able to upload any big files from his/her IOS/Android device to the server'.In that situation, you suppose to get the File instance by a component like <input type="file"> rather than get file from server and store it into a blob and then upload it.Blob loads all data into memory at once when the data is from server, so it causes memory error.
If the big file which user want to upload must be downloaded from a server, you should download the file chunk by chunk (need to do some changes of the backend download codes) and upload it in the same way.
If you get file from <input type="file">  and use File.slice to get file chunks it won't cause memory errors, do it as what you did.


iTunes library .xml vs. .itl

Question: I have iTunes 12.6. I read that after 12.2 iTunes doesn't create .xml to store playlists. Is the .itl the same thing?  Will it have my playlists?  I tried importing the library.itl to my new computer, but nothing happened.  How do I get my playlists to a new computer when using iTunes 12.2 or later?
Comment: Welcome to Ask Different. Unfortunately, your question doesn't provide enough detail for us to help you. Reading [how to ask a question](http://apple.stackexchange.com/questions/how-to-ask) may improve your chances of getting a good answer. For now, can you please edit your question (there's an _edit_ link below it) to add info such as: (1) What type of computers are you migrating from and to (i.e. Mac > Mac, PC > Mac, etc). (2) If from Mac > Mac, do you have a Time Machine backup of the first Mac? (3) How are you trying to import the library?
Comment: I am copying Mac to Mac.  Yes, I have a Time Machine backup of the first Mac, but could not find the .xml file on the most recent backup.  I am guessing that is because iTunes does not use .xml after ver.12.2 (or so I read). I copied all music onto my new machine first in a music folder, then imported it into iTunes.  I don't remember if I drag and dropped or if I used Library>import playlists>music.  Either way, all music was in iTunes, but playlists were not.  Hope that clarifies, sorry I was ambiguous at first, just frustrated. Thank you!
Answer: It sounds like the reason you've run into problems is that you've tried to manually migrate across your iTunes data from your Time Machine Backup.
Without knowing exactly what you did, if you copied the entire iTunes folder from your TM backup to your new Mac, one thing you can try is to tell iTunes where that folder was copied to. To do this you would:

Open iTunes
Go to iTunes > Preferences (or just press command,)
Select the Advanced tab
Now you'll see an option where you can set your iTunes Media Folder location

Migration Assistant
Since you're migrating to a new Mac, you'd probably be better off starting again and using Migration Assistant to transfer all your data across. This will give you the option of migrating what you choose from a Time Machine backup or directly from your other Mac (if you have a way of connecting to it). Migration Assistant also provides other options.
To use Migration Assistant:

On your new Mac, open Migration Assistant (by default it's in your Applications > Utilities folder)
If you happen to have another user logged in, you'll be prompted to log them out first. If not, you'll see an Introduction screen instead.
Click on Continue
You may be prompted to enter your password - if so enter it and click OK
You'll now be asked how you'd like to transfer your data.
Select the option applicable to you (most likely the first one which allows you to transfer from a Time Machine backup)
Click Continue
Follow the prompts to migrate the data you want

Note: This process may take some time.
For more information see Move your content to a new Mac.

iTunes library .xml vs. .itl


How does HQ work in Black Ops?

Question: I'm unsure how to be effective in HQ games, how exactly does that mode work?
Answer: Capture and hold a control point of three on a map. The longer you hold, the more points your team gets. The game ends either on the maximum score of 9000 or after the time runs out, the team with the higher score wins. A default match duration of 15 minutes is assumed.
See Wiki for details.
Comment: Also, once your team captures the HQ you won't re-spawn immediately after death. There is a delayed re-spawn timer.
Comment: Actually, you won't respawn at all, if you get killed after your team captures the HQ. After the HQ is destroyed or becomes offline, you can respawn.

How does HQ work in Black Ops?


How to get custom (non-player) heads in minecraft 1.10

Question: I have seen a tutorial to do this, the one with changing your skin, but I'm using it with /summon and the ArmorItems NBT tag (The head is only present while the player is playing it), and I want my map to work whenever someone decides to play it.
Comment: please , be more specific and try to give us photos of your creation you made so far. I don't understood anything you tried to explain
Answer: Do /give (your player name) Minecraft:command_block and inside the command block type /give @p minecraft:skull 1 3 {SkullOwner:"[username]"}
At the [username] type the players name that you want and yeah.
Do ruthless tomato his my favourite!
Comment: A couple of formatting tips. Don't bold the whole message. Bolding is supposed to be for **emphesis**. Use preformatting for code sections. Makes them stand out better. For line break, `space-space-enter`. Or, for new paragraph, `enter-enter`.


How should I configure my firewall using iptables commands to defend against hacking?

Question: I need to add extra security to my Android device using iptables and a firewall to defend against hackers. My specific goals are to prevent a hacker from remotely breaking into my device to begin with and, in the event spyware is remotely placed on my device, my data/activity cannot be uploaded to whatever command center the hacker controls. Which commands should I use for maximum hacking defense? So far I only know about closing all ports except 80 and 443. I also need to know how to block all ports except those two, both incoming and outgoing, without preventing myself from browsing the web and other basics.
Comment: '`my goal is...  in the event spyware is remotely placed on my device, my data/activity cannot be uploaded to whatever command center the hacker controls`' and `'without preventing myself from browsing the web and other basics'`.  To browse the web, your firewall needs to allow outgoing connections on ports 80 and/or 443.  If your firewall allows outgoing connections on ports 80 and/or 443, then connections to the attackers' server on these ports can be used to upload your info to their servers.
Comment: True. Well, even with that being a factor, what are all the commands I should use to add extra security? And I'd still like to close all ports except 80 and 443. I found a guide near the end of this page: https://bobcares.com/blog/iptables-block-port-range/ but it needs some changes
Comment: Oops, it doesn't need any changes.
Comment: @guestmar21 there are no "commands" to learn. Firewalls have rules. Antivirus is configured by the vendor. From all your comments, I think that you have some misunderstandings and confusion about how all this works, which is making it impossible to answer your questions directly. The concept you are looking for is "hardening". And hardening is far more than just firewalls and antivirus. And on a phone, doesn't even include firewalls.
Comment: OP, you may want to consider using `ufw` (uncomplicated firewall).  ufw runs 'over' iptables, and ufw makes it much easier to configure simple firewall rules than using iptables directly.  See https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04 for more infol
Answer:
I wonder what corporations and politicians and oil barons do to
protect their devices from targeted hacking?

Ask Jeff Bezos or Angela Merkel, they'll know.
Oh wait ...
It always depends on your adversary. There's a difference between Joe hacker and the NSA.
The average Smartphone usually does not expose any public internet services itself and is often behind some NAT anyways. So theoretically no one from the outside can connect to it directly. Often you "invite" attackers by connecting to their phishing websites, installing some crap app ...
Telemetry/Tracking is also just some kind of legal version of exfiltration.
Preventing exfiltration is nice in theory but in practice only limiting traffic to port 443 and 80 still gives the attacker the ability to exfiltrate data over those ports. Not to mention some lower level stuff like WIFI, Bluetooth, mobile network ...
Smartphones are made to communicate in many ways.
The average politician targeted by the average nation state better does not do any stuff on his phone which could have negative impacts on him. Like storing all his duck pics ...
The true chad politician, however, would store all his duck pics there on purpose because a) remove the attack vector of some moral outrage and b) because the images exploit some vulnerabilities on the attackers system and send all their duck pics to youduck.com
2:0
You'd better prevent or detect the step which happens before exfiltration i.e. compromise. You'd need to know what the system does normally and when it misbehaves. You also need to know if normal=desired (see telemetry ...) That's a lot of work. iptables/firewalling is only a small part of it
Answer: On a typical Android device from a reputable manufacturer, all inbound ports should already be closed out of the box. Unless you know for a fact that some ports are open for whatever reason, I don't see the benefit in setting up a firewall to close inbound ports that are already closed.
For closing outbound ports other than 80 and 443, this also comes across to me as likely to be highly ineffective and mostly providing a false sense of security. If I were an attacker, the most obvious way to exfiltrate data out of a device without raising immediate red flags would be to put up a standard web server and send the data via an HTTPS request on port 443. So allowing ports 80 and 443 pretty much also allows the most straightforward data exfiltration method.
Overall I'd say that a firewall just isn't an effective tool for this job. You'll get a lot more actual security by following standard common sense practices, like using a device that is receiving security updates regularly and being cognizant of the apps you are installing.
Comment: Thanks. I wonder what corporations and politicians and oil barons do to protect their devices from targeted hacking? I find it hard to believe that everyone with a smartphone or a computer is just a sitting duck with no truly effective way to defend themselves from hackers.
Comment: @guestmar21: There are several basics: Just don't install arbitrary apps on the phone. Protect your phone against physical access by others. Use a phone where the vendor provides fast and reliable software updates.
Comment: @guestmar21 I would refer you to [this recent blog post](https://googleprojectzero.blogspot.com/2020/12/an-ios-zero-click-radio-proximity.html) from Google Project Zero to get a sense of what it takes to hack a smartphone. One the one hand, it takes incredible talent and time to discover an attack like this. Not many individuals would be able to pull it off. On the other hand, it only took one guy six months to discover a way to gain complete control of every iPhone in their vicinity. Imagine what a government capable of hiring hundreds of similarly talented people can do?
Answer: No system is 100% secured. What you can do is mitigate or minimize risk. You cannot avoid Risk. If you want to avoid risk you have to avoid using this solution/device or service.
As per your comment, you are ready to disconnect it from internet. Keep your device isolate environment. That mean don't connect device into external network such as internet. You are secured from internet based attack.  You don' need additional commands to execute.
But still you are not 100% secured.
Comment: I understand that there is always a risk, I've even heard people say that "all" operating systems are "swiss cheese" to hackers. But iptables and antivirus and etc. exist for a reason so I would like to learn some commands.


How to fully manage users and groups with web GUI and create templates for new users?

Question: I currently have an Ubuntu server with 10-15 users. I have some CLI experience, but I am not a fully CLI ninja. I currently have some groups made in the CLI to manage different groups of users.
In the near future we will probably expend ( how much more is not sure right now). Before things get out of hand I am currently looking for some sort of central managing system to manage the users and groups. I have looked at Puppet and it does a really good job at different things, but not so good at managing users at the servers (FYI, I have never used Puppet and this is just from researching the Internet. Some even say that it is bad practice. Please tell me if this is not true !!! ).
So, what I would like is some sort of webgui to manage the users and groups. So I can click to what software can be used and what folders can be accessed and not.
I have looked at gnome-system-tools and is ok to use for making new users and to add them to groups. If somebody would like to add the programs than can be used with a certain group you still have to go to the CLI.
Question: Is there some sort of web GUI to manager users and groups from a linux server?
P.S. Just to be sure, I am not looking for something like LDAP or any other central login methods. I would just like to manage the users and groups and what they can do.
Update
Webmin was not what I was looking for. It can create users and groups. But I cannot make a group and say what software can be used with that group or even what wallpaper will be used. So I am more looking to get some sort of way to create a standard template I can constructe ( in the web GUI ) for different types of users and use that over and over again when making new users. And if something changes overtime I can simply change the template and the changes affect all the users in that group.
Answer: Yes, there are many such tools. One I happen to have used personally, is webmin. It can do all sorts of things through a simple and intuitive web interface, including user administration:

To install Webmin you first have to add the repository.
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Then you have to add the key of the repository:
cd /root
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc

Update your system so Ubuntu will check for the new repository:
sudo apt-get update

You can install it on Ubuntu with
sudo apt-get install webmin

And then point your browser to https://localhost:10000 to access it (if that doesn't work, try http://locahost:10000). I have never used it on an Ubuntu system or any other with no root account so I'm not sure, but you might have to enable root to use it.
Comment: Thanks for the answer. I will check it out. If you know any other options, please let me know (just to compare).


Irreducible in $\mathbb{Z}[\sqrt{-5}]$

Question: How can I prove that $2+\sqrt{-5}$ is irreducible in $\mathbb{Z}[\sqrt{-5}]$? I tried to show by $2+\sqrt{-5}=(a+b\sqrt{-5})(c+d\sqrt{-5})$ but I could not get a contradiction.
Answer: If $2+\sqrt{-5} = AB$, then $9=N(2+\sqrt{-5})=N(A)N(B)$ where $$N(u+v\sqrt{-5})=(u+v\sqrt{-5})(u-v\sqrt{-5})=u^2+5v^2$$ is the norm.  If $N(A)=1$ or $N(B)=1$, then $A$ is a unit or $B$ is a unit, respectively.  So if $2+\sqrt{-5}$ is reducible, there must be $A,B$ with $N(A)=N(B)=3$.  Show that there can't be any $A$ such that $N(A)=3$.
Comment: Show there are no integer solutions to $u^2+5v^2=3$. @ALannister Clearly, $v$ must be zero, or $u^2+5v^2\geq 5$. So now you need $u^2=3$.
Comment: Yes, but there really aren't that many elements of norm $9.$ $\pm 2\pm\sqrt{-5}$ and $\pm 3.$ @Vadim
Comment: how do you show correctly that there can't be any $A$ such that $N(A) = 3$?
Comment: logically, I thought that's how it should be done, but since I'd never actually seen anyone do it before, I wasn't sure. Thank you!
Comment: So by this logic, all elements of $\mathbb{Z}[\sqrt{-5}]$ of norm $9$ are irreducible?
Answer: While you already have a very big hint, I thought it would be worthwhile to expand a bit on the conceptual motivation. Generally, when studying factorization theory in rings of algebraic integers one can deduce a great deal from studying the factorizations of their corresponding norms - which form a "simpler" multiplicative submonoid of the integers (cf. the method of simpler multiples). This is true simply because the norm map is multiplicative $\,N(xy) = N(x)N(y)\,$ so it preserves many properties related to factorization. For example, in many favorable contexts (e.g. Galois) a number ring enjoys unique factorization iff its monoid of norms does. For references (Bumby and Dade, Lettl, Coykendall) see my sci.math post on 19 Dec 2007 partially excerpted below (see the post for AMS reviews of related interesting papers). See also here for analogous methods for factoring polynomials via their "simpler" evaluations.

Let $d\,$ be a squarefree positive integer, with $\,d > 1,\,$ and let $R\,$ be
the ring of integers of the real quadratic number field $\,\Bbb Q(\sqrt d).\,$ Let $\,z \in R\,$ be such that $\,N(z)\,$ is composite.
Question $(1)\!:\  $ Must $z$ be reducible in $R\,?$

No, e.g. inert primes $p\,$ have $\, N(p) = p^2.$
A number ring is a PID iff its atoms have prime power norms,
i.e. exactly one prime $\,p\,$ occurs in norms of an irreducible element
$\,N(q) = p^n,\,  p,q\,$ atoms in resp. rings. The proof is easy.

Question $(2)\!:\ $ If there exist nonunits $\,x,y \in R\,$ such that
$\,N(x) N(y) = N(z),\,$  must $\,z\,$ be reducible in $\,R\,?$

No, e.g.  $\,x = y = 3,\,  z = 5 + 2 \sqrt{-14}.$
Bumby and Dade [2] classified those quadratic number fields $K$ where
reducibility depends only on the norm. Denoting the class group by $H,$
they proved that $K$ satisfies this property iff
(a) $\ H\,$ has exponent $2,\,$  or
(b) $\ H\,$ is odd, $\,$  or
(c) $\ K\,$ is real with positive fundamental unit and the $2$-Sylow subgroup
of the narrow class group is cyclic.
Note the above example $\,\Bbb Q(\sqrt{-14})$ has class group $\,K = {\rm C}(4)\,$ with exponent $4$.
See Coykendall's paper [1] for a recent discussion of related results
and generalizations.
[1] Jim Coykendall. Properties of the normset relating to the class group.
http://www.ams.org/proc/1996-124-12/S0002-9939-96-03387-4
http://www.math.ndsu.nodak.edu/faculty/coykenda/paper3.pdf
[2] 35 #4186  10.65 (12.00)
Bumby, R. T.  Irreducible integers in Galois extensions.
Pacific J. Math.  22  1967 221--229.

Irreducible in $\mathbb{Z}[\sqrt{-5}]$


Triagulations of 4D Euclidean Lattice

Question: I am interested in Euclidean gravity models such as Regge's simplicial gravity model. These models use triangulations of $\mathbb{R}^4$ with periodic boundary conditions. While there are many papers using such triagulations, I have not found an algorithm for generating such triangulations. Could someone explain how to generate a regular 4D triagulation of the unit 4 lattice ($\mathbb{Z}^4$) that is invariant under lattice translations? I have found algorithms for 2D and 3D lattices but do not understand how to generalize these.
Answer: There is a paper by P. S. Mara : Triangulations of the cube. But easier to find the article "impact of topology in cdt quantum gravity" : https://arxiv.org/abs/1604.08786, page 5, where we explicitly write a triangulation of the hypercube (citing mara) .
A comment:
In Regge calculus the deficit angle gives  the curvature, thus you will not find a translation invariant smooth but discrete triangulation in 4d. This version that I cite can be used to construct Triangulations. In the appendix we even give another one, which is smaller but more complicated. Due to the 4 type of simplices, it's hard to imagine these objects.

Triagulations of 4D Euclidean Lattice


Glass rendering very dark/black

Question: I'm trying to achieve a basic clear glass material, but it always renders as "black" glass. I'm new to Blender, so I'm probably making a fairly simple mistake here.

Thanks for looking...
Comment: Share the blend file here please
https://blend-exchange.giantcowfilms.com
there's a hundred things you could be doing wrong and we can't possibly list everything :)

Make sure your transmission samples in Light Paths under the Render properties is higher than 0 (bump it up to 3-4 for now)
Comment: Trying the file, at least 6 bumps maximum is needed to give a better result.
Comment: Thank you, m.ardito. I was under the impression that my light paths were still at their default settings, but this can't have been the case. I need to spend a little time getting to understand them.
Answer: Render settings light bounces, you need to increase their count. You can increase the maximum and transmission only for glass other bounces are used in different cases.
Basically light paths or bounces indicate how many times the emitted ray will change direction (hit a surface and bounce of).
Minimum are least number of bounces / light paths emitted. This value should be pretty low for performance but shouldn't be 0.  1-2 works fine for most scenes.
Max bounces indicate maximum number of bounces. If diffuse bounces are set to 10 and Max is set to 5 the maximum will still be 5.
Transmission is for glass objects using ... Well transmission. That's exactly what you're looking for. Keep it high for such a scene.
Glossy light bounces are for reflections, you could also increase that one a bit as well.
Generally only the first 5 bounces change the image quite a lot, the further you go the less visual impact it'll have.
Performance wise it scales weirdly, the first few bounces are the most complex for the program and the rest still slow it down just a lot less.
Just don't set your bounces all the way down to just 1 - 2, it usually looks bad.  :)
Comment: Hi can you explain how to change light bounces thanks
Comment: If it's still needed, you do that under render settings in the properties window. The tab is called Light Paths and there you have light bounces settings.

The more you set the slower it'll render but the more realistic the lighting will be, however there's a certain point of diminishing returns, I usually avoid using more than 16 bounces unless it's a product shot and render times don't matter. Glass and transparent objects may use a lot more if you get the dark edges on transparent or glass materials.

Glass rendering very dark/black


This filters in memory right?

Question: I Just want to make sure I understand this correctly...
search is an object that contains a querystring.
Repo.Query returns an ObjectQuery<T>.
From my understanding the chained linq statements will filter the results after entity framework has returned all the rows satisfying the query. So really ALL the rows are being returned and THEN filtered in memory. So we are returning a bunch of data that we don't really want. There's about 10k rows being returned so this is kind of important. Just like to get my confusion cleared up.
var searchQuery = Repo.Query(search)
                .Where(entity =>
                        entity.Prop1.ToUpper().Equals(prop1.ToUpper()) &&
                        entity.Prop2.ToUpper().Equals(prop2.ToUpper()))
                .OrderBy(entity => Repo.SortExpression ?? entity.prop1);

Answer: Your Repo.Query(string query) function should return IQueryable<T>.
Then you can filter and order without getting all rows first.
IQueryable(Of T) Interface
hope this helps
Answer: If this is to SQL, this will most likely create a SQL query and filter on the server and not in memory.
As a matter of fact, the statement above wouldn't actually do anything.
It's only when you iterate over it that the query will be executed. This is why certain providers (like the EF to SQL one) can collapse expression trees into a SQL query.
Easiest way to check is to use LINQPAD or the SQL Profiler to see what query is actually is executed.
Comment: Ok... Well its to Oracle using Devart.. But if I debug and do a `searchQuery.Count()` (omitting the where clause) I see 10k items. And of course when I run the `where` clause it filters it to the 3k rows I want. Haha I keep confusing myself, I'll see what I can find for tools to see whats actually happening I guess.

This filters in memory right?


Some picture of my site are broken in mobile version

Question: Some picture of my site are broken in Mobile version . But they are perfectly ok and showing in pc . this is only happen to mobile version. If you vist the page then look at the picture beside 'Buy now' button in mobile version .
Link : http://www.hlwphone.com/iphone-xs/
Answer: The problem is those image URLs start with http://localhost/ instead of (presumably) http://www.hlwphone.com/. It's actually unrelated to desktop vs. mobile; you just notice it on mobile because then you're not looking at it on the same computer as the Web server.


How to remove or deactivate the default apache2 server on Snow Leopard?

Question: I want to install XAMPP on my MacBook Pro (OS X 10.6.6).  XAMPP installs apache2, MySQL and some other things.  Since it installs apache2, I need to either be able to remove the apache2 installation that comes installed on OS X, or deactivate it so XAMPP can install it's version.  Can anyone help me out with this?  I'd be extremely grateful.
Peter V.
Answer: copy XAMPP to the applications directory, then open up system preferences, go to the sharing pane, and then uncheck the box next to web sharing. start the xampp control panel, and start xampp, open a browser to local host, if you can see that its working.


iPad - xib ignoring orientation on view loads

Question: iPad question:
We have views that we're initializing from .xibs, with each .xib containing both landscape and portrait layouts.
The first view we load respects the orientation of the device, but any subsequent views seem to have confusion over which orientation they should be using.  Or, rather, they seem to ignore orientation altogether and go with whichever orientation the .xib file was saved with.  (i.e. We saved a .xib file in landscape, and even though the device was held in portrait position, it loaded the view from the .xib with a landscape layout.)
This is how we're calling in these views:
<code>Settings *settingsTEMP = [[Settings alloc] init];
self.settings = settingsTEMP;
[self.view insertSubview:settings.view atIndex:0];
[settingsTEMP release];
</code>
The first of the calls (the one that respects the device's orientation) is in the viewDidLoad. The second, which uses a different view (the one that doesn't respect the device's orientation) is in a method that's called after a button is pressed, but uses the same syntax.
If we put both into viewDidLoad, they both respect the orientation.
We've tried searching for anyone having similar issues but have been thus far unsuccessful.  Thanks in advance for any help you can provide.
Answer: I use the following
<code>
UIInterfaceOrientation toInterfaceOrientation = self.interfaceOrientation;
if ((toInterfaceOrientation == UIDeviceOrientationLandscapeLeft) ||
            (toInterfaceOrientation == UIDeviceOrientationLandscapeRight))
    {
        NSLog(@"vSettings UIDeviceOrientationLandscape");
        CGRect contentRect = CGRectMake(0,0,1024,768);
        vSettings.bounds = contentRect;
        CGRect myFrame = vSettings.frame;
        myFrame.origin.x = 0.0;
        myFrame.origin.y = 0.0;
        vSettings.frame = myFrame;
        UIImage *image;
            image = [UIImage imageNamed: @"Default-Landscape.png"];
        [backGroundSettings setImage:image];
        }

</code>
I hate having to do this as it seems a right fudge but it works for me. Called just after I create the view.


Why not using cross validation for estimating the error of a linear model?

Question: Cross validation (CV) seems to be a simple and useful tool for estimating the out-of-sample error of a linear regression model, even though it is rarely used for this purpose.
Why that? Is there a better ways for error estimation?
Is it possible to estimate the out-of-sample error by only using the training data?
Comment: You need to state your ultimate goal.  For linear models we  have a closed-form expression for an unbiased estimate of residual variance if you are honest about the predictor degrees of freedom in its denominator.
Comment: Perhaps, but a bit more important is that all the predictors were pre-specified and none was deleted by seeming to be 'unimportant'.  Otherwise, d.f. needs to be the 'effective d.f.' as in http://www.citeulike.org/user/harrelfe/article/13265069
Comment: "honest about the predictor degrees of freedom" ... which can become difficult if the data has (or possibly has) a clustered structure. And yes, depending on what you want/need to measure, other procedures may be more appropriate.
Comment: Given the assumptions that go into the closed-form expression and the potential to run into the multiple comparisons problem before you even choose what to regress on, is it not usually better to rely on cross-validation and a test set to estimate the predictive power of a linear model?
Answer: I see it used quite often in fact. Note that the popular predicted residual error sum of squares (PRESS) statistic calculated from the residuals & diagonal elements of the hat matrix is what you'd get by performing leave-one-out cross validation.
Alternatives to cross-validation include splitting the sample into training & test sets, & bootstrapping to estimate the optimism in any measure of fit & then correcting for it. See Steyerberg et al. (2001), "Internal validation of predictive models: efficiency of some procedures for logistic regression analysis", Journal of Clinical Epidemiology, 54, pp 774 – 781 for a comparison. Splitting the sample isn't a good idea unless you have a large sample size (in the tens of thousands, I've heard).
Comment: In analytial chemistry it is used so often that the measures get their name accordingly: e.g. $RMSE_{CV}$


Do Artificial Neural Network with non-linear activation only in the output layer follows linearity?

Question: I am using a model with linear activation in the hidden layer and non-linear activation in the output layer. Could you please help to know whether such models exhibit linearity or not?
The non-linear activation is required to scale the output.
Answer: A non-linear layer is a matrix multiplication followed by an activation function. A linear layer is just a matrix multiplication.
You have a matrix multiplication, then another matrix multiplication, then an activation function.
Two matrix multiplications in series are equivalent to one matrix multiplication, so your network is equivalent to one non-linear layer.
Answer: You are speaking about generalized linear models (GLM)
Comment: Do the model GLM follow semi linearity? I am new to this. Could you please help to provide detail on how it works?
Answer: If you have a sigmoid activation in your output layer, and linearities before, you can interpret it as a logistic regression model for binary classification (if output dimension is one.)
Also, in practice, having multiple linear hidden layers is a waste of resources because you can define an equivalent linear layer whose weight matrix is the linear combination of those.
Moreover, intermediate linear layers can be useful to "adjust" (i.e. expand or decrease) the output dimension of the previous layer (including the input layer.)
In general, you want to have multiple non-linear layers (i.e. whatever layer with non-linear activation on top) in the middle of your model (i.e. as hidden layers) because the activation of the output layer is often (if not always) problem dependent: e.g., in regression it can be linear.
Having multiple non-linear functions in your neural-net allows it to model (learn) more complex functions, so exploiting the universal function approximation thing: indeed, assuming a correct architecture, loss function, and optimization procedure.


Mac numpad keypad works as directional pad

Question: I have a keyboard with an Apple/Mac layout (Option and Command instead of Alt and Windows keys), but I can't get its number keypad to work. I was able to figure out that the number keys are being used as a directional pad (4 as left, 6 as right, etc.) I found some advice online to press fn+F6 twice to change the numpad's behavior but it doesn't do anything.
Answer: Figured it out and thought I'd save someone else the trouble.
The clear key in the numpad (in the top left) functions as a numlock on this keyboard (the key that regulates how the numpad functions). Press the key to toggle between the numpad's two functions (as numpad and as directional pad).
Comment: Actually, it **is** the numlock key, from the keyswitch on downwards.  The USB code that is sent over the wire is the `NumLock` code.  The differences lie in (a) what is engraved on the keytop and (b) how Apple operating systems interpret that keycode.
Comment: The key functions as "clear" on OS X so it's likely that the key default "numlock" function as it would be on any other keyboard. (If the keyboard was recognized properly, there would be no numlock toggle.)


Connecting one Raspberry pi pin to many IR sensors

Question: I'm currently using pin 3 on my Raspberry pi to run one of my IR sensors. But I need to use 4 IR sensors for the purpose.
 Is it possible to connect all the 4 IR sensors to the same pin using a bread board and be able to differentiate among all the 4 IR sensors when I code for it.
I'm making a Car with 4 IR sensors on all 4 sides, so as to detect any kind of obstacles and move without hitting any objects.
Please help. Thanks a lot.
Comment: Please tell me if you're using analog or digital sensors?
Comment: It is a digital sensor.
Answer: No, not connected to a simple digital input GPIO.
Two reasons:

You can't differentiate between the sensors.
Generally IR sensors actively set their outputs high or low.  If a sensor raises an alarm its output will be overridden by the other sensors denying the alarm.

To use multiple sensors on the same GPIO they need to be part of a bus.  Perhaps search for IR sensors which use the Dallas 1-wire bus or the I2C bus.
Answer: Using digital sensors there is no way to differentiate between the 4 sensors on the same pin.


LPD6803 led with FastSPI_led library

Question: I'm a Arduino newbie looking for help.
I've got a sketch that turns 60 LPD6803 ledpixels into a clock.
The sketch is not very stable and I was told to use a different library.
FASTSPI_led should be lots faster.
The sketch reads a RTC and turns the corresponding led's on in a specific color:

Red for minutes
green represent hours
blue for seconds.

The brightness is also controlled by a LDR. For example, the sketch uses the following line in the loop to set the (hour) led.
<code>strip.setPixelColor(h, 0, 0, brightness);
</code>
h = led number, brightness the green level as in RGB.
The lib from Adafruit is quit easy to use for this sketch!
But now for the problem...
I'm looking at the FastSPI_led lib and can't figure out how to change my code. I managed to come this far, but array's, structs and variables is beyond my league! I need a bridge between my code and the lib. Basically, what I want to achieve is having the same principle, but using the FastSPI_led lib. I've been staring at it but don't see how-to. I'm desperately looking for someone who's willing to help me out on this one. The FastSPI_led lib can be found at [Google].
The entire sketch can be found here.
Answer: I also have an issue controlling more than 344 LEDS modules with LPD-6803 drivers.  I've been using the fastspi led library to accomplish this (http://code.google.com/p/fastspi/) for a bit but now that I've added a few more modules and gone over 344 the code appears to halt.  At 344 everything works as intended but any number over this causes none of the commands to be sent out of the arduino.

LPD6803 led with FastSPI_led library


Does Xcode 4 run "stable" on OS X 10.7 DP?

Question: and will Apple accept software built in this environment for iTunes AppStore and Mac AppStore?
Answer: If you're thinking about using Xcode 4 and Lion as a "stable" coding environment, don't do it now. Lion has a lot of bugs already "enjoyable" and quite possibly a lot more to be found in the following weeks. You'll have to reinstall your OS/Xcode quite often when new releases become available.
It's nice to try things ("new" AppKit stuff) and investigate if certain things work in Lion or how will they react to new tech like "Versions", Full screen, apps being resizable from any corner, etc. All these new things will require new code and current devs will certainly want to add these capabilities. That's what this is all about.
Other OS X betas in the past were certainly stable (especially after a couple of releases) but I can't recall a "first" one being barely usable beyond experimentation.
Launchbar is buggy as hell at the moment.
Comment: Words of wisdom.     If I hadn't fixed Dropbox to work, I wouldn't have been able to use Lion.
Comment: Thank you Martin and Nathan for sharing. I too feared to venture into uncharted territory as I develop apps for a living. I very much appreciate you spending time to share your thoughts. Thank you.


What would the moment of inertia of a hollow cylinder a distance to the axis of rotation be?

Question: So I understand that the inertia of a hollow cylinder about a tangent axis to its surface is $\frac{M}{2}(R_1^2 + 3R_2^2)$, but what if this axis is not a tangent to the cylinder? So it is some distance form the cylinder.
Comment: Use the Parallel Axis Theorem
Comment: Hey many thanks for your guidance! Therefore, would it be the moment of inertia about the axis passing through the center of mass, plus MR2^2 where R2 is the distance of the axis passing through the center of mass and the axis a distance x from the surface of the cylinder?
Answer: Using the parallel axis theorem you have
$$\begin{array}{r|l}
\text{mass of cylinder} & m \\
\text{radius of cylinder} & R \\
\text{MMOI about center axis} & I_{\rm center} = \frac{m}{2} R^2 \\
\text{rotation axis to center distance} & (x+R)\\
\text{MMOI about rotation axis} & I_{\rm rotation} = \frac{m}{2} R^2 + m (x+R)^2 \\
\end{array}$$
Comment: Thank you so so much!! I greatly appreciate it!! :D


Request Information from iPhone/Php developers

Question: recently I hired a freelancer to develop an iPhone application for my website, this application will get information from the DB of the website, normally I should give to him the access to the DB to take the information needed. The question is, how to let him take the information needed without safely, i.e preventing the danger from hacking or accessing to the DB of the website or do some modifications on it... What can I do ?
Answer: Without knowing more about your site and iPhone app, here are a few questions you need to ask yourself:

Does the developer/iPhone app need direct access to the database? If you're concerned about security, is it possible for your website to expose the needed portions via an authenticated web service?
If it is necessary to provide direct access to the database, is it possible to mitigate the risk by having a read-only version for the application? Provide a userid that has access only to the portions of the database required for the app to work.
Are your database/web site/server's patches and security practices up to date? Do all that you can to ensure that your data can't be hacked by following best practices in this area.
Comment: Thank you for your answer, actually the developer need some information from the database, so how can I let him take those information without any risk ?
Comment: @Zikooz - What sort of information is in the database exactly?  The developer should not need access to the database to write the software.  If you tell him the exact schema of the database he should be able to write the required code.  If he needs test data, then setup a test database, and provide him access to it.
Comment: @Ramhound - And if I want that he takes some information from DB, can I create a .php page that contains the informations of DB, then  he can include it into his code without know the password and the other information of DB, So, is it safe or not ?
Answer: I am not sure , how does it work in Iphone app,  but I prefer the JSon calls When I use PHP. I think there is any method to call JSON from an Iphone application if it is HTML based.
Comment: Yes, Apple's SDK includes a simple JSON parser/encoder. And there are a variety of third party ones with more flexibility.
Answer: Ideally, you'll be providing only indirect access to secured data via a service. This service will handle security such as identity authentication and security/access levels.
A quick Google and StackOverflow search will reveal several different service design options for connecting to a web service from an iOS device.


Want to switch the SIM card from my iPhone 4 to 6s plus

Question: I want to insert my existing SIM card from iPhone 4 to iPhone 6s Plus. I want to know if I remove the SIM card from my existing phone, will the data and photos and contacts and whatsApp chats will be deleted or will it remain in the phone? Please guide me on this.
Comment: iirc , the SIMs are different sizes, so unless you have one that each size can snap out of its parent, you'll need a new SIM.
Comment: @Tetsujin, while the SIM cards are indeed different sizes, the iPhone 4 size can be trimmed down to iPhone 6S+ usually using a dedicated tool (or scissors and careful cutting).
Comment: The data that you want to keep (photos, contacts, etc), is this on the iPhone 4? And you want it on the iPhone 6S+? Or, are you swapping SIM cards but keeping the same phone? The answer depends on what you're exactly doing, which is unclear from your question. This is because the data that you've listed all live on the phone, not the SIM.
Answer: If you used iCloud in your iPhone 4, it's most likely you will still have your contacts and photos in your 6S Plus if you'll use the same iCloud account. If purchased music from iTunes and apps from the App Store, you will still be able to have them on your new phone. However, chat message history depends on the app developer. Some have servers to save your messages in and make them available in case the app is installed in another phone/platform (like Skype), and some just save your messages locally (on your phone) which makes them unavailable to other installations of the app.
Comment: Thanku but my iCloud account is not active


How related are ellipses and right cones?

Question: Since the formula for the lateral area of a right cone is the same as the formula for the area of an ellipse, are there any deeper connections between these two geometric objects, other than the fact that an ellipse is a conic section?
Answer: Here is an intuitive explanation of why they should be equal:
Imagine taking a cone of radius $r$ and slant height $l$, removing the base of the cone, and putting it in a vise (the sides of the vise will be exactly $2r$ apart). Now squash the point of the cone down flat -  the sides of the vise are preventing any expansion in one direction, so all of the extra "material" of the cone goes into extending it's footprint along the axis parallel to the sides of the vise. The result will be an ellipse with one radius equal to $r$ (this is perpendicular to the sides of the vise), and the other radius equal to the slant height (this is parallel to the sides of the vise).
So, the area of the "lateral area" part of a cone (i.e. the surface area, minus the base) is equal to the area of an ellipse with radii equal to $r$ and $l$.
Comment: Is there an intuitive way to see why the right angle makes the squashing an isometry?
Comment: BTW, I subsequently mentioned this to my students, so, you've had a direct and immediate impact on the mathematics education of some high school students. Is MSE great, or what?
Comment: I'm trying to think of one, but I think my brain is fried from lack of sleep. I just posted the first thing that came to mind. I would guess it's something like the vertical distance between points got converted to increasing their distance in the parallel-to-vise direction.
Comment: @Mike: It really is great! I'm glad to have helped.


How do research papers differ from research articles?

Question: What is the difference between a research paper and a research article? Frequently these two terms are considered in the same category. So, what features distinguish these two terms?
Comment: I always thought paper to be a kind of slang :)
Answer: Research article refers mainly to research published in a journal, whereas research paper refers to a research report whether it is a published one or not.
Answer: I don't think you will find a general definition that is universally applicable. But a research article could, in some cases, be a work that covers a number of papers, or the work of many people, and that attempts to bring ideas together, rather than to present fresh research itself.
A research paper, probably is more specific, presenting the work of some particular author(s) on a particular project.
Thus a research paper, presents an advancement in a field, whereas an article can be more general, not tied to a specific project, but generalizing a bit to give context to other work and bring it together.
But others can have different definitions, and this is just a personal observation. Your usage may vary. And I notice from other comments made here, that there are other views. Some will use the terms interchangeably, of course.


Tax Incidence and distribution

Question: Although the tax incidence is generally dependent on the nature of the elasticity of the demand or supply, in special scenarios can the producer take up the complete burden of the tax so that the price paid by the consumers does not change?
If this is possible does this mean that the supply curve is shifted in order to change the tax incidence?
Answer: There are two possible answers here, depending on whether you want to take a partial or general equilibrium setting. Note that the partial equilibrium analysis of tax incidence is only taught in undergraduate micro textbooks but is not considered a sensible approach in current research.
Partial Equilibrium: Suppose your supply is perfectly inelastic (for example a non-rival but excludable good which you produced last period) and demand is perfectly elastic (let's say another firm produces a perfect substitute with perfectly elastic supply sold at some price p). Then the producer will bear the full burden of the tax.
General Equilibrium: In a general equilibrium setting, anything can happen. In response to a tax, both supply and demand curves may shift. However, in this case the standard definition of tax incidence is no longer meaningful. In such cases, researchers either calculate some loss function for each consumer or simply look at price changes to analyze tax incidence.

Tax Incidence and distribution


Contraction mapping does not hold in metric space

Question: Let $X=\mathbb{Q}\cap [1,2]$, i.e $X$ is the set of rational number between 1 and 2 inclusive.
We can consider $X$ to be a metric space by endowing it with the usual distance function, i.e for $x,y \in X$ we put $d(x,y)=|x-y|$. Now we define $f:X\rightarrow X$ by $f(x)=x-\dfrac{x^2-2}{2x}$.
Ones should check that if$x\in X$ , then $f(x)\in X$ as well. This means checking that if $x$ is rational and in $[1,2]$ then $f(x)$ is also rational and in $[1,2]$.
Prove that $f$ is a contraction mapping but $f$ does not has a fixed point.
This is my homework exercise, but I am not good at mathematics, so please feel freely helping me. Thank you very much !
Comment: Ah, I remember false, $\frac{3}{2}\ge 1$. but that's why I need you help in solving this problem. I may be need a more precise solution. sorry because I am not good at mathematic.
Comment: You have three things to prove: (a) $f$ is a function from $x$ to $X$. (b) $f$ is a contraction. (c) $f$ has no fixed point. Can you prove any of these statements? What have you tried?
Comment: By definition of *contraction mapping*, you need to show that there exists $0 \leq k < 1$ such that, for all $x, y \in X$... (among other things)
Comment: Yes, I can prove that $f$ is a contraction.Infact, I can prove that $|f(x)-f(y)|\le \dfrac{3}{2}|x-y|$. But what about the proof for fixed point ? is it too obvious that we have to solve the equation $f(x)=x$?
Comment: @msnaber: look again at the definition of a contraction: what you have proven is not enough. Yes, a fixed point of $f$ is exactly a solution (in $X$) of $f(x)=x$.
Answer: Ok, first you can transform $f(x)$ into $f(x) = \frac{x^2+2}{2x}$ (by taking $x$ to the fraction and subtracting from $2x^2$ the value $x^2-2$). Then you can notice, that in the numerator and the denominator there are rational numbers, since you multiply and add rational numbers. So the whole fraction is rational.

Now: is it in $[1,2]$?
Assuming that $x \gt 0$ we have:
$\frac{x^2+2}{2x} \ge 1$ iff $x^2+2 \ge 2x$ iff $x^2 - 2x + 2 \ge 0$ iff $(x - 1)^2 + 1 \ge 0$ which is true for any $x$.
Is it smaller than 2?
$\frac{x^2+2}{2x} \le 2$ iff $x^2 + 2 \le 4x$
Hint for that: analyse the maximum and minimum values of appropriate sides of the inequality.

Now you want to show that it is a contraction. It means that you want it to be Lipschitz, and the Lipschitz constant should be smaller than one. In these situations the easiest way is to use the Lagrange theorem. The derivative is a simple monotonous function (wolfram says: $1/2 - \frac{1}{x^2}$), so you can easily notice that its supremum (actually supremum of its modulus) is smaller than 1.
And finally a less calculus-like part of the task: Why is there no constant point?

If you look at f as a function from $[1,2]$ (without intersecting with rational numbers), then all the above calculations are still true. Let it be called $F$. $[1,2]$ is a complete metric space, so a contraction must have a constant point and it is unique. You can easily calculate that $F(x)=x$ holds for $x=\heartsuit$, so the only constant point of $F$ is $\heartsuit$. Since $\heartsuit$ is not a rational number we know that $f$ has no constant points.
Comment: This is a very nice answer.  Just an idle question: is there some reason you write "Lagrange's Theorem" instead of "The Mean Value Theorem"?  First, as an American mathematician it was news to me that this theorem was traditionally associated with Lagrange.  (See the footnote http://www.jstor.org/pss/2324274 for some historical information.)  Second, if this is a theorem of Lagrange, it is one of hundreds of such things.  When you don't have hyperlinks available, doesn't this make it a little difficult for the reader to determine which Lagrange Theorem you mean?
Comment: @PeteL.Clark: Thanks. There is no special reason. Maybe at first I didn't remember the English name and preferred to use the surname. At my university this theorem is always associated with Lagrange. Or maybe I assumed that when speaking about basic analysis it is clear which theorem is intended. Good to know that the MVT isn't commonly associated with Lagrange, I'll try to remember about it in the future. Anyway, even if one is offline, the destination address of a hyperlink is available after mouseover and the address here contains the name, so I hope not to have troubled anyone too much.
Comment: Well, actually the last part is also calculus-like, there is no need to use topology and complete spaces here =)
Comment: thank you very much savicko!
Comment: Pedantic nitpick:  In your second paragraph, you're not assuming that $x\neq 0$, but rather that $x > 0$.  This guarantees the inequalites don't reverse direction when you multiply by $2x$.  +1 anyway for the $\heartsuit$!
Comment: @JasonDeVito: Thx, corrected.
Answer: Somewhere between a comment and an answer: the map $f$ is nothing else than the "amelioration function" $T(x) = x - \frac{f(x)}{f'(x)}$ one studies when applying Newton's method to search for roots of a differentiable function $f$: here the function is $f(x) = x^2-2$.
Aside from providing general orientation, this observation is directly helpful in at least one part of the problem: a glance at the above formula for $T$ shows that a real number $c$ is a fixed point for $T$ iff it is a root of $f$: $T(c) = c \iff f(c) = 0$.  Thus the fixed points of $T$ on all of $\mathbb{R}$ are $\pm \sqrt{2}$.  Since these are not rational numbers, we see that the given function (which I am calling $T$) has no fixed points on $\mathbb{Q} \cap [1,2]$.
I recently covered Newton's method in my "Spivak calculus" course: some notes on it are available here.  One point that I found interesting was that in the analysis of the convergence of Newton's method one uses contraction mappings but not the Contraction Mapping Principle.  This comes down to the point made above: in general, $T$ has a fixed point iff $f$ has a root.  Now of course just starting with a differentiable function $f$ it need not have any roots (e.g. if $f(x) = e^x$, $T(x) = x-1$).  But one can show that if $f$ has a simple root $c$, then there is an interval $[c-\delta,c+\delta]$ which is $T$-invariant and on which $T$ is a contraction mapping.  Then the rate of convergence to the known fixed point comes in handy, and for this we do not need completeness!
Comment: If you assume just differentiability of $f$ and $f'(c)\neq 0$, there might be $f'(c+\varepsilon)=0$ for arbitrarily small $|\varepsilon |$, so $T$ is not well defined unless I am mistaken. In your notes you have some additional assumptions about $f$. I think we need $f'$ to be away from $0$ to prevent Newton's method from going away and to be bounded in order _not to lose_ the contracting property. But it seems not enough to _get_ the contracting property. What do you propose? $f \in C^2$ like in your notes?
Comment: @savick01: yes, I am not just assuming differentiability of $f$: as you say, in order to prove the convergence to the root I assume that $f$ is $C^2$, although for the point in question it would be enough for $f$ to be $C^1$.  (It seems likely that $C^2$ is stronger than one really needs to assume, but $C^1$ is probably really needed.)


Will , going to , or something else and why?

Question: Should i say

Are you sure you will play the next match ?

Or

Are you sure you are playing the next match ?
Answer: Both of them are correct and both of them ask essentially the same question.  There is, however, a very subtle difference between these two sentences that could influence me to prefer one over the other in different situations.
Simple future is often used for statements of intent. So your first choice is more natural if your are asking whether the person is sure that they intend to play.  For example:

It looks like you twisted your ankle badly in the last match.  Are you sure you will play the next match?

There is reason to believe that the player's intent may have changed, so you can use simple future to ask about the new state of their intent.
On the other hand, present progressive often refers to fixed plans to do something. So the second choice would be more natural if I'm asking about plans that have already been made. For example:

I thought that your match had been scheduled for tomorrow. Are you sure that you are playing the next match?

Here the question is about the state of the fixed plans for the next match. This time it's less about what the player intends to do and more about what the plan is for what they will do.
Again, this difference is very subtle. In many cases your two sentences are going to be interchangeable.


How many methods can I use to acquire depth data?

Question: I am a newbie in Robotics. As far as I know, there're generally two ways to acquire depth information of a scene. One is the stereo vision method which applies two cameras. The other is the RGBD sensors such as Kinect and Primesense. It seems that both methods are in use currently. However, I do not know what are their advantages against each other.
I think the Kinect is a perfect solution over stereo vision ignoring its expense. So I have two questions here:

Is there advantages of binocular methods over Kinect besides expense?
As I know, both the two methods are confined with a limited distance detection range. In real world applications, we sometimes also need depth data at distance. Is there a method that we can acquire or estimate data information at far distance( not considering  laser-based detectors ).

Further more, my application may be a small flight vehicle. Which method and equipment should I choose? Will the traditional binocular camera be too slow for my application?
Answer: Actually kinect sensors are similar to stereo-cameras. They are made up of two devices, an IR emitter and a IR receiver. The emitter projects a light-dots pattern of known shape and size, while the other device receives the actual reflected dots. From the deformation of the pattern is possible to find out depth, but the maths behind it, as far as I know, is the same of stereo triangulation with known correspondences (see this video as an example).
The main disadvantages of kinect when compared to stereo-camera systems are:

it does not work outdoors
it has a range of a few meters (less than 8m).

Stereo-cameras, on the contrary, work outdoors. Their range depends on the baseline, i.e. the distance between the cameras: the higher it is, the farther are the points that can be triangulated. However, most of commercial stereo-cameras, with baselines of few cm, have an accuracy of a few meters (see for example this commercial stereo device).
You can build yourself a stereo-rig to match the accuracy you need, but if you want good accuracy the device will not be cheap if compared to a kinect (depends mostly on the cameras you think to buy) and will cost you time to set up.
Finally, if you have to triangulate very far points, then you probably need to use a Structure from Motion algorithm (see Wikipedia for a quick definition).
Comment: Well, the 1st version Kinect uses the structured light method, but the 2nd version makes use of time-of-flight methods. I think 2nd version Kinect actually is different from stereo-cameras.
Answer: I know you said "not considering laser based detectors," but I am assuming you are discounting them due to price? There is a LIDAR unit available from sparkfun for less than $100 which claims to have a range to 40m. That's about half the price of a Kinect sensor. AFAIK, this unit only measures range to a single point, I'm not sure how easy it would be to implement it as a rastering scanner.
Comment: It can only measure ranges to a single point. I think it will be extremely difficult to extend to rastering
Comment: @user49550, I don't think it would be "extremely difficult." The original raster device, the CRT, was built from a photon gun that beamed light to a single spot.
Answer: For gathering depth information and in general for mapping, there is no perfect solution yet. You need to have a good idea about application before choosing a sensor. Try to narrow down your options. Are you going to use it indoor or outdoor? How fast you want the depth measurements (you can use a single camera, but it will take around 10 seconds to generate a good point cloud)? What is the range? How accurate you want it to be (Lidar)? What resolution you need (e.g. 320x240)? What is your processing capabilities? Weight limits? Are you going to have vibration (no Lidar then)?
Configuration of stereo-vision sensor directly affects the range and accuracy. You can increase the distance between two cameras to get more reliable measurements for larger distances. It's not too difficult to make your own stereo-vision sensor. The only tricky part is two levels of calibration. One is for flatting the recorded images of each camera and the other is calculating geometric translation relation between two cameras. You can also add more cameras to your system. For example, there is a PointGrey sensor that uses 3 cameras using the same principle used in stereo-vision.
Time-of-flight cameras are generally smaller and lighter. Faster to process and give more information (e.g. color). They are not good options for outdoor or applications requiring long ranges. Emitted light might reflect more than once (does not happen too often like in sonar sensors) and give inaccurate measurements.
Speaking of sonars, you might want to look at side-scan sonars.
Comment: Do I have to calibrate the binocular cameras every time I use it? Even if I make them fixed( i.e. I fix their relative position and all other internal parameters and take the system as a whole) and take the whole system to different places?
Comment: If they are fixed, once is enough. If you change the relative position, you only need to calibrate the geometric parameters.
Answer: I'm not familiar with internals of Kinect, but don't these RGBD devices essentially use stereo vision internally?
Regardless, stereo vision needs some software to give you RGBD values (there are most likely libraries already available for free), but those devices have that software already written for their particular technology. In the end, the data you get is similar.
Regarding your second question, the farther the distance between the cameras, the more 3D you can see. So if you go with two cameras, the advantage is that you can always adjust their distance based on how far your target is. Xtion, Kinect and similar technologies are optimized for a very particular scenario (recognizing people in front of the TV withing a couple of meters), so of course they are only suitable if your conditions are similar.


Blocking domain via ufw and iptables

Question: Does anyone know a way to block the domain name of a website (www.firstlightfcu.org) while still allowing access to the site using the IP address (188.8.131.52)?  I tried blocking the website using iptables which worked perfectly and then allowing the IP address using ufw. The site is blocked altogether whether I use IP address or domain name to access it.  I know this is supposed to be possible but I guess I'm missing something and I'm a new user with ubuntu.  Any help pointing me in the right direction would be greatly appreciated.
Comment: You'd have to analyze the traffic at the application layer. This kind of behavior is better suited to a (transparent) proxy that can block on server name and SNI.
Comment: Problem I see with that is the site seems to be served via HTTPS so it wouldn't necessarily be proxy-able.  Need more info on how your network is setup, what clients and how many, etc.  For example, if you run your own internal DNS server you could spoof the domain name and point it to 0.0.0.0 or soem internal server w/ a "nice" error message, etc.   And out of curiosity, why block a bank's website?
Answer: If it's a question of your students, then they might want it for their own computer. They can modify their etc/hosts file and map that domain to a different IP address like:
<code>127.0.0.1    www.firstlightfcu.org   # localhost
192.168.1.5  return.empty.example    # just some other address
</code>
Depending on what they map the domain name to, they will see different error messages, timeouts or just nothing.
Be aware, though, that many web servers are not reachable by their IP address alone, because that IP address hosts more than one domain. So the web server will give you one of those domains it hosts, not necessarily the domain you (they) want.
You may want to read https://pi-hole.net/ to learn more about such techniques to modify browser experience.
Answer: First, UFW is just a frontend of iptables. If you know how to write iptables rules then you don't need UFW since it basically just translates your so-called uncomplicated rules to iptables.
Secondly, blocking domain name using iptables is not quite effective since the name resolution works on the application layer; you make a request to a DNS server which would return ip address of the given domain in your DNS request; while iptables is more suitable to filter communication on network and transport layer.
What you can do is to configure a proxy server for your clients which you can use to block access to a particular domain name, on the application layer, without blocking the ip address of that domain itself. To make your clients to use your proxy without making configuration on each client, you can use transparent proxy.

Blocking domain via ufw and iptables


What's the roadmap to reach nirvana?

Question: Considering I don't know anything about Buddhism expect it leads to something precious called Nirvana, what should be my approach to reach there? From my experience in academics I believe reaching the peak of any field requires strong fundamentals, rigorous training/practice and then creation (ie, invention or discovery of stuff previously non existent or unknown). Does same principle applies here? Is it possible to reach the peak of Budhhist way while being a normal human (who has obligations to fulfill and lives in society) ? Do I need to join a monastery to practice Buddhism?
Comment: You cannot escape boredom. And you can be bored anywhere. I'd rather be bored in front of my computer than in a monastery where there's nothing to entertain myself with. And these days, even those esteemed monks e.g. Ajahn Brahm, etc. use computers. So, try not to escape because you can escape life only at death.
Answer: The roadmap to nirvana is one of the most basic parts of Buddhism. It's called the Noble Eightfold Path. It consists of:

right view
right thought
right speech
right conduct
right livelihood
right effort
right mindfulness
right passaddhi/prasrabhi (doesn't translate to a single word in English, but has to do with practicing all four stages of dhyāna, AKA meditation)

As you might expect, it does require rigorous training. In fact, most Buddhists actually don't reach nirvana in their current lifetime, but a lay person can reach nirvana just like monastics can.
Comment: In fact, most Buddhists actually don't reach nirvana in their current lifetime,.... From perspective of science it's obvious that there's nothing as "next lifetime" so is there any effort in Buddhist community(in past or present) to make the process of reaching nirvana more efficient so that it can be reached in our only lifetime.
Comment: A majority of Buddhists believe in reincarnation as Hindus during the Buddha's time taught it. It plays a lot into the concept of samsara and karma. However, some see reincarnation as less literal. Some believe that karma is one's actions is the effect one's actions has not only of people of today directly affected by them, but in addition, those in the distant future could be affected by that action too, similar to the Butterfly Effect. In that case, the goal would be to create a future that would expose people to the Eightfold Path.
Comment: Actually if you look at existence scientifically you will see that the "next lifetime" as you are calling it is quite assured. Observe your surroundings, now try to find any phenomena that is permanent, try to find phenomena that is not effected by causality, now try to find phenomena that does not transmigrate, Now if you cannot find any single phenomena that has these characteristics, why would you then think "you" are permanent, unaffected by causality and are unable to transmigrate...
Answer: Nirvana comes naturally along the path who has figured out the game of life. I mean if you have ever played those games called Grand theft Auto or any of the massive open world games. Initially you are absolutely immersed in the game because it has pulled your attention so much like a black hole sucking in but after a while you get tired of repeating the same things over and over again.
The key is to trick your brain since essentially reality is more or less some kind of a simulation. You can tune out the world by relaxing because you have become tired of exploring stuffs in the world. Meditation is taking a break.
Nirvana is the realization that this life is a big fat joke. Now, you just keep doing what you are doing until you die. So, nirvana is no escape because you got stomach to feed. :)
Comment: It it's true at all, then it's just fabulous thing to do. Amazing perspective friend that.
Comment: nirvana is no escape because you got stomach to feed?
Comment: Wrong...........
Answer: Do I need to join a monastery to practice Buddhism?
Not necessarily.

Buddha only encourages us to be in the present, which is the only path to Nirvana.
How to be at present?
Buddha teaches how to be in the present all over the Damma. (Buddha's teachings.)
It's about concentration. It's about knowing what's going on in you, around you. (Not dreaming about the past and future.)
You can practice Samatha meditation to get absolute concentration.
(This is not the true purpose of Buddha's teaching.)
Nirvana?
Now, One should use this concentration/ability to be in the present to understand the Four Noble Truths(Nirvana).
Which is vipassana meditation (The process of using concentration to understand the Four Noble Truths).
Which is the main goal of Buddhism.
After someone attains Nirvana, they won't rebirth again. So No suffering, No purpose for living, rebirth, death.
Thanks . Any questions are welcome. ☸.

What's the roadmap to reach nirvana?