Link to a specific inode

Question: I have a file that was deleted, but is still held open by a program. I found the inode number using lsof. How can I create a hard link back to that inode?
Answer: You can't create a link to it, but you can get it back. Let's do an experiment:
$ echo blurfl >myfile.txt
$ tail -f myfile.txt &
$ rm myfile.txt

myfile.txt is now gone, but the inode is kept alive by the tail command. To get your file back, first find the PID of the process keeping the inode:
$ ps auxw | grep tail
sunny      409  0.0  0.0   8532   824 pts/5    S    18:07   0:00 tail -f myfile.txt

The PID is 409. chdir to /proc/409/fd/ and list the contents:
dr-x------ 2 sunny sunny  0 2009-07-24 18:07:18 .
dr-xr-xr-x 7 sunny sunny  0 2009-07-24 18:07:17 ..
lrwx------ 1 sunny sunny 64 2009-07-24 18:07:33 0 -> /dev/pts/5
lrwx------ 1 sunny sunny 64 2009-07-24 18:07:33 1 -> /dev/pts/5
lrwx------ 1 sunny sunny 64 2009-07-24 18:07:18 2 -> /dev/pts/5
lr-x------ 1 sunny sunny 64 2009-07-24 18:07:33 3 -> /home/sunny/tmp/myfile.txt (deleted)

The /proc/[PID]/fd/ directories contain symlinks to file descriptors of all files the process uses. In this case the symlink "3" points to the deleted file. So, to restore the file, copy the contents to a new file:
$ cat 3 >/home/mydir/saved_file.txt

Comment: @Rob: No, it doesn't. If the file descriptor is in use, the symlink points to valid data, otherwise the symlink wouldn't exist in the first place. When the file is closed, the symlink disappears. You did have a space after the "3", right? If not, you'll output the contents of file descriptor 3 in the current shell instead, and _that's_ probably empty.
Comment: The only problem with this is that if the file is still being written to then the copy you make will be truncated. There's probably no time between when the write stops and the file is closed to do this so that you get a complete file.
Comment: This doesn't work for me. Given that '3' is a dangling symlink, not a "real" file descriptor, it always just creates an empty file.
Comment: I've done this with a filesystem debugger in the distant past (e.g. "debugfs dump"), but the concept is the same.
Comment: you may as well use `ln` to create a hardlink instead of copy. It is possible only when your hardlink location is on the same FS as original file. No data will be physically moved/copied, it's just another name for same file.
Answer: to get the whole file if it is still written to try tail -c +1 -f
from:
https://unix.stackexchange.com/questions/25527/how-to-follow-a-la-tail-f-a-binary-file-from-the-beginning
(btw: ln from the fd on /proc doesn't work, just tried that)
Answer: There is no portable way to do this under Linux. Best way would probably be to get all activity on the file-system to cease, kill the program that holds the file open, unmount the file system and use a file-system debugger to re-attach it to a directory. If you have the file system exported through NFS, at least some versions of NFS may allow you to read the file data across NFS.
Comment: you may lose the file once you kill the program

Link to a specific inode


Is null an Object?

Question: Is null an Object in Java?
Comment: No it's not, and for those who wonder why such a question, there are languages where null is indeed an object like any, for example Ruby.
Comment: In Scala, which is very meticulous about types, there is a type `Null` (a *trait*, actually) having a single instance `null`.
Comment: @JRL: Just out of curiosity, I wonder how that influences how JRuby works...  (I'm not familiar enough with that level of implementation to know for sure.)
Comment: To add to @JRL's comment - Ruby's rough equivalent to `null` is `nil`, which is an instance of [NilClass](http://www.ruby-doc.org/core-2.1.2/NilClass.html)
Comment: Or javascript, in which `null instanceof Object` is false but `typeof(null)` returns `'object'`.  Is it an object in that case?  Who knows.
Answer: If null were an Object, it would support the methods of java.lang.Object such as equals(). However, this is not the case - any method invocation on a null results in a NullPointerException.
And this is what the Java Language Specification has to say on this topic:

There is also a special null type, the
  type of the expression null, which has
  no name. Because the null type has no
  name, it is impossible to declare a
  variable of the null type or to cast
  to the null type. The null reference
  is the only possible value of an
  expression of null type. The null
  reference can always be cast to any
  reference type. In practice, the
  programmer can ignore the null type
  and just pretend that null is merely a
  special literal that can be of any
  reference type.

I think this can be boiled down to "null is special".
Comment: So an object in Java is only an object if it is equal to or subclasses `java.lang.Object`. Practically - yes. You can't create a class that is not a subclass of java.lang.Object, but I never thought about it from a more philosophical point of view
Comment: @Srichakradhar: yes, we can! Which you can find out more easily by trying it in code than by asking here.
Comment: "The null reference is the only possible value of an expression of null type". It is time to read the Specifications doc. :)
Comment: Just like the square root of -1. `i` is special.
Comment: Curiously, of all things, the [API doc for `NullPointerException`](http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html) makes mention of a »`null` object« … :) But then, it was also okay to talk about »null pointers« …
Comment: You said: "The null reference can always be cast to any reference type". So, can we return null(typecasted-if allowed) in a method with an object reference(return) type?
Comment: @GeroldBroser yep! :)
Comment: Please, change link to http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.1
Comment: @GauravMall It's not that special. `i²`  is `-1` again. ;)
Answer: According to the Java spec, null is a type that can be assigned to an object variable (as a value as noted in the comment). You cannot instantiate or create variables of this type though, you must use the literal null provided by the compiler.
Comment: null is a type and a value.
Comment: The `null` name is an "instance" of the `null` type, apparently.
Comment: `null` is not a variable, it's a literal: [JLS, 3.10.7. The Null Literal](http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.7)
Comment: Re "_`null` is a type that can be assigned_": 1) `null` (in code) is the _null literal_, not the _null type_ 2) Types cannot be assigned to variables in Java in general, see [JLS 4.1: "_There are \[...\] two kinds of data values that can be stored in variables \[...\]: primitive values (§4.2) and reference values (§4.3)._"](http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.1)  It's [the null reference](http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.7) that can be assigned via the `null` literal. ...cont'd...
Comment: 3) _object_ in "_object variable_", compared to class variable, usually doesn't refer to the type but to the lifetime. When referring to the type it's usually called _variable of a reference type_ or, for short, _reference (type) variable._ I'm aware of 4 types in the Java API that expose instance/object variables (there may be more): [arrays with its `length`](http://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html#jls-10.3) and the subclasses of [`java.awt.geom.Point2D`](http://docs.oracle.com/javase/8/docs/api/java/awt/geom/Point2D.html).
Answer: Absolutely not: null instanceof Object returns false.
Comment: And yet it is assignment compatible with all reference types.
Answer: JRL (and others) wrote:

No it's not, ...

As often, it depends from where you look at it, who you believe more.
According to the JLS, yes, it is. Especially if you rephrase the question to: "Is the null literal of type Object?".
In addition to JLS 4.1 cited by Michael Borgwardt above:
See JLS 3.10.7:

A null literal is always of the null type.

and JLS 4.10:

The subtypes of a type T are all types U such that T is a supertype of U, and the null type.

or JLS 4.10.2:

The direct supertypes of the null type are all reference types other than the null type itself.

[Emphases by me.]
According to Eclipse 2019-09's compiler it's not:
true.toString();  // Cannot invoke toString() on the primitive type boolean
null.toString();  // Cannot invoke toString() on the primitive type null

According to OpenJDKs 12.0.1 javac it is:
true.toString();  // error: boolean cannot be dereferenced
null.toString();  // error: <null> cannot be dereferenced

Where the angle brackets imply that null is of an other than a primitive type. And according to JLS 4.1:

There are two kinds of types in the Java programming language: primitive types (...) and reference types (...).

if it's not the one it's the other.

Claudiu wrote:

null is kind of ugly.

Au contraire, null is beautiful. What would you suggest as default value for a reference type variable instead? An arbitrary bit combination? Welcome to access violation or, even worse, pointer hell!

Joachim Sauer wrote:

null is a type and a value.

There are actually three items in conjunction with null (see also JLS 3.10.7):

The (otherwise unnamed) null type.
The null literal.
The null reference value. (Commonly abbreviated as null value or simply null.)

(1) Note that, according to JLS 4.10.2 cited above, the null type uses multiple inheritance not only for interfaces but for classes as well. Which we all know is not possible for us application programmers.
(2) The null literal might be imagined as a variable being defined as:
JVM_global final null_type null = new null_type();
Note also JLS 3.9:

A variety of character sequences are sometimes assumed, incorrectly, to be keywords:

null is not a keyword, but rather the null literal (§3.10.7).

Concerning null instanceof <any type>
With JLS 4.10.2 in mind ("the null type is a subtype of every type") null instanceof <any type> should be supposed to evaluate to true, shouldn't it? At first sight, yes, but JLS 15.20.2 gives the insight answer:

[...] the result of the instanceof operator is true if the value of the RelationalExpression is not null [...]. Otherwise the result is false.

