What rules and conditions to add when creating a user group policy for authors

Question: I have created a new User Group.
The users from this group should have access to only a specific Content Collection in CMP.
But even before that, I'm  stuck at creating the User Group Policies.
How do I know what Rules, Entities, Conditions to add.
Also,  where can I explore, what each entity means. I could not find this info in the documentation.
Answer: The security model for a user group is rule-based. A policy is defined on a user group and each policy can have multiple rules. Each rule consists of conditions and permissions. Rules and conditions are specified for entities of a specific Entity definition. The combination of rules and conditions determines the Entities in scope. The following permissions can be defined on the rule level:

Core Entity API permissions:

Read: allows access to a portal page

Create: allows creation of entities related to the entity definition on rule level

Update: allows editing entities belonging to the related entity definition

Delete: allows editing entities belonging to the related entity definition:

Asset entity only API permissions:

Submit: allows submitting entities for review

DirectPublish: allows users to directly approve entities without undergoing the entire approval workflow

Approve: allows approving entities under review

DownloadOriginal: allows downloading the original rendition file

DownloadPreview: allows downloading a preview rendition file

Order: allows downloading multiple entities of the related entity definition simultaneously

CreatePublicLinks: allows users to create public links for assets

ReadPublicLinks: allows users to see the public links of assets

Asset Only UI permissions:

AddVersion: allows users to create versioning on asset entities

CreateAnnotations: allows users to create annotations on asset entities

ReadAnnotations: allows users to view annotations of other users

CreateDraft: allows users to secure original file and create a draft to make necessary modification to a prior approved asset entity

ViewNotWatermarked: Per default watermarked renditions are set for non-administrator users. Checking this checkbox allows users to view renditions for instance a preview without watermarking

ViewFileHistory: Allows users to view alternative files of asset entities

ViewDataHistory: Allows users to view any modification made on each field property of asset entities

You will find more details in the below document for Rules, conditions etc. Also there is an example that they have provided to setup securities.
https://doc.sitecore.com/ch/en/users/31/content-hub/administration--user-group-policies.html
Comment: The doc was for 3.1 and when I checked for latest versions, it was only until 3.3 and our CH is 4.1+. So, I'm not sure if I'm looking at the right info from 3.3. Secondly, the challenge for me is to understand what entities should be used and what conditions for those entities, when creating a rule. The doc explains permissions, which is fine. Any doc which explains entities & respective conditions in context of UG policies.


How should I improve my Retopology? Having trouble with creating proper edge loops

Question: Using Blender 4.1 and Retopoflow 3.4
I'm beginning to learn retopology for better mesh deformation in animation and have given it a few goes now, but am feeling a little stuck. I'm especially having issues determining proper edge loop amount based on mesh area (for instance the torso doesn't need as many as the hands, etc). I also end up accidentally creating triangles when I want to maintain a quad  focused retopology.

Here is my in-progress retopology of a basic human sculpt I made, and I'm aware it has several issues. I was wondering if anyone has any advice on where to go from here? I'll attach a few more images of problem areas below as well.

Thanks in advance!
Answer: Maybe choose this topology for the hand:

And you can clean the body this way:
Comment: Thanks moonboots, but I feel like this gets rid of proper edge flow which is what I'm looking for.
Comment: could you please elaborate?


How do I add a source IP range in an AWS security group?

Question: I can add IPs in the form x.x.x.x/24. But how do I add a range of say 50 IPs? It seems silly typing them all in!
Answer: Security Groups expect CIDR notation. Hopefully, depending on the range you're talking about, you can find a CIDR block that matches most of them, but for the outliers, you'll need to add them manually.
For the future, try and design your network around subnets instead of "ranges".
Comment: @GodAtum If you're not working on something insanely secure, `x.x.x.0/24` will whitelist x.x.x.0 - x.x.x.255. If you really need it to be .51 - .250, use something like http://www.ipaddressguide.com/cidr#range to get the list (in your example, `x.x.x.51/32 x.x.x.52/30 x.x.x.56/29 x.x.x.64/26 x.x.x.128/26 x.x.x.192/27 x.x.x.224/28 x.x.x.240/29 x.x.x.248/31 x.x.x.250/32`).
Comment: Its a whitelist to unblock a set of static IPs that the ISP has issued. Unfortunately I dont have control of that. They are like x.x.x.51 - x.x.x.250
Answer: Not sure if it's related to your use case, but what we do is that clients need to be connected to a VPN in order to access a certain service on a server, e.g. RDP. The VPN server has a elastic IP and therefore I only need to add one IP address to the security group for this service (e.g. RDP).
Comment: Can you add the VPN service into the server you're trying to protect? Or does this VPN have to exist on an external server?


Should we answer questions if the answers can be found elsewhere on the site?

Question: I have this confusion all the time, I see people posting some questions which aren't exactly duplicate to other questions on Stack Overflow but with a little google search, the answer can easily be found on stack overflow for those questions. So should we answer those questions or flag them?
Comment: Sometimes people answer the question beause they cannot find a duplicate, or because they are not sure that it will be closed. It happens that we see the same person *both* write a short answer and vote to close the question. That's ok.
Answer: If you have the rep, vote to close as an exact duplicate. If you don't, put a comment pointing to the duplicate, and others will pick it up and VtoC (I think this will be just as quick as flagging for a moderator, depending on how niche the subject matter is). Repeating the same answers doesn't really help anything, even if you repeat all of the answers and all of the comments. This just splinters the knowledge. Keeping the duplicate question closed can be helpful if the wording or content is significantly different (it can direct users to the same answers even if they used different search terms).
Comment: That depends, if the questions are different but the ANSWERS still solve the question, then vote to close as duplicate. If the answers on the old question don't solve the new question, then regardless of how the question is worded, it doesn't sound like a duplicate to me.
Comment: If the answer to another question is likely to be useful (because it's related) but is not actually an exact duplicate, you can just post a comment with the link and something like "related question".  If you wanted to, you could post an answer with a summary of that link, and what needs to be done to turn that related answer into a solution for the OP.
Comment: as i said before, the questions aren't exactly duplicate, but if they do a little google search they can easily get their way to similar questions on stack over flow, so in that case flag or answer?
Comment: okay, I'll keep that in mind.


When and Why is XML preferable to CSV?

Question: sometimes it feels like XML has been used just because it was fashionable.
Answer: Some strengths:

You can validate XML data against XSD
You can easily provide contracts (as XSD) to other parties that should either create/consume XML data, without literally describing them
You can have one to many relations in multi-levels in XML data representation
XML is arguably more readable than CSV
XML is natively supported by the .net framework

To name a few from the top of my head.
Comment: XML is more readable than CSV - > far from always! firstname,lastnames like John,Doe Bart,Smith Will,Bate as opposed to the whole  stuf for example. With few fields, the tags make things often less readable
Comment: This list is already quite good. In my opinion, you should also add that there are standard parsers available everywhere, and that XML compresses quite good, so the larger size is not really an issue.
Comment: +1 But XML is not always more readable
Comment: @Peter & @surfrbum: I didn't say that XML is **faster** readable than CSV. If you only have few columns, CSV is almost certainly faster to read. When there are lots of columns CSV is impossible to read especially when there are undefined values inside. But I edited my answer anyway. :)
Comment: I feel XMLs are intuitive to read especially when they hold hierarchical data. Imagine reading a comma separated App.Config file!.
Comment: well, I would say it's a kind of biaise opinion as there is no weakness presented. and therefore give an incomplete information.
Comment: It was never stated to be unbias.
I work with csv a lot.l Don't like it one bit.
Its only advantage is that file sizes are significantly smaller for large datasets.
altho oleDB does allow a schema.ini file to specify datatypes it is very hacky imo.
I am strongly leaning towards not using csv anymore.
Comment: "XML is more readable than CSV - > far from always!".
Comment: @SteJav: You've  misread the statement. *XML is **arguably** more readable than CSV* is the way that's written.
Comment: Xml vs CSV is a trade off. XML gives you all of these wonderful features at the cost of speed and efficiency.
Comment: Robert - No mis-reading. "...You've misread the statement. XML is arguably more readable than CSV..". Hence my statement stands:- "far from always" is therefore not incorrect.
Answer: .csv files are good when your data is strictly tabular and you know its structure.  As soon as you start having relationships between different levels of your data, xml tends to work better because relationships can be made obvious (even without schemas) just by nesting.
Comment: This has been my experience as well, when choosing between xml and csv.  If your data naturally lends itself to a structured table format, then csv may be the best choice.  If not, xml may be the safe choice.
Answer: XML has become the default for its many benefits that lots of other people have already mentioned. So the question really becomes "When and Why is CSV preferable to XML?".
I feel CSV is preferable to XML when:
- you are loading simple tabular data
- you are in control of both the generation and consumption of the data file
- the dataset is large
CSV is perfectly usable if the first 2 points are true, and has a performance benefit that becomes more significant the larger the dataset is.
I did a quick test loading ~8000 records each with 6 text fields. Loading and parsing the XML took ~8 seconds. Loading the CSV took less than 1 second.
The overhead of XML is worth it in a lot of cases, but when the stars align, CSV makes more sense.
Answer: CSV is useful when you just have a series of a values that relate to some piece of information and you know you will always store values for each field.
XML has the benefit of having self-describing data (tags) and having hierarchy - which gives you a lot more flexibility in the way that you store the data.
Answer: I found an interesting performance test on the net. God example of drawbacks of XML when the features of XML is not needed.
"I tried Steven's experiment from a different angle. I filled an Excel XP
spreadsheet with a single-digit number, saved it in both XML and in a
comma-delimited text file (CSV). I then compressed both with WinZip and then
opened both with Excel. Here's what I found:
The XML file was 840MB, the CSV 34MB -- a 2,500% difference
Compressed, the XML file was 2.5MB, the CSV 0.00015MB (150KB) -- a 1,670%
difference.
Equally dramatic is the time it took to uncompress and render the files as
an Excel spreadsheet: It took about 20 minutes with the XML file; the CSV
took 1 minute -- a 2,000% difference."
http://www.xml.com/pub/a/2004/12/15/deviant.html
Comment: That's a limit case because you have a lot of small data with a '' delimiter that weighs the file.
Answer: You can have a much more complex hierarchy, etc. and structure with XML vs. CSV. It offers a lot more flexibility.
Comment: Flexibility always comes with complexity. The more stuff your TV does, the more buttons on the remote.
Answer: XML is preferrable over CSV when the data is unstructured (unknown schema) and will be read by a human.
Arguably, unless the data contains predominantly text, CSV is also meant for human consumption.
Also relevant, is if your data is 2 or 3 dimensional.
CSV is most suitable for 2 dimensional text, and due to its' verbosity, XML works well with 3 dimensional data.
The whole "standardness" of XML is hyperbole, and should not be taken literally. XML does have huge technical issues and many of the solutions aren't particularly elegant, or in many cases useful:

It uses text to specify its own text-encoding (chicken and egg?)
None of the more common schema languages for XML work particularly well.
The ancient and commonplace way of creating mark-up languages using <tags> is not particularly helpful as a standard.
XML tries to retroactively shoehorn more powerful mark-up languages such as the SGML based ones, into itself, creating a mess of incompatible legacy.
It still remains to be determined whether or not XML text escape sequences can work for anything but the most simple cases (ie. friendly data).

To be clear, XML is probably the incorrect choice for 90% of the data interchange it is currently being used for, since those uses break some or all of the above assumptions.
Answer: Of course it is fashionable and buzz-worthy sometimes. It all depends on your application. I prefer config files in XML because they are easy to parse. Whereas, I use CSV files for DataGridView or database dumps.
This Daily WTF : XML vs CSV The Choice is Obvious will help you make your decision ;)
Answer: I have found of the greatest advantages of XML to be the parsing functionality and the strict validation that comes out-of-the-box with most XML libraries. The insistence on well-formedness and easy-to-understand error message (xyz not closed in line x, column y) are a real help compared to hunting broken values, or unknown behaviour, because of an error in the CSV file.
Answer: In addition to the other answers, XML allows you to specify which character set the document is in.
Answer: CSV is more lightweight if you want to move things about since its normally 2  more times smaller than XML
XML is standard and won't be hit by different OS'es version of CSV
Comment: If you use attributes you can really cut down on how large the XML is.
Comment: You can also compress XML quite good, even if you don't use attributes. I have some test data here that compressed XML with really small (read: one to three letter tags and attributes) elements is compressed to about 14% of the original size.
Answer: I don't have enough reputation to comment on the relevant answer, but someone suggested compressing the XML as a way to gain size parity with csv formats. While this is true, XML compression can somtimes come back to bite you. If you are transferring XML data from point to point and it fails, it's nice to be able to read the XML and figure out what went wrong. If the XML is compressed and the transfer fails, it's sometimes not possible to decompress it and examine the contents. In other words compressing XML cancels out the human-readability advantage it has.
Comment: That's why you compress it with gzip (transparently using zlib) you can view the data with zcat as easily as you can cat a CSV file and gzip -t will tell you if there has been any corruption. How do you know if your csv file has been corrupted?
Answer: I would say use XML (and or JSON) because someday you or someone (with a short temper and a large gun collection) may have to go find an error in the CSV data.
So yes, I'm saying readability, don't forget to think of the other guy! He may be thinking about you.
Comment: +1 lol yes very true - Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
Answer: XML provides a way of tagging your data with metadata (provided by the tag names and attribute names), whereas CSV does not. Couple this with the ability to define structured hierarchies and it makes XML easier to understand when provided with just the data, whereas CSV would require an accompanying tool or document to describe how each value is interpreted.
Answer: You can easily traverse through XML data even when you have complex data.
Check these links:

The Advantages of XML Over CSV
XML vs CSV
XML vs CSV : The Choice is Obviou
Answer: Structured, human readable, easier to edit, validation, parsability, transformability, typing, namespaces, powerful libraries behind it, are all amongst many of the reasons.
Above all else though it is standard.
Comment: HTML is SGML. XML is SGML. HTML is NOT XML. XHTML is XML.
Comment: Good point. Strong similarities being XML is SGML, but yes HTML is not XML. XHTML is my preference these days. I like my HTML to be as structured as XML.

Still preferable to coding a web site in CSV though ;)
Answer: And again one more for XML: The X in XML stands for Extensible (I know, not really mnemonic :-P). That means, with the help of the XML namespace mechanism, you can join any two XML languages you like and combine them in the same document. Given that there is only one CSV 'language' (not counting the myriads of delimiter styles), XML can handle quite a lot of complexity, and that in a modular way.
This however, is the advantage of CSV: If you really have tabular data, XML syntax is most often overkill.
Comment: only one CSV 'language' = Quick question what's the separator for a csv file in the european version of Excel?
Answer: I've also found that some cvs generators/parsers have a lot of difficulty with general text data.  Long text strings with a lot of carriage returns and commas and quotations, etc etc, just make life really difficult when it comes to manipulating a cvs.
SSMS likes to truncate csv for fun.
Comment: Exactly the problem. If you are considering csv, you should more consider colon separation such as, key:value:key:value or whatever. This is how *nix has always done it and for good reason.
Answer:
There are existing parsers and emitters for it in every language and database
They deal with encoding for me
They deal with escaping for me

