Monad join function

Question: While monads are represented in Haskell using the bind and return functions, they can also have another representation using the join function, such as discussed here. I know the type of this function is M(M(X))->M(X), but what does this actually do?
Answer: Actually, in a way, join is where all the magic really happens--(>>=) is used mostly for convenience.
All Functor-based type classes describe additional structure using some type. With Functor this extra structure is often thought of as a "container", while with Monad it tends to be thought of as "side effects", but those are just (occasionally misleading) shorthands--it's the same thing either way and not really anything special[0].
The distinctive feature of Monad compared to other Functors is that it can embed control flow into the extra structure. The reason it can do this is that, unlike fmap which applies a single flat function over the entire structure, (>>=) inspects individual elements and builds new structure from that.
With a plain Functor, building new structure from each piece of the original structure would instead nest the Functor, with each layer representing a point of control flow. This obviously limits the utility, as the result is messy and has a type that reflects the structure of flow control used.
Monadic "side effects" are structures that have a few additional properties[1]:

Two side effects can be grouped into one (e.g., "do X" and "do Y" become "do X, then Y"), and the order of grouping doesn't matter so long as the order of the effects is maintained.
A "do nothing" side effect exists (e.g., "do X" and "do nothing" grouped is the same as just "do X")

The join function is nothing more than that grouping operation: A nested monad type like m (m a) describes two side effects and the order they occur in, and join groups them together into a single side effect.
So, as far as monadic side effects are concerned, the bind operation is a shorthand for "take a value with associated side effects and a function that introduces new side effects, then apply the function to the value while combining the side effects for each".
[0]: Except IO. IO is very special.
[1]: If you compare these properties to the rules for an instance of Monoid you'll see close parallels between the two--this is not a coincidence, and is in fact what that "just a monoid in the category of endofunctors, what's the problem?" line is referring to.
Comment: Regarding footnote [0]: why is the `IO` side effect special/different from any other side effect?
Comment: Put far more abstractly, we can say that join is the witness to the fact that a monad is closed under endo-functor composition (adding a new layer of m, as in (m (m a)) as opposed to merely (m a).  These two are the same "kind" of thing (a monad), and join makes the relationship between them concrete.
Comment: @Jasha IIUC the IO monad is used as a bridge between the impure world *outside* and the pure world *inside*. It's actually the only non-pure part of Haskell. It's needed because the environment in which a program runs is not pure, e.g. reading a line from the console or getting the current time doesn't always return the same value. The `IO` monad is very likely handled specially be the compiler itself.
Answer: What join does has been adequately described by the other answers so far, I think. If you're looking for a more intuitive understanding...if you're wondering what join "means"...then unfortunately the answer is going to vary depending on the monad in question, specifically on what M(X) "means" and what M(M(X)) "means".
If M is the List monad, then M(M(X)) is a list of lists, and join means "flatten". If M is the Maybe monad, then an element of M(M(X)) could be "Just (Just x)", "Just Nothing", or "Nothing", and join means to collapse those structures in the logical way to "Just x", "Nothing", and "Nothing" respectively (similar to camccann's answer of join as combining side effects).
For more complicated monads, M(M(X)) becomes a very abstract thing and deciding what M(M(X)) and join "mean" becomes more complicated. In every case it's kinda like the List monad case, in that you're collapsing two layers of Monad abstraction into one layer, but the meaning is going to vary. For the State monad, camccann's answer of combining two side effects is bang on: join essentially means to combine two successive state transitions. The Continuation monad is especially brain-breaking, but mathematically join is actually rather neat here: M(X) corresponds to the "double dual space" of X, what mathematicians might write as X** (continuations themselves, i.e. maps from X->R where R is a set of final results, correspond to the single dual space X*), and join corresponds to an extremely natural map from X**** to X**. The fact that Continuation monads satisfy the monad laws corresponds to the mathematical fact that there's generally not much point to applying the dual space operator * more than twice.
But I digress.
Personally I try to resist the urge to apply a single analogy to all possible types of monads; monads are just too general a concept to be pigeonholed by a single descriptive analogy. What join means is going to vary depending on which analogy you're working with at any given time.
Answer: From the same page we recover this information join x = x >>= id, with knowledge of how the bind and id functions work you should be able to figure out what join does.
Comment: Or, somewhat more intuitively when thinking about join in terms of IO, `join x = do { a <- x; a }`
Comment: I finally understand this, but it wasn't easy at all
Answer: What it does, conceptually, can be determined just by looking at the type: It unwraps or flattens the outer monadic container/computation and returns the monadic value(s) produced therein.
How it actually does this is determined by the kind of Monad you are dealing with. For example, for the List monad, 'join' is equivalent to concat.
Answer: The bind operation maps: ma -> (a -> mb) -> mb. In ma and (the first) mb, we have two ms. To my intuition, understanding bind and monadic operations has come to lie, largely, in understanding that and how those two ms (instances of monadic context) will get combined. I like to think of the Writer monad as an example for understanding join. Writer can be used to log operations. ma has a log in it. (a -> mb) will produce another log on that first mb. The second mb combines both those logs.
(And a bad example to think of is the Maybe monad, because there Just + Just = Just and Nothing + anything = Nothing (or F#  Some and None) are so uninformative you overlook the fact that something important is going on. You can tend to think of Just as simply a single condition for proceeding and Nothing as simply a single flag to halt. Like signposts on the way, left behind as computation proceeds. (Which is a reasonable impressions since the final Just or Nothing appears to be created from scratch at the last step of the computation with nothing transferred into it from the previous ones.) When really you need to focus on the combinatorics of Justs and Nothings at every occasion. )
The issue crystallized for me in reading Miran Lipovaca's Learn You a Haskell For Great Good!, Chapter 12, the last section on Monad Laws. http://learnyouahaskell.com/a-fistful-of-monads#monad-laws, Associativity. This requirement is: "Doing (ma >>= f) >>= g is just like doing ma >>= (\x -> f x >>= g) [I use ma for m]." Well, on both sides the argument passes first to f then to g. So then what does he mean "It's not easy to see how those two are equal"?? It's not easy to see how they can be different!
The difference is in the associativity of the joinings of ms (contexts)--which the bindings do, along with mapping. Bind unwraps or goes around the m to get at the a which f is applied to--but that's not all. The first m (on ma) is held while f generates a second m (on mb). Then bind combines--joins--both ms. The key to bind is as much in the join as it is in the unwrap (map). And I think confusion over join is indicative of fixating on the unwrapping aspect of bind--getting the a out of ma in order to match the signature of f's argument--and overlooking the fact that the two ms (from ma and then mb) need to be reconciled. (Discarding the first m may be the appropriate way to handle it in some cases (Maybe)--but that's not true in general--as Writer illustrates.)
On the left, we bind ma to f first, then to g second. So the log will be like: ("before f" + "after f") + "after g". On the right, while the functions f and g are applied in the same  order, now we bind to g first. So the log will be like: "before f" + ("after f" + "after g"). The parens are not in the string(s), so the log is the same either way and the law is observed. (Whereas if the second log had come out as "after f" + "after g" + "before f"--then we would be in mathematical trouble!).
Recasting bind as fmap plus join for Writer, we get fmap f ma, where f:a -> mb, resulting in m(mb). Think of the first m on ma as "before f". The f gets applied to the a inside that first m and now a second m (or mb) arrives--inside the first m, where mapping f takes place. Think of the second m on mb as "after f". m(mb) = ("before f"("after f" b)). Now we use Join to collapse the two logs, the ms, making a new m. Writer uses a monoid and we concatenate. Other monads combine contexts in other ways--obeying the laws. Which is maybe the main part of understanding them.

Monad join function


How to avoid duplicate look up combination in many to many relationship?

Question: I am trying to learn many to many relationships for salesforce objects, I was able to implement it using a junction object where there are two master-detail relationships. But it causes a duplicate issue. For example, if I have three objects Student, Course, Course Student Relationship; using Couse Student Relationship object as junction object and Student and Course as master objects, I was able to assign multiple students in the same course and a student can take multiple courses. But it also allows me to assign the same student to the same course several times. What is the best way to solve it? I tried the validation rule but apparently, validation rule can only check if the lookup is populated or not. Is there any way to check and show error like validation rule without using trigger ?
Answer: You can create a Unique field (Unique_Course_Student_Relationship__c) on the junction object and populate it with a concatenation of StudentId and CourseId through a record-triggered flow on create.
CASESAFEID(StudentId) + CASESAFEID(CourseId)
This will ensure that there's never two junction records with the same Student and Course as the value of that field needs to be unique and an error message will display and let the user know they're creating a duplicate of an existing Id.
duplicate value found: Unique_Course_Student_Relationship__c duplicate values on record with id: 000000000
Answer: You can write a before trigger on the junction object and check if the combination already exists. If yes then use addError to throw an error.
Comment: Any other way apart from trigger?
Comment: I dont think so, because you will have to use a SOQL to get the record which already exists in the system.
Comment: Oh forgot a simple field solution. @Kris solution above will absolutely work fine.


Is there any information on whether (and/or when) Flixbus will come to the Midwest?

Question: Flixbus started operating on the West Coast last year, and a week ago it began operation on the East Coast. I was wondering if there is some information, official or not, on whether it is planning to enter the Midwest, and if so, then when? I wasn't able to find anything.
Comment: For those voting to close as "primarily opinion-based," this is asking if there is any information (i.e. not opinions) on the subject. If there is no public information (and I suspect there isn't, as a new operation may want some time to focus on their new routes before considering expansion), that's an answer.
Comment: Just curious, why are you interested in FlixBus' plans considering there are the dozens of intercity bus companies already operating in the midwest already?
Comment: @user77409 more competition helps for sure but they're definitely not always cheaper: e.g. for DC-NY July 4th we've got 6 cheaper bus companies on Busbud. (Disclosure: Busbud is my day job.)
Comment: And how would you prove a negative? Maybe one of their employees left a hint in a Facebook comment...
Comment: @chx by adding another answer? You could even make a CW answer listing relevant sources that haven't mentioned it (to the best of your searching).
Comment: @Carl Flixbus is much cheaper.
Answer: If there is a publicly announced plan for expansion I'd expect to find it in Flixbus's press releases, but there's nothing there. There's also nothing there about the services recently started on the East Coast, so it might not be the most reliable source.
If there are announcements on Facebook I couldn't find them amongst the noise. There's a reference on Twitter to the article referred to by the OP, but I didn't see anything else relevant. There might be references in the newsletter they say they send out, but I didn't find an archive to check.
So, nothing in the obvious official sources. Anything unofficial can be ignored by the company if it doesn't suit them.
Answer: FlixBus announced their Texas and New York expansions in this Press Release last December. Texas started very soon after it was announced, much sooner than New York which started almost half a year later. They can move quite fast to start routes when the right opportunity presents itself.
So far they haven't announced it publicly, nor do they have any jobs posted that would hint at such an expansion.


c# how to implement real-time image streaming

Question: I'm trying to transfer an image data from my machine to a remote machine in real-time like vpn so the image changes over time.
After trying udp, I realized that it's size limit makes that impossible.
Before I try tcp, I want to ask if there is a utility that I can use.
Someone told me that even that will not be real-time and I need to send the differences only.
Please give me some guidance.
Comment: This is called video streaming, and lots of working solutions exist for it - google for "C# video streaming"
Comment: Video streaming solutions such as LibVLC typically restrict users to using a files with specific format. I do not have a video. I'm just rendering images with opengl.
Answer: UDP size limit is not the issue or constraint here. TCP or UDP both will have a packet data size limit (configurable) and requires tweaks to receive and send buffer to elongate those limits to some extent.
In your case that changing image data is to be sent and used in real time so as @EugenRieck suggest go for video streaming options and you will be able to achieve what you intend to, based on the problem description provided.
Video are basically rendering of frames (images) per second.
Answer: As it says in wikipedia, "The practical limit for the data length which is imposed by the underlying IPv4 protocol is 65,507 bytes" for UDP;
so I tried TCP instead and it works perfectly fine.
The rendering speed over different countries is acceptable as realtime eventhough I have no compression algorithm.
Any ideas to improve it are relavant and welcome.


How does the spacetime curvature cause an object to attract towards the ground?

Question: An object moves at a constant speed relative to the local spacetime but due to the warped spacetime it appears as if accelerating. How does spacetime curvature exactly causes this effect?
Answer: The relevant part of the mathematics here goes by the name "geodesic deviation". This is the fact that lines which are as straight as possible, near any given event, do not behave the same way as straight lines in a Euclidean space. The worldlines of Earth and a nearby object such as a dropped apple are both geodesic, but the two geodesics approach one another more and more rapidly. A nice analogy is to draw geodesic lines on a sphere. If you start with two lines at the equator, both heading in the direction "north" and setting out parallel to one another, and then continuing each as straight as possible, then they will nevertheless meet at the north pole. Something similar happens to worldlines in spacetime, only now you have 4 dimensions and the temporal dimension is not quite like the spatial ones.


Automatically run a script when an object is transformed or a condition is met

Question: I am new to blender coding and I made a script to calculate a complex bone rotation. The script is intended  to run like a constraint in the sense that it will execute only when the "target" object is
transformed. As I am still learning blender API I would like to know which is the best way to implement this.
Answer: Driver
It should update if one of the variables changes:
Rotate N objects identically, but with unique variations
Consider using the driver interface even if you do something more elaborate, just in order to communicate the dependency in the depsgraph, as done here, where the solution was to add a driver using a particular variable (meaning not a variable in Python function, but a variable visible in the driver popup in the graphic interface), and therefore guaranteeing that by the time the driver is being evaluated, the variable has already been evaluated.
Msgbus
As in the comments in the code, not all changes will send a message through the bus...
Example of persistent usage of «bpy.msgbus» and how to manage it?
Depsgraph update handler
Here's a nice technique by Martynas Žiemys:
Operator that runs when a value input is changed
Frame change handler or 3D view draw handler
Just keep running a function on each frame change or even each draw call and check if properties of interest changed before running CPU intensive code:
Use a driver to programmatically set the positions of many vertices
You can even cache calculated data similarly to Physics simulation, as in this Q&A:
Distributed interaction visualization
Consider how updating values may require you to update the view layer, and therefore refresh the viewport by... Redrawing it, which should trigger the function again. Beware of accidentally making an infinite loop if your own function changes a state in such a manner, that on the next redraw it changes the state again…
Which is the best?
3d view draw handler will be constantly run, so it will always work. However, it's a script that needs to be run every time you open your project. You can enable auto-execute, but it requires some security consideration I explain here:
How to randomise any value every frame between specific interval?
That makes the project harder to share.
The driver, on the other hand, if not used in a hacky way as above, works out of the box, but its functionality is limited.
Comment: Nice collection.. which kind of reminds me.. haven't seen @batFINGER for a bit.....
Comment: @RobinBetts I hope he's either enjoying well deserved vacation, or hacking at the problems deserving his time.


Reading snappy compressed input in pig

Question: I have a file that I am trying to load into pig that is compressed with snappy.  I set the configuration options in grunt like was described in this jira issue but I am still getting the compressed data in the results.
When I run the job it does say:
org.apache.hadoop.io.compress.snappy.LoadSnappy - Snappy native library is available
for the job I do a simple
a = load '/path/to/snappy/file' using PigStorage() as (x, y, z)
then:
dump data
will output the compressed data.
Does anyone know what I can do to read the data correctly?  Thanks in advance.
Answer: PigStorage uses PigTextInputFormat for input, which will detect and use Snappy compressed files, but the files must have the correct extension for hadoop the hadoop compression codec factory to know to use snappy.
My guess is your files don't have the .snappy extension, try renaming the files and trying again

Reading snappy compressed input in pig


Assign 2 page layouts to System admin profile

Question: Suppose if I have an Object A and it has two page layouts layout1 and layout2. Layout1 is used for App1 and Layout2 is used for App2. So is there a way to default the layout for system admin, like if system admin launches app1 then layout1 should be displayed and if he launches app2 then layout2 should be display by default. Is there a way to achieve this?
Answer: No, the page layout depends on the Record Type and the Profile. You might want to add your voice to this idea.
Answer: If you're in Lightning and the object you're on is custom (standard objects not yet supported), you can achieve this by not utilizing page layouts and instead leveraging Dynamic Forms on Lightning Record Pages.
Instead of letting the page layout dictate the fields, you'd do all this through the Lightning record page and then do the assignment through the existing functionality which allows you to assign based on record types and application.


Should I use a definite article with 'media'?

Question: I found a bit of a discrepancy. On the one hand, in the Longman dictionary, the word 'media' goes with 'the' in expressions like 'the news media', 'the mainstream media'. On the other hand, through Google search, I found out that expressions like 'Chinese state media' go with no article. Please explain.
Comment: "Media" is plural. You can refer to all or some of them.
Answer: Plural words, like "media", do not always require an article. It depends on whether or not you are referring to something specific.

Horses eat grass. (Horses, in general, eat grass.)
The horses eat grass. (These particular horses eat grass.)

If you say, "The Chinese state media" you are referring to the specific media operated by the Chinese state. However, you can say, "Chinese state media" to refer, generally, to media operated by the Chinese state.
You should also keep in mind that newspapers (if that's what you are reading) always try to conserve words where possible, so if a phrase doesn't really need an article (such as "Chinese state media") a newspaper writer will often leave it out.
Comment: What about 'the mainstream media' etc. (the Longman dictionary)? The expressions don't refer to specific news outlets, rather to a specific group (pretty much like 'Chinese media')
Comment: @Sergey I'm not sure I totally understand the question... "the" indicates that you are referring to something specific; it could be a single thing, or a group of things. "The mainstream media" means the dominant media outlets, as opposed to all news media. However, you can also refer to "mainstream media" as a general category. It depends on the context.
Comment: I don't understand why 'Chinese state media' (as a whole) is not specific enough. You could apply the same logic to 'mainstream media': if you mean specific mainstream media, use 'the', no article if you refer to it generally


RSA Public key-Prove that if any one of p,q,ϕ(n) is known, then you can quickly use it to find the other two as well.

Question: I'm a little confused as to how to go about this, I've read through the bottom answer to this question : RSA solving for $p$ and $q$ knowing $\phi(pq)$ and $n$ but in that question they find p and q after knowing phi(n) AND n. Any help would be appreciated, thanks.
Comment: Everyone is supposed to know $n$.
Answer: Given $p$:

$q=\frac{n}{p}$
$\phi(n)=(p-1)(q-1)$

Given $q$:

$p=\frac{n}{q}$
$\phi(n)=(p-1)(q-1)$

Given $\phi(n)$:

$p=\frac{(n-\phi(n)+1)+\sqrt{(n-\phi(n)+1)^2-4n}}{2}$
$q=\frac{n}{p}$
Answer: Let's first look at the two easy cases. If you know either $p$ or $q$, then finding the other two are very easy given that $pq =n$ and $n$ is publicly known.
Given that you know $\phi(n)$, then the answer provided in the link you gave is a really clever way of finding $p$ and $q$.
Comment: Thanks for the reminder, I don't think I had fully understood that n and e are publicly known.


Podcast ep on iphone 5s will not delete

Question: I've moved to the UK and just got a new 5s phone and restored it from my old settings on my US iphone 5. One glitch I've noticed seems to be w/ iTunes music or podcasts showing up on the phone in songs when I didn't move them to the phone. I had 3 on there I didn't want. 2 deleted fine, just like any of the individual songs can delete. 1 podcast ep will not. I hold my finger down on it and slide to the left and no red delete option will show, but it will on any other song. I go to the ep, click the red lines in the top right corner to get me to the individual song again and while other songs will delete that way as well, this again will not. The red delete rectangle won't show. I hook it up to my mac and verify no podcasts are synced. The category is greyed out. The artist is not checked under artists, the individual ep is not checked, it's not in a playlist I've synced nor is it in genre I've synced. This is a complete mystery how this is still on the phone at all. It plays no problem, but I want it deleted off the phone entirely. I've turned the damn thing off/on a few times. How do I remove this? What's going on?
Answer: Go to the settings app on iOS. Check podcasts and be sure to disable sync there. At that point a local delete should work properly.

Podcast ep on iphone 5s will not delete


Measuring distance between features in linear units from vast layer in geographic coordinates in gdal

Question: I have a point layer for a large area. The layer is in a geographic coordinate system. I need to make some distance-aware work with features from this layer. Actually, I need to build a buffer-layer with 100 meters, but it doesn't matter. The first idea is to project the layer, make a buffer and transform back to the geographic coordinate system. However the area of the layer is pretty big and, as I understand, I cannot use the only projected coordinate system without significant distortions. So, I need to use several projected coordinate systems or use haversine to build a buffer. Both approaches do not look neat and convenient. Is there a more natural way to build a buffer (or measure distance)? I would like to use gdal/ogr.
Answer: To build the buffer layer, a good approach seems to me to use a conformal projection and to scale the radius of the buffers by the inverse of the scale factor of the projection.
For example, you can use the Mercator projection and build the buffers with a radius = 100m / SEC(phi). Where phi is the latitude of the point to buffer, and SEC(phi) is the Scale Factor of the Mercator projection.
To measure distances, the haversine formula seems to me a natural way, but you can give up some accuracy in the calculations and project to a system that does not deform so much the distances within your study area, i.e. with a Chamberlin trimetric projection (Wikipedia, proj-string).


Changing keyboard to steering wheel in F1 2012

Question: Recently installed F1 2012 and began using it with keyboard. Since then I've brought a Nitho Drive Pro v512 Air steering wheel but cannot get it to work with the game. The device is installed, drivers installed and I can change some of the controls under My F1 to be used by the steering wheel. However, it's almost impossible to drive (like using the keyboard before) and the vast majority of functions still require the keyboard. It's as if the game is not fully recognising the steering wheel. Can you help?
Answer: F1 2012 works on pre-defined controller maps, like most Feral games. The support for many controllers is built-in and automatically activates.
However in your case, your wheel controller is from a less-known manufacturer, so Feral does not have a keymap written into the program.
Your solution is as follows:

Ensure your controller is connected, powered, and that all drivers are functioning. Launch F1 2012. From the main menu, navigate to My F1 and select Driving Controls. Now set the control profile to Custom by clicking on it. Set Override Input Device to Steering Wheel and click View/Customise Profile. You can now manually map the controls to your wheel by clicking on the command (eg: Turn Left) and then moving the control surface on your wheel (eg: Moving the wheel left).

If that doesn't help, it means your controller is unsupported as a native wheel by F1 2012, so try this:

Download XPadder and install it. In the XPadder interface, map your wheel control surfaces to the normal keyboard controls used in F1, eg: map 'Pressing the accelerator' to 'UP arrow'. Once you have completed this for the entire keymap, start up F1 2012 and in My F1 set the control profile to Keyboard. Essentially, while playing, your input goes from your wheel to XPadder, which translates it into a simple key-command for F1 to interpret. (Wheel > XPadder > F1 2012)

I hope this solves your problem :)


If I factory reset my iPhone would it mess up my SIM contract?

Question: I have an iPhone 6 and would like to know if I could factory reset my phone and still be able to use all my data, minutes, and texts as soon as I set the phone up again?
Comment: I feel I have fully addressed your question. Please consider accepting my answer by clicking on the checkmark next to it. Else, let me know if there is anything you don't understand.
Answer: Typically a reset does not affect your contract, because the iPhone's state is independent of the SIM contract. Although it is best to verify that with your SIM provider, you should not need to worry about the contract falling apart because it is bound to the physical card itself.
Let me explain:
That means that while a factory reset of the iPhone may sound like every piece of information linking back to you is permanently deleted, some data like the Serial Number, MAC address etc. is still unique to the device (hence doesn't change upon reset).
As logical links such as those created by the software (iOS) are prone to change, physical ones such as the unique identification mentioned above don't. If, and yes, only if the provider of the contract linked the SIM to your iPhone, it would most certainly be linked to the unique codes such as your iPhone's serial number - for greater accuracy.
The iPhone (or any phone for that matter) does not track your usage, the network provider does.
Comment: Good answer! Not to be picky, but technically, your device does keep track of some usage. You can go under  Settings > Cellular and see how much data you have used and how much each app on your phone as used. You can also see the total call time for the phone. However, that's just simple stats that are only on your device.
Answer: Yeah that wouldn't be a problem at all.
As long as you have backed everything up prior to resetting you will be good to go.
The only thing you may lose is your current data use and other network related stats like that.


Frequency analysis

Question: What's the difference between Constant Bandwidth Filter and Constant percentage bandwidth filter?
I mean not just the basic difference but a little detailed one, couldn't find much on the internet!
Answer: Consider a band-pass filter with centre frequency $f_0$ and bandwidth $\Delta f$, determined by a specified attenuation with respect to the response at the centre frequency.
Consider the ratio
$$Q = \frac{f_0}{\Delta f}$$
defining a quality factor for the filter (the quality factor can be defined in different ways, more or less equivalent, but this is the most useful for your question).
Now imagine to have a filter with variable $f_0$ or several filters with different $f_0$'s. You can easily imagine two limiting cases: the variable filter has bandwidth independent of the centre frequency; or the variable filter has also variable $\Delta f$ in such a way that the ratio $Q$ remains constant, independent of the centre frequency. The former type of variable filter is a constant bandwidth filter; the latter a constant percentage bandwidth filter.
For instance, when you analyse a signal with the fast-Fourier transform (FFT), it's like having many constant bandwidth filters, one for each bin. The same type of filter is present in analogue RF spectrum analyser.
The constant percentage bandwidth filter is more typical of spectral analysis in acoustic applications, for instance when you consider octave or third-octave filters. What do they mean these names?
An octave corresponds to a frequency doubling: so in octave filters the higher endpoint of the bandwidth has frequency equal to twice that of the lower endpoint. Let's denote by $f_\mathrm{L}$ the lower endpoint and by $f_\mathrm{H}=2f_\mathrm{L}$ the higher one. The centre frequency is $f_0 = (f_\mathrm{L}+f_\mathrm{H})/2 = 3f_\mathrm{L}/2$ and the bandwidth is $\Delta f = f_\mathrm{H}-f_\mathrm{L} = f_\mathrm{L}$. The quality factor is then
$$Q = \frac{3f_\mathrm{L}/2}{f_\mathrm{L}} = \frac{3}{2}$$
The quality factor is independent of the centre frequency and the filter is indeed a constant percentage bandwidth filter. If you take the reciprocal of $Q$, you get a ratio, typically less than 1, which can be expressed in percentage of the bandwidth with respect to the center frequency: hence the name constant percentage bandwidth filter.

Frequency analysis


Having a problem with hair particles

Question: So i've been modelling a boardgame figurine, and i wanted to add hair on it. I set the settings and all kinds of stuff, but halfways trough decided to separate the hair into two sections, and each would have different hairlengths.
I separated the hairlayer i duplicated from the head, but when i set the hair length value on one part, the hairlength changes on the other part as well
I dont know why they're still sharing that same number, since i separated them. Can anyone help me explain why this happens and how can i fix it?
Answer: If they have the same preset, they will share the properties. Hit on the little + near the Settings preset to create a new slot for the second one.

Having a problem with hair particles


What are rules of thumb with setting bounties?

Question: I have been recently been given the privilege to start a bounty. I have been browsing the unanswered to get some questions a chance to be answered. What are some good rules to go by to award questions bounty?
Answer: In my opinion, the best kind of question to give a bounty is a clearly stated question that happens to not have a well-written answer yet, particularly when a good answer would be long or otherwise effortful.
Clearly stated:

It should not be unclear what the question is; answers should not be guesses.
The question should be easy to read. This can be fixed with editing if it's unambiguous but poorly written.

Not having a well-written answer:

Perhaps the question has just happened to not get any answers the first time around.
Or a good answer will require some effort (e.g. to compile information or draw diagrams).
Or the information already exists, but the existing answers don't explain it in a way which will consistently make sense to someone who doesn't already know a lot about the subject.

But, of course, it's your own reputation to distribute as you see fit.
Answer: Ben,
Here is some information about bounties: https://ham.stackexchange.com/help/search?q=bounty.
Does that help answer your question?


Is it possible to list all files starting with a letter, but not directories?

Question: I need for my home assignment somehow to get a list of all the files starting with the letter F, I know of the command:
ls F*

But it also gives me directories, is it possible to only show actual files?
Answer: POSIXly:
find . ! -name . -prune -type f -name 'F*'

With zsh:
print -rl -- F*(.)

Answer: Sure - using find (which does not sort names as ls does, so I added that):
find . -type f -maxdepth 1 -name 'F*' |sort |xargs ls -l {} \;

or (if you want only the names)
find . -type f -maxdepth 1 -name 'F*' |sort

The -maxdepth option is not in POSIX, but since you tagged this with bash, we can make some assumptions.  For instance, it works with OSX (the other platform where people generally use bash).
In any case, left to itself, find will show files in subdirectories, which is something that ls will not do without adding a -R option.
One issue with find is that its output may include filenames with nonprinting characters (blanks, etc).  Both Linux and OSX find provide an extension (not in POSIX) called -print0, which works with xargs complementary extension -0.  So you could do this:
find . -type f -maxdepth 1 -print0 -name 'F*'  |sort -z |xargs -0 ls -l {} \;

or (if you want to give up the sorting feature), you could use straight POSIX:
find . -type f -maxdepth 1 -name 'F*' -exec ls -l {} +

Sorting is mainly an issue when you want a detailed listing, but the POSIX + would not be helpful if you want a sorted list, since (still legal) newlines in the list of names would interfere with sorting.
@cuonglm points out that POSIX has the -prune option, which says:

-prune
  The primary shall always evaluate as true; it shall cause find not to descend the current pathname if it is a directory.

and if you are using "." for the argument of find (as done here), then there is no need of the -maxdepth option.  True enough, but if we pursue the analogy to ls further, then "." is the equivalent of ls -a, while strictly matching OP's question would drop the "-a" option and the argument to find could be "*".  However (as reminded by @cuonglm), -prune is only useful for directories, and find * -prune would match directory contents.
One could also use a shell wildcard expansion, e.g.,
for n in F*;do [ -f "$n" ] && echo "$n"; done

which is (probably) preferable to ls F* since it does not convert nonprinting characters into question marks, wildcard expansion in either case runs into command-length restrictions.
Ultimately, the answer depends on whether OP wants a listing or a list of names.  But in either case, ls by itself cannot do the job.
Comment: `-maxdepth` is not POSIX
Comment: `-type f` only selects regular files and not the other types of non-directories (the OP's question is unclear though since directories are just one of many types of files). Use `! -type d` for non-directories. `[ -f "$n" ]` returns true for regular files and symlinks to regular files. `[ ! -d "$n" ] || [ -L "$n" ]` for non-directories.
Answer: I could use the find command:
find ./ -name "F*" -type f

-type f means you want regular files only.
Comment: This will list files in subdirectory, which glob `F*` didn't.
Comment: Yes that's right.


How to calculate Graham's margin of safety?

Question: Graham in his famous book devotes a chapter on how margin of safety is important. Can someone give examples how can we find this margin of safety?
Comment: Hopefully it's not related to [Graham's number](https://en.wikipedia.org/wiki/Graham's_number).
Answer: The margin of safety can be calculated by computing an intrinsic value and comparing it to the current price. For example, if the intrinsic value was 100$ and the stock is trading at 80$ your margin of safety would be 20%.
In practice, the difficult part is getting the intrinsic value right. No matter how you compute it, you will always rely on assumptions about future growth and earnings which are unlikely to be exactly right. This is where the margin of safety comes into play. A large margin of safety allows the investor make a profit even if the estimates where a bit off.
The ideal case for Graham would be a company that is trading below its book value as this has a built-in margin of safety even without projecting future earnings. A company that has a book value of 100$/share (after deducting debt) but is trading at 80$ would be a very safe investment as liquidation of the company will still return more than you paid.


How did physicists conclude that 98% of mass is due to the strong force?

Question: On a video on YouTube called 'weak and strong nuclear force (9/15)' at 0:55 a scientist said that 98% of mass is due to the strong force.
Comment: Here's a video that explains it in Layman's terms.    https://www.youtube.com/watch?v=Ztc6QPNUqls
Answer: If you mean the mass of the hadrons, it is because of the energy/mass contributed by the gluons carrying the SNF and virtual quarks and antiquarks, which is high compared the three valance quarks. The valance quarks are the three "permanent" quarks that we think make up the proton and neutron. The Higgs field has a much lower effect on the mass of these particles than the effect described  above.  I am not sure about the 98 percent figure though.

From  Wikipedia Hadrons

Hadrons, however, are not composed of just three or two quarks, because of the strength of the strong force. More accurately, strong force gluons have enough energy (E) to have resonances composed of massive (m) quarks (E > mc2) . Thus,virtual quarks and antiquarks, in a 1:1 ratio, form the majority of massive particles inside a hadron. The two or three quarks are the excess of quarks vs. antiquarks in hadrons, and vice versa in anti-hadrons. Because the virtual quarks are not stable wave packets (quanta), but irregular and transient phenomena, it is not meaningful to ask which quark is real and which virtual; only the excess is apparent from the outside. Massless virtual gluons compose the numerical majority of particles inside hadrons.


How do you support upper floors in tall buildings?

Question: When I build a skyscraper out of LEGO and the floor above is weak do I remove the flooring from above and a pillar underneath and then put the floor back or something?
Comment: Howdy Tibor, we don't work for LEGO, but there are folks on here who can definitely answer this.
Answer: Extra support in form of pillars/walls underneath (remember that also weighs something and as such should be supported) is one (and probably the most widely used) solution, another would be to build the floor thicker, and depending on how weak the floor is and how much it has to support yet another solution might be to just not care.
Answer: Most real-world buildings will have one or both of the following features:

Load bearing columns - in tall tower blocks you'll often find the lifts, emergency stairs, etc form a central column that the floors can be anchored to.
Supporting beams - these are typically steel beams that travel from one load bearing wall to another, and the floor will then rest on those.

Where you have both these features, the supporting beams will go from the exterior walls to the support columns, or from column to column, providing both rigidity to the structure and support for the floors.
Your LEGO builds should aim to incorporate those features if you need to support plates that are smaller than your building's floor plan.


What is the importance of EM field theory in electrical engineering?

Question: I am a student of electronics and instrumentation engineering and have a course of electromagnetic field theory in our semester. Though haven't gone so deep in subject but have some primary idea about the subject. I just want to ask where is field theory necessary and what should be the best approach to read the subject?  I am not an expert in the subject and having many difficulties to understand it. Can anyone tell me which points are necessary and which aren't?
Comment: Welcome to the stack. Are you talking classical field theory or quantum field theory or is it the mathematics of fields? Better to ask a specific question about a specific problem you are having rather than a general 'I don't understand field theory what should I know ' which is likely to get closed as it is too broad and answers will be opinion based. As we are unfamiliar with your syllabus and the level required perhaps the best person to ask is your lecturer.
Comment: As for the topic question - electricity, and hence EE are FULLY built on top of field theory. All of the implications that are considered by some as EE, like Ohm law e.t.c. are just implications. Models built after performing some assumptions and simplifications. Of course, what you refer by field theory (btw, what is it? Maxwell equations?), is a model as well of some lower level stuff..
Comment: Thank you for guiding me. I am talking about classical field theory includes electrostatics magnetostatics and electromagnetic waves. In short which is also called electromagnetic field theory.
Comment: @Olin Opinion based ? Maxwell would be spinning in his grave (and radiating appropriate frequency Hertzian waves, no doubt)
Answer: Demietra95,
It all depends on what field of electrical engineering you work, but it would be the best to learn all of that you said that you learning on course. Never enough knowledge. You'll need something of that in some of your future projects, and the best way to understand that theory and a lots of calculations and tasks is while working on some projects. So don't worry just do your best, learn as much as you can, and your life will be so much easier later. Be persistent and don't give up :)
Comment: I was a student also, not much time ago, and I understand your confusion :)
Comment: Sir /mam @Master Yoda can you tell me what should be the best book to learn this subject from the basic to the advance level ? I want to understand the subject properly and gain some knowledge from this.
Comment: Almost every book is good book, but I recommend you to attend to some online video courses like this one http://ocw.mit.edu/resources/res-6-001-electromagnetic-fields-and-energy-spring-2008/ also look there https://www.google.rs/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=electromagnetic+field+video+course
Comment: I recommend Electromagnetic Fields by Wangsness. Takes you from vector calculus all the way up to electromagnetic radiation via maxwells equations.


Touchpad randomly clicks when lid closed after updating Synaptics touchpad

Question: After updating my Synaptics touchpad driver to the latest version from the Synaptics website (Older versions had a bug and I couldn't enable moving the mouse while typing), my touchpad is randomly clicking around the screen when the lid is closed. Is there any fix for this?
Answer: Oh... I just realized what's happening. The lid is pressing down on the touchpad, and now that Palm Check is disabled, it's successfully clicking around the screen.
The problem wasn't the new driver version but rather me being able to successfully disable Palm Check!


Time series model residual plot keeps indicating AR(3)

Question: Like the title says, my residuals keep indicating an AR(3) model. My original model was AR(14), but the residuals' acf and pacf indicated an AR(3) and so did the ar function and auto.arima. So then I fit an AR(17), and then the residuals indicated AR(3) again. What could be going on here?
Comment: Can you provide a reproducible example?
Answer: My Guess as to why you are getting the results you are getting is that your model is over-parameterized due to faulty model identification . As to precisely why,I suggest that you contact the author and present your data and ask why .
The standard error of the acf is based VERY ROUGHLY on 1/SQRT(# OF OBSERVATIONS) thus if your sample is large you have VERY VERY ROUGHLY a  very small standard error and thus a large t value ...that is one possibility ... A second possibility is that the software you are using is just not working for that time series as it may have embedded deterministic activity such as a quarterly effect for the most recent half of the series OR change in error variance all of which may be beyond the "pay grade" of your softwares of choice. If you wish to post your data I will try and help you further .
I have been modelling time series for a little over 50 years and have never seen a data set that requires the model you are finding/using ...so I suspect the model may be probably inadequate unless you have a large sample size and are over-believing the apparently significant t values for the acf of the errors.
EDITED AFTER RECEIPT OF DATA:
I used 140 monthly values from 2006/3 and obtained the following reasonable model that used a log transform , three pulses and a seasonal pulse that commenced 2011/1 and ARIMA structure using AUTOBOX my tool of choice. It generated the following acf of the residuals  with 140 values the se of the acf is approx 1/12 or .07
Note that my reflections of a large sample size , the need for a power transform and the onset of unusual seasonal activity starting at period 59 of 140 came to pass. Just lucky I guess ! or maybe not so ! . This is the model summary  and forecast plot
EDITED TO RESPOND TO YOUR VERY GOOD QUESTION/OBSERVATION ABOUT THE NEED FOR A LOG XFORM
The decision to take a log transform is based upon the linkage between the expected value and the variance of the residuals. When (and why) should you take the log of a distribution (of numbers)? . Thus after forming a model including any necessary deterministic structure one conducts the Box-Cox test to investigate the need for a power transform given that the variance change didn't occur deterministically over time . Following is the results of that test . . Early researchers (without the benefit of our computing power) thought and taught that the test should be conducted on the original data which of course assumes a model with only a constant removed whereas the Box-Cox approach was based upon the variance of the residuals NOT the variance around the mean.
I have seen cases where one can detect increasing variance in the observed series so while it is true that this occurs it is not necessarrily the basis for the test but rather often coincidental to the way the variance of the errors changes. http://autobox.com/pdfs/vegas_ibf_09a.pdf slide 14
 may help you in this regard where the variance around the mean leads to a bad conclusion about the need for a transform due to anomalies at the higher levels of the series.
As an aside I present here the ACTUAL and CLEANSED data  and to my eyes there is a DEFINITE increase in variance at the higher levels suggesting a possible need for a power transform like logs as the variance (around the expected value) increases with time. The graph suggests a point in time that the variance of the errors deterministically changed. AUTOBOX tested for that but the resultant test was inconclusive. http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html
Comment: I used the last 10 years of this data set: https://fred.stlouisfed.org/series/CEU0500000003. I should also mention that I fixed some of the AR(14) coefficients to 0 to get the smallest AICc. I did this one by one, if you're wondering. Thanks for your help.
Comment: Hmm could you explain your reasoning behind choosing a log transform? The series' variance did not appear to be increasing with the mean.


Change edit approval/rejection

Question: I accidentally clicked reject on the suggested edit on this question(https://stackoverflow.com/questions/5726269/). I can't find the button to change it to Approve?
Answer: There is no undo at the moment, I always planned to have undo gmail style. But we have resisted complexity here. Once you have undo, you have to add a slew of checks prior to undoing.
On SO the community will pick up and approve if you just made a mistake. On other sites, you can go and manually apply the edit if this was an honest mistake.
Comment: I think we need the added complexity of an undo. [Here's one example why](http://meta.serverfault.com/questions/5299/i-accidentally-rejected-a-suggested-edit-that-should-have-been-approved-what-do?cb=1)
Comment: If there is going to be undo functionality, there should be a limited time period to exercise it.  An editor might make future decisions based on whether a given edit is accepted or rejected.  Regardless of the timeline, an editor should get clear feedback about a (rare) decision reversal like this.
Comment: Don't ask me @A.M. I have not idea, no longer work for SE
Comment: I just accidentally approved the edit.. and while looking for the help, I ended up here, on this post. We are people, and we all do some mistakes, be it a deliberate or an accidental one.. mine was pure accident.. but yeah, I feel not OK accepting the very minor, yet unjustified edit.
Answer: In general, you can't undo your review actions. The exceptions are when you can revert the changes your action effected - so, in the case of approving a bad suggested edit, you could rollback the edit. The other option would be to flag for moderator attention and ask them to override the edit.
These two actions may sound the same, but they aren't. Rolling back such an edit would still leave the person who suggested it with the two rep they earned for having it approved - in the case of spam or destructive edits, this would be bad. On the other hand, moderators have the ability to reject an edit after the fact, thus removing the reputation earned - with the caveat that there can't have been an intervening edit (or rollback). Given that, you'll have to pick one of the two options; you shouldn't both rollback and flag as the mod won't be able to do anything at that point.
Fortunately, in most cases, reviews require more than one person to act, so hopefully, if you approve a bad edit, someone else will catch it and it won't get through.

Change edit approval/rejection


Textbook on classical E&M in curved spacetime

Question: Can anyone recommend a good reference for classical electrodynamics that goes over electrodynamics in curved spacetime that doesn't assume much knowledge of GR -- that is it builds up the tensor calculus and GR principles itself?
Comment: I think Carroll's textbook on GR may be a good start - he has a section of QFT in curved spacetime. If you're really interested in the classical theory, maybe you can try to work it out yourself if you just know the Lagrangian, you can at least find the equations of motion and such.
Comment: Comment to the question (v2): Do you mean QED or are you only interested in classical ED? Please edit the post accordingly. Here is a quantum version: http://physics.stackexchange.com/q/110763/2451
Comment: I'm not really looking for a book on QFT, I'd prefer a book on the classical theory.  It doesn't necessarily have to just be on E&M in curved spacetime.  It could be a book which covers the more standard topics of a first grad-level book on E&M with curved manifolds at the end.  Or a book on Classical Field Theory which goes over GR before electrodynamics (or more likely goes back over electrodynamics at the end).  I can't seem to find a book like either of those.  @Danu Yeah, if I can't find a resource, I'll just work it out myself.  I'd just rather have a text if there is one.
Comment: Does landau and lifschitz's classical field theory book do this?  This sounds like the type of thing they'd do.  I know that my advisor did some work on the scattering of fields by black holes.
Answer: The Classical Theory of Fields by Landau and Lifshitz fits the bill reasonably well.  It doesn't develop electrodynamics from scratch in the context of a curved spacetime, but it does have a three-page section covering the equations of electrodynamics in a curved spacetime, after spending seven chapters developing electrodynamics in the context of flat spacetime.  Unlike Griffiths or Jackson, the development of electrodynamics maintains contact with special relativity from the start. Indeed, the book's first two chapters are a coverage of the basics of SR.  The book still presents the material using the traditional 3D vector fields with div, grad and curl, but it alternates between using that pre-relativistic treatment of electrodynamics with a special relativistic treatment using four-vectors and tensors.
The book requires about as little knowledge of GR as possible prior to its coverage of electrodynamics in curved spacetime.  In fact, in a sense the book hasn't really yet covered GR at that point, since it doesn't cover the Einstein field equations until later.  The only material in between the special relativistic treatment of electrodynamics and the treatment of electrodynamics in curved spacetime is one chapter that extends the tools used in SR to curved spacetime.
Answer: You might find Gauge Fields, Knots, and Gravity by Baez & Muniain useful.
It doesn't specifically deal with electromagnetism in curved spacetime, however,  the first chapter develops differential geometry with the goal of reformulating Maxwell's equations. It assumes no knowledge of GR.
The third and final chapter develops some aspects of GR.


Flat hose wrapped around a cylinder

Question: It was always taught to me that friction is independent of surface area. I was recently made aware that that is only partially true. My question is: would a layflat hose and a rope of equal weight and diameter produce the same frictional force when wrapped around a pole?
Comment: the materials in contact have an impact on the friction. look up coefficients of static friction or see the chart here https://www.engineeringtoolbox.com/friction-coefficients-d_778.html
Comment: Related - It is not a difference in area rather one of a difference in the normal force https://physics.stackexchange.com/q/19951/104696
Answer: The rope around the pole is going to generaly produce more friction. Tho this has nothing to do with surface area,since at both situations the surface area is the same. So as u have always been taught friction has to do with the normal force. While a lay flat rope can only produce normal from gravity ,the pole one can get tight under the right conditions and what ever is pulling on it going to create more normal force.

Flat hose wrapped around a cylinder


Which type of yield do finance professionals refer to when talking about "bond yields"

Question: I am aware that there are many different ways to measure a bonds yield including YTM and the Current Yield.
However I am not quite sure which yield is being referred to in a yield curve and other instances of a bond's yield.
Answer: Yield to worst is common because it is assumed that the company will exercise the call option if they can refinance at a lower rate.
Answer: Depending upon your finance area (asset manager, loan structurer, trading, etc.) there will be different measures of yield.
However, as far as I am concerned, in fixed income trading for discussion that take place between interbank brokers, client and market makers regarding prices, and strategy or research pieces released by investment banks the same nomenclature is ubiquitous. Yield means yield-to-maturity.
Additionally other measures such as asset-swaps prices or credit spreads are calculated as the differences between two yields based on yield-to-maturity which also demonstrates its universal usage.
Answer: Bond returns can be broadly categorised into recurring payments and capital gains.
Recurring payments are called coupons and are usually given as a percentage of the face value of the bonds. Even if the price of the bond changes over time, the (annual) coupon rate remains constant because it is based on face value, not bond price. The bond might have provisions for changing the coupon rate under various conditions.
Expected capital gains (or losses) for bonds are calculated as the difference between (expected) sale and (actual) purchase prices. If you bought a bond for $105 and it has a face value of $100 payable at maturity, you have an expected capital loss of $5. If you sell it prior to maturity at $108, you will have an actual capital gain of $3.
Bond yields are typically quoted based on the expected coupon payments and expected capital gains to either the next call date or to maturity. They are a measure of the total gain of the bond if the bond holder doesn't sell the bond.
You mentioned bond yield curves.

A yield curve is a line that plots the interest rates, at a set point in time, of bonds having equal credit quality but differing maturity dates.
  - Yield Curve, Investopedia

The coupon rates of different bonds might be different, but the yield of bonds with similar credit quality would be expected to be similar. Since the coupon rate is fixed, this means the price of the bonds change. Bonds with higher coupons tend to become more expensive while those with lower coupons tend to become cheaper. Since the yield is a measure of total return, it can give a useful comparison between bonds with different coupon rates and maturity dates, assuming continued payment of coupons and repayment of the face value, etc.


Using a Ubuntu AWS instance as tunnel for RDP to simulate bandwidth

Question: I have a bunch of windows instances on EC2 which I can connect to using RDP.
I want to test the performance of RDP under various bandwidth and latency conditions.
I know about thetc qdisc tool which allows us to control traffic on particular interfaces on a machine. However I would like to keep this independent of my developer machine. I wanted a setup in which I have another box - most probably a ubuntu AWS instance which I could configure so that my RDP connections are routed through that machine's interfaces and I can set bandwidth controls on different ports of that machine. This will act as a gateway to my RDP connections, so that I can see how RDP performs under certain bandwidth condtions by connecting to the appropriate port on this gateway.
I explored some tools like the rinetd server and tried to work with iptable rules. The closest thing to what I required was SSH port forwarding, using the gateway. However I see some strange performance hence I want to do away with SSH and see if I can get a transparent (SSH free) solution. I want a setup in which I could just rdp into a port on the gateway and the gateway automatically "forwards" this connection to the (preconfigured) remote machine. And the traffic coming back from the remote machine should also be redirected through the gateway back to my client. That way I can use tc qdisc on the gateway and study RDP under various settings.
Answer: Not to say you won't get it running the way you're envisioning it, but you may have an easier time of it if you use a tool that limits bandwidth on the Windows boxes themselves. A few examples include,

NetLimiter
Shunra vCat

These tools will constrain the bandwidth or, in Shunra's case, impair the ping or packet loss of the network. You can then connect directly from your test client and not worry about routing the connection in order to limit bandwidth.
Comment: That is also helpful, I will check this out as well. Thanks!


Dijkstra for negative weights by adding a constant

Question: I have slight modification for graphs which has negative weights for finding shortest path . If the graph has all non negative weights then by Dijkstra's algorithm , it can be done in O(VlogV + E) . So for the graphs having negative edge weights , find min(weights) = K and subtract K from all weights so that we end up with positive weights. Then apply Dijkstra's instead of bellman ford algorithm which takes O(VE) time to find path and then add K to all paths.
Does this method work? If it does then why bellman ford algo is still relevant , If not why?
Answer: No, this doesn't work. A path of length $\ell$ will have $\ell K$ added to its weight, so your transformation can make a path with several light edges weigh more than a path with a few medium-weight edges.  (Consider the effect of adding $2$ to each weight in a path of two weight-$1$ edges vs a path of a single weight-$3$ edge.)


RSA and Prime numbers distribution law

Question: I have read a few articles and watched some Youtube videos explaining the algorithm of RSA. It seems that RSA is mainly based on a mathematical trick (Prime Factorization). I am wondering though what's the relation between both Prime Factorization and Prime numbers distribution law? and also what would be the sort of RSA if someone could figure a mathematical solution for Prime numbers distribution (e.g: unsolved Riemann hypothesis)?
Comment: This is answered in the answers to another question [here](http://crypto.stackexchange.com/questions/31024/could-riemann-hypothesis-solve-certainly-rsa)
Comment: Imagine the number of atoms in the universe. Then put this many prime numbers into each atom in the universe. Then the whole universe would contain (very roughly) as many primes at there are primes with $512$ bit. Any thought of iterating over prime numbers (even if you know exactly where to look) is not realistic.
Answer: The best factorisation algorithms are already much faster, subexponential but superpolynomial in complexity, than any improvement possible in brute force key search algorithms due to the Riemann Hypothesis, which would still be exponential in complexity.
The Riemann hypothesis would give a much better error term in the Prime Number Theorem, i.e., the distribution of the primes. This improvement, however, won't have much bearing on factoring efficiency. At the large sizes used for RSA, there are way too many prime number pairs that could have been used to obtain the RSA modulus $N.$

RSA and Prime numbers distribution law


Unable to perform DNS queries over IPv6 from laptop

Question: I was trying to perform a DNS query over IPv6 from my laptop using dig, and it didn't work. Here are the details:
ping6 google.com works fine
dig -6 google.com times out due to being unable to reach any servers
dig -6 @fd85:x:x::1 google.com works fine
dig -6 @2601:y:y:y::1 google.com also works fine
The last two requests are being made directly to my router where I am running dnsmasq.
I couldn't figure out how to see what DNS servers are being sent to my laptop over DHCPv6, but on my phone it lists these three (set automatically):
192.168.1.1
fd85:x:x::1
2601:y:y:y::1

The reason why I am asking on this forum is because it appears to be a problem only for my laptop, since my phone correctly sees the DNSv6 servers.
I am running Ubuntu 20.04 and my network settings show the IPv6 method and DNS as 'automatic'.
Answer: Nevermind, this is because nothing is listening locally for dns requests over ipv6, see this github thread: https://github.com/systemd/systemd/issues/12159


Processing Vocals/Layers of Vocals

Question: In some of electronic music songs' parts, you can hear multiple vocals at the same time. One male, one female vocals but it's different than de-esser effects, it is like being recorded on the same song, same lyrics but you can hear one vocal like it is harmonized.  An example of this would be the vocals in "Too late, all gone" by How To Destroy Angels.
My question is how can such a thing can be done, which effects, what kind of mastering / mixing / effects techniques might have been used while doing this ?
Answer: Although they could be multiple vocal tracks as per slim's answer, there are also dedicated effects, vocal harmonic processors, that automatically reharmonize sounds including singing.  The can come as dedicated effects units, e.g. the DigiTech Vocalist Live 3 , or software modules, e.g. Antares Harmony Engine Evo.  Most of the units for vocal processing allow for the specification of the intended chord, rather than just having the synthesized voices being a specific interval above/below the source material.
Answer: I believe that in this case they have simply recorded multiple vocal tracks. Each track has different effects applied - EQ, bit crunching, distortion, reverb in various combinations.
In addition, it's very likely that the vocal recordings have been chopped up into short samples and arranged in a DAW.
Answer: For your specific example "Too late, all gone" by How To Destroy Angels, most of the vocals sound a lot like they were processed digitally from the same female vocal.
There is also a male vocal for repetition. But considering its quite limited use and different tone than the back vocals, I think that most harmonizing vocals are obtained digitally using auto harmonizers from the female vocal.
These are assumptions based on hearing, only the producer of the song can explain the real case.
Anyway, there are many plugins out there for this purpose. Look for vocal harmonizers.
About the process, mixing and mastering doesn't have to do with this technique. This is normally done during the production before mixing and mastering. But also for many electronic music mixing and producing became a simultaneous task.

Processing Vocals/Layers of Vocals


Using Selenium on Mac Chrome

Question: Recently got a mac and was able to run Mozilla without any issues but having trouble installing chrome extensions and running it for selenium. Can someone guide me through the process of installing the extension and running selenium on Mac chrome.
Answer: If you want to use Selenium WebDriver with Chrome, first download ChromeDriver - WebDriver for Chrome. This can be installed via Homebrew with brew install chromedriver, or manually by downloading, extracting, moving and setting the PATH as follows:
$ cd $HOME/Downloads
$ wget http://chromedriver.storage.googleapis.com/2.22/chromedriver_mac32.zip
$ unzip chromedriver_mac32.zip
$ mkdir -p $HOME/bin
$ mv chromedriver $HOME/bin
$ echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile

Source: install and set path to chromedriver on mac or linux
You should then read Getting started with ChromeDriver on Desktop, in particular the sample code which shows how you map the path to the executable and  instantiate ChromeDriver. If you have a reference to the driver in the PATH variable, you can omit the configuration line.
You can install both packed (.crx file) and unpacked (directory) extensions via ChromeDriver. See the code snippets for setting either up here.
If you were using Selenium IDE for FireFox instead, there is no version available for Chrome. The best alternative I know of is iMacros for Chrome.
Comment: Thanks for answer, can you please guide me through the process of installing brew install chromedriver. I tried to install it from terminal but cant seem to do it. I have also searched for a solution online but dint work out.
Comment: @Ravi You need to install the [Homebew](http://brew.sh/) package manager. You just need to run the command they put the website, which downloads the installation source and executes it via the ruby interpreter
Comment: I have done using "brew tap homebrew/cask" and "brew cask install chromedriver" on Terminal (MacOS)
Answer: Sometimes you will face a problem with the old version of chromedriver and when you try to install it using this command:
brew cask install chromedriver

It shows you the following:
Error: It seems there is already a Binary at '/usr/local/bin/chromedriver'; not linking.

However, you can the following step:
brew cask reinstall chromedriver

If it still shows you the same error, you can remove it with the following command
rm /usr/local/bin/chromedriver

and install it again
brew cask install chromedriver

You should have the last updated version of chrome driver
Comment: Thanks buddy. Didn't hit me the idea of just removing the driver and install.
Answer: I think that the easy way for running mac osx, chrome and selenium together is like this on mac os terminal:
# download selenium jar
curl -L0 https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar -o selenium-server-standalone.jar

# install chromedriver using cask
brew cask install chromedriver

# start chrome driver
brew services start chromedriver
#==> Successfully started `chromedriver` (label:homebrew.mxcl.chromedriver)

# start selenium server
java -jar selenium-server-standalone.jar
#14:38:20.684 INFO - Selenium build info: version: '3.9.1', revision: '63f7b50'
#14:38:20.685 INFO - Launching a standalone Selenium Server on port 4444

Comment: When running 'brew services start chromedriver', I get 'No available formula with the name "chromedriver"', any idea why?
Comment: Nope, even after running `brew cask install chromedriver` theres nothing under `brew services list`
Comment: Maybe now has a new name, or formula, check with this brew services list, it should be installed
Answer: I guess you have a couple of options.

either manually downloading chrome driver and adding it to your PATH,
or using webdriver_manager package

Manually downloading chromedriver
The first option is to manually download chromedriver and add it your PATH:
Step 1: Download chromedriver
# You can find more recent/old versions at http://chromedriver.storage.googleapis.com/
wget http://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_mac64.zip

Step 2: Add chromedriver to your PATH (e.g. /usr/local/bin)
unzip chromedriver_mac64.zip
cp chromedriver /usr/local/bin

You should now be able to run
from selenium import webdriver

browser = webdriver.Chrome()
browser.get('http://localhost:8000')

without any issues

Using webdriver_manager
Alternatively, you can use webdriver_manager that contains most web drivers.
First install it with pip:
pip install webdriver_manager

And for Chrome in particular, you should do
from webdriver_manager.chrome import ChromeDriverManager

browser = webdriver.Chrome(ChromeDriverManager().install())
browser.get('http://localhost:8000')

Answer:
One way is if you have homebrew on your mac, then on terminal, use this command
brew install chromedriver
Then you need to download chromedriver on your machine, do it from
http://chromedriver.storage.googleapis.com/index.html
Download latest version
It will look like, "chromedriver_mac32.zip"
(doesn't matter if its 32 bit, it will work for 64 bit MAC as well)
Use this code for open Chrome if your chromedriver that you downloaded is inside your project folder and looks like this
..Project folder/Chrome/chromedriver
 System.setProperty("webdriver.chrome.driver",
 System.getProperty("user.dir")+"/Chrome/chromedriver");
 driver=new ChromeDriver();

Comment: Thanks for the tip to just list out the actual full path to chromedriver!
Answer: Use chrome driver, download from here
https://sites.google.com/chromium.org/driver/
Add the file in pycharm project, then use this cmd to disable permission pop up
xattr -d com.apple.quarantine chromedriver

Also in python program, use these lines, make sure chrome is installed in Applications
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

options = webdriver.ChromeOptions()
options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'

driver = webdriver.Chrome('/Users/<Username>/PycharmProjects/selenium_py/chromedriver')
driver.get('https://www.google.com')

Answer: Install chromedriver directly with brew install chromedriver.
The chrome driver is located in /usr/local/bin/chromedriver.
If you reload your terminal with source ~/.bashrc or source ~/.zshrc, depending on your setup or restart the terminal if should work.
If it does not work add the chrome driver to your PATH. You need to add /usr/local/bin/chromedriverto your ~/.bashrc or ~/.zshrc by adding the line:  export PATH=$HOME/bin:/usr/local/bin:$PATH.
Answer: The easiest way to do this after downloading the right chromedriver is with the oneliner:
sudo chmod a+x chromedriver && sudo mv chromedriver /usr/local/bin/chromedriver

Using Selenium on Mac Chrome


How did Newton explain his interference rings without wave optics?

Question: Nowadays we know it is a consequence of the wave property of light. But ironically it was discovered by Newton who held the particle point-of-view of light. So how did he explain his discovery?
Comment: He considered the "interaction" of light particles with a vibrating aether. See e.g.Robert Iliffe & George Smith (editors), [The Cambridge Companion to Newton](https://books.google.it/books?id=9fA4DAAAQBAJ&pg=PA289) (2nd ed), page 289-on.
Comment: He thought the wave theory predicted that the interference pattern would be bright in the middle, so that when it was observed to be dark in the middle, that falsified the wave theory. He was mistaken because he didn't understand that a reflected wave could be inverted.
Answer: "Newton rings" in thin plates were discovered not by Newton but by Hooke, and not in 1717 but in 1664 (Boyle described a similar phenomenon in soap bubbles at about the same time). Hooke reported his experiments in Micrographia (1665), from which Newton learned about them, "in which book he hath also largely discoursed of this… and delivered many other excellent things concerning the colours of thin plates", as he acknowledged in his Discourse of Observations (1676). But when the Discourse was converted into Opticks and published  after Hooke's death the mention was taken out, hence the successors learned of them as "Newton rings", see Encyclopedia's summary. In fairness, Hooke only reported the picture qualitatively, whereas Newton performed detailed measurements so precise that Young could later derive wavelengths of various hues from Newton's data to high accuracy.
Despite the commonly repeated assertion that Newton's optics was corpuscular (and this was likely his initial intuition) his considered position was actually a hybrid of corpuscular and wave theories (reminiscent of the later de Broglie's pilot wave theory), although he presented the wave part as "hypothetical". The hybridization already appears in his optical manuscripts of 1670-s, when he had to accomodate the partial reflection and refraction in thin plates and diffraction (discovered by Grimaldi in 1665), see Brewster's survey at the Newton Project. As a result, Newton's corpuscles were not elementary but had what we now call internal degrees of freedom, vibration modes, which he called "fits" and which interacted with the all-pervading "luminous ether". Here is a detailed explanation from Preston's Theory of Light (freely available online):

"The existence of both reflection and refraction at the surface of a transparent substance presents at first sight a great difficulty in the emission theory, for it is not eaay to conceh-e how the same surface may at one time reflect and at another refract an impinging molecule. To meet the difficulty Newton was led from his observations on the coloured rings of thin plates (chap. VIII) to endow the luminous corpuscles with periodic phases or fits, as he terms it, of easy reflection and easy transmission, so that sometimes they are in a condition to be reflected, and sometimes in a condition to be refracted at a transparent surface.
"To communicate these fits to the luminous corpuscles he imagined all space to be filled with an all-pervading medium or ether. The luminous corpuscles, on striking a reflecting or refracting surface, excite waves in this ether which overtake them at regular intervals, and assist or oppose their motion periodically, so that at any new surface they are refracted or reflected according as the wave assists or opposes the corpuscle. The element of periodicity thus so ingeniously introduced, and which is so fundamentally involved in a wave motion, we should naturally expect to be independent of the angle of incidence. However, to reconcile the theory with his observations on thin plates, Newton found it necessary to suppose the length of a fit to vary as the secant of the angle of incidence, and it does not appear easy to account for such a law."

And here is Newton himself in book II of Opticks applying his hybrid theory to explain the rings in thin plates:

"Every ray of light in its passage through any refracting surface is put into a certain transient constitution or state, which in the progress of the ray returns at equal intervals and disposes the ray at every return to be easily refracted through the next refracting surface, and between the returns to be easily reflected by it... This is manifest by the 5th, 9th, 12th, and 15th observations (coloured ring). For by those observations it appears that one and the same sort of ray at equal angles of incidence on any thin transparent plate is alternately reflected and transmitted for many successions accordingly as the thickness of the plate increases in arithmetical progression of the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, etc."

Strictly speaking, Newton only needs coordinated "fits" to explain the rings, and mathematically his explanation is essentially equivalent to that in wave optics. But the nature of this coordination remains mysterious without the ether. To cover his bases Newton in Opticks first professes the familiar hypotheses non fingo pretense:"What kind of action or disposition this is or whether it consists in a circulating or a vibrating motion of the ray, or of the medium, or something else, I do not here inquire". But for those "averse from assenting to any new discoveries but such as they can explain by a hypothesis" he provides the rest of his account phrased into rhetorical questions (the idea dates back to Hypothesis Explaining the Properties of Light, 1675):

"And the vibrations or tremors incited in the air by percussion continue a little time to move from the place of percussion in concentric spheres to great distances. And in like manner, when a ray of light falls upon the surface of any pellucid body, and is there refracted or reflected, may not waves of vibrations, or tremors, be thereby excited in the refracting or reflecting medium at the point of incidence and continue to arise there, and to be propagated from thence... and are not these vibrations propagated from the point of incidence to great distances? And do they not overtake the rays of light, and by overtaking them successively, do they not put them into the fits of easy reflexion and easy transmission described above?"
Comment: @BenCrowell As far as I can tell the dark spot played no role in Newton's rejection of wave theory. He did not experiment with thin plates until 1675 but judges the wave theory untenable already in 1660-s, his chief objection being that waves can not spread in straight lines. It is repeated, along with a list of others, in Opticks 30 years later, but the dark spot is not there either. In Hypothesis (1675) he mentions that Hooke's "ethereal pulses" are "capable of explaining" thin plates phenomena.
Comment: *mathematically his explanation is essentially equivalent to that in wave optics* Equivalent to the correct theory of wave optics (including inverting reflections) or equivalent to his own incorrect understanding of wave optics (omitting the existence of inverting reflections)?
Comment: Newton's own theory, with its vagueness on transmission of fits, could accomodate any kind of spot at the center by adjusting their distribution, obviously one could do the same with the pulses, see [Hypothesis at Newton Project](http://www.newtonproject.ox.ac.uk/view/texts/normalized/NATP00002). But I saw the dark spot mentioned in this context before, it might be a later "rational reconstruction" (possibly by Young). At the time the wave theory wasn't developed enough for the difference to matter.
Comment: One can easily see diffraction patterns through fabric, eg. :[Curtain diffraction](https://www.itp.uni-hannover.de/fileadmin/arbeitsgruppen/zawischa/static_html/strange.html) (about 10% down the page). I'm wondering when that was first noted. I can't find a Question here.


Help on designing a castle to defend a large wall

Question: I am writing a novel and I am working on the design of a castle that is defending a long wall at the border of a land to prevent invaders. I am currently trying to think of the design of the castle, because it is essentially part of the wall, to help defend it. I can't decide on a good design for it.
I considered a concentric style castle, but then I realised that if they retreated to the inner wards, it would just leave the invaders free to enter the lands and ignore the inner wards. Does anyone have any good ideas?
Comment: Just wondering, how do you expect a castle to help defend a wall? I'd say just put all your castles behind the wall; otherwise, attacking armies will avoid your castles entirely and focus on the less-defended sections.
Comment: The purpose of a castle is to be a strongpoint, either to provide shelter for the surrounding population against raiders, or to force an invading army to deal with it lest they leave their supply lines vulnerable to a hostile force.  It doesn't really have a place on a Great Wall-style defensive fortification.
Comment: @Mark - Beg to differ. It provides shelter for local troops in the event of a local defeat by the invaders, and also provides the source for a sally against the rear of the invaders if they simply bypass the castle. This means that the invaders really need to reduce the castle, and the time spent doing this allows for the creation and deployment of a counter-force deeper in the home territory, or diverted from other parts of the wall.
Comment: This really depends on bow long the wall is, past a certain distance communication lag makes a fortification pointless.
Answer: There are some real-world solutions for this:

Hadrian's Wall, made in the days of the Roman Empire (122 AD erm... CE for you politically correct types), to defend Britania from picts and other unconquerable people in the north. They placed small, fortified positions along sections of the wall. Furthermore, these smaller fortified sections had the potential to call for backup from Housesteads, which looked something like this:

Note that the north gate and wall were part of the actual wall. One could easily see these housesteads acting like castles; strong points along the wall where one can hide from potential invaders. Alternatively, these housesteads could have been strong points to march out of and to retreat to.

The Great Wall of China had forts in addition to watch-towers and battlements. We often see the smaller watch towers, which would in turn signal other towers, allowing larger forces, which were garrisoned in forts, to meet the opposing enemy.

Perhaps the most important thing about really long walls is that they are a gamble to buy time and restrict enemy movement. The wall prevents enemies from freely moving in and out of lands, and prevents large forces from simply marching through an area. The extra time it takes for large forces to go through the wall is spent by the defenders amassing enough troops to stop the invasion. This castle along the wall could simply be a place for this response force to live, like the housesteads on Hadrian's Wall.
Comment: I was planning to answer but this pretty much covers it.  Nice answer.
Comment: Thanks. It's a good idea. I think I'll be having multiple fortifications along the wall. I accepted your answer.
Comment: +1 for referring to the actual real world cases. Both the Romans and the Chinese were fairly competent about such matters, there is no benefit in trying to come up with a different solution. Unless you add magic or higher technology, it won't be better.
Answer: Real-world examples have already be shown by previous answers, then here are a few thoughts :
There should be several small castles along the wall, more than a big one somewhere, in order to protect a long wall. Now let's take only one of them.
Its efficiency does not only depends from how your castle is build, but where it is build.
I assume that when the enemy reaches your land, he wants to pass you wall and go behind. Thus, there is no interest in attacking or destroying your castle if it can be avoided. Find were your enemy would try to invade your land if there were no wall at all : probably a large plain or valley, where an army can pass easily.
Put your castle(s) where it annoys the travelers most
On the top of the hills, filled with archers. That place where the river is less deep. Right above this narrow passage.
Previous fortifications could force your enemy to go on a certain way. If there is not only one way, you can make one of them seems easier.
Protect the wall
Keep in mind that if the enemy army can both push your own army deep behind the walls on your castle and still attack the wall outside, where they are tighter, they might be too numerous to be stopped (for your circular walls idea).
You can not hide your castle behind the wall if your goal is to protect the wall. You said your castle was part of the wall, but it doesn't have to be entirely behind. The more forward it is, the more outside land its arrows can reach.
If you make concentric walls, a part of the wall can only protect itself and not the other. You could try something like a star (where each branch can cover the others) inspired by fort Vauban :

It doesn't have to be triangular, you could have several walls like a comb, with archers on the top. If there are several small branches, if the enemy destroys or take one of them you still have the others. With concentric walls, once they are in, you have to go back.
Think about machicolation, especially if you manage to put your castle on the heights.
Answer: One thing you might need to clarify, which will greatly affect the kind of fortification you will need, is this:
What level of weaponry are you looking at giving the attackers and defenders? An army using spears and stones will need a different defensive structure to an army equipped with artillery, snipers, tunnelers, air support, nukes.
Unless your wall extends completely from one end of your country to the other (and even then you've still got problems) it can simply be bypassed by going around the sides, as the Germans did in WW2 with the Maginot Line. The Great Wall of China didn't stop the Mongol invasion, nor did the Atlantic Wall stop the allies from getting into France in WW2. Admittedly the Atlantic Wall wasn't actually a wall, but a series of complementary fortified positions.
The main thing you'd be looking for would be converging fields of fire along the walls, possibly from buildings projecting from the walls themselves, such as caponiers like this one.
By having a castle disconnected from the wall, you're making it much more difficult the reinforce, resupply or evacuate the occupiers of the castle. Having it connected to the defensive wall by tunnels, walkways etc. gets around that.
Any defensive line can be breached at its weakest point (or any point) if you apply enough force to it.
Walls and fortresses are costly to build and maintain, require high manpower to protect and cannot be repositioned.
But you really need to define the level of weaponry technology in use.
Answer: The issues of walls has been addressed very well by the other answers, so I will look at the castle itself.
The main reason to have a large castle is both as a fortification and also as a base. Sitting behind the walls and waiting for the enemy is a passive defense, perhaps appropriate if the enemy outnumber you by a considerable margin, or you are blocking the only approach route (i.e. you are at the head of the only pass or valley leading into your kingdom). If you are more inclined for an active defense, then a large castle provides quarters for cavalry to go out and scout, and men to sally forth to engage the enemy.
In your construct, I am imagining a large wall backed by small garrisons, with the large castle farther in the rear, blocking the main access route to the kingdom (perhaps there are other, smaller castles blocking secondary routes. The garrison of the castle rotates with the smaller fortress garrisons, but the main purpose is to send out a force to relieve sections of the wall when it is under attack, or to counterattack forces which have crossed the wall, and potentially sent punitive expeditions across the wall in the other direction.
Answer: If you were designing. Castle to protect a wall. From the castle every  Area of the wall would need to be visible and then watched at all times that way any threat would be seen Second, a form of  Quick and preferably discrete communication that would rally your troops or army to defend the oncoming threat would be vital. Perhaps the idea is the castle is a decoy where as the wall houses your defenders always prepared
Answer: Medieval castles are basically a wall connecting round (less commonly quadrangular) towers (triangular bastions appear with cannons). In the Iberian peninsula it was common for castle walls to be protected by a second, small outer wall, a barbican. The space between the barbican and the castle wall should be clean of hiding places so that, if the invaders broke through the barbican the defenders on the walls and towers could easily target them.
For your particular case, I'd suggest the main wall to consist of short panes between towers. The barbican would be placed in front of it because it will sustain the brunt of the attacks, thus shielding the main wall. There should be forts (which may look like a traditional castle) at regular intervals (within sight of eachother, so that signals with fire and flags can quickly pass messages around) and preferably on high ground.
Answer: Design the castle in accordance with the direction the threat is coming from, and the terrain. Put your barracks and armories closer to where the enemy is coming from, so when you're attacked, you can get to the defenses more quickly. Make sure that your lines of communication and movement are as short as possible, and that you can see everything. Remember, the shortest distance between two points is a straight line. You should level all of the terrain in front of the castle, cutting down every tree and bush, and set fire to any vegetation so that not only does the enemy have no cover, but they also don't have basic survival materials for a siege, or wood to make siege towers and battering rams.
Pick a spot, ideally, where the terrain in front is flat, and the terrain behind is mountainous or hilly. Maybe you use a river to defend in the front, or have marshes guard your flanks. You want your forward walls to be rounded, to deflect projectiles, and to make the enemy's attacks be like waves hitting a rock. You also want the castle to be part of the wall, as this will protect you from being outflanked and keep your supply lines open. Remember, a garrison force for the smaller castles along the wall needs only be 1/10 the size of the force attacking it. 1 man can defeat 10, 10 men can defeat 100, and 100 can defeat 1,000, especially if they are defending fortifications.
Just remember the principles of geometry, economy of force, and defensive construction, and you'll be fine.


How to parent object to armature without losing vertex groups

Question: Hi I have a mesh which I have already defined vertex groups for the bones but have not parented to the armature yet. I want to parent the object to the armature without losing my vertex groups (whenever I press armature deform envelope weights or automatic weights, my vertex groups are cleared and blender inserts its automatically calculated vertex groups for the bones). Is there a way to do this?
Answer: You can select your mesh, go to the properties panel, assign an armature modifier and choose your armature as "object".
If you use Ctrl+P
, "Armature deform" is the same, as long as you are sure not to have choosen "with empty groups", nor "with envelope weights", nor "with automatic weights".
Comment: I have forever wondered what "Armature Deform" might do different from the other options in the Dropdown. It just adds the Armature Modifier without any groups! Thank you for sharing, this one is not even in the documentation!


"No Boot Device is found"

Question: I have a Dell-Precision 5510 laptop with Ubuntu 14.04 installed. I left it unused for about a month, and when I tried to turn it on, turn-on button lighted up, stayed this way in about 20 or 30 seconds, and then died.  After a few hours, the screen at last lighten up, and after showing the Dell logo, it told me : "No Boot Device is found. Press any key to rebooot the machine".   I did it, but it went through the same routine back to the same message. I am terrified; any idea what can be done?
Comment: Sounds like something's wrong with the disk. It has either been corrupted or removed.  This issue is not related to Unix, as far as I can tell. Try booting from a live-USB to investigate further.
Comment: Thanks,  Kusalanand. I feel terribly stupid (just a plain user...) -- but I don't know how to do a live-USB...
Comment: Did you change boot mode from UEFI to BIOS or vice-versa? Error is from UEFI/BIOS, not seeing bootable files either in MBR or in ESP - efi system partition. Also can be drive error as posted below.
Comment: Sorry, oldfred, I've been away from my comps for about three weeks, and didn't check out your reply. Thanks for your reply. On substance: how I can change  boot mode from UEFI to BIOS or vice-versa if I want to check out your idea?
Answer: English is not my native language so please be patient.
This sound more like a Hardware problem, than software. My first advice would be remove all Hard Drives, clean the RAM memories and the board too.
Try first to boot again with only one RAM module and keep switching them  until the device boot to DELL bios Menu or further. Then you can discard a RAM issue.
The second try would be the Hard Drive, you can create a LiveUSB of linux to search bad sectors (use dd or Gparted) or any problems alike.
Comment: After that you could try the LiveUSB option, I updated my answer with a link to tutorial.
Answer: When my comp got to "No Boot Device is found. Press any key to reboot the machine", I tapped the key F2 many times until it open up a page that had a list of various options, and in the top section "General" I clicked at "Boot options" (or something like that). It opened another page, which among other things asked me about which option I want to choose -- just two of them -- "Legacy" and  "UEFI"; it showed that the current one is "Legacy". Following a hint offered by @oldfred (see in "Comments")  who mentioned  the term "UEFI" (beats me if I know what is that:), I decided to click at it instead of "Legacy", and it worked! When I returned to a previous page (by clicking "Exit"), it showed me a starting Ubuntu page! The comp is still telling me that there is an error in system programming, but otherwise I am happy to have at least my data back....

"No Boot Device is found"