[Emphases by me.]
Ask yourself what makes more sense (from an application programmer's point of view):

Giving false and thus indicating that a reference expression is not of a type exposed to us, i.e. indicating it's not referencing anything useful to us

or giving true, thus informing us that the expression evaluates to a special reference, the null reference, referencing an "object" we don't know whether it even exists and which is of the special null type which has no name, is not exposed to us but via the null literal, is a subtype of any type including multiple inheritance and is to be ignored anyway? Consider also the more practical example:
   class Car implements Vehicle {
   ...
   Vehicle car = null;
   ...
   boolean b = car instanceof Car;  // True? There's not even an instance
   ...                              // which could be of type Car.

Which also leads to:
Why is instanceof not a proper way to say something about null's Object-ness?
It's called instanceof not sameorsubtypeof. That means we are comparing an instance's type with a type, not two types. Now null means: "There is no instance" and if there is no instance there's no instance's type. It's obvious that comparing nothing with something is supposed to lead to false.
Or in a "more" real world example:

I have a real-size picture of an apple (=reference type) in my hands with »Big Apple« (=reference type name) written on it.
There's a table (=heap) in front of me.
If there is an apple (=instance) on the table there is a cord (=reference) connected to it.
I hold the other end of this cord in my hand (=reference variable) .
I trace the apple along the cord and compare it with my picture (=instanceof).
If the apple is of the same size or bigger than the picture the writing »Big Apple« applies to it (=true).
If it's smaller, then not (=false).
If there is no apple on the table (=no instance) and, hence, no cord exists (=null) the writing doesn't apply either (=false). Because: Is no apple a big apple? No, it's not.

As Michael sums up: "null is special" indeed.
Comment: Apple and null? Aren't you afraid of a lawsuit? :)
Answer: Null is the lack of an object.
Comment: Tommy: JLS 4.1: "There is also a special null type, the type of the expression null, which has no name."
Comment: But the null type is assignable to every reference type.
Comment: There is no "null type"; null is a specific value of non-primitive expressions (i.e. references; there is no "reference type" in Java either, to my understanding).
Comment: @TommyMcGuire Re »_there is no "reference type" in Java_« see [JLS 4.1: "_There are two kinds of types in the Java programming language: primitive types (§4.2) and reference types (§4.3)._"](http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.1)
Answer: No, it is not an object.
Answer: No, it's not an instance of a Class nor a Class. It's a reference to nothing.
Edit: haven't read the spec so the above may not be 100% accurate.
Answer: As explained in the chapter 4.1 The Kinds of Types and Values of the Java Language Specification, null is a type which has one value, the null reference (and is represented by the literal null):

There is also a special null type, the
  type of the expression null, which has
  no name. Because the null type has no
  name, it is impossible to declare a
  variable of the null type or to cast
  to the null type. The null reference
  is the only possible value of an
  expression of null type. The null
  reference can always be cast to any
  reference type. In practice, the
  programmer can ignore the null type
  and just pretend that null is merely a
  special literal that can be of any
  reference type.

You might want to read about the Null Object Pattern (that I  don't recommend) though. See the C2 Wiki or Wikipedia for more on this pattern.
Answer: No, is not an object as null instanceof Object will always return false also there is only one null, not one for each class.
Comment: In fact, `null instanceof ` will return `false`, too.
Answer: According to the Java Spec,

There's also a special null literal
  that can be used as a value for any
  reference type. null may be assigned
  to any variable, except variables of
  primitive types. There's little you
  can do with a null value beyond
  testing for its presence. Therefore,
  null is often used in programs as a
  marker to indicate that some object is
  unavailable.
Answer: Java handles objects via references. Null is a breakdown of OO-ness of Java, since it drops you below OO level. No it is not an object it is a VALUE of a reference. And it has nothing to do with object paradigms, but relates to plumbing of Java, that enables objects.
Answer: Is null an instance of java.lang.Object? No.
Is null an object? depends on the definition of "is".
Comment: Wrong site herein? → https://philosophy.stackexchange.com/ ;)
Answer: Object foo = null;
System.out.println(foo.toString());

The first line shows null can be assigned to type Object, but the second line will demonstrate it is certainly not an Object and eventually results in a java.lang.NullPointerException
Answer: No ,null is not an object.It is a reference type and its value does not refer to any object and so there is no representation of null in memory.
Comment: The OP asked for (the type) `Object`, not _object_ (as in _instance of a type_). And [if one rephrases the question accordingly...](https://stackoverflow.com/a/12886252/1744774)

Is null an Object?


DEV & QA Story Point Total

Question: If dev thinks a story is 3 and QA says, it's a 5.  You don't add them together to get 8, correct?  I've always had the impression that whatever the consensus is, that's what the point value will be.  Meaning, if the only person saying it's a 5 can't justify why, then the whole story including the QA testing would be a 3.   I hope that makes sense.
Comment: It sounds like your dev and QAs are estimating their *efforts*. What they ought to do is estimate the relative size of the story.
Comment: Is "QA" something that is integrated in your team or an external step? Are both estimating the whole process, including dev *and* QA or is each estimating their own part?
Answer: Correct, although the really important part of this is the conversation:

"Hey QA, I thought this was a relatively simple story. I'm interested to hear why you think it is a 5"

As the team works together for a while you start to get the devs understanding more about the QA side and the QA's understanding more about the dev side.
Answer: Your method is correct. The whole idea is that if, in this example, the team later decides that 3 was an underestimate, they might say 5 the next time.
If you can keep ego or pride out of the estimates (there are no 'right' estimates; and in this example the QA person should not later gloat on 'being right it was 5'), then the team will get better at estimation and completing the sprint.
Treat it like a game: "Let's see if we can estimate everything so well, that we 'score' another sprint."
Answer: Within a Single Team

If dev thinks a story is 3 and QA says, it's a 5. You don't add them together to get 8, correct? (sic transit)

You tagged this "agile" but not with a specific framework. Based on that, let's start by assuming you have a single, cross-functional team with both developers and testers working collaboratively on the same team. In that case, the goal is to reach a consensus among the team members on the relative level-of-effort is for the whole team to complete the user story in a way that meets the Definition of Done. Since all members are on the same team, they are collectively responsible for completing the whole story, not just estimating sub-tasks parceled out to individuals. Each story, if properly decomposed using INVEST criteria, has a singular estimate for completion rather than representing the sum of multiple deliverables.
Since your developers think this story is easier to complete than your testers do, there's a conversation that needs to happen about the total level of effort involved. Perhaps the story is easy to code but hard to test, or the developers and testers may be over- or under-estimating based on unspoken assumptions about their own work or the work done by other members of the team. Regardless of the reason, it's an opportunity for them to talk together and plan how the work will be done and why it will be easier or harder to complete than someone else expects. They can then re-align their estimates based on the additional information.
If they still can't agree then the team can split the difference, or pick the high or low estimate. It doesn't really matter, as long as the team is consistent about it. Either way, over time the actual range of the team's velocity will converge based on the estimation technique employed. A small, one-off difference like this isn't really statistically significant over the life of a project or (in many cases) even within a single iteration.
With Multiple Teams
On the other hand, if developers are tossing code over the wall to QA, then you don't have a single user story. You actually have at least two, each with its own assumptions about what's involved and how hard it may be relative to other work. In that case, your estimates could potentially be additive, but story-point estimates are generally not comparable between teams. Some frameworks like SAFe gloss over this by treating story points as days as a way of "normalizing" estimates across teams. However, story points are a measure of relative effort, not a proxy for time, so SAFe's use of the term will likely lead you astray.
If you have multiple teams, you shouldn't just add the story points of related stories. Instead, you should let each team use its own story point estimates and then use the velocity of each team to try to estimate time if that's what you're really measuring anyway. If you're genuinely trying to estimate level-of-effort between two teams with different estimation baselines, then you could use velocity, cumulative flow, or some other metric to try to combine the estimates into a combined estimate within a given confidence interval.
At a more basic level, you could toss the whole paragraph above and just ask the two teams to estimate the story together as if they were on the same team. Then use that collaborative estimate in whatever form makes the most sense for the overall project. Since there's no substitute for communication, asking the teams to work together on a plan and a single probability-based estimate makes more sense than trying to convert dissimilar units anyway.
Conclusion
Regardless of your structure or technique, communication and collaboration are the key. If you don't have good communication and collaboration within the team or between teams, an "estimate" isn't even an educated guess; it's just a random number given based on insufficient information and lack of planning.
Facilitate the conversations, and help the teams work together on a common plan. As long as that happens, you'll either resolve the difference in estimates or make the difference irrelevant to successful delivery of the common product increment.
Answer: For me the story-point estimation process looks like this:

Everyone blindly estimates the whole story in points, including development, testing, releasing, fixes.
Differences are discussed shortly
Revote blindly
Decide on points

Now what todo when there is still a disagreement in points after the revote? I personally always just take the highest number. Because in your case the 3 might be a 3,5 and that only fits the 5 bucket. I like to see the points series as buckets, and take the one that surely fits the content.
On the short term I always try to under-promise and over-deliver, rounding up helps with this. I would only discuss points that differ more than one step on the scale, like 3 and 8. For a 3 and 5 I would just pick the 5 without any discussion, because it is faster and good enough.
Overall it does not really matter how you pick your final number, just try to be consistent over time. Also it depends on the goal of the points, predictability versus conversations.
Also be aware you are comparing estimates of essential complexity, but in reality it is accidental complexity that costs the most time and has the highest uncertainty. Therefor if you are researching Agile software development estimates please watch: 7 minutes, 26 seconds, and the Fundamental Theorem of Agile Software Development

DEV & QA Story Point Total


How do you measure the volume of a mesh?

Question: Is there a function in blender to measure the volume of the mesh that you input in the geometry nodes? For example let's say I have a cube with the dimensions (10,10,10), then it should output 1000.0 because that is the volume of the cube.
Comment: Hello and welcome! No, unfortunately this functionality does not currently exist. With a simple geometric shape it could be calculated (for example in case of a cube), but for more complex meshes there is no built-in way here.
Comment: When I've wanted to do this (actually, I wanted to find the center of gravity of a mesh, something slightly different) I've boolean'd it with a bunch of cubes, then counted the number of cubes in the output (which you can do by scaling along individual origins to 0, merging by distance, and then reading the statistics.)  But that's a sampled solution; you probably want to see analytic solutions like discussed at https://blender.stackexchange.com/questions/63113/is-it-possible-to-display-volume-of-a-mesh-object .
Answer: Using Blender 3.4's topology nodes and recreating this answer will give you the volume of a mesh.
public float SignedVolumeOfTriangle(Vector p1, Vector p2, Vector p3) {
    var v321 = p3.X*p2.Y*p1.Z;
    var v231 = p2.X*p3.Y*p1.Z;
    var v312 = p3.X*p1.Y*p2.Z;
    var v132 = p1.X*p3.Y*p2.Z;
    var v213 = p2.X*p1.Y*p3.Z;
    var v123 = p1.X*p2.Y*p3.Z;
    return (1.0f/6.0f)*(-v321 + v231 + v312 - v132 - v213 + v123);
}
public float VolumeOfMesh(Mesh mesh) {
    var vols = from t in mesh.Triangles
               select SignedVolumeOfTriangle(t.P1, t.P2, t.P3);
    return Math.Abs(vols.Sum());
}

The above code recreated in nodes:

Apologies for the spaghetti, Blend file is attached so no one has to recreate it.
You can check the results by enabling and using the built-in "3D-Print Toolbox" addon.
Comment: This is awesome ! I would just replace the "Points Count" output type to Float instead of Integer so that you don't lose on precision.
Comment: Very nice and efficient approach.
Answer: There is at list a possibility of volume calculation but it's painfully slow, you have to stop the calculation on the last frame so it's not very practical, furthermore it doesn't work with moving objects.

It's based on the buffer hack. At every frame it increment the Z position of a plane accordingly to the index and with a Mesh Boolean it calculate the surface of this cross section of the mesh. Then the mesh section is instanced and the surface is stored in a Store Attribute node.

At the end, after the buffer hack, a Statistic Attribute calculate the mean of all the surfaces (except the first and the last witch are those of tangent planes and cause problem with the boolean, any way there surfaces is equal to 0), multiply it by the height and this volume value is stored too.

You have to set the definition by setting the Start Frame and the End Frame with a Driver.
I hope it will help somebody one day...
Answer: You can use rigid body ops.
bpy.ops.rigidbody.object_add()
bpy.ops.rigidbody.mass_calculate(material='Custom', density=1) # density in kg/m^3
volume = ob.rigid_body.mass

https://blender.stackexchange.com/a/304033/72020


Can I put an Ethernet port in my brick wall?

Question: I want to set up a new network in my home and need one by where my computer is. The problem is I don't know if I can put the ethernet cable and port into the wall without problems. Thanks in advance
Comment: What's on the other side of the brick?
Answer: Two issues - cable and port.
Cable through brick wall
If one end is on one side of a brick wall and the other end is on the other side of the brick wall, drill a hole with a hammer drill and a masonry bit and fish the wire through. A brick wall could be just a couple of layers of brick but often has cinderblock or (as I found when I replaced my oven years ago) all kinds of stone, concrete and junk inside. Ideally you want a bit long enough to go all the way through everything in one shot. Not an easy job, but usually not too hard with a decent drill and bit.
Cable on surface of brick wall
If you can't easily go through the wall, or you need to run the cable a distance along the wall for other reasons (e.g., the router is 20 feet down the wall on the same side) then use a surface raceway. Basically, a plastic or metal rectangular tube that you mount on the wall and stick the wire inside. Some people don't like the look, but running cable inside a brick wall is not practical so it is either on the surface in a raceway (better than just leaving the wire loose) or through to the other side. If you have a baseboard or molding on the bottom of the wall then you can, depending on the details, either mount a raceway to the baseboard/molding easier than mounting to the brick, or staple the cable directly to the baseboard/molding.
Depending on the type of wall (interior vs. exterior) and where you need to run the cable, and what is underneath the floor, you may be able to drill down through the floor instead and run the cable through the room or crawlspace underneath. However, that is sometimes tricky too depending on the ceiling of the lower level.
Port
Surface mount the port. Do NOT try to cut a hole for a box into the brick - it can be done but is absolutely not worth the effort. You can either use a standard box designed for mounting on the wall and put a regular Ethernet wall plate on the box, or use a smaller surface mount port. A standard box has the advantage of allowing for 2 or more ports - easily up to 6, for additional Ethernet or phone or cable TV.
Comment: @LeeSam, I agree.  I only offered it as an alternative to consider.  The OP may be looking at the most direct way to get from point A to point B, without realizing that the difficulty of going through a brick wall could make a less direct route a lot more attractive.  That's also why I put it in a comment instead of an answer.  :-)
Comment: Good answer, but I would try to avoid the brick entirely.  Just keep everything at floor level.  If there is any kind of baseboard or molding, it may be possible to attach to that.  If it's necessary to go through the wall, look for a non-masonry wall to go through, and run extra cable for the distance.  Look at going through the floor.  Explore WiFi or Powerline options.
Comment: @fixer1234 Agree regarding baseboard/molding - I'll add that. Through the wall - it all depends. I have a big long masonry bit from the first time I needed to do something like this, and I've used it a few times since then - sometimes there is no practical alternative. Through the floor makes sense sometimes, but there are many possible issues. WiFi & powerline work for lots of people, but not everyone, and also depends on if they need to run other cables at the same time (not mentioned in the question but certainly possible).
Comment: @fixer1234 "I would avoid the brick entirely" and "look for a non-masonry wall to go through" is not answering the question. The OP isn't asking for options to the masonry wall.
Comment: Just occurred to me that it could be just a decorative brick facing on only one side.  In that case, just find a mortar joint that isn't in front of a stud (via stud finder and tape measure on the other side), and drill through that.  Mortar is easy to drill through, but brick takes forever and breaks and chips.
Comment: @fixer1234 That could be, but it could also be like the brick wall my oven & fireplace are in. Or something in between. Agree that drilling through mortar is a LOT easier than drilling through brick.


antiderivatives of $\frac1{x-1}$

Question: I was told to find the anti-derivative of this problem: $$\int\frac{2x^2-13x+18}{x-1} dx$$
I solved the problem - first dividing and then finding the anti-derivative: $$x^2-11x+7(\ln(x-1))+c$$
The given answer was the same as mine, but they put the $x-1$ in $\ln(x-1)$ in absolute value - $\ln|x-1|$. Why?
Comment: $\int {\mathrm{dx}\over x} = \ln|x| +C$
Comment: General reminder even to many professional mathematicians: The family of all antiderivatives of $1/x$ is given by $\begin{cases} \log(x)+C \text { for } x > 0 \\ \log(-x)+D \text{ for } x < 0 \end{cases}$ for possibly different constants $C,D \in \mathbb R$. The other formula as quoted above is the imprecise version which is, unfortunately, taught in many calculus textbooks, presumably because it's short and already allows nitpicking with the absolute value.
Answer: Because the domain of $\ln$. it will not allow negative numbers inside ;)
Answer: Consider what happens if $x<1$: The original function makes complete sense, so there ought to be an antiderivative, but your expression doesn't make sense. Calculate it, and $\ln(1-x)$ appears. The two antiderivatives for $x<1$ and $x>1$ are most easily stitched together with an absolute value.
Answer: A lot of people are telling you it's a domain error, but I will try to give an explanation for a beginner level calculus student looking at this problem. This isn't exactly your problem, but explains why we include the absolute value around $\ln|x|$.
Look at this integral
$$
\int_{-2}^{-1} \dfrac{1}{x} dx
$$
Now if you graph this function it is very clear that this function is defined on this interval, so you should be able to take the area under the curve right?
Since you know that the antiderivative of $\frac{1}{x}$ is $\ln(x)$, the result should be
$$
\ln(x)|_{-2}^{-1} = \ln(-1) - \ln(-2)
$$
Wait, that's illegal! $\ln(x)$ is not defined for $x\leq 0$ (well unless we're in complex plane, but thats a whole other can of worms)! So in order to make sure this integral is correctly evaluated for $x<0$, we need to place absolute value signs around the argument
$$
\int_{-2}^{-1} \dfrac{1}{x} dx = \ln|-1| - \ln|-2| = -\ln2
$$
Comment: This is the best answer here (+1)
Comment: -1. Saying "oh, the formula I [falsely] believe to be true does not work -- well ok, I just put an absolute value sign at a place where it seems useful" is not the kind of argument I expect from my calculus students.
Comment: A better argument would be "hey, look at the graph: the area which that integral measures would be the same as $\int_1^2 \frac{1}{x}dx$, but it's *beneath* the $x$-axis, so it gets a negative value". And then in a next step one could generally get $\int_a^b \frac{1}{x} dx = - \int_{-b}^{-a} \frac{1}{x}dx$. And then, that a general antiderivative of $1/x$ on $(-\infty, 0)$ is given by $-ln(-x) +C$.
Comment: @TorstenSchoeneberg Nvm, misread the limits.
Answer: Hint: Since we have $$\int\frac{1}{x}dx=ln(|x|)+C$$

antiderivatives of $\frac1{x-1}$


String theory in the context of quantization prescriptions

Question: My new question here: has string theory been analyzed somewhere in the context of various quantization prescriptions formulated in a mathematically sound way? I mean something like geometric quantization, Klauder Quantization, Brownian quantization etc. It is important to know if string theory ever passed through all the mathematical requirements that define a quantum theory; and by the way, are all the mathematical prescriptions defined consistently? Do we have a mathematically sound (consistent) prescription for quantization that is free of ambiguities?
People generally boast with the fact that string theory is "mathematically consistent" as a quantization of 1 dimensional objects. Is it so indeed? Is the "quantum" part in string theory really exactly the way it should be? and is the "way it should be" really known?
Comment: I suppose quantization of strings is (at least) as consistent as what we do with QFT :P Only, the UV behaviour is better!
Comment: I suppose that a topological series expansion may require a slight generalization at least in the context of BRST quantization but then what do I know? In the end we are talking about a theory that should presumably explain interactions between black holes, subject where I am (as everyone else) a complete ignorant...
Comment: I am wondering if that was a spam or a simple misunderstanding: what I mean is a mapping from classical to quantum, like deformation quantization, geometric quantization etc. where you start from a symplectic manifold define a pre-hilbert space, define a polarization etc. The notes in the comment above are at best off topic... but forgivable if unintentional... the notes by "Heisenberg"
Answer: The core of perturbative string theory has a mathematically rigorous formulation. In fact much of mathematical physics and mathematical insight into quantum field theory as such has been gained from the study of the low-dimensional QFTs that constitute the worldvolume theories of the string and the various branes. For instance the axiomatization of QFT in the "FQFT" flavor (roughly dual to the AQFT picture) historically originates in insights gained in the study of (topological) string (namely the Moore-Seiberg axioms). On the other hand, the attempted implementations and applications of core string theory are vast and numerous, and when it finally comes to string phenomenology the usual level of rigor is just that common among practicing quantum field theorists. On the far end, deep aspects of string theory that are felt by many researchers to be of metaphysical relevance, such as the "landscape of string theory vacua" have led and are leading to speculations that are not anymore backed up by any disciplined reasoning.
More in detail:
The quantization of the string sigma-model may be obtained cleanly via the mathematical sound process of geometric quantization, see the references on the nLab at string – Symplectic geometry and Geometric quantization. The famous Weyl anomaly of the string is formally understood in terms of anomalous action functionals, see for instance (Freed 86, 2.). Various other obstructions to quantization (quantum anomalies) in the background fields for the string sigma-model such as notably the Freed-Witten-Kapustin anomaly, have been understood in fine detail in terms of obstructions in differential cohomology, see for instance (Distler-Freed-Moore 09).
Particularly well analyzed are the two special sectors of first quantized string theory, that of rational conformal field theory, which contains the example of strings propagating on Lie group manifolds – the Wess-Zumino-Witten model; as well as the example of topological strings. Rational conformal field theories indeed stand out as one non-trivial and rich class of QFTs which have been subject to complete mathematical classification (in the same sense in which mathematicians for instance do the classification of finite simple groups). For details on this classification see on the nLab at FRS formalism.
For the topological string much more is true. The topological string has effectively become a subject in pure mathematics, with its rigorous axiomatization via the TCFT version of the cobordism hypothesis-theorem, its formulation as mathematical homological mirror symmetry, its relation to geometric Langlands duality etc.
But the FQFT-axiomatics that serves to mathematically formalize the topological string is not restricted to the topological sector, it also applies to the physical string. For instance Huang's theorem shows that the familiar description of physical string via vertex operator algebra is an instance of the FQFT-formalization. Indeed, in FRS formalism these two formalizations, vertex operator algebras (via their modular tensor categories of representations, and TQFT combined via the rigorous AdS3-CFT2 and CS-WZW correspondence give the classification of rational CFT). (In particular this says that in this low dimensionl holography and AdS-CFT duality is rigorous, of course this is far, far from true in higher dimensions.)
In summary this is a level of rigour with which the worldsheet 2d QFT of the string is understood which is well beyond of what one typically encounters for non-trivial interacting (non-free) QFT. And this is full non-perturbative quantum field theory (on the worldsheet!), not just the approximation in perturbation theory.
From here on, also string field theory (its action functional, that is), has a completely rigorous formulation in terms of operads and L-infinity algebras (Lie n-algebras for n→∞).
A snapshot of the state of the art of rigorous foundations of string theory as of 2011 is in (Sati-Schreiber 11).

The above text with hyperlinks for all technical terms is also on the nLab at string theory FAQ -- Is string theory mathematically rigorous?.
Comment: I see what you are after here. Right, so I am not aware of a decent discussion of the space of geometric quantization choices on the string worldsheet itself, the usual Kähler polarization looks maybe too canonical to have inspired many to look for something else. One exception is..
Comment: One exception is Klaus Pohlmeyer and a few of his followers to this day. Pohlmeyer had been hoping that if one changes something about the string quantization prescription that then the critical dimension would go away, see the review here: http://arxiv.org/abs/hep-th/0403260 (together with an argument for why it does not). The latest work inspired by Pohlmeyer is http://arxiv.org/abs/1204.6263 , which gives a rigorous but perturbative quantization of the 2d Nambu-Goto action, claiming that the anomaly is not seen there.
Comment: I suppose what you are after may not be in the literature yet. But another among articles that study spaces of choices in producing string worldsheet QFTs (for the rational case, e.g. WZW) is Runkel et al.'s "Uniqueness of open/closed rational CFT with given algebra of open states" http://arxiv.org/abs/hep-th/0612306 .
Comment: Thank you! And congrats for the nlab posts! I read them relatively often. The references therein are also quite useful! :) Now, to the subject: there are several steps in the formal procedure of quantization where choices of a certain degree of arbitrariness are being made (see choice of Polarization, choice of a section of a fiber bundle, choice of a picture, choice of a ghost structure, etc.). The next question: is it possible that certain choices of this kind interact such that new structures emerge? Say, Kahler polarization and spin or complexification and a specific metric?
Comment: hmm... gets somehow closer to what I have in mind except that I must insist on being consistent with previous quantization prescriptions, i.e. not to get nonsensical results when applying this to old known theories. Also, the result may not necessarily be elimination of critical dimension but something maybe even better :)