That's all that matters to me.
Sure, there's a semi-standard way to do escaping in CSV (i.e., "the way Excel does it"), and it's not exactly hard to write yourself, but it does take some time.  And then you've got to implicitly agree on a character encoding out-of-band.  But then, because it's so simple, people try to write it themselves, and invariably screw up either #2 or #3.
JSON also meets #2 and #3 and is getting close to satisfying #1.  It's also arguably simpler, at least for non-document files.  Not surprisingly, I find myself using it more and more, internally and externally.
Answer: And I also prefer it because it's much more readable.

When and Why is XML preferable to CSV?


Did the Daleks kill Davros?

Question: I read that the Daleks from Doctor Who put their creator, Davros, on trial. Does anyone know if they killed him, or at least what happened to him afterward?
Comment: Can you [edit] to include the information you found then? It would be helpful to know where to search for this.
Comment: Where/when did this happen? In a TV episode, novel, comic, Big Finish audio, ... ?
Comment: i read that they did this in a TV episode on wikipedia, when I was doing research on them.
Comment: [*The Trial of Davros*](https://en.wikipedia.org/wiki/The_Trial_of_Davros) (theatrical production)? [*The Davros Mission*](https://en.wikipedia.org/wiki/The_Davros_Mission) (audio play)?
Comment: I think OP is referring to the end of the episode *[Revelation of the Daleks](https://en.wikipedia.org/wiki/Revelation_of_the_Daleks)*, but they would need to clarify that themselves.
Answer: This happens in the Sixth Doctor story Revelation of the Daleks, broadcast in two parts in March 1985. From Wikipedia's plot summary:

Daleks loyal to the Dalek Supreme arrive from Skaro, called by Takis who now realises what has been going on. Takis leads the grey Skaro Daleks to Davros' laboratory, where they are met by cream and gold Necros Daleks who are loyal only to Davros. A battle ensues, during which Davros' only usable hand is shot off by Orcini. The grey Daleks then take Davros to Skaro to stand trial.

However, the audio story The Juggernauts, first released in 2005, revealed that Davros never actually stood trial - the prison ship that was carrying him crash-landed on the planet Lethe, allowing Davros to escape his captors. So no, the Daleks didn't kill him or do anything else to him, because they never got the chance.
It's worth noting that the Daleks have attempted to kill Davros on multiple other occasions. Notably, the first story he appears in, Genesis of the Daleks, ends with him being shot and seemingly killed by his own creations when they realise he is not a Dalek himself and thus "impure". However, Revelation of the Daleks was the only time they attempted to make him stand trial.
Comment: okay, thanks! this has helped my studies of doctor who significantly!

Did the Daleks kill Davros?


Why is my cats top fur matted?

Question: What causes my cats matted fur? I think its sap from the bushes she crawls into. Others say long haired cats get knots when they shed.
Comment: Welcome to Pet Exchange, what breed is your cat?
Answer: All cats shed, and even short haired cats can get mats when they shed; long haired cats are even more prone to it. The best way to prevent that is by regular grooming. (Some cats will self-groom efficiently enough, but may develop hairball problems). Try brushing once or twice a week to see if that helps. If sap is causing the problem, I would expect it to be sticky. If the mats seem to be dry and not brittle, then shedding is most likely the problem.

Why is my cats top fur matted?


How can I set up a tax rate for all countries?

Question: I want to sell my products in every country in the world for a fixed tax rate on all my products. How can I do this?
Answer: In order to setup a fix tax rate,you need to follow process::

Add New Attribute with the attribute settings select Fixed Product
Tax from the drop-down menu Catalog Input Type for Store Owner
Assign that attribute to  Attribute Sets
Add tax to product  from manage product
By default, fixed product taxes are disable so in addition to all the
above things you also need to enable fixed product taxes. To do this
go to System menu > Configuration > Tax button in the Sales section on
the left > Fixed Product Taxes panel on the right. Then set the Enable
FPT drop-down menu to Yes. and click on the Save Config

See more detail here


What does it mean to equilibrate a column in size exclusion chromatography and why is a buffer used?

Question: I'm reading a procedure on size exclusion chromatography and it says that the first step is to equilibrate the column with buffer. What does this mean?
Comment: *To equilibrate the column with buffer* just means to run the column with the buffer only for a while.
Comment: Why is this done?
Answer: You want to make sure that your protein does not get damaged in the separation process. The protein travels faster than the small solutes in its solution, and will encounter the small molecules that are on the column, i.e. it will encounter different ionic strength, pH etc. So before you apply the protein solution to the column, you make sure the column is treated with an appropriate solution.
The solution is often called the buffer because it contains pH-controlling buffer substance. You can use size exclusion chromatography to separate by size, but also to switch from one buffer (or more general: one set of small solutes) to another. This is called buffer exchange, and there are short thick columns for that purpose (for separation, you would use a long thin column).


What are two eleven letter words with distinct letters?

Question: By this I mean two 11 letter words that contain 22 different letters. Do words like these exist?
Comment: My guess would be no, because of the heavy restriction on the vowels. Do you suspect that something like this could exist?
Comment: Can you please define "word"? What dictionary are we using? Are proper nouns, plurals, conjugations, loanwords, etc. allowed?
Comment: I originally misread the problem as finding 11 2-letter words, using each letter at most once.  The maximum turns out to be 8: aa, by, de, jo, mm, nu, qi, sh
Comment: Pretty much anything should work.
Comment: Hello and welcome, the [tour] and [help] should explain what is on topic here. This doesn't look look like a puzzle or about making a puzzle. Maybe you could [edit] that in. As for the question of what you define to be a word, and anything should work... Would you accept these two words I've just made up: Abcdefghijk and Lnmopqrstuv ? That's an extreme example, but  you really should pick a word source to let answerers know if their words would be valid of not.
Answer: My answer is

 No. There does not exist a pair of unique 11-letter English words that both each have 11 different letters and also do not share letters.

My method for finding this answer:

 I grabbed all the 11-letter words from http://www.allscrabblewords.com/11-letter-words/ and made a list of words that contained 11 unique letters. This list has 363 words. I then checked each pair of words to see if any pair didn't share letters. Unfortunately, this check revealed 0 word pairs.

The OP asked a secondary question, and my answer is:

 Question: Which 2 11-letter words contain the most distinct letters
 It took less time than I expected to run through all combinations, but I found 15 pairs of words that have 20 distinct letters. The first pair that also each contain 11 distinct letters are:
downrightly lumberjacks
Comment: It would take a lot longer because the full 11 letter word list is rather large. Finding the greatest number of distinct letters from 2 11-letter words that each have 11 distinct letters is a much quicker ask.
Comment: Would you be able to use this method to find two words that contain the greatest number of distinct letters possible?
Comment: I did the same thing as Joel and got the same answer (too slow though).  @HyperioxX - Do you mind if I ask what the goal is?  It feels like you're trying to do something specific with this.
Comment: It's for an eleven letter wordle game, and I'm trying to figure out the best combination of two words to start with. Ideally I don't really care about q, x, z, and j, but whichever two words cover the most letters are ideal.
Comment: I ran this search against a larger word list (called "british-english-insane", with more than 1111 words of exactly 11 letters), no hits there either.
Comment: My favorite word pair, missing only fjqvxz, is patchworked stumblingly


How do I add in a octagon shape from a plane mesh?

Question: I'm new to Blender and currently watching tutorials on modeling. In this video, at 6:50, the person adds a Plane mesh that is already in a octagon form; it has 4 vertices but looks like an octagon. I've been trying to find out how he did this but can't find out the answer.
Comment: Could you be more specific. I see two planes, but not an octagon. You can add up to 2 screenshots to further explain your problem.
Comment: The guy does add in 2 planes but they look like octagons as seen by 6:57. When I try to add in a plane in my project, they look like complete circles.
Answer: To have an octagon out of a square (4 vertices) add a subsurf modifier

To make a real octagon add a mesh>Circle and make it 8 vertices:
Answer: The guy does not have Screencast Keys enabled, but if he did, you would know that he keyed Ctrl + 1 (1, not Numpad 1), which is the keyboard shortcut for adding a Subdivision surface modifier immediately after adding the plane.
If Ctrl + 1 doesn't work for you, you can go to the Properties panel > Object modifiers tab and add a Subdivision Surface modifier manually. Even if you use the shortcut, you still need to tweak the settings in that tab. A normal Subdivision Surface modifier looks like this:


Managing flame direction (Cycles)

Question: I have a fire on my scene and it goes upwards. I want it going in a horizontal direction. How can I achieve that? Changing Temperature Difference only flips direction in the vertical axis.
Comment: Wind force field can help with this issue but it is still unknown if it possible to control flame direction by flame settings.
Answer: Overview:

You can control flame direction by Normals from Mesh that is your Flow object. In this example I'm using Circle filled with Triangle fan.
Mesh:

As I said before, simple Circle. You can check where Normals direction will go in Edit Mode > Mesh Display tab > Normals.
Flow:
Now in Flow settings you'll need to turn on Initial Velocity. Set Source to 0 and Normal to something higher then 0. This value will control the initial flame speed. By now flame will be rising but we can change it in Domain settings easily.

Domain:
In Domain settings you will need to set Temp. Diff. to 0. This will make flame straight. Higher value = faster smoke rising.

Managing flame direction (Cycles)


How can I do mod without a mod operator?

Question: This scripting language doesn't have a % or Mod(). I do have a Fix() that chops off the decimal part of a number. I only need positive results, so don't get too robust.
Comment: Could you mention and maybe tag which "silly" scripting language you're talking about?
Comment: Heh. It's some embedded language on this Roku digital signage video player. It probably does have a Mod somewhere but I sure can't find it and it has like Arctan() and NaturalLog() so I'm really confused how they skipped Mod.
Comment: I think it's a silly language called "homework"
Comment: glsl before 3.0 also lacks mod for integers
Answer: Will
// mod = a % b

c = Fix(a / b)
mod = a - b * c

do? I'm assuming you can at least divide here. All bets are off on negative numbers.
Comment: depending on what you want for negative numbers, it can be adjusted. there is `fix()` that always truncates and there is `int()` that always rounds downwards (`int(-2.5)=-3`)
Answer: For posterity, BrightScript now has a modulo operator, it looks like this:
c = a mod b

Comment: @MDXF - it does not provide answer to the *title* of the question but materially answers is: if you read the body, it says "This silly scripting language doesn't have a % or Mod()" - that was the case at 2010 but no more.
Comment: This does not provide an answer to the question.
Answer: a mod n = a - (n * Fix(a/n))
Answer: If someone arrives later, here are some more actual algorithms (with errors...read carefully)
https://eprint.iacr.org/2014/755.pdf
There are actually two main kind of reduction formulae: Barett and Montgomery. The paper from eprint repeat both in different versions (algorithms 1-3) and give an "improved" version in algorithm 4.
Overview
I give now an overview of the 4. algorithm:
1.) Compute "A*B" and Store the whole product in "C" that C and the modulus $p$ is the input for that algorithm.
2.) Compute the bit-length of $p$, say: the function "Width(p)" returns exactly that value.
3.) Split the input $C$ into N "blocks" of size "Width(p)" and store each in G. Start in G[0] = lsb(p) and end in G[N-1] = msb(p). (The description is really faulty of the paper)
4.) Start the while loop:
Set N=N-1 (to reach the last element)
precompute $b:=2^{Width(p)} \bmod p$
while N>0 do:
    T = G[N]
    for(i=0; i<Width(p); i++) do: //Note: that counter doesn't matter, it limits the loop)
        T = T << 1 //leftshift  by 1 bit
        while is_set( bit( T, Width(p) ) ) do // (N+1)-th bit of T is 1
            unset( bit( T, Width(p) ) ) // unset the (N+1)-th bit of T (==0)
            T += b
        endwhile
    endfor
    G[N-1] += T
    while is_set( bit( G[N-1], Width(p) ) ) do
        unset( bit( G[N-1], Width(p) ) )
        G[N-1] += b
    endwhile
    N -= 1
endwhile

That does alot. Not we only need to recursivly reduce G[0]:
while G[0] > p do
    G[0] -= p
endwhile
return G[0]// = C mod p

The other three algorithms are well defined, but this lacks some information or present it really wrong. But it works for any size ;)
Comment: Hi @shalec - we do not encourage answers that only contain links to outside resources. These [link-only-answers are discouraged](https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers).
Comment: Can you copy and paste the relevant parts of the linked PDF into your answer? That would greatly improve the quality of this post.
Comment: Of cause. There are 4 algorithms mentioned. I will edit those.
Answer: What language is it?
A basic algorithm might be:
hold the modulo in a variable (modulo);
hold the target number in a variable (target);
initialize modulus variable;

while (target > 0) {
  if (target > modulo) {
    target -= modulo;
  }
  else if(target < modulo) {
    modulus = target;
    break;
  }
}

Comment: I think there is an error for the case where `target==modulo`. Infinite loop.
Answer: This may not work for you performance-wise, but:
while (num >= mod_limit)
    num = num - mod_limit

Comment: by not working performance-wise, did you mean like when num is around 2**63 and mod_limit is 3?
Comment: @tloflin, hope you don't mind but it should have been ">=" rather than ">".
Answer: In javascript:
function modulo(num1, num2) {
  if (num2 === 0 || isNaN(num1) || isNaN(num2)) {
    return NaN;
  }

  if (num1 === 0) {
    return 0;
  }

  var remainderIsPositive = num1 >= 0;

  num1 = Math.abs(num1);
  num2 = Math.abs(num2);

  while (num1 >= num2) {
    num1 -= num2
  }

  return remainderIsPositive ? num1 : 0 - num1;
}

Comment: While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations!


Why wouldn't Wolverine use Sabretooth's help when he time-travelled to 1973?

Question: It was shown, in X-Men Origins: Wolverine, that from their childhood days to 1975, Wolverine and Sabretooth were together. In X-Men: Days of Future Past, when Logan travelled through time back to 1973, why wouldn't he seek help from Sabretooth?
Comment: Time constraints in the plot as well as character conflicts and how long a movie would it have been?
Comment: @Himarm: Hey, at least it had Liev Schreiber.
Answer: For one thing, Wolverine was kind of busy and working on a schedule. It would have been difficult to go to the trouble of tracking down Sabretooth, particularly if Victor was on a mission for William Stryker at the time. He could have been literally anywhere on Earth, and Logan, having suffered serious memory loss at the end of X-Men Origins: Wolverine, and likely still not regaining all of his memory even by the time of the film The Wolverine, may very well not have remembered where Victor was at the time.
You must also remember that Victor and Logan weren't exactly on good speaking terms by the time the present-day events of X-Men: Days of Future Past took place. Victor had murdered several of Logan's friends, attempted to murder several others, broken Logan's original bone claws, worked with Stryker, attempted to kill Logan, joined up with Magneto, fought the X-Men on several occasions, and shown a severe bloodlust which included at least one attempted rape. It is highly unlikely that this is the sort of person Logan would turn to for help, even if most of Victor's crimes were still in the future.
Comment: Your answer would be valid if DoFP took place AFTER the events of X-Men Origins: Wolverine. As the OP stated, however, DoFP is two years prior to Logan leaving Team X.
Comment: @Omegacron: Because Victor and Logan's relationship was so healthy when Victor was trying to rape Vietnamese girls? I took account of the two year time difference in my answer.
Answer: Because he does not remember where Sabretooth was. Maybe Sabretooth was right now in China meanwhile Wolverine in America. Wolverine had no time to "search" Sabretooth.