Is there a RPC API equivalent of fetching my Ethereum balance by using CURL in the cli?

Question: Since metamask connects to a RPC server and passes in the eth address to make a api request. Is it possible to do the same functionality using CURL in the cli to do a basic balance inquiry of an ethereum address?
Answer: Yes it's possible using Infura.
Just checking quick here, there's a JSON RPC call you can make using curl.


SharePoint List Version History -Restore full list or multiple items

Question: is there a way to restore a prior version of a sharepoint list? I have versioning switched on and able to restore items individually, but I am looking to restore hundreds of records. Is there a way to revert to a prior list, just like how you can restore a prior file, as of the last backed up version??
Or is there a way to restore multiple items at a time? I can't seem to find an answer through googling. Any help would be greatly appreciated! Thanks!
Comment: Which version of SharePoint are you using?
Answer: Using the version history of a list, you can only see the changes done on a particular item during its lifetime.
There is no option to restore the entire list or a particular item using the version history
What you can do is, using a power automate or console application you can get the version history of a particular item using Rest API and update the same item using the Rest API or Update item in power automate.
Using this logic you can restore the entire list.
https://mytenant.sharepoint.com/sites/mysite/_api/web/Lists/getbytitle('mylist')/items(1)/versions?$select=Title,VersionLabel
Comment: Thank you for the response and suggestion! I will definitely make note of this for next time. I had to try to restore everything before users noticed the incorrect data, so I did it the ugly way. I literally went into each and every record to revert each item back to the prior one in the version history. There were 700 records! I kept thinking there's gotta be a better way..  but I couldn't find anything through my research..