Why wouldn’t Wolverine use Sabretooth's help when he time-travelled to 1973?


Consistency in a list

Question: When listing a number of things in a sentence, I know the word form of the items must be consistent like verb1, verb2, verb3 and so on. My question is, can gerund phrases and nouns can be in a list? Is a gerund phrase considered a noun? For example, "This surgical device is used for cutting parts, incision, insertion, and fixing components." It sounds wrong to me. Thank you.
Comment: cutting parts?? fixing components??
Answer: Yes, gerunds can be used  in lists. To do so, you have to supply a verb to go with nouns.
Please use the following methods for cleaning the houses:
1 - vacuuming the indoor steps
2 - washing the kitchen floors
3 - spraying decks with hoses (if a hose is available.
So, then, in your example, you'd get:
This surgical device is used for: add a verb to each
- cutting parts
- making incisions
- inserting parts
- and fixing components.
That can also be written:
This surgical device is used for cutting and inserting parts, making incisions and fixing components.
[I said inserting parts as an example. It is probably not medically accurate.]
One just has to find a verb to accompany the noun to create parallelism.
Comment: Okay, thank you. But what I meant was, can gerunds and (strict) nouns together be in a list? Like in "The device can be used for incision, insertion, and fixing components." Or do all the items have to be either in gerund form or in noun form like in your answer,
Comment: I advise using one or other, not mixing them. incision, insertion and  components or my example.  Be aware that if you say; ***can be used for cutting parts***, that is very ambiguous: can be used for cutting parts [ can mean ***to cut parts*** or ***parts that cut***]. The same is true for "used for fixing components." It is ambiguous. It's best either to list nouns or list actions. My example avoids the ambiguity through providing a verb for each noun. Otherwise, you could use: cutting, incising, inserting and affixing.
Answer: Ideally, parallelism should be maintained in all aspects of sentence construction.
In your example, there are many different ways of doing this.
Here are some possibilities. I am using exaggerated examples in some cases to make a point, and assume they would not be actually acceptable replacements:

This surgical device is used for cutting, incising, inserting, and fixing components.
This surgical device is used for cutting parts, incising skin, inserting pieces, and fixing components.
This surgical device is used to cut, incise, insert, and fix components.
This surgical device is used to cut parts, incise skin, insert pieces, and fix components.
This surgical device is used for separation, incision, insertion, and correction.

Of particular note is a problem with this construction:

This surgical device is used for cutting parts, incising, inserting, and fixing components.

Even though all verbs use an -ing form, two of the items specify items being acted upon and the other two don't. (What's being incised? What's being inserted?)
This is corrected in 1. by suspending mention of a noun until the end of the sentence; the verb in each list item acts on this thing. In 2., it is corrected by having each list item mention its own noun.

Consistency in a list


Are there any bills that do not need to be paid at all?

Question: Do all bills need to be paid, or are there any types of bills that do not need to be paid at all?
Here are some examples that I can think of:

A bill that claims a service that I never received.
A bill that is too old.
An unfair bill.
Comment: This question feels too broad. There are an almost an infinite number of bills you should not pay... For products you didn't order, bills not addressed to you... Try and be more specific on what kind of bills you are thinking of not paying, that would make this question better.
Comment: Also define "need". You never "have" to pay any bill. There just may be consequences to not paying.
Comment: @Gendolkari, I mean, by not paying the bill, there is no consequence whatsoever.
Answer: Sure, there are all kinds of reasons why you may not be legally obligated to pay a bill.
The most obvious would be if the bill is fraudulent. If I sent you a bill for a product that I had never sent you and that you never ordered, that's pure fraud, and you are certainly not obligated to pay it.
If we had an agreement but you are not satisfied that I lived up to my part, that's more complicated. Like if, say, I said I'd repair your car for $500, and I really did some work but that car is still not running correctly, you have grounds to dispute the bill, but you can't just refuse to pay and suppose that that will be the end of it. IF you can't work it out with the other party, your only legal recourse is to go to court. (Or maybe some form of binding arbitration.)
In the United States, there is a statute of limitations on how long someone can wait to collect a bill. In my state of Michigan, for example, someone to whom you owe money in general has 10 years to bring a lawsuit against you. If they wait more than 10 years, there's nothing they can legally do to force you to pay. (Don't rely on this number, I'm just using it for an example. There are special cases and different categories and whatever.)
I just got married last year and a debt collector apparently found out and I guess figured I might have more money than she did, and so sent us a bill for a 30 year old debt contracted by her first husband whom she divorced like 20 years ago. There was some fine print on the bill that said that the statute of limitations had expired and so if we didn't pay they could not sue us or hurt our credit rating. (I'm guessing they were required by law to say this and didn't include it just because they wanted to be nice.) If it was for something that was really for her, maybe I would have felt morally obligated, but it was for something her ex had bought for himself. So we just ignored it and have heard nothing further.


Connect firewire MacMini to thunderbolt MacBook Pro

Question: I have a MacMini that only has a firewire port, I want to connect it to my MacBook Pro via its thunderbolt port, can I do this so that I can then (using target mode) display my Mac mini on my macbook pro)? What equipment would I need todo this?
Answer: You would need a Apple Thunderbolt to FireWire Adapter.
You can find it here for $29
Please also read this.
Apple's Thunderbolt FireWire adapter can connect to Macs via both ends, but can only be used in one direction.


I Recieved an Error Trying to Add A Synonym, Why?

Question: I tried to propose a tag synonym for ww2, but I received the error "Only moderators can propose version specific synonyms".  I thought after 1200 rep, you were able to propose tag synonyms.  Does anyone know what this means?
Answer: Looks like we have a bug with detecting tags that apply to different versions of software - an artifact of the Stack Exchange platform being born out of programming Q&A. :)
I've passed it up the chain to the dev team.
Answer: It's supposed to be 1250, maybe your rep was not synchronized?  That's about the only thing I have seen before, where what I see as Rep was not quite what I was gettng for tools but an hour later all was fine.
Try again and if you get an error let us know.
Comment: Yeah, that's kind of what I thought.  I'll update this when it becomes more clear.
Comment: Tried again.  Recieved this error:
*Failed to propose synonym:

Version specific synonyms can only be created by moderators*
Comment: heh...must be a permissions thing.  If you let me know the synonym, I'd be happy to add it.
Comment: Yeah, its "wwii".  I still have no idea what a "version specific synonym" is.  I assume it must be more privileged than a run-of-the-mill synonym.
Comment: I think its the fact there was already a tag for wwii that was used on two questions, since one was already closed I did the merge so the synonym now exists anyway.  And two questions got updated.  So all good.


What happens when the Call of Duty 4 - Modern Warfare solo campaign is beaten on a higher difficulty?

Question: I played through and beat the solo campaign of Call of Duty 4 - Modern Warfare on the Recruit difficulty when I first purchased the game a long time ago.  I vaguely remember the game telling me to try beating it on a higher difficulty.  Do you get a multiplayer perk or something?
Answer: As far as I know, the only difference is (on 360, possibly on PS3 too) there is an achievement for beating the game on one of the top two difficulty settings, and several achievements for beating groups of missions on the top difficulty setting.
Comment: That's the only difference on PC as well.
Answer: Once you've completed the single-player campaign, you get access to a mission called 'The Mile High Club'. When completed at Veteran level, you get a Achievement that's normally the one you need to get the full 1000/1000 on the XBox version.
Answer: I've beaten it on Veteran.  There's absolutely no difference other than that it's a HELL of a lot harder.
Comment: The only parts I found hard were defending the computers in the estate and the boat ride out. Compared to MW1, it was easy.


Novel in which an alien ship crashes & the teen survivor helps thwart an alien invasion

Question: I'm looking for a teen paperback novel that's at least 20 years old. An alien ship crashes & the only survivor was a teenage boy. I think the captain of the ship was his uncle or father, & had the boy get into an emergency pod. He had two hearts, and telepathic abilities. He required a higher oxygen content at night, but could manage without the extra oxygen during the day. He befriends two human teenagers - I think it was a boy & a girl. He, his friends, and (I think) a military group end up thwarting an alien invasion. The aliens took over human bodies. He could recognize the aliens by their thought patterns or a feeling, & humans could recognize them by an odd look or possibly shimmer in their eyes. It ends with the boy returning to his home planet, & his friend gave him a packet of grass seeds for his home planet, because it had almost no vegetation.
Comment: Except for the ending, this matches the *Animorphs* series by K. A. Applegate.
Comment: I know the exact novel you are talking about. I read it as a kid. I remember the boy crashed on the planet from an escape pod. He used his telepathy to help learn our language faster. The other aliens would take over bodies and to kill them you had to force it out of the body and stab it through the eye. I wish I could remember the name of the novel. It was only one book, though. not a series. could be from the 70's or 80's.
Answer: From Science fiction book about an alien boy with two hearts
The book is The Boy Who Saved Earth by Jim Slater.
Summary:

He came from another planet. Unfortunately he did not come alone… When
  evil alien forces attack Earth and intend to destroy it, Marcou – the
  14-year old from outer space – must use his telepathic powers and
  ultra ray secret weapon to try to stop them.

One of the Goodreads reviewers says:

I remember reading this as a kid back in the 90s. Although I don't
  remember much about the plot anymore (except that he saved Earth, of
  course), I remember enjoying reading this book and giving me a taste
  of what sci-fi has to offer and for that I always appreciate this
  book. This is probably out of print now but I was prompted to look up
  this book here on Goodreads after seeing a picture of two hearts in an
  alien somewhere on the web because the alien boy has two hearts! I
  also, for some reason, have never forgotten the last line of this book
  which is "grass might grow on Gundra (the home planet of the boy)."


What to do when KMeans returns fewer than K clusters?