How do I add window stools to my new windows?

Question: I installed new Jeld-Wen windows and saved the old stools.  I'm trying to figure out how they should be attached but these windows don't seem to be designed to take a stool -- they are flush with the drywall all around.  Referring to the picture, I can butt the stools up to the window wood and have them "floating", supported by trim piece underneath, but that would leave them susceptible to being pulled away from the wall it seems.  If I were to lay them on top of the window's existing wood, then the finger catch to lift the window would be blocked.  Is there a way to add a stool here besides having it float, or are these just designed to have no stool?
Answer: Looks like you could "float" them level with the existing frame, but screw in from the window side (through the face away from the room, into the part you call a stool that I'd call a sill) which would firmly attach the stool to the windowframe so it could not pull away from the wall.
They are probably designed not to have one, yes - "picture-framing" windows is one more place to cut costs, and cats and plants don't have effective lobbying groups to prevent it.
Answer: The Family Handyman has an article on How to Install Craftsman Trim, which says to simply glue and nail the stool to the jamb using 2 1/2" finish nails.
Once you have the stool cut to length, add a bit of wood glue to the length that will sit against the window frame. Position the stool where you want it, and drill pilot holes through the stool and into the jamb using a 5/64 drill bit (using a clamp to hold the stool in place can be useful). Next, fit 8d finish nails through the stool and into the jamb. Install the apron tight up against the bottom of the stool, making sure to nail into the framing when attaching it.
You could install a more substantial apron, and additionally nail through the stool and into the apron. This will add a bit more support for the stool (especially if the apron is attached to the framing), but may or may not fit aesthetically with the rest of the trim.
Obviously with this method you'll not be able to do chin-ups from the stool. But once the nail holes are filled and the piece is finished, it should look nice for years to come.


How do I rip an audio CD to a single file?

Question: Many programs rip audio as one file per track. I'm looking for a program or method that can rip the whole audio CD to a single file.  Which program or method can do this in Ubuntu?
Comment: One audio file (WAV), one compressed audio file (OGG, FLAC, ...MP3), or one data file (ISO)? :)
Answer: At least a command-line application abcde, found in the universe, can handle ripping the whole CD into one file.
After installing, the basic usage would be (in Terminal):
abcde -1 -a default,cue -o wav