Question: I've implemented K-Means in Java and have a bit of a head scratcher.  I select my initial centroids by choosing a random value in each dimension within the range of values of the data points.  I've run into cases where this results in one or more of these centroids not ending up being the closet centroid of any data point.  So what do I do for the next iteration?  Just leave it at its original randomized value?  Pick a new random value? Compute as an average of the other centroids?  Seems like this isn't accounted for in the original algorithm, but probably I've just missed something.
Answer: Most implementations of k-means define initial centroids using actual data points, not random points in the bounding box drawn by the variables. However, some suggestions for solving your actual problem are below.
You could take another data-point at random and make it a new cluster centroid. This is very simple and fast to implement, and shouldn't affect the algorithm adversely.
You could also try making a smarter initial selection of cluster centroids using kmeans++. This algorithm chooses the first centroid randomly, and picks the remaining K-1 centroids to try and maximize the inter-centroid distance. By picking smarter centroids, you are much less likely to encounter the problem of a centroid being assigned zero data points.
If you wanted to be slightly more clever clever, you could use the kmeans++ algorithm to make a new centroid whenever a centroid gets assigned zero data points.
Answer: The way I've used it, the initial values were taken as random points from the data set, not random points in the spanned space. That means each cluster has at least one point in it initially. You could still get unlucky with outliers but with any luck you'll be able to detect this and restart with different points. (Provided "K clusters of points" is an adequate description of your data)
Answer: Instead of picking random values (which can be pretty meaningless if the space of possible values is large in comparison to the clusters), many implementations pick random points from the dataset as the initial centroids.


How to display User Mapping for offline databases?

Question: When I use the GUI (SSMS) to review the User Mapping, where the Login has mapping to a database that is offline (or otherwise not available) I get the message below and it only displays Mapping for databases that are online.

One or more databases are inaccessible and will not be displayed in list

All the details should actually be in the Master DB, there should be something I can run that will show me what the full User Mapping is.
How can I display User Mapping for offline databases?
Answer: You can use sys.databases joined with sys.server_principals
SELECT sd.NAME AS databaseName
    ,sp.NAME AS database_owner
FROM sys.databases sd
INNER JOIN sys.server_principals sp ON sd.owner_sid = sp.SID
WHERE sd.state_desc = 'OFFLINE' --> since you want for offline databases !

You can even use at your own risk --> sp_msloginmappings ( <-- Undocumented and unsupported :-) )
Comment: That helps, I would also like to be able to see if they are a user on a database not just the owner.
Answer: You are making a false assumption here

All the details should actually be in the Master DB, there should be something I can run that will show me what the full User Mapping is.

Consider that if you restore a backup from one instance to another, the database brings over all the existing users (database detail) without there having been a login (instance detail) created.
Even if you could query the master database for user information about offline databases it would only include information where a login exists.  Any users that have database user accounts without a login, would not be identified.
No one can read an offline database, your only option is to set the database to read-only, find what you want and set it back to offline (assuming it is offline for a reason)


Are all fixed-lens cameras mirrorless?

Question: As far as I can tell, consumer interchangeable-lens cameras are all categorized as single-lens reflex, rangefinder, or mirrorless. I feel like I never see these classifications used, though, for fixed-lens cameras like the Leica Q, Sony RX1, or Fujifilm X100T. Are all such cameras mirrorless or do some of them use a mirror and prism?
Answer:
Are all fixed-lens cameras mirrorless?

No. At least Olympus E-10 is DSLR (the mirror does not flip though, it is somewhat similar to SLT).
There may be more examples from film era, dunno.
Comment: Yes, a good few film-era examples from Olympus. When most manufacturers were producing interchangeable-lens autofocus SLRs, Olympus mostly opted for a non-interchangeable-lens reflex design which they termed "ZLR" - Zoom Lens Reflex.
Comment: There were a number of 'pellicle mirror' SLR's which had a fixed mirror, including the EOS 1N RS and the Nikon F2 HS. These mirrors were partially reflecting, so some of the light went up to the viewfinder and the rest went to the film. Advantages were that when motor driven these cameras had very high frame rates, and no vibration from mirror slap. Disadvantage was that the light hitting the film was attenuated by 1/3- the portion that was redirected to the viewfinder. Search for Pellicle mirror on Wikipedia for a comprehensive discussion.
Answer: Another example of no.
The dual lens cameras have a mirror. https://en.wikipedia.org/wiki/Twin-lens_reflex_camera
Not to expose the film, but they have one, and normally they have fixed lenses.
Answer: Probably all fixed lens cameras are mirrorless. The purpose of reflex viewing (the mirror) is for the viewfinder to be able show exact view of multiple lenses.  Today, the digital sensor can also show it.
My opinion is if they don't say Reflex, they are assumed mirrorless. We used to never need that distinction. :)
Twin lens reflex (Rolliflex or Yashica type) are fixed lenses, and are mirrorless in the film path, but the viewfinder second lens uses a fixed mirror.  I would call that mirrorless.  :)
Comment: A rangefinder is similar - there is no mirror in the path of the light that goes from subject to media at any time. There *is* a mirror, but that is for determining parallax for focus adjustments.
Comment: Reflex means there's a mirror in the viewing system, so it's surely an oxymoron to claim a TLR to be "mirrorless". I always think it's a bit silly anyway to try to pigeonhole older cameras into "mirrorless" or not - what's the point? At one point, Hasselblad marketing were printing nonsense that the SWA from 1954 was the first mirrorless Hasselblad.
Comment: Mamiya produced (popular but large and heavy) interchangeable-lens TLRs.

Are all fixed-lens cameras mirrorless?


HTTP website redirect all except 1 file to https

Question: I have a website where I'm wanting 1 file (version.txt) to be accessible via regular HTTP, but I want everything else to redirect to https. To do this, I added the "RedirectMatch" line below in my /etc/httpd/conf.d/somewhere.com.conf file (running centos7). Before I wanted to serve this file via HTTP, the line was a "Redirect permanent" type line. When I first made this change, I did some tests and it appeared to work; I was definitely able to access version.txt with plain HTTP, and I thought other accesses were being redirected to https. However, I just navigated to the website today and noticed it was all coming over HTTP. I have very little knowledge with websites, so I'm guessing that my testing for the redirect was faulty due to browser caching or something that tricked me into thinking it was working.
The question: in my conf.d file below, why doesn't the website redirect everything except version.txt to https? How can I change it so that it allows HTTP access of version.txt, but redirects everything else to HTTPS?
<VirtualHost *:80>
  ServerName somewhere.com
  ServerAdmin email@example.com
  DocumentRoot /var/www/somewhere.com
  ErrorLog /etc/httpd/logs/error_log_somewhere
  CustomLog /etc/httpd/logs/access_log_somewhere combined
  RedirectMatch permanent "^(/*version.txt/.*)" https://somewhere.com$1
</VirtualHost>
<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/somewhere.com_ssl_certificate.cer
  SSLCertificateKeyFile /etc/pki/tls/private/_.somewhere.com_private_key.key
  SSLCertificateChainFile /etc/pki/tls/certs/_.somewhere.com_ssl_certificate_INTERMEDIATE.cer
  ServerName somewhere.com
  ServerAlias www.somewhere.com
  ServerAdmin email@example.com
  DocumentRoot /var/www/somewhere.com
  ErrorLog /etc/httpd/logs/error_log_somewheres
  CustomLog /etc/httpd/logs/access_log_somewheres combined
</VirtualHost>
ServerSignature Off
ServerTokens Prod
Header always append X-Frame-Options SAMEORIGIN

edit: bonus if you have any ideas on what fooled me into thinking it was working at first
Answer: You can use the below redirection inside <VirtualHost *:80>.
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]

Above rule will redirect any context to https with context.


Distribution of binary sequences?