The command should create a full-length file with a cue file. Instead of wav, you can use ogg, mp3, flac, spx, mpc, m4a if you have the codecs.
Answer: KDE has this functionality built into the desktop!
You simply open the audio cd folder and you get:

all tracks listed as ogg and mp3 files, each with their own file name.
An ogg and mp3 file, named "all" (or similar name) which represents ALL tracks in one file.
You also get other codecs listed depending on what is installed.

Now these are not true ogg/mp3 files [yet]. You simply copy any of these virtual files into another folder and kde then creates true audio files in the target folder. Real simple.
See: What really happens with audio CDs in KDE 4.x?
(If you have a Gnome ONLY system (I usually have both available) you might try KDE's K3b program which runs on Gnome, but I am not certain if it has this feature.)
Answer: Lets say you have a 17 track album (like Abbey Road).
Stick the CD in you computer, open a command line terminal window and navigate to a directory you want your huge WAV file to end up in. Then issue this command:
cdparanoia 1-17 -w Abbey.wav

1-17 means Tracks 1 to 17
-w means output to a WAV file
"Abbey.wav" is the name of the WAV file that will be created.
Answer: cdparanoia is pretty neat to rip an audio CD to wav files one file per song.
This is a lossless process, and once you have the wav files,
you can slice and dice and do anything you want with them,
for example concatenate into a single file using sox, for example:
cdparanoia -B
sox *.wav cd.wav

Answer: fre:ac is my preferred program in linux. It is fast (supports parallel processing) and supports ripping to a single file. I usually rip my audio books to one mp3. Just make sure to go to
1) Options>General Settings>Encoders>"Encode to single file"
2) Options>General Settings>Processing>"Treat the combined tracks like a single track"
3) Options>General Settings>Ripper>Settings (here you can check all boxes under "automation" (Read CD contents on insert, Start ripping automatically, Eject disk after ripping)
Good ripping to you :-)


Installing Ubuntu alongside windows, OS not detecting?

Question: I have just formatted my hp envy laptop with windows 8.1 and i tried to install Ubuntu but failed as it is not detecting OS so that it can be installed alongside. I have tried all your support of legacy mode and secure boot on off option but it did not work, i need Ubuntu plzz help, what to do??
Answer: You should install Ubuntu in another hard drive partition not in the same where Windows is installed which is usually C drive. Do one thing. Format some other partition of may be D or E (if you have these). Format them completely. And when you install Ubuntu select that formatted drive. It should install smoothly and should be able to detect. If you still face problems then edit your question telling what exactly you have done in installing process. Installing Ubuntu is really easy than other flavours of Linux.
Answer: Hope this helps: How to install Ubuntu 14.04 alongside Windows 8.1


Filipina under working visa in Oman wishes to travel to India

Question: I am a Filipina under working visa in Oman. Can I travel to India and if yes does Filipino citizens have visa on arrival to India and if no what is the requirement?
Answer: The Philippines is listed as one of the countries who passport holders are eligible for an e-visa.
Assuming you intent to travel to India for tourism purposes, you you apply on the official website:

https://indianvisaonline.gov.in/evisa/tvoa.html

Please note, this isn't a visa on arrival, you have to submit your details online before departure.
Answer: You can apply for an eVisa providing you meet the eligibility criteria https://indianvisaonline.gov.in/evisa/tvoa.html


jQuery UI Draggable/Sortable - Get reference to new item