Question: I have two binary sequence and wanted to test if there is a similar patterns between the two. This is a completely new topic for me. Are there ways to define distribution of a binary sequence (distribution of 1, for example)? And how to check if the two sequence are similar?
Comment: Start with bitwise XOR
Comment: Thank you.  Could you please be a little more specific?
Comment: Say, you have two sequences of equal length: 1001 and 0001, then the bitwise XOR operation will give 1000, sum the bits you get 1. That's the difference. Compare it to 1001 and 0110, you get XOR 1111, the sum of bits is 4, i.e. for bits are different.
Answer: As Aksakal says, start with the bitwise Exclusive OR. A standard name for what he is proposing is finding the Hamming distance -- the number of places where the sequences differ -- between the two sequences.  It is easy to show that if the sequences are chosen at random (all $2^n$ are equally likely to be chosen), then the expected value of the Hamming distance is $\frac n2$.  Thus, if the Hamming distance is close to
$\frac n2$, the sequences are quite different. If the Hamming distance is close to
$0$, the sequences are very similar. If the Hamming distance is close to $n$, the
sequences are almost complementary to each other: flipping all the bits in one
gives you a sequence that is very close (in the Hamming metric) to the other.
If the Hamming distance is exactly $n$, the sequences are complementary,
for example, $1001$ and $0110$ in Aksakal's example.
There can be other measures of similarity that people can think of. For
example, $10111001$ and $01011100$ of length $8$ have Hamming distance $6$,
but the latter has the trailing subsequence $1011100$ which is just the leading
subsequence of the former. So, this is a "similarity" that is of interest
in several applications (especially in engineering which is where I am coming
from). Look for literature on Hamming autocorrelation and crosscorrelation
of sequences.
Comment: @bankrip, also consider this sequence 1010 and 0101. This would have hamming distance 4, as per Dilip's answer, but some could say the sequences are very similar. For instance, 1010 is a mirror image of 0101. Also, the simple one bit circular [shift](http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/bitshift.html) would produce 0101 from 1010 etc. It's important to figure out what does *similar* mean.
Answer: you need to first define in what terms you want to assess the similarities. For instance, you can think of the sequence $i$ of length $N_i$ being sampled from a binomial (with parameter $p_i$); here the comparison can simply be a comparison of $p_1$ and $p_2$. You can approximate them with normal (mean = $N*p*(1-p)$ and do T-test.
Another way can can be to look at higher order statistics (e.g., entropy) and compare the two sequences in that term ...
As you see, depending on the problem you want to solve, the comparison can have different meanings.

Distribution of binary sequences?


Connection pool to MySQL server?

Question: I find many resources about how to create the connection pool with JNDI to the MySQL Server; however, I want to know if I just want to use a standalone Java class to connect the MySQL Server and with a connection pool mechanism (without the help of app server), how could I figure it out?
Comment: Do not assume that using a connection pool is a good design. In practice it may create more problems than it solves.
Answer: If you are not using an app server to handle your connection pool, the other option are implement one yourself, where you have to pay attention to which connection is dead and re-init, hands out free connections upon request, etc... Here is a little light reading on it: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html
Other way is look for connection pool java packages such as this one: http://www.snaq.net/java/DBPool/, this is the first package I found googling, so I have no idea if it is good or not, just an example.
Answer: Tomcat's connection pool is a separate component named DBCP. You can download it and use it without Tomcat:
http://commons.apache.org/dbcp/
Another very popular connection pool is C3P0 (which I believe is used by Hibernate internally). It can be downloaded here:
http://sourceforge.net/projects/c3p0/

Connection pool to MySQL server?


Silverlight application will not install out of browser

Question: I have created a Silverlight application that runs OOB with extra features. We've taken a few machines and wiped them completely, installed XP and full service packs and updates and installed Silverlight for a few kiosks at a customer location. When I right click in the app and select Install Out of Browser, it does nothing. The option is there to install out of browser, but it does nothing. Installing the application OOB works fine on all other machines besides these two Dells. They're running XP SP3 + IE8. Any ideas?
Comment: Is the user running the OOB application an administrator?
Are you getting any errors in the event log that can help?
Does the install dialog come up at all?
Answer: I was able to figure it out with the help from another programmer here at the office.
We checked to be sure that the user running the application had Admin rights, and anything else we could think of, but it was something I didn't expect... although it made sense after we figured it out.
Don't use PNG files as the icons for the application if you want your app to run on Windows XP. They work fine in-browser, Macs and any Windows OS at or above Vista. However, when you try to install the application OOB either through menus or the SLLAUNCHER.EXE method, it will fail silently because XP cannot handle 32-bit PNG files.
Answer: Make sure the user running the application has rights to the temp directories.  This will prevent the application from working on a computer where the user rights have been altered (as is common for kiosk applications)


TV series about aliens that hook up to an energy source called 'The White'

Question: As far as I know this was around 2012. I thought the show was named THE WHITE, but haven't found anything on it. Also, I have only found one other person who remembers this show, which as far as I know only aired one episode. The aliens in it looked human, but had suction cups on their forearms and would stand in pods and 'plug into' an energy source called "The White".
Comment: What channel did you see this show on, and in which country? And can you tell us anything else about the show? Like were there humans in the show? Was it set wholly or partly on Earth? And were the aliens antagonistic or benign?
Comment: Obvious nasty sarcastic pun elided.
Answer: In Star Trek: DS9, the jem'hadar were addicted to a substance called ketracel-white, which was sometimes referred to just as "the white".
Comment: The Jem'Hadar tubes were inserted right above their left collarbone, nothing on their forearms. Also DS9 had like 130 episodes or something.
Comment: @Derek If you weren't a big DS9 fan and then tuned into one of the jem'hadar / vorta centric episodes, you might think to yourself, "Wow, what is this new show?"


copying and working on OSX .app files (folders) in linux

Question: tldr;
I want to run a script over an external hard drive and tar.gz every folder that ends with .app into their own archive. That is, I don't want them all in one tar.gz file, I want to create one for each folder.
I can generate a list of folders to be worked on via:
find /Volumes/External1 *.app -prune -print

I would now like to compress each of these into their own archive.
A second part to this is that I would then like to copy all those files, and every other file on the drive, including the archive, but not the folders they relate to, and copy them all to another location.
more info
I have created a linux raid box to act as a file server for my network. I mostly have Apple and Linux devices, although the occasional windows box does connect.
The issue I've been having is that OSX .app files are actually a folder, and it has a convoluted underlying structure.
I have been collecting all the drives in my network and backing them up to the file server. I generally run an MD5 hash over them on the OSX box, and then in linux I'll use MD5DEEP to confirm the hashes.
The actual problem is that directory counts and file sizes almost never align when dealing with .app folders. Everything else is matching up beautifully, except when it get's to one of these folders.
What I'm trying to do now in an effort to simplify everything is create a tar.gz file of each .app folder, and leave them in their present location (ie co-located with the .app folder) and I am going to store the tar file instead of the .app folder. This way it's a single file, easy to hash, copy, re-hash.
I have finally worked down to a list of files I want to work with that I can generate with:
find /Volumes/External1 -name *.app -prune -print

two final steps
1. create the archive
This is my first sticking point: I don't want to create a single archive of all of these folders. I want one archive for each folder. So expanding from the generated list, how do I push the list into individually created archives?
2. moving everything from the drive
The drive is formatted in Mac OSX (Journaled) format, so I will be moving these files over a gigabit network and not actually plugging the external drive into the linux box (I am aware there is a way/hack to turn journaling off, do the copy, and turn it back on, but I am unaware of the implications of doing so, and as a result, I'd prefer not to do that. I'm happy to let it run overnight).
When I generate the copy command (I could do it from a terminal on either end), I would basically want to match up a command line that copies:

files and folders on the drive of any type except
folders have names ending in ".app"
not a file or folder located within such a folder
and to be sure to include the archive

To that end I have come up with:
find /Volumes/External1/ | grep -v '.app/'

which I can work with directly or send it to a file and work with that list. I suppose a file list is better, because it provides me with some level of "these are what I worked on"
my thinking

generate a file list of all .app folders (list 1)
find /Volumes/External1/ -name *.app -prune -print > files.apps.list
run a script that compresses each folder in list 1 to an archive (leaving the original folder in tact)
your assistance thanks
generate a second file list excluding .app folders (list 2)
find /Volumes/External1/ | grep -v '.app/' > files.noapps.list
run a script over list 2 that moves each file across the network
your help again, thanks

I'm thinking that both of these steps extend the find list that I can generate by -exec each step with tar and cp, but I'm now lost at how to put these together.
Thank in advance
Answer: Have find run the archiver.
find /Volumes/External1/ -name *.app -prune -exec script_to_archive_and_move {} \;

where script_to_archive_and_move is an executable that takes a .app name as an argument, archives it, then moves the archive file to its final destination. With this approach, you don't need the second find command at all.
Comment: but wouldn't that ONLY copy the `.app` archives? I'd need the second iteration of `find` to deal with everything else, wouldn't I?


How to fit an ARMA process to residuals in R

Question: I have a quadratic regression model with three statistically significant coefficients: intercept, time, and time^2. The residuals of the model show significant autocorrelation. I understand that you can find an ARMA process for the residuals simply by using the ar or arima function and getting the coefficients [i.e. res.ar=ar(resid(fit),method='mle')]... but how do you refit the regression model with the autocorrelated residuals (for purposes in forecasting)? I'm thinking of terms of auto.arima
Comment: I was going through my old answers and noticed this one was not accepted. Do you perhaps need further clarification?
Answer: You are correct that it makes sense to estimate the "main part" of the model simultaneously allowing for the error term to have an ARMA structure (as opposed to doing this in two steps, which would be less efficient). Simply add the main regressors (time and time^2) via the argument xreg in the function arima or auto.arima. It will estimate a regression with ARMA errors. You can read more about this and related techniques in an enlightening blog post "The ARIMAX model muddle" by Rob J. Hyndman.
Comment: Ok, so I attempted what you recommended, but I'm still not quite sure if it's correct. I have

`>adjust=auto.arima(FTEs,xreg=cbind(ftime,I(ftime^2)),max.p=5,max.q=5,trace=T,seasonal=F,allowmean=F)`

`FTEs` is the original data. I obtain an ARMA(3,1) process. But I can't seem to make any forecasts with the model. Instead, I get an error: `Error in predict.Arima(adjust) :
  'xreg' and 'newxreg' have different numbers of columns`
Comment: @Darragh, you have to include the future values of `time` and `time^2` via `newxreg` when forecasting.
Comment: @Darragh, did it work out?
Answer: Rather than a two stage approach fitting time ,time sq , time cubed there could be level shifts , pulses and untreated ARIMA structure that are giving you "fits" . Following @whuber "Fitting  polynomials to data can be a deceptively poor approach: a tiny bit of overfitting can result in models that are grossly bad because higher degree polynomials can (and often do) vary so wildly in between the data values and will be horrible extrapolators". . In building a model that includes memory , level shifts , time trends (as needed .. perhaps a break in trend ! , anomalies , changes in seasonal pulses , parameters and error variance you have all you need under 1 roof , so to speak .


Make a certain block unplaceable?

Question: I was wondering if there is a way to make a block such as bedrock or obsidian unplaceable in a certain area, because I wanted to give players creative mode for a game, but I don't want them to use bedrock or obsidian in their creations. Is there any way to make a block unplaceable using commands?
Answer: You could testfor anyone with obsidian or bedrock in there inventory and if they have it then remove it.  /testfor @a[r=10] {Inventory:[{id:"minecraft:obsidian"}]}
/clear @a[r=10] minecraft:obsidian

Or another method is, you could testfor the player holding the obsidian and bedrock in there hand with a command like this:
/testfor @a[r=10] {Inventory:[{Slot:0b,id:"minecraft:obsidian"}]}
If you wanted to use this method you would have to testfor slots 0-8, just change the zero.
then if you didn't want to remove the item you could change there gamemode to adventure
/gamemode a @a[r=10]

increasing the radius will increase the area you wish them not to place those blocks.
For the second method I suggest having a clock hooked up to the testfor command that triggers a sticky piston with a redstone block on the end.  When the testfor activates true then the sticky piston will extend activating the gamemode change.  When they leave the radius the sticky piston will deactivate pulling the redstone block into another gamemode command returning them to there previous gamemode.  It would look somthing like this:
I think method one would be more useful in your case.
Comment: The only thing with this is that it would clear the inventory of all players if one player is holding obsidian. Is there any way to fix this so that it only targets the player holding it?
Answer: I just realized that the easiest way to do this is to have a fill clock setting off two command blocks that replace all bedrock/obsidian with air.

Make a certain block unplaceable?


How to finger Dm -> Dm9?

Question: I'm playing a song that goes Dm to Dm9. Moving from either open Dm or fifth-string bar Dm to the pictured Dm9 shape feel pretty awkward. Is there a better shape or fingering? I imagine Dm->Dm9 in any key can't be too uncommon.
Answer: It's towards the dusty end, but barre 10th fret, and finger 12th fret 5th string, and 12th fret top string gives the 9th part of the chord. So Dm barre there,(with 12th fret 4th string if you want, otherwise it's Dm7) and Dm9 follows easily.
EDIT: an alternative - similar to the chord window in the question, but maybe not easy fo you, would be very much like D9 where evrything is in 5th fret, except 4th fret 4th string (quite an easy chord to finger), but move the 4th string from F♯ down to 3rd fret, giving the m3 of F♮. But getting to it from where? Maybe 5th fret barre Am shape?
Answer: Do you really need the 7th? If not, could you use this inverted m9(no 7) (or m add 9):

or even this sus2:
Comment: Wouldn't do _that_... voicing the seventh so low would make the voicing very markedly different from root position.
Comment: This can be easily extended to include the C on the G-string.
Comment: @leftaroundabout on A string?
Answer: Use the open E for the 9th.

Dm : x5776x
Dm9 : x5x560 (leave out the 5th)

How about
- Dm11 : x57060
It's a nice idea to combine one or two open strings with stuff. Here's an etude

x57060
8x7060
7x7760
6x7760
6x5760
5x5760
5x5660
3x3330
3x2330
1x2230
x13230
3x2330
x02330
x08680
x57460
Answer: That depends on a few factors.  Like whether or not you want all notes in the voicing, whether the style of the song is folk or rock versus Jazz.
I personally have no problems with the fingering
(x, 5, 7, 7, 6, x)  to  (x, 5, 3, 5, 5, x)
which would require a shift back.  Another option is.
(x, x, 3, 2, 3, x) or (x, 0, 3, 2, 3, x) to (x, 5, 3, 5, 5, x)
You could even use (x, 5, 3, 2, 3, x) if you can grab it.
Lastly if you want an open string tone and feel.
(x, x, 0, 2, 3, 1)  to  (x, x, 3, 2, 3, 0) or (x, x, 0, 2, 3, 0) if you don't mind the ambiguity of not having the 3rd.
An more obtuse voicing might be,
(x, x, 0, 2, 3, 1) to (x, x, 2, 2, 3, 1)
Answer: It really depends on the style you are playing, e.g. full strums vs fingerpicking.
On top of existing answers, you can play Dm7 either ways:

x5356x, with the minor 3rd on top;
x5353x, with the root on top. You bar on the 3rd fret with the 1st finger, so you are basically playing a G7sus4 on 3rd position.

Drive by Incubus makes exactly that (but in Em) by the way!
Answer: you also got the strechy voicing of Dm-add9
Dmadd9
x57975
to
Dm
x57755
or
Dm9
x5355x
 to
Dm/f
x877710x
way up:
Dm9/c
xx10101012
to
Dm/c
xx10101010

How to finger Dm -> Dm9?


Why does fluid pressure decrease as fluid velocity increases according to Bernoulli's principle?

Question: I'm studying aerodynamics. I understand Bernoulli's principle very well, I just can't wrap my head around why pressure decreases as velocity increases. Like the garden hose example: if you cover the hose with your finger, water flows out of the hose faster (and somehow pressure decreases) but when the finger blocks the hole, wouldn't that add extra pressure on the fluid?
Comment: This link explains it pretty clearly: https://www.youtube.com/watch?v=TcMgkU3pFBY
Answer:
I just can't wrap my head around why pressure decreases as velocity increases

This is a classic misunderstanding of Bernoulli's equation. What Bernoulli's equation actually says is that the velocity will increase in the direction of decreasing pressure: $P_2-P_1=-\frac12\rho(v_2^2-v_1^2)$. This makes sense: if the pressure is higher on the left than on the right, then the fluid will speed up to the right. This is just like if I pushed on a block with $5\,\rm N$ of force and you pushing on the block in the opposite direction with $10\,\rm N$ of force: the block would accelerate away from you and towards me, thus speeding up towards where the smaller force is being applied.

Like the garden hose ex: if you cover the hose with your finger, water flows out of the hose faster. (and somehow pressure decreases....) but when the finger blocks the hole, wouldn't that add extra pressure on the fluid?

Yes, it would add extra pressure. Let's assume the hose is completely horizontal so that Bernoulli's equation for comparing the fluid inside the hose ($1$) and just outside the restriction ($2$) is (expressing pressures as gauge pressures)
$$P_1+\frac12\rho v_1^2=\frac12\rho v_2^2$$
And our constant flow rate
$$A_1v_1=A_2v_2$$
Which gives us for the pressure $P_1$ and the velocity $v_2$:
$$v_2=\frac{A_1}{A_2}v_1$$
$$P_1=\frac{(A_1^2-A_2^2)\rho v_1^2}{2A_2^2}$$
For a constant $\rho$, $v_1$, and $A_1$, both $P_1$ and $v_2$ increase with decreasing $A_2$ (i.e. the smaller the restriction the larger the pressure before the blockage and the larger the velocity right after the blockage). The larger pressure before the blockage as compared to after the blockage results in an acceleration of the fluid through the blockage.
Comment: Just want to add that as $A_2\to 0$ Bernoulli equation ceases to be applicable because of significant viscous effects.
Comment: @BioPhysicist, now if I put a small  surface inside the fast moving fluid won't it be bombarded strongly by the faster moving fluid than it would've been if put in the slower moving fluid?  Thus suggesting that the pressure is greater where the velocity is higher?
Comment: @Kashmiri That's not the same thing. Look at a derivation of Bernoulli's equation.
Comment: Oh, so we are considering static pressure?
Answer:
i just can't wrap my head around
why pressure decreases as velocity increases..

When velocity increases then you obviously have acceleration.
Now what is causing this acceleration?
As always (according to Newton's second law, $\vec{F}=m\vec{a}$)
acceleration is caused by a force.
In this case the force acting on a piece of fluid
comes from the pressure difference,
making a net force pointing from higher pressure to lower pressure.

(image from ResearchGate - Diagram of the Bernoulli principle)

These thoughts can be made quantitative to actually prove Bernoulli's law.
Consider a small cylindrical slab of fluid (with mass $dm$, area $A$,
thickness $dx$, and moving with velocity $v$).

From Newton's second law we have
$$dm\frac{dv}{dt}=F_{\text{left}}+F_{\text{right}} \tag{1}$$
The mass of the slab of fluid is
$$dm=\rho A\ dx \tag{2}$$
The pressure forces acting on the left face (where pressure is $p$)
and on the right face (where pressure is $p+dp$) are
$$\begin{align}
F_{\text{left}} &=pA \\
F_{\text{right}}&=-(p+dp)A=-\left(p+\frac{\partial p}{\partial x}dx\right)A.
\end{align} \tag{3}$$
Inserting (2) and (3) into (1) we get
$$\begin{align}
\rho A\ dx\frac{dv}{dt}
  &=pA-\left(p+\frac{\partial p}{\partial x} dx\right)A \\
  &=-\frac{\partial p}{\partial x}dx\ A.
\end{align} \tag{4}$$
Dividing by $A\ dt$ we get
$$\rho v\frac{dv}{dt}=-\frac{\partial p}{\partial x}\frac{dx}{dt} \tag{5}$$
or
$$\rho v\frac{dv}{dt}+\frac{\partial p}{\partial x}\frac{dx}{dt}=0. \tag{6}$$
This can be rewritten to give
$$\frac{d}{dt}\left(\frac{1}{2}\rho v^2+p\right)=0 \tag{7}$$
or
$$\frac{1}{2}\rho v^2+p=\text{const} \tag{8}$$
which is just Bernoulli's law.
Answer: Here's a perspective from a former chemistry student. I'll try to explain using molecular motion.
I once taught myself compute programming and made a particle-geometry collision simulator to test the following, and it seemed to work, so I'm drawing on the intuition that I learned from that project.
Background:
Pressure is one measure of kinetic energy transfer from moving particles to a surface that they collide with. Temperature is another measure, though observed through different measurements. They cannot be separated. The rate of kinetic energy transfer depends on (1) the number of particles and (2) how much kinetic energy they already have. Keep the number of particles constant and increase their kinetic energy (ex: heat them up), and the number of particle collisions with nearby surfaces will increase, which increases the kinetic energy transferred to nearby surfaces (increase T and P). Keep the kinetic energy of the system the same but increase number of particles, such as a chemical reaction that creates multiple smaller particles out of a single large molecule, and the number of particle collisions with nearby surfaces will again increase, increasing the kinetic energy transferred to nearby surfaces (increases T and P). Note: Burning fuel will do both of these, both increasing the number of particles and the kinetic energy of those particles.
Remember PV = nRT, even if the system is not ideal.
Fluid velocity is a macro-level measurement of may particles generally traveling in the same direction.
What happens if all particles are moving in the same direction? Particles are always moving, but how would they all move in one direction? Particles will always travel in a straight line (unless electric charges are involved) until they collide with something, and then they'll bounce off and continue on (or sometimes chemically react if the conditions are right). If particles are all moving generally in one direction, then the particles are generally not colliding with anything to stop them. That's about the long and the short of it. High -> low pressure is not so much a "push" as it is the particles escaping a high collision environment. Open a door between a high pressure chamber and a low pressure chamber and the particles will "rush" (that is, high velocity) from the high pressure chamber to the low pressure chamber by means of few collisions in the direction of the low pressure chamber. This will continue until eventually all particles in the combined chamber are colliding with each other and the container at a uniform rate, the particles and kinetic energy from the high pressure chamber having been distributed through collisions throughout all the particles in the combined chamber.
More to your question:
Not all pressure measurements are created equal. There is no universal measure of pressure for a fluid in motion. The measured pressure depends on whether you measure from the side of the flow or inline with the flow, which hopefully makes sense now since pressure is one of the measures of kinetic energy transfer through collisions. Measure from a direction that is going to have few particulate collisions with the sensor and you're going measure low pressure.
Assuming that the particle count and the kinetic energy of the particles are kept constant, then particles generally traveling in one direction are not colliding with their environment as much as if they were confined. Again, a neutrally charged particle will travel in a straight line until it collides with a surface or another particle. As long as it hasn't collided with anything, then it will continue in the same direction. Reasoning in reverse, if we see particles moving generally in one direction, then we can safely conclude that they are not colliding with anything that will substantially change their direction, and any collisions that do happen are going to be at a shallow angle, the kinetic energy transfer (and therefore pressure measurement) will be small, and the direction change minimal.
In general, if the particles are moving one direction

Measure from the side, you're not going to get a lot of collision on the pressure sensor
Measure inline with the flow and the pressure sensor is going to get a mouthful

From the side:
Open a value to a high pressure gas chamber, and the gas at the nozzle will quickly no longer be inhibited when traveling that direction and will travel with all the kinetic energy that it has in that direction until it collides with something outside the chamber. Put a long nozzle on the container and mount a pressure gauge prior to the valve and perpendicular to it, and you will find that, when the nozzle is closed, that there are particle collisions all around that pressure gauge's sensor from particles traveling into the region of the nozzle and then bouncing back into the chamber, but when the nozzle is opened, any particles that were previously colliding with the nozzle will no longer bounce back from the valve, and now the pressure gauge's sensor isn't seeing as many collisions and the pressure is observed to drop.
I may need correction, but I believe that this "side pressure" concept is generally referred to as static pressure, and this is the one that decreases as fluid velocity increases perpendicularly to the direction of measurement.
From the front:
Put a pressure gauge in the direction of travel though, like putting on a nozzle that mounts a pressure gauge inline with it and then turns 90 degrees before the valve, and there will be less pressure drop from nozzle closed to nozzle open. The particles escaping through the valve have to take that 90 degree bend first and they'll slam into the pressure sensor, and then other particles will come behind them and slam into them, repeat, building up and keeping a localized area of high collisions (and therefore high pressure) at the 90 degree turn.
I think that this "in your face" pressure is called dynamic pressure, but now we need to get more precise. I think that dynamic pressure is a momentary "in your face" pressure, but pressure buildup due to incoming fluid flow, like the kind that will build up on the 90 degree bend in my example, or on the leading edge of an airfoil, or on anything else that is pointed in the direction of travel, is called stagnation pressure. These two are not exactly the same.
Combine a pressure sensor pointed in the direction of travel with another pressure sensor pointed 90 degrees to the side, add some Bernoulli pressure calculations that I'm not familiar with to calculate dynamic pressure and then airspeed and voila! You have a pitot tube!
Does this help the concept?
Comment: Very intuitive.
Comment: Static pressure is the pressure measured when at rest relative to the fluid.
Answer:
I just can't wrap my head around why pressure decreases as velocity increases.

That's somewhat backwards. That makes it sound like a decrease in pressure is caused by an increase in velocity, when it's more that an increase in velocity is caused by a decrease in pressure. If there is a pressure differential, that means there is a net force on the fluid, which means the velocity increases.
From a conservation of energy point of view, higher velocity means higher kinetic energy, and that energy has to come from somewhere. One place it can come from is the internal energy of the pressure.
One explanation for how wings generate lift is that the air above the wing is moving faster, which causes lower pressure, but that explanation is incomplete: the wing is exerting a force on the air, which means that the conservation of energy argument doesn't work. Bernoulli's principle allows us to infer a decrease in pressure from an increase in velocity only when the internal energy of the pressure is the only possible source of the increase in kinetic energy.

but when the finger blocks the hole, wouldn't that add extra pressure on the fluid?

When you talk about something being "extra", you need to be clear about what's it's extra with respect to. If you put your finger on the hole, the water next to your finger isn't at a higher pressure compared to the water elsewhere in the hose, but it is at a higher pressure compared to what it would be if you hadn't put your finger there.
Without your finger, the water starts out with some high pressure from the water company, and the pressure decreases as it flows through the hose. At the moment it comes out of the hose, it has little pressure, so the transition from just inside the hose to just outside the hose doesn't involve much decrease in pressure, so the velocity doesn't increase much.
When you put your finger on the opening, the water retains most of its pressure throughout the hose. So now when it exits the hose, its pressure decreases significantly, and its velocity increases.
Answer: For this to understand let us consider a room in place of a hose  say of length $l$ in which a ball is bouncing up and down and colliding elastically with the ceiling and the floor continuously.
Now if we increase the speed of the ball in this upward or downward direction using some techniques, the ball will strike the ceiling and the floor with a greater momentum and thus the change in momentum will also increase and hence will apply a greater force and hence pressure on the ceiling and the floor will increase.
But what if we push the ball in the horizontal direction ?
If we give it a appreciable horizontal speed , it will rarely strike both the walls before coming out of the room and hence we can conclude that the pressure on the ceiling and the floor has decreased with increase in kinetic energy.

Now since you considered a hose , let's see what happens with it. When you decrease the opening, water being incompressible must speed up so that volume of water coming in equals volume going out. This will add extra pressure on the water molecules but in the oposite direction of flow and from Newton's third law, the force and thus pressure by water on your hand will increase .
But the pressure on the side walls of the hose will decrease for the same reasons given in the first example.
So it is better to define which pressure is being considered before applying Bernoulli's Principle to get a better physical understanding of it.
Hope it helps a little .


5-7 hour layover in Guangzhou; Should I leave the airport and explore?

Question: I have a 5-7 hour layover at Guangzhou Baiyun International Airport and wanted to see if anyone recommends leaving the airport to explore. From what I've gathered, you can leave the airport in China for 72-hours on a temporary visa as long as you have an outgoing ticket, BUT it looks like traveling to the city is an hour each way. Not sure if it's too tight to pull off. Thoughts?
Answer: If you've got seven hours, I'd go for it.  The city is indeed a bit of a hike away (~50 min), but since the connection is by subway, the trains are very frequent (every 5 min) and very reliable.  To minimize hassle on return, make sure you have a boarding pass for your connecting flight before leaving the airport and time yourself to get back two hours before your flights, as immigration and security can be slow.  This still leaves you with a good 2-3 hours of time to explore, and this site (no affiliation) has suggestions for various points of interest easily accessed from the airport, including travel times.
But if you've got only five hours, it's a bit more touch and go: it's technically possible, but you're unlikely to have more than an hour to actually see and do stuff, and staying at the airport would be the easy/safe option.
Comment: I agree. I had a stop there a few months ago of 15h. If you have more than 5h, I suggest to take the subway to the city centre at the park. Have a walk and some amazing cantonese food and enjoy the view of the buildings and make sure you're back on time since the airport is very big and there can be queues at security etc.


Perfect loop in OmniGraffle

Question: How can I draw perfect, recursive arrow in Omnigraffle? I'm looking for a cleaner method than the one below.
Comment: have you tried the Omnigraffle forum? https://discourse.omnigroup.com/c/omnigraffle
Answer: You can make one with a circle and a no-stroke line. Let's start with the object that the arrow should be connected to:

Now draw a circle next to the object:

Now add a line (magnetized to the starting object) with an arrowhead at the start. Draw the line out until the angle of the arrowhead is about right. We're eyeballing it here.

Now change the stroke style to "No Stroke":

And you've got a recursive transition arrow!

Perfect loop in OmniGraffle


Does aluminium foil still reflect heat if covered?

Question: If I place a foil covered sheet of board in my window to reflect heat back into the room,  will closing the shutters and pulling the curtains over it render it useless ? Will foil on the other side reflect cold back outside ?
Answer: As Broken Admin mentioned, its better to think of the foil as reflecting heat rather than reflecting cold.  Its not that it reflects the cold from outside to keep it outside, its that it reflects the heat from inside.
Metalized foils like these reflect infrared radiation.  Every object emits it.  The hotter the object, the more it emits.  If you have a really hot object, like 800 degrees hot, it can even glow in the visible range.  But even if its colder, it's emitting in the infra-red range.
The idea is that, without the foil, every surface in your house is emitting and receiving a bunch of infrared radiation based on its temperature.  Mostly its in balance, but some of that radiation reaches the window and escapes into the cold outside.  If you put foil in place, it instead reflects the heat back into the house to get re-absorbed by the floor/walls/etc.
This foil is more effective than, say, painting the windows, because that surface also has conduction to deal with.  The windows are simply colder than the rest of the house.  Perhaps not quite as cold as the outside world, but cold.  So painting them would help a little, but you'd still have a cold square that wasn't radiating quite as much.  Foil reflects the radiation rather than absorbing it, so the temperature of the foil isn't nearly as important as it was in the case of painting the window.
So with the shutters and curtains, the foil still works.  Why?  Because the shutters and curtains are still quite warm, being fully inside the house.  They are radiating, and losing heat through the window.  A layer of foil reflects that heat, letting the shutters or curtains reabsorb the heat.
What you shouldn't do is have the shutters or curtains plastered against the foil.  In that case, the infrared radiation would play a smaller part because conduction directly through the window, foil, and into the shutters/curtains would dominate.  But as long as there's a nice insulating air layer between them, it will do the job.
Comment: Thank you for this very thorough answer
Answer: I'm unsure what exactly you are describing, but from what I understand $-$ you plan to "reflect" heat from outside the window away from the room. I'll attempt to explain a basic idea.
Closing the curtains and shutters would prevent some heat from entering, but heat which makes it past the curtains and shutters will be reflected away from the room.
The foil on the in-facing side will not reflect "cold", as cold is just the absence of heat. But it will reflect any existing heat from exiting the room.
If I misunderstood your question, please comment, as I'd be happy to provide a more accurate explanation.


What is the phase velocity of light in graphene?

Question: This article states that light can "slow down by a factor of a few hundred" when it strikes graphene. I've read elsewhere that the index of refraction of graphene is about 2.65 + 1.27i. According to the article shouldn't the refractive index be a few hundred? How is this possible? What is the phase velocity of light in graphene?
Answer: It is a mistake in the David L. Chandler MIT News article. The research paper "Efficient plasmonic emission by the quantum Čerenkov effect from hot carriers in graphene" doi: 10.1038/ncomms11880, states that "plasmons in graphene can have an exceptionally slow phase velocity, down to a few hundred times slower than the speed of light". But plasmons are not light waves, but collective excitations of electrons (propagating at Fermi velocity). Chandler misunderstood the nature of plasmons because of the use of the term "Čerenkov effect" which is not the same as "Čerenkov light". The paper has discovered that the carriers in graphene with speed larger than that of the graphene plasmons emit "Čerenkov plasmons".