Question: I am using the jQuery UI Draggable/Sortable demo (http://jqueryui.com/demos/draggable/#sortable) for the basis of my project. I need to get a reference to the
 that gets cloned into the sortable when the sortable receives it. I tried the sortable's receive event, but that only gives a reference to the original draggable
, and not its clone.
Comment: yes i'm using the clone helper...trying to get a reference to the newly cloned
Comment: had this exact problem
Answer: In the demo you reference, there's actually a bug; after you drag an item down it inserts a cloned li with an id which is a duplicate of its brother's into the DOM, so beware (a bug was filed about this but there's no activity around it).
I did a few things to achieve this:

To get around the limitation of the demo that I described above, instead apply a class to the draggable items that will be linked to the sortable:

Drag me down

Make items with that class draggable, instead of selecting an element by id:
 $(".new-item").draggable({
     connectToSortable: "#sortable",
     helper: "clone",
     revert: "invalid"
 });

Tap into the stop event of the sortable, and perform some simple logic about the item that was dropped, leveraging the fact that an item with the class new-item could only have been dropped (and isn't simply an existing item in the sortable):
$("#sortable").sortable({
    revert: true,
    stop: function(event, ui) {
        if (ui.item.hasClass("new-item")) {
            // This is a new item
            ui.item.removeClass("new-item");
            ui.item.html("HI");
        }
    }
});

Note that you could use the data-* attribute instead of adding a helper class.
Here's a working example: http://jsfiddle.net/andrewwhitaker/twFCu/
Hope that helps.
Comment: Thank you for that, I was having a bit of trouble with this situation as well.
Comment: I was trying everything with the stop - on .draggable and getting nowhere - saved me a bunch of time, thanks
Comment: @reabow: Glad to help!
Answer: And if you want another very rough-and-ready way to get that item just to remove it or something, just reference it in the drop as
var _clone = $(".ui-draggable-dragging");

Of course that class is removed just AFTER the drop, so that reference gets lost and you can't do anything that isn't immediate.
The answer above is more robust but if you're in a crazy rush...
Answer: If you don't fear accessing the Sortable's internal state, you can do the following:
$('#sortable').sortable({
  receive: function() {
    // Sortable.currentItem refers to the item just added.
    // jQuery UI < 1.10 uses "sortable" as its data key,
    // jQuery UI >= 1.10 defines an "instance" method to get the current instance.
    var $item =
      (
        $('#sortable').data('sortable') || // jQuery UI < 1.10
        $('#sortable').sortable('instance') // jQuery UI >= 1.10
      ).currentItem;
  }
);

Fiddle: http://jsfiddle.net/t33bt/12/
Keep in mind though, that this might not work in a future jQuery UI version anymore because it doesn't use the official API. But nonetheless it works even in jQuery UI 1.11 (current version as of time of this writing).


How to send custom header (metadata) with Python gRPC?

Question: I want to know how to send custom header (or metadata) using Python gRPC. I looked into documents and I couldn't find anything.
Answer: I figured out reading the code. You can send a metadata param to the function call, where metadata is a tuple of 2-tuples:
metadata = (('md-key', 'some value'),
            ('some-md-key', 'another value'))
response = stub.YourFunctionCall(request=request, metadata=metadata)

Comment: More recently this needs to be a list of 2-tuples:

metadata = [('k1', 'v1'), ('k2', 'v2')]
Comment: If you have only *one* header, like for example, `metadata = (('md-key', 'some value'))` this code will fail. You have to add them as array as follows: `metadata = [('md-key', 'some value')]`
Comment: It's not so much that the request fails but that Python won't interpret that as a 2-tuple. You can also use `metadata = (('md-key', 'some value'), )`
Answer: Pls read the example in github.
For example:
        response, call = stub.SayHello.with_call(
            helloworld_pb2.HelloRequest(name='you'),
            metadata=(
                ('initial-metadata-1', 'The value should be str'),
                ('binary-metadata-bin',
                 b'With -bin surffix, the value can be bytes'),
                ('accesstoken', 'gRPC Python is great'),
            ))

Or if you want to define a interceptor
        metadata = []
        if client_call_details.metadata is not None:
            metadata = list(client_call_details.metadata)
        metadata.append((
            header,
            value,
        ))
        client_call_details = _ClientCallDetails(
            client_call_details.method, client_call_details.timeout, metadata,
            client_call_details.credentials)

Something important is that the metadata's key can not has upper case character (It has troubled me for a long time).
Comment: Metadata keys must be lowercase chars.  That's just horrible and frustrating.  `ValueError: metadata was invalid`
Comment: Direct link to the example: https://github.com/grpc/grpc/blob/master/examples/python/metadata/metadata_client.py
Answer: If you metadata has one key/value you can only use list(eg: [(key, value)]) ,If you metadata has Mult k/v you should use list(eg: [(key1, value1), (key2,value2)]) or tuple(eg: ((key1, value1), (key2,value2))
Comment: https://stackoverflow.com/editing-help
Comment: please consider editing your answer to include proper formatting, and to add references and/or links to supporting materials.


How to find about structure of bitmap and JPEG files?

Question: I'm trying to write a very simple image processing program for fun and practice. I was using System.Drawing. ... .Bitmap class to handle images and edit their data. but now I want to write my own class of Bitmap object implementation and want to know how bmp files (and other common bitmap formats) and their meta-data (indexing, color system & etc) are stored in files, and how to read and write them directly?
Answer: http://www.wotsit.org/ is a good place for file format documents
BMP is pretty simple and a good place to start.  The next one I'd do is TIFF and then you can pick the compressions that seem easiest to do.  The main issue with jumping to JPEG is understanding how to do the compression.
There are open-source libraries for the main formats that you can look at for guidance (libpng, libjpeg, libtiff).
Answer: The BMP file format is a simple one, you'll have little trouble creating your own.  But you'll hit the wall on a compressed format like PNG, TIFF or JPEG.  Nobody writes an encoder for these, there are well established reference implementations for them.  They are written in C, the universal language for libraries like these.
Google "libpng", "libtiff" and "libjpeg" to find them.  You'll need a C compiler to turn them in a DLL that you can P/Invoke.
Answer: You're looking for the Wikipedia aricles on the BMP and JPEG file formats, and the File and FileStream classes in .Net.
Answer: Wikipedia is your friend I think;

Bitmap - File format
More formats


Is it worth uninstalling apps with background processes?

Question: I visited Apps -> Running and uninstalled the apps there that I don't use. I then installed OS Monitor and realised that a huge amount of apps run in the background with 0% CPU Usage (I have 36 processes). Many of them I don't actually use very regularly. Would it improve my system performance to uninstall them or does 0% CPU usage mean that it wouldn't? Is there a way to stop these processes automatically starting up?
Comment: Why would you want to stop them if they're not using CPU?
Answer: When you finish using an app, Android doesn't kill the process right away. It simply stops it running, and leaves it alive as a cached background process. This way, when it needs to start the same app again, it's already present in memory, so Android doesn't have to spend time and energy on loading the app from storage again. The effect is to make apps start faster and reduce battery use. Android will only kill these cached background processes when necessary to free up memory for apps that are actually running. There's no time limit: even if it turns out you don't use the app again for another week, it still might be present in memory.
If you want to uninstall all apps with cached background processes, you'd have to uninstall every app on the device. Every app can be cached this way, even if it never does anything in the background.


What's the relationship between X and VNC?

Question: I thought they were completely different. But I just noticed, running Screen Sharing on MacOS that the window titlebar says "pitosalas's X desktop". I thought Screen Sharing on MacOS is a VNC client and so, I am confused.
Answer: Not sure what your exact setup on your Mac and possible the other machine is, but:
On Linux, you run xvnc or a similar program, which is both an X server (for X clients, i.e. your desktop apps, to connect to) and a VNC server (for other VNC clients which want to see your screen to connect to). What it shares is a virtual framebuffer.
On a Mac, there's XQuartz, which is also an X server for Mac applications which need to connect one. It's possible that this includes something similar to xvnc when screen sharing is active.
So whatever your concrete situation is, it's very likely there's an X server involved somewhere, which shares its framebuffer via VNC.
And yes, the VNC protocol and X servers are indeed completely different.
Comment: Could you comment in general whether a graphic-intensive application would perform better on X or on VNC?
Comment: It's pretty difficult to comment on that in general. The wire protocol of X uses graphics primitives, but modern X applications often use OpenGL anyway, which doesn't work with the basic X protocol. VNC on the other hand transfers changed framebuffer parts. "Graphics intensive" normally means OpenGL, so I'd consider something like [virtualgl](https://virtualgl.org/About/Introduction), which is neither X nor VNC.


The numbers of something or the number of something

Question: I am ielts student.
When I  use graphs to show  information over time.
I don't know how to express correctly.
For example,
1.The graph shows the number of books read by men and women at Burnaby Public.
2.The graph shows waste recycling rates in the U.S. from 1960 to 2011.
I wonder what time I need to use numbers instead of number or rate instead of rates.
Answer: Well, "the number" alone is strictly singular in itself. And when "of" is added, the phrase, "the number of", will call for a plural noun (i.e. trees)
Personally, I have never seen the statement "the numbers of..." when describing or assessing a graph or a data set. Commonly, you use "the number of" because you are specifically describing or referring to a one particular thing in the graph as in:

"the number of students who wish to study abroad next year"

Likewise for rate.

"the rate of change in the annual global temperature"

Why would "number" and "rate" be plural anyways when you will be referring to one concept or set of things observable from a graph?
Comment: Thanks for your help. But like the following example in ielts tasks. It shows ^ rates ^in its task question. So I don't know what is the rule.           https://www.testbig.com/ielts-writing-task-i-essays/graph-below-shows-waste-recycling-rates-us-1960-2011summarise
Answer:
I wonder what time I need to use numbers instead of number or rate instead of rates.

Are you talking about one number or rate, or more than one?

The graph shows the number of books read by men and women at Burnaby Public.

I don't think anyone would say number is wrong here, but it's arguably a little bit ambiguous. Does the number of books read by men and women mean the sum of books ready by men and those read by women, or does it mean that the graph shows books read by men and those read by women separately? Presumably, the graph is displayed somewhere nearby, so any confusion can be resolved by just looking at the graph, but if books read by women and those read by men are displayed separately, then it's a bit more precise to say the numbers of books read by men and women.

The graph shows waste recycling rates in the U.S. from 1960 to 2011.

Again, are you talking about one rate or several? If there's just one line on the graph showing the rate of recycling for the entire US over time, then I'd use rate. On the other hand, if the graph has multiple data series (e.g. one for each state, or one for each kind of recyclable material), then I'd use rates.


Best practice of use member of Primitive types

Question: How I should write: long.MaxValue or Int64.MaxValue?
Are there standard from Microsoft?
Answer: long.MaxValue

because you are coding in c#.
Int64.MaxValue is a .NET type.
Answer: Default StyleCop settings will tell you to use long.MaxValue.
Answer: This is subjective, but I find Int64.MaxValue easier to read, because the capital letter makes it stand out clearly as a static member of a type called Int64, rather than an instance member of a local variable called long (not that there could ever be a local variable called long of course).  But I don't think anyone reading your code is going to be confused whichever way you do it!
Comment: Indeed: for example, I'd always declare a variable as long rather than Int64.  But for some reason accessing *members* via the lower-case name doesn't come as naturally to me.  Inconsistent?  Yup, I guess so.  **grin**
Answer: I would match it to the type of the variable it is being assigned to.  If you are using long in the variable declaration, use long.MaxValue.
Answer: Jeffrey Richter writes:
I prefer to use the FCL type names and completely avoid the primitive type names.
...
In C#, long maps to System.Int64, but in a different programming language, long could map to an Int16 or Int32. In fact, C++/CLI does in fact treat long as an Int32. Someone reading source code in one language could easily misinterpret the code's intention if he or she were used to programming in a different programming language. In fact, most languages won't even treat long as a keyword and won't compile code that uses it.
Answer: I prefer the Int64.MaxValue.
Also think about this case:
float  val = Single.Parse(..);
Single val = Single.Parse(..);

I do believe that the 2nd (FCL type name) is more clear than the 1st (built-in type name).


How to move faster in Terraria?

Question: Is it possible move faster in Terraria? I mean, when you are very deep in the underground is it possible returning to the surface faster, using elevator, for example, or other things? Or when you need to move from the left edge of the world to the right edge?
Comment: There is [this useful wiki page](http://terraria.gamepedia.com/Movement_speed#Horizontal_movement) about items that modify your horizontal movement speed.
Answer: There's rocket boots you can get for going up faster.
Each Anklet of the Wind you equip adds 10% to movement speed. (But as of 1.06, they no longer stack, though you should be able to have one Anklet and one Aglet)
Hermes Boots increase movement speed by 100%, but take a while to accelerate.
Comment: In 1.1, you can now combine hermes boots and rocket boots into spectre boots, the new boots and some armor sets increase movement speed, there are enchantments that increase movements speed, and you can make wings for flight and slowfall. combine all of these methods and you should be going pretty fast
Comment: And in 1.3+ there are Lightning boots, which are even faster yet!
Answer: There are multiple ways to go fast in Terraria as for the 22.214.171.124 version.
I'll list all the non-accessories ways to transport yourself, many of them imply blocks or wire placement.
Now, in 1.3, if you have a stopwatch in your inventory, you can know precisely your speed at any given moment.
Example : Your normal walking speed without any bonus is 15 mph.
Pre Hardmode Tier
Sunflowers
Gives you the 'happy' buff, which always works as long as at least one sunflower is in your proximity. Percentage seems to be 20% or 25%.
Swiftness potion & food
+45% speed
the potion add 25% to your speed, and the food (which gives you the 'well fed' buff) will add 20%.
Note : These speed buffs only affect your max speed without any speed boots on.
If you have them, these buffs will only affect your acceleration and not increase the max speed.
Ropes
Very cheap yet very useful. With them, you can travel long vertical distances without caring about fall damage, you can also travel horizontally, but it's very slow.

upward speed : 41 mph
downward speed : 51 mph (the exact same as regular falling speed)

Speed Hookshot
If you are pretty familiar with the hookshot, you can move around quite quickly
Horizontal : Hook the ground to the far left/right and jump before it has fully retracted to keep the speed. Flat ground, and up-slopes are recommended for this use.
Vertical - upwards : set some platforms, on the way up, and when you hook them, jump just before reaching them to keep the vertical speed and re-use immediately the hookshot to reach the next platform.
However, if you have ropes, you better use them on vertical pathways.

normal hookshot : 55 mph
bat hookshot : 81 mph
its speed can be overwhelming sometimes.

Rails & Minecarts
you can go horizontally or diagonally with a very solid speed. All you need is some iron and wood.
1 wood + 1 iron bar (or 1 lead bar) = 50 pieces of track.
You can make the minecart jump with a slope in order to spare some tracks blocks, make sure your speed is sufficient and your track planning is correct, or you might suffer fall damage inside the cart.
You can even change direction thanks to bumper tracks (hammer the end of a track twice)
Now, with the 3 different carts, universal track jumping is not recommended, as the max speed is different from the 3 carts (but it can be used to guide different types of minecarts into different tracks)
Minecart speeds :

Default cart : 51 mph
Iron cart : 66 mph (same as v1.2.4)
Mechanical cart (from expert mode) : 102 mph

If the mecanist NPC is here, buy her 4 boosters (for 2 gold coins) and place them on the track, you can now get from 0 to maximum speed with the minecart.
Magic mirror/Ice mirror/Cell phone/Recall potion
It is cheap and teleports intantaneously the player who uses it to his spawn, but it only works in one way.
Hardmode Tier
The steampunker will be your best friend for these ones
Asphalt
Buy her a Blend-O-Matic to create a road where you can run fast on it, even without speed boots.
2 stone blocks + 1 gel = 1 asphalt block
In fact, asphalt multiplies your normal max speed, so if you're using speed buufs (sunflowers, potions, food), this max speed will be affected !

Without anything : 53 mph
With sunflowers : 64 mph
With +45% speed buffs mentionned earlier : 77 mph
45% speed + sunflowers : 85 mph

After several testings, it seems that 85 mph is the maximum cap, and you may lose contact with the ground is you use slope with a speed superior to 80 mph.
Frozen slime block
Buy her a Solidifier to solidify 1 gel in a slime block and combine it with an ice block.
There is no friction on those blocks, once you have enough speed, you can let go, but the goal here is to get the best speed, and you can do it without having to run :

Use the hookshot's pulling speed : you can do it easily with hooking the middle of a door and then open the door after stabilizing.
Remember that the bat hook has the best pulling speed from all the hooks.
speed reachable : ~80 mph
Use a cart. Being on frozen slime blocks in a cart won't keep your speed, you must exit the cart as soon as you are on slime blocks (you can exit it by going left/right when not on rails)
Also, if you go on the wrong direction when on the slime blocks, you'll lose all your speed.
speed reachable : ~100 mph (with the cart from expert mode)

Teleporter
The fastest way to travel in the game, and probably the most expensive.
You need 2 teleporters on both sides, and connect them to wires and any kind of wire input to use them.
Mounts
Some mounts are very fast, like the unicorn one.
Using them will spare you the need of building anything, while still being faster than any wings/hoverboard.
the unicorn goes at 62 mph. In comparaison, the hoverboard's horizontal setting can only go to 52 mph horizontally.
Portal Gun
This little boy is dropped by the final boss at 100% chance, and when you hold this item in your hand, you can acquire momentum by falling at extreme speed, which can be converted into vertical, or horizontal speed.
However, you can't use the portal gun to teleport yourself to any far destination, A portal despawns when the player is approximately 1600 feet away (800 blocks)

Vertical down : just fall with the gun in hand, you'll continuously accelerate until you reach 179 mph !!
Vertical up : place a falling pit where you can reach 179 mph, and place the two portals on a ground, within the distance restriction : you'll end up rising at blazing speed. If you mount a flying pet and fly up as soon as you crossed the portal, you can keep the speed until you're done.
Horizontal : falling pit, 179 mph, one portal on the ground, and one portal on the side of a wall next to frozen slime blocks. Warning : behavior with slopes might be flawed with this speed.

Game breaking Tier
HOIK glitch
It exploits the slopes mechanism for an optimal speed, and the cost is only basic, solid blocks !
You can use it at any moment in the game, but you can end up stuck in walls if you're not careful enough.
The maximum speed obtainable with this is :

2 blocks per frame (= 1/60 second), at horizontal speed.

which is 120 block per second.

3 blocks per frame, at vertical speed.

which makes an unbeatable 180 blocks per second.

For comparison, a 20 mph speed is approximately 16 blocs per second (measured with 131% of normal speed, no boots).
This would mean that a 179 mph speed (see portal gun, horizontal set-up) would reach around 143 blocks every second, which is faster, but it would require the player to defeat the final boss while the HOIK glitch can be done in very early game.
Comment: This post is five years old and edited last year, but as of 1.4, I am able to reach speeds of 104mph using Terraspark Boots, Swiftness Potion, and Asphalt.  I haven't done any further testing yet, but ran across this post and the max speed is incorrect.
Answer: There is also a Magic Mirror which will teleport you from where you are to your set spawn point.
Nothing that works the other way round as far as I know though.
Answer: As far as getting down to the lower levels as fast as possible, a straight shaft works great.  Just dig a 2-square wide shaft straight down as deep as you'd like.
You'll have to account for fall damage however.  Either find a Lucky Horseshoe (no damage on fall), Cloud in a Bottle (jump just before you land), or make a Grappling Hook (grab the wall just before you land).  EDIT:  As Acorn mentioned in a comment, placing cob webs at the bottom of the shaft should to the trick as well.
EDIT:  Another method I've found that works great outside is using the grappling hook on the ground some distance ahead of you.  As soon as it grips you get a burst of acceleration.  If you click again in the air before the grappling hook fully retracts you can ride out the increased speed for a while.  This works best on flat or slightly down-sloped ground; not so great on an inclined slope.
Comment: Couldn't you just put cobwebs at the bottom of the shaft?
Comment: You can also put water at the bottom of the shaft.  It seems to slow you down and prevent fall damage.
Comment: @Acorn: Good thought.  Probably much simpler than anything other than the Lucky Horseshoe.
Comment: Another cool grappling hook trick is to grapple to a closed door, and open the door while grappled to it. You get a small burst of speed.
Answer: In version 1.2 was added Lightning_Boots as upgrade of Spectre_Boots and also Asphalt_Block. On it you have greatly increased running speed.
Great for underground tunnel and skybridges.
Answer: I found that in the recent mobile update there is a glitch that when you go on a wood platform hammered to the second or third form (looks like a stair) and place them on top of each other you glitch through them and you break the maximum speed. I reached the highest possible point of the world from the lowest possible point in the world in under 20 seconds. It's faster than anything else going upwards! (only works vertically/upwards).
Comment: Welcome to Arqade! While this is a great answer already, adding a picture or a video will make this a perfect answer.
Answer: @jos already mentioned the magic mirror, but Saving and reloading also puts you back at your spawn point. This serves as an easy alternative for the early game (although it requires more patience).
Comment: It is a bit boring but useful early game. Another way is suicide but in this case you loose part of coins.
Answer: Another alternative is to reforge your accessories.  The Quick prefix grants up to a 4% increased movement speed, and with a maximum of 5 accessories, this can easily be a 20% speed boost.
Answer: Use a lightning boots wings anklet of the wind aglet and the bundle of balloons this helps a lot and also layering or adding your whole world on the ground with asphalt blocks will make you run at least 20 times faster than usual :-))
Answer: I found that to get across the world quickly, you can use: Quick Fishron Wings, Quick Anklet of the Wind, Quick Frostspark Boots, Quick Aglet, Quick {Accessory of your choice}.

How to move faster in Terraria?


Read ECONNRESET comes up when amqp restarts

Question: Currently I create one Sender class client which can send messages to amqp, and also reconnect to amqp. When messages need to be sent to amqp, if the connection is failed, Sender can try to reconnect to amqp three time. Here are the codes https://gist.github.com/richzw/e39237aa1fe31c15a587
Then I test it with following codes,
var Sender = require('./sender.js');
var amqpAddress = 'amqp://localhost';
var sender = new Sender( amqpAddress, 2000, 3, sendMessageCallback );

function sendMessageCallback( ) {
    console.error('Message can NOT be sent due to MessageBus error');
}

// send message every 5 seconds
var CronJob = require('cron').CronJob;
var send_message_job = new CronJob({
    cronTime: '*/5 * * * * *',
    onTick: function(){
         sender.deliverMessage( key, msg );
    },
    start: true,
});

send_message_job.start();

Then I try to stop and start amqp service randomly. I find when I restart amqp service at the first time, the sender can continue to send messages normally. However, when I try to stop the service at the second time, the following error comes up, and the program is crashed.
Error: read ECONNRESET at errnoException (net.js:905:11) at TCP.onread (net.js:559:19)
I try to test it several times with the same scenario, the above error always comes up at the second time. Why? Can anyone help me figure out how to handle it?
Answer: Actually, the exception ECONNRESET can be caught in the error event.
Sender.prototype.handleDisconnections_ = function() {
    return this.con_.on('error', (function( that ) {
        return function( err ) {
            //if ( err.code === 'ECONNRESET' ) {
                //return when.reject( err );
            //}

            return that;//.retryConnect_( that.attempts_, that.retryDelay_ , err );
        };
    })(this));
};


EJB stateless session beans and stateful session bean

Question: I have gone through various books on stateful and stateless session bean and how they work. I want to know the real usage of these ejbs and advantages over using plain java classes. Basically when do you go for stateless ejbs and when do you go for stateful ejbs. I want a real time application.
Comment: you mean differences between stateless and stateful ejb?
Comment: @shamsi not exactly but no theory answer.
Comment: possible duplicate of [Stateless and Stateful Enterprise Java Beans](http://stackoverflow.com/questions/2351220/stateless-and-stateful-enterprise-java-beans)
Answer: the usage of these type of ejbs are usually in service layer as service classes.
EJB3 stateless and stateful bean are actually POJO (with some annotations) and they don't have any big difference with normal classes.
but in term of usage, they have some abilities that you can't find in normal classes like:

they can be called remotely (e.g. RMI protocol).
they can use application server context resources like DB Connection and Transactions.

stateless or stateful:
- if a task or process can be done in a single step (by a single method call) stateless is the right option
    like a authentication process
- if a task needs a series of method calls (more than one) and you need to keep previous results to use them in next call, then go for stateful.
like a shipping process (select items, add/remove and then do the transaction)
http session or stateful?
ejbs can be served in application server and they may have different type of clients like a normal swing application or ..., so you can't relay on http session in these cases.
if your appserver and  webserver are different (distributed) its not good idea keep data in http session and pass/getback it to/from app server (network overhead).
Comment: to maintain state we can use http session
Comment: @Suresh: yeah, that's true also, its up to you to choose the right place to keep the state.
Comment: when do you go for http session vs stateful also stateless
Comment: @Suresh look at last part of my answer
Answer:
Stateless session bean are lightweight: they do not store information about a specific user. They are usually used in a static way. For example a client ask for a product information will communicate with a stateless session bean. ("You want the price of product 'YXZ', here you go!")
Stateful session bean however remember's the client information. They contains data about the user actions. For example, let's say a user go through a shopping cart. The steps will be stored in a stateful session bean (for example, user it at the payment step).

You really need both type of session bean in any website. Unless you web site is so basic that anything can be done with stateless session bean (a read-only web site really).
Any web site that track a user through cookies, will need a stateful session bean. Be aware however that you can decide to put very little session information in a session bean and store that information in a database. But you still need some session management.
Comment: we can use httpsession to maintain client state.
Comment: i have read that everywhere. but i want to know when  you will prefer , your experience in using them.
Answer: Developers prefer to maintain state in web layer in modern enterprise applications. I have never seen a real world web application using Stateful Session Bean. It is a scalability issue also.
Answer: An example is a shopping cart stateful session bean that tracks a client's product choices and can execute a sale when requested.


How to find a normal to an hypersurface?

Question: I have to apply the Israel junction conditions in a region in which a hypersurface with O(3) symmetry separates two spacetime with Schwarzschild metric (with masses $M_+$, the exterior one, and $M_-$, the interior one). The hypersurface is:
$$\Sigma_{\pm}=\{(t_{\pm}, r_{\pm}, \theta_{\pm}, \phi_{\pm})| F_{\pm}(t_{\pm},r_{\pm})=r_{\pm}-R(\tau(t_{\pm}))=0\}$$
where $\tau$ is the proper time on $\Sigma$.
Now the question: the result given by the article for the normal unit vector is
$$n_{\pm\mu}=\frac{\partial_{\mu}F_{\pm}}{\sqrt{|g^{(\pm)\mu\nu}\partial_{\mu}F_{\pm}\partial_{\nu}F_{\pm}|}}=(-\dot{R},\dot{t_{\pm}},0,0) $$
How can I find that $n_{\pm\mu}=(-\dot{R},\dot{t_{\pm}},0,0)$?
Comment: The normal is the gradient with the denominator to normalize it...
Comment: Ok, but I need to understand the calculation to get the result $n_{\pm\mu}=(-\dot{R},\dot{t_{\pm}},0,0) $ in detail
Answer: If your embedding of the hypersurface is given by a level-set function $F$, the normal vector to that hypersurface is given by the exterior derivative of that level-set function, ie
\begin{equation}
n = dF
\end{equation}
Any vector tangent to your surface will be obtained by a path entirely within $\Sigma$. For a path $\gamma \in \Sigma$, the tangent vector to that path is $\dot{\gamma}$, but we also have that $F(\gamma(\tau)) = 0$ for every $\tau$, therefore
\begin{equation}
\dot{F}(\gamma(\tau)) = \dot{\gamma}(\tau) dF(\gamma(\tau)) = 0
\end{equation}
This is the $1$-form $dF$ and the vector $\dot{\gamma}$. If we put this in coordinate form, this is simply (with $u = \dot{\gamma}$ our tangent vector)
\begin{equation}
g^{\mu\nu} u_\mu \partial_\mu F(\gamma(\tau)) = 0
\end{equation}
In other words, this vector is indeed always orthogonal to any tangent vector.
To make it a unit vector, we simply divide it by its norm, as usual :
\begin{equation}
n = \frac{dF}{\|dF\|}
\end{equation}
Or again, in coordinates,
\begin{equation}
n_\mu = \frac{\partial_\mu F}{\sqrt{g^{\mu\nu} \partial_\mu F \partial_\mu F}}
\end{equation}
Comment: Yes, but how can I find the result $n_{\pm \mu}=(-\dot{R}, \dot{t_{\pm}},0,0)$?
Comment: Is $R$ a specific quantity here?
Comment: It's the trajectory of the hypersurface (look at the definition I gave)
Comment: So can you help me?


Mobile SDK, XCode 6 XIB and Storyboards

Question: When you create a new project in XCode 6.* using the  SF Mobile SDK, there is no option to use Storyboards, XCode 's version of XIB files.
I want to work with Storyboards but not with XIB files.
is there a way around this deadlock ?
Thanks
Comment: That's just a project template to populate a new app with the mobile SDK. You can add storyboards to your app at any time after creating the project. Also it is not accurate to say "Storyboards, Xcode's version of XIB files". They are two separate things, both part of Xcode.
Answer: In addition to Jonathan's comment above, you can look at this sample project which hooks up an older version of the Mobile SDK to Storyboards.
The bottom line though - the mobile SDK provides you a template code structure to work off and you can remove the XIB dependencies and introduce the storyboard. To know more about that, read here.

Mobile SDK, XCode 6 XIB and Storyboards


Display datetime in user's timezone

Question: How do I get datetimes like publication time to be displayed in a user's given timezone? I haven't been able to find a plugin that works.
Answer: You could use a service like Google Timezone you could get the users lat/lng data using geolocation then store that in a transient agains the IP address. Don't rely on the IP as users on a satellite connection like me can have the location pinged as thousands of km away.

Display datetime in user's timezone


Override nodereference_autocomplete functionality

Question: I would like to edit the functionality contained in nodereference_autocomplete() so that it will only return a subset of all nodes. What would be the best way to override this default functionality?
Comment: Since we're having a huge discussion below about what you're intentions are, please clarify what you are trying to do.
Answer: This isn't exactly the same question, but I think this answer is just as valid.

If I understand you right, you can use a View as the source for the nodereference widget, and give it appropriate filters to only show nodes of a certain type authored by the current user. Or have I got the wrong end of the stick?!
Answer: An autocomplete function is, in Drupal 6, registered as menu callback. For example, this is the code used by user.module to register the function that autocompletes the usernames.
<code>function user_menu() {
  $items['user/autocomplete'] = array(
    'title' => 'User autocomplete',
    'page callback' => 'user_autocomplete',
    'access callback' => 'user_access',
    'access arguments' => array('access user profiles'),
    'type' => MENU_CALLBACK,
    'file' => 'user.pages.inc',
  );

  // …
}
</code>
If you want to alter the autocomplete function defined from a module, you just implement hook_menu_alter() to alter the menu callback definition that uses the autocomplete function as menu callback.


From where is a DES key generated?

Question: GOing over a lecture on DES
I got most of it except WHERE DOES DES KEY COME FROM?
Does an authority give you the key or what?
Simple language please
Comment: It's not easy to explain without either getting bogged down in theory or omitting dangerously many criteria, but the short and inaccurate version is that you generate a random number of the appropriate order of magnitude. I'm hoping for someone with more crypto knowledge than me writing a proper (read: actually reliable and accurate) answer.
Comment: Which other (somewhat modern) ciphers do you know? Where does the key for *those* some from?
Comment: @delnan and does it use a 48-bit key or a 56-bit key??? The professor goes on to say  that there are 48-bit round keys.
Comment: I dont know a lot, this is my first
Comment: Ok, so from the 56-bit key a sub-key of 48-bits is generated right?
Comment: It is a shared public key, right?
Answer: The simple answer is that the key is and must be picked at random. You grab a bunch of bits from wherever, and hope that they are random enough to resist attacks on the key generation algorithm. (It's worth noting that many real-world attacks on cryptographic software have focused on the particulars of the key generation, rather than the cryptographic algorithm itself.) There is no central authority involved; in fact, having such a central authority would largely defeat the whole purpose of encryption (which is to transform a large secret - the plaintext - into a small secret - the encryption, or more accurately the decryption, key).
DES is a symmetric encryption algorithm, which means that to decrypt the data you must have the same key that was used to encrypt it. That leads to key distribution problems, but it's much easier to securely distribute and store a small key than a large plaintext, and keys can be distributed ahead of time provided that you can store them securely.
Asymmetric, or public/private key, algorithms solve the key distribution problem by using different keys for encryption and decryption - the mathematics that makes that possible is rather involved and varies between algorithms, but the general approach is that the encryption and decryption keys have nontrivial mathematical relationships - but have other issues of their own. Security is always a trade-off between different considerations. The most well-known such algorithm is probably RSA.
The only provably secure encryption algorithm is a properly used OTP (one-time pad), but that requires a properly random key the length of the message to be encrypted and the key must never be re-used, so is not very useful in practice for anything beyond short messages between parties who already have some sort of secure communications channel that just isn't "good enough" for sending the messages involved. For example, a trusted courier might be used to distribute key material; the courier is slow, whereas the OTP-encrypted message can be transmitted over a satellite link or Internet e-mail with no risk of being understood if it is intercepted, as long as the key can be trusted to be secure.
Specific usage scenarios might involve a central key distribution facility of some kind even for symmetric-key encryption algorithms, but I really think that those are truly the exception in that case.
Also, like @delnan touched at, what other encryption algorithms are you familiar with? It's worth keeping in mind that DES is trivially easy to break these days, even with consumer-class hardware and a naïve brute-force attack on the key.
Answer: The cryptographic key is just a series of bits.
At the simplest level, the key is generated from a hashed version of a password.  The key (ie the specific series of bits) must be re-creatable otherwise you will not be able to decrypt the encrypted object.
Technically, you could just use the password without hashing for the key, but it makes me shudder to think of doing it that way.  NOT secure.
DES has some funkiness with its key length being either 56 bits or 48 bits.  I don't know of any other ciphers with a similar key length characteristic, so I would ignore that aspect.  The 48 bit key is not just a subset of a 56 bit key, they're different.
DES has nothing to do with public / private key pairs.  DES is a symmetric encryption algorithm, whereas public / private keys indicates an asymmetric algorithm.

From where is a DES key generated?