How can I include an existing custom sitemaps listing in wp-sitemap.xml?

Question: I have several existing custom sitemap xml files, and I'd like to know which add_filter to use to add those custom sitemaps to the existing https://www.example.com/wp-sitemap.xml page.
Answer: There are a lot to choose from.
I would start with wp_sitemap_init, whose documentation states

Additional sitemaps should be registered on this hook.

Note that you'll have to be running WordPress 5.5.0 or up for this hook to be available.
Looking at the code, it appears that this action allows you to register new items in the global $wp_sitemaps object, which is a WP_Sitemaps object.
Comment: Thank you.  I have definitely seen the links you provided, and have seen several examples of registering a new sitemap provider, etc. but they all seem overkill if all I'm wanting to do is add a couple of sitemap xml file links inside the existing default wp-sitemaps.xml file.  Any insight on a simpler approach is much appreciated.
Comment: I did a bunch of work on a Multisite sitemap for my employer's website, but it appears I ignored all the filters (or—since it was a while ago—some of the filters might not have existed yet) and basically wrote something up from essentially scratch.


Stuck in my role with a manager who does not give any trainings or benefits or career growth

Question: I am working as a Technical Program Manager in Sales Ops.Due to org restructure, I was moved to Sales Technology team. Ever since I moved into this team, my manager has become insecure and is not interested in my growth and career. I worked with this manager in a different capacity in my previous role (as a stakeholder). Our org has started a major migration project to create a new CRM system using out of the box features on the latest version. Inspite of promising me that I would be involved with this project in the near future and I should set aside sometime for this work for months, he has not involved with this new project yet. Any developer or QA who wishes to have a call with me during our scrum meetings, he advises them to add him or his favourite team member.He had one meeting discussing about my career aspirations and what role I would like to do going forward and advised me to share a plan with him. However, he has not approved any trainings as discussed in the plan and neither is supporting me with my career growth. When I brought up this in our 1-2-1 meeting, he advised me that I could have a chat with his manager. He has cherry picked some team members to work on the new project and providing them with training on the new version as well as training for new certifications. However, he advises me to continue doing support tickets with no timelines for progress or growth. I have been commended by my team and other teams I worked with for doing an excellent job to a high standard but with this role, I feel under valued and unappreciated with no real growth in my career.I cannot move to other teams due to hiring freeze and cannot look for roles outside of my company at this point. Please advise how I ride out this manager and make some real progress in my career.
Comment: Please edit your post to have some structure - nobody wants to read a big wall of text.
Comment: This seems more like rant: What is your actual question? "I ...  cannot look for roles outside of my company at this point" : that seems to be your main problem. Fix that first. You will not have a career at this place and if you want you need to to leave. Start working on that.
Answer:
I feel under valued and unappreciated with no real growth in my career.

I am really sorry to hear that. Sounds like you're working in a "relationship" company - or at least in a "relationship" team, where a relationship (who you know and are on good terms with) is valued higher than what you do, aka your performance.
It's probably much more pervasive and common than we'd like to admit.

Please advise how I ride out this manager and make some real progress in my career.

I can only see two paths out of this, and it'd probably be wise to pursue both simultaneously:

Lay low. Do not bring up your disappointment, discouragement, dissatisfaction with the management or anyone else. If you can find it in you, compliment the management and coworkers where they do a good job. (I don't mean boot-licking. Rather: praise where it's deserved and appropriate does go a long way.)
Make yourself marketable and a "hot item". Take classes, study, seek gigs, volunteering opportunities, projects, internships - anything where you can gain valuable experience and skills that will help you land your dream job. Understand that this part is nobody else's responsibility - this is all on you. I am sure you've heard this before: Always be learning.

P.S.:

cannot look for roles outside of my company at this point.

Why not?
Answer:
my manager has become insecure and is not interested in my growth and
career

Unfortunately, that isn't their job nor their responsibility. In an ideal world, your manager and your company would take an interest in, and provide opportunity for, your career growth. Sadly, many do not.
If you can't find ways to find the growth opportunity you seek on your own, and if your manager and company aren't providing those opportunities, and you can't go elsewhere for a new job, you'll have to live with the situation.
Comment: Career growth and personal development should be and very often are a part of a managers responsibilities. How can you assert that it is not when you have not read the job description of the OPs manager?


What's the difference between the telnetd and inetutils-telnetd packages in Ubuntu?

Question:
Recently, a work came to me which needs to set telnet on linemode.so i install telnetd with apt install telnetd, which is controlled by inetd, and this operation will add new line telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd in /etc/inetd.conf
after install telnetd by this way, i tried many ways to enable linemode in telnet service yet all failed ,so i removed telnetd by apt remove telnetd
then i reinstall telnetd by apt install inetutils-telnetd, this operation also add new line in /etc/inetd.conf which is telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/telnetd.after doing this, i add a -l option in this line and restart telnetd. in this way, line mode is enabled and works well.
althrough work is finished, but still can't i figure out why these two ways are different. what's the difference between these packages telnetd and inetutils-telnetd
Answer: telnetd provides the netkit implementation of telnetd, whereas inetutils-telnetd provides the GNU Inetutils implementation. The latter supports the -l option to force line mode, whereas the former relies on negotiation with the client.
In most (if not all) cases, the Inetutils version of telnetd is more appropriate than the netkit version (within the limitations of the protocol).
See also What are the differences between iputils-ping and inetutils-ping?
Comment: thanks for replying, i get it. it's a treasure  for me to know why it behaves like this.
Comment: is there any way to enable line mode through telnetd?
Comment: What client are you using to connect to `telnetd`?
Comment: telnet client from windows features on win10


How may I give the current time as the modification time for a file or directory in a tar archive

Question: I want to create a tar archive which will have files and directories. I need to change the modification time of these files and directories so that their modification timestamp is the current date and time when I'm doing the compression. How may I do that in shell script?
Comment: `touch` all files before archiving them?
Comment: It's `touch`. See `man touch` for details.
Comment: How can i do that.
Can you just tell the command to do that?
What i can do on directories
Answer: If you have GNU tar, you can use the --mtime option to store arbitrary modification times; in your case,
tar cf archive.tar --mtime="@$(date +%s)" ...

will use the current time for all modification times stored in the archive.
Comment: appreciate the answer
Comment: This is a good hint for `libfind` that is used by `star` and many other programs: it seems to be a good idea to add  `-chatime`, `-chctime`, `-chmtime` primaries to modify these values in `struct stat`.
Answer: To update the modification timestamp on everything under a directory dir (including the directory itself):
find dir -exec touch {} +

You would do this just before you create your tar archive of the dir directory.
Comment: Do you really like to shredder all time stamps in the file system?
Comment: @schily Only in the directory that will be archived.


Output before and after the loop

Question: I'd like to hook into the loop, ie. have_posts() maybe? and output some code before and after.  Is there a filter for this so I can use it in a plugin without needing to edit themes?
Answer: The function the_post() (source) triggers the action loop_start when it is first used in the loop. This is used in every WP_Query loop, so you may want to check if the current query is the 'main' one (assuming that's the query you wish to target)
add_action( 'loop_start', 'wpse107113_loop_start' );
function wpse107113_loop_start( $query ){
     if( $query->is_main_query() ){

     }
}

The last time have_posts() is called it triggers the action loop_end (source), so similar to above:
add_action( 'loop_end', 'wpse107113_loop_end' );
function wpse107113_loop_end( $query ){
     if( $query->is_main_query() ){

     }
}

Answer: Thank @Stephen Harris for the above answer :)
Just a very important note, when using the loop start/end you need the code below to prevent unwanted trigger of your code in the head.
if ( $query->is_main_query() ):

    ... code here

endif;

Output before and after the loop


How to debug a LINQ Statement

Question: I have a Linq to objects statement
 var confirm = from l in lines.Lines
 where (l.LineNumber == startline.LineNumber) || (l.LineNumber == endline.LineNumber)
 select l;

The confirm object is returning an 'Object Null or Not A Reference' at at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
If the result of the query was empty, it would just return an empty enumerator. I know for a fact that there are no null objects in the statement. Is it possible to step through the LINQ statement to see where it is falling over?
EDIT When I said I know for a fact that there are no null objects it turns out I was lying :[, but the question remains, though I am asuming the answer will be 'you can't really'
LINQPad is a good idea, I used it to teach myself LINQ, but I may start looking at it again as a debug / slash and burn style tool
Comment: 42. Actually if you read my edit, it's that I did have a null reference, despite my assurance to the contrary
Answer: Yes it is indeed possible to pause execution midway through a linq query.
Convert your linq to query style using lambda expressions and insert a Select statement that returns itself somewhere after the point in the linq that you want to debug. Some sample code will make it clearer -
        var query = dataset.Tables[0].AsEnumerable()
            .Where (i=> i.Field<string>("Project").Contains("070932.01"))
 //         .Select(i =>
 //         {return i;}
 //           )
            .Select (i=>i.Field<string>("City"));

Then uncomment the commented lines. Make sure the {return i;} is on its own line and insert a debug point there. You can put this select at any point in your long, complicated linq query.
Answer: I'm not sure if it's possible to debug from VS, but I find LINQPad to be quite useful.  It'll let you dump the results of each part of the LINQ query.
Comment: Like the other side of the pillow.
Answer: You should be able to set a breakpoint on the expression in the where clause of your LINQ statement.
In this example, put the cursor anywhere in the following section of code:
(l.LineNumber == startline.LineNumber) || (l.LineNumber == endline.LineNumber)

Then press F9 or use the menu or context menu to add the breakpoint.
When set correctly, only the above code should have the breakpoint formatting in the editor rather than the entire LINQ statement. You can also look in the breakpoints window to see.
If you've set it correctly, you will stop each time at the function that implements the above part of the query.
Comment: This may not be the answer the OP was looking for, but helped me a lot. I thought Visual Studio was unable to debug lambda expressions, mainly because when I was inserting the breakpoints (with the cursor at the wrong column) it was painting the entire line, not just the lambda I wanted to debug, but also because Quick Watch window is unable to evaluate lambda expressions.
Comment: To clarify, the debugger will enter the linq query following *the first reference* to the variable that holds the linq query
Answer: I wrote a comprehensive article addressing this very question published on Simple-Talk.com (LINQ Secrets Revealed: Chaining and Debugging) back in 2010:
I talk about LINQPad (as mentioned earlier by OwenP) as a great tool external to Visual Studio. Pay particular attention to its extraordinary Dump() method. You can inject this at one or more points in a LINQ chain to see your data visualized in an amazingly clean and clear fashion. Though very useful, LINQPad is external to Visual Studio. So I also present several techniques available for use within Visual Studio because sometimes it is just not practical to migrate a chunk of code over to LINQPad:
(1) Inject calls to the Dump() extension method I present in my article to allow logging. I started with Bart De Smet's Watch() method in his informative article LINQ to Objects – Debugging and added some labeling and colorization to enhance the visualization, though still it pales in comparison to LINQPad's Dump output.
(2) Bring LINQPad's visualization right into Visual Studio with Robert Ivanc's LINQPad Visualizer add-in. Not sure if it was through my prodding :-), but the couple inconveniences present when I was writing my article have now all been admirably addressed in the latest release. It has full VS2010 support and lets you examine any object you like when debugging.
(3) Embed nop statements in the middle of your LINQ chain so you can set breakpoints, as described earlier by Amazing Pete.
2016.12.01 Update
And I just wrote the sequel to the above article, titled simply LINQ Debugging and Visualization, which reveals that true LINQ debugging capability has finally arrived in Visual Studio 2015 with the about-to-be-released new feature in OzCode. @Dror's answer to this question shows a tiny glimpse of it, but I encourage you to read my new article for an in-depth "how to". (And I do not work for OzCode.:-)
Answer: [Disclaimer: I work at OzCode]
The problem with LINQ is that it's hard to impossible to debug - even when dealing simple queries a developer is forced to refactor his/her query to a bunch of foreach loops, or use logging.
LINQ debugging is supported in a soon-to-be-released version of OzCode (currently available as an Early Access Preview) and it helps developers drill into their LINQ code as well and pinpoint those hard to catch exceptions inside queries
This is what your query would look like in OzCode:
Answer: It is possible to step inside the LINQ expression without setting any temporary breakpoints. You need to step into the function which evaluates the LINQ expression, e.g.:
var confirm = from l in lines.Lines
              where (l.LineNumber == startline.LineNumber)
                    || (l.LineNumber == endline.LineNumber)
              select l;

 confirm.ToArray(); // Press F11 ("Step into") when you reach this statement

 foreach(var o in q) // Press F11 when "in" keyword is highlighted as "next statement"
    // ...

Answer: Check the exception stack trace and see the last bit of your code that executed.
Comment: That's how I got to System.Linq.Enumerable.WhereListIterator`1.MoveNext()
Comment: What's the last line of *your* code that executed? WhereListIterator is not your code (it's a LINQ API).
Answer: From the looks of the error I would suggest you take a look at line.Lines and make sure its enumerator is implemented properly. I think it's returning a null when it shouldn't.
Oh and just make sure the line and line.Lines objects aren't null or returning nulls as well.
Answer: While it isn't a way of debugging, I'd suggest using the following:
using (var db = new AppContext())
        {
            db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
            // Rest of code
        }

You can then check the output window when debugging to see the SQL generated from your LINQ query.
Answer: To step through the LINQ statement just put a breakpoint on linq statement and then when it starts to debug that line then
Right click on it
click on Run To Cursor option
It will start to execute code line by line as we do normally.

How to debug a LINQ Statement


How to track ethereum nodes with using geth or other client?

Question: I want to track Ethereum nodes, like the Ethereum node tracker at etherscan.
I want to get information about all Ethereum nodes. For example, total number of Ethereum nodes, total number per country, OS type, etc.
I have searched the web but have not found a way to do this.
Can I get information about other Ethereum nodes by using a library such as web3js to access Geth or other clients?
Or does Etherscan use its own software?
Answer: You can check all that stuff via etherscan by going on to the following address
https://etherscan.io/nodetracker/nodes
Furthermore you can filter the node by OS, Country and Type of the node.


Assigned static ip address doesn't retain

Question: I changed my computer's dynamic ip address to static, but after reboot when I opened local area connection properties, then I saw IP address and subnet mask values have become empty. Then just to confirm, i typed command ipconfig in cmd, the same values were shown to what I entered in local area connection properties before rebooting my system. So my question here is how can i force my computer to keep static ip address even after reboot?
Comment: Normally those settings will will stay after a reboot. Have you tried it multiple times?
Maybe you changed a wrong adapter?
Comment: the reason it is so far because of my wifi-router?
Comment: Then have you changed the correct adapter? If you're using Wifi, you need to set the wifi adapter properties.
Comment: I think i should reserve my computer ip address in DHCP settings.
Answer: If your router supports static dhcp addresses, assign a static dhcp lease to your computers MAC address and you will always get the same IP address every time your computer gets one from your router.


which tiers should i catch exception when using DAL BLL and web Presentation Layer

Question: I write a three tiers web application. DAL BLL and web Presentation Layer,every tier has methods , so the question is where should I catch exception( using try catch),in web?BLL?or DAL? and why? thank you.
Answer: Its better to catch exception at database layer and throw it to business layer and than from throw from business layer to presentation layer.
I rethrow exception by using throw keyword and do not display exception to user just show the error message and log exception using LOG4NET or in the file which way you find easy for you.
You can check this post how to throw exception without hiding the detail : Handle Exception Carefully
Comment: could you give a example more detail ,thanks .may be a blog is ok.:)
Answer: An Exception is part of the interface of any method.
<code> int doSomeThing( ... ) throws Some exceptions
</code>
the exceptions may be explicit, as in Java's Checked Exceptions, or implicit. None the less the caller must anticipate exceptions and decide what to do - sometimes a method may decide just to allow the exception to propogate, exceptions from things you call become part of your formal interface.
My approach:

Each layer should encapsulate its implementation details; in particular end-users should not see technical error messages
Robust applications must log error symptoms to allow problem diagnosis

Hence, in Web/Presentation tier, we catch all exceptions and display friendly messages to the user. There tend to be a small number of common scenarios:

The business logic layer temporarily can't service your request (eg. DB is down), I include in this heading the unexpected, null pointers and so on, they are caused by coding errors, but they are remediated down in the business layer
You, mr customer, are not authorised to do that
Your request is invalid, it violates some business logic rule (no you can't specify a bull-dozer attachment for your new Rolls Royce)

I find that the UI sometimes displays the error information differently in those cases, and hence I like to distinguish them. This leads me to design my Business Logic interfaces to throw corresponding Exceptions: TransientException, AuthorisationException, InvalidRequestException.
The InvalidRequestException tends to have useful payload to help the UI format a useful response.
The TransientException can include technical information (like DB XXX has problenm YYY) not for display to the user, but as an aid to diagnosis in a distributed system.
The business logic layer is responsible for catching the myriad problems from lower layers and producing the exceptions for the UI.
The Data access layer should follow the principle of First Failure Data Capture: catch problems log the error in detail and throw some suitable exception.
Answer: Dont use try catch  in all your methods unless you are sure to handle the error.You can probably use catch in DAL ,log the exception and throw it up the layer.
see this post Exception handling
Answer: The link given by Pranay Rana, describes the correct way to propagate the exceptions from layers however, it is not necessary to warp methods in try catch in underlying layers( DAL, BAL) until unless you need to take some action against exception.
Wrap the methods in try catch when some code segment is mandatory to be executed before exiting the method e.g cleaning up SQL connection/resources before exit. Warp your methods like
<code>Try
{

}
Catch
{
throw;
}
finally
{
//Mandatory code segment
}
</code>
Make sure to wrap the calls (in UI or any other layer) in try catch. The exceptions will be caught at the calling point, even there is the methods are not wrapped in try catch in underlying layers.


What's the biggest cube you could have before gravity rounded it?

Question: I took this question from Quora because it seems interesting and this community would have some fun with it.
I would assume that one would use the modulus formulas for force to counteract the gravity, but given that the question details allow for "a solid cube, although internal structure is fine (honeycomb, etc)," this might get more complicated.
Comment: The easy observational way, no first principles required: larger than oddly shaped asteroids, smaller than round moons.
Comment: From what material is this hypothetical cube constructed, specifically? That can make a tremendous difference. For ready example, a cube made up of room-temperature water molecules need only be microscopic before gravity and surface tension round it. A cube made up of diamond, on the other hand, could theoretically be extremely large before gravity would have any effect.
Comment: Related: http://physics.stackexchange.com/q/58023/
Comment: A duplicate on [astronomy.SE]: http://astronomy.stackexchange.com/q/5918/
Comment: Giant hunk of metal? Carbon fiber? Diamond. Super dense neutron star material? I don't know -- I haven't taken material science classes and my understanding of shear etc. is shaky, but why is the assumption that the largest object has to be a rock/iron so implicit?
Comment: related: http://skeptics.stackexchange.com/q/5848/
Comment: @Thoth19: The Scheuer paper actually discusses mountains on neutron stars.
Comment: Of possible utility: [Chappell et al, 2012](https://arxiv.org/abs/1206.3857).
Answer: I'll take the question to be referring to solid rock. In reality, I think small asteroids are loose jumbles of rubble with a lot of vacuum between the rocks, and larger bodies like Ceres may have been liquid when they formed.
Googling turned up [Scheuer 1981], which can be found online for free by googling. S/he estimates the maximum height of a mountain to be
$$ \sim h_1 = \frac{4Y}{\rho g}, $$
for a mountain with an ordinary shape, or, for special Eiffel-tower shapes specially cooked up for the purpose, about $5h_1$, where the 5 is $\ln(E/Y)$. Here $Y$ is the shear strength and $E$ is the Young's modulus. Let's say that our cube is close enough to a sphere so that we can estimate $g$ at its surface as for a sphere, $g\approx (4\pi/3)G\rho r$. The corners of the cube can be considered as mountains of height $h=\alpha r$, where $\alpha\sim 0.1$. The result is
$$ r=\frac{1}{\rho}\sqrt{\frac{3Y}{\pi \alpha G}} $$
Scheuer gives $Y/g_{earth}=1.5\times10^6$ kg/m2 for granite, i.e., $Y = 1.5\times 10^7$ N/m2, and $\rho\sim 2.65\times10^3$ kg/m3. Plugging in numbers gives $r\sim500$ km.
This seems to be sort of roughly in the right ballpark. Vesta has a radius of about 250 km and is shaped like a potato. Ceres is 480 km in radius and is very spherical.
If the only relevant dimensionful variables are $Y$, $G$, and $\rho$, then the expression for $r$ is constrained to have this form, except for dimensionless factors, regardless of the other physics we use in order to derive it. I think MariusMatutiae and I, after some discussion in comments, arrived at the same answer by inputting similar physics, while I think Johannes' similar result came about because the 1000 m/s he used for the thermal velocity at vaporization is a characterization of the strength of chemical bonds, which makes it sort of equivalent to the information contained in $Y$, to within an order of magnitude.
Scheuer, "How high can a mountain be?," J. Astrophys. Astr. (1981) 2, 165–169.
Answer: I am rather surprised that neither link posted above gives a simple discussion of the effect, so here it goes.
Let us consider many asteroids of cubic shape, of constant density $\rho$, and of varying side $l$. We ask when, roughly, self-gravity will be able to perturb this shape into a spherical one. A cube of side $l$ has the same volume as a sphere of radius $l_2 =(3/4\pi)^{1/3} l \approx 0.62 l$. If we draw this sphere with the same center as the cube, we see that the cube, compared to the sphere has peaks (8, corresponding to the vertices) and troughs (6, corresponding to the face centers). Thus the question becomes: when can self-gravity slide the peaks into the troughs?
We can see this in terms of force: every point close to a peak will feel a component of the gravity force along the surface; only the vertices will feel a purely radial force. This component of the gravity force along the surface is a shear, and materials tend to fracture whenever the shear exceeds some critical value, which is generally close to their Young modulus.
Now we assume we have to relocate a fraction $q$ ($\approx 0.1$) of the total mass $M$ from the peaks to the troughs; the acceleration this matter feels is a fraction $q'\approx 0.1$ of the local acceleration of gravity $GM/l^2$, so that the total stress $\sigma$ (i.e., force per unit surface) becomes
$$
\sigma \approx \frac{q q' G M^2}{l^2 4\pi l^2}
$$
which is to be compared to the rock's critical stress, $\sigma_{crit}$, which we can take safely to be $\sigma_{crit} \approx E$, the asteroid's average Young modulus. Using the approximation of fixed density, $M = 4\pi \rho l^3/3$, we see that the gravitational shear exceeds the rock's critical shear for radii exceeding a critical radius $l_{crit}$, which agrees with our intuitive feeling that small rocks may have arbitrary shape, while the Earth and Mars are spherical.
Also, we find that reorganization of the asteroid's shape occurs for
$$
l > \left(\frac{9}{4\pi}\frac{\sigma_{crit}}{q q' G\rho^2}\right)^{1/2}\;.
$$
Using values adequate to rocks, we find
$$
l > l_{crit} \approx 1000 km\;,
$$
which jibes nicely with the fact that the asteroid Itokawa, of approximate dimension $0.5 km$, does not display a spherical shape.
Comment: This seems considerably too small. For instance, Vesta has a diameter of 500 km, but it has a highly irregular potato shape.
Comment: After my first comment, it looks like MariusMatutiae changed $l_{crit}$ from 10 km to 1000 km and inserted a G in the equation. After those changes, the answer looks similar to my own answer, so I think we're in agreement.
Comment: 6 troughs, not 8. A cube has 8 vertices, but only 6 faces.
Comment: @LoganR.Kearsley Oops, thanks for the gentle reminder...
Comment: Ben's post is correct. There are many asteroids much larger than the 10km limit, which are far from spherical. Did you underestimate the shear that compact materials can withstand?
Comment: I don't think this calculation is right. The final expression doesn't have $G$ in it, and therefore it doesn't have any input that depends on how strong gravity actually is in our universe. This seems to have happened because of the reasoning involving $q'$, which doesn't make sense to me. "the acceleration this matter feels is a fraction q′≈0.1 of the local acceleration of gravity" I don't understand why it would feel less than the full, local value of g...?
Comment: I used $\rho = 3 gm cm^{-3}$ and $E = 100 GPa$.
Answer: To answer this difficult question, we must first establish a mechanism that converts a solid cube into a sphere.
Several answers have already been given here, in which the Young's modulus is used for evaluation.
But this module characterizes elastic properties.
What does an elastic cube compressed by gravity look like?
I considered a 3D model of elastic body for which the elastic properties are not violated under strong compression.
Figure 1 shows an elastic cube compressed by gravity. We see that even with very strong gravitational compression, the cube remains a cube.

Can be assumed this is due to the fact that the gravity of the cube is not isotropic.
This can be seen using the analytical model of gravity of the cube, published on https://arxiv.org/abs/1206.3857v1
However, when I used the isotropic gravitational potential, the result was similar - Fig. 2. It may be necessary to add viscosity to the model so that the protrusions can spread.

This model implies an estimate for the size of the cube, which could undergo noticeable gravitational compression
$$L>\frac {k}{\rho}\sqrt {\frac {E}{G}}$$
Here $k$ is a numerical coefficient,$\rho$ is a density, $E$ is a Young's modulus, and $G$ is a gravitational constant. From here we can determine that $L=10^7 m$ for $\rho=5515.3 kg/m^3$ and $E=200 GPa$  (Earth parameters) which is comparable to the diameter of the Earth.
Comment: 1. This is a hypothetical elastic body that contracts in a gravitational field. We are interested in body shape. 2. It was a typo, fixed.
Comment: I don't understand some of your explanation.
1: in Figure 1, how much empty space is in the object, what is its solid incompressible minimum? (we can assume it is too small to undergo electron degeneracy)
2: in the formula, what substance is that? I don't know anything that's 55 tons/m^3.
3: your formula seems to say that a cube made of carbon fiber (E=200+ GPa, ρ = 2000 kg/m^3) could be substantially larger than the Earth, which doesn't sound right to me.
Answer: Some simple scaling relations suffice to determine the size beyond which gravity prevents non-spherical rocks from forming:
A molecule of mass $m$ is bound to a mass $M$ of linear size $R$ with gravitational binding energy approximately equal to $G M m / R$. If this gravitational binding energy far exceeds the molecular binding energy $E_b$, gravity will prevent any shape other than a sphere from forming.
Using $M \approx \rho R^3$ and $E_b \approx k_B T_b$ with $T_b$ the temperature at which molecules boil off, it follows that the gravitational binding exceeds the molecular binding if approximately $$R \sqrt{G \rho}> \sqrt{k_B T_b/m}$$
Here, $1/\sqrt{G\rho}$ represents a timescale of the order of the minimum orbital period for objects gravitationally bound to a mass with density $\rho$ (depending on the density typically some 1000 seconds) and $\sqrt{k_B T_b/m}$ representing the speed at which molecules manage to escape their molecular bonds and boil off (typically less than 1000 m/s).
It follows that the size $R$ beyond which gravity dictates spherical shapes is of the order of 1000 km.
Comment: Although this does give a number in the right ballpark, I don't think the logic is correct. The gravitational binding energy you're using is the difference between the surface and infinity, which isn't relevant to the object's internal structure. What I think you've actually estimated here is the size of an object whose gravity well is deep enough so that if further material accretes onto it by gravitational collapse (starting from rest, far away), the material will be vaporized on impact.
Comment: @BenCrowell - the key physics is that of rupturing molecular bonds due to gravitational rearrangements. Also, remember this is an order of magnitude estimate: rearranging matter over distances 10% of the objects size and over infinite distances yield - within an order of magnitude - the same gravitational energy change.
Answer: I'm going to take a stab at this question myself. However, I am not at all a structural engineer, so I'm probably doing something wrong.
I researched materials for a bit, and discovered that although diamond is very strong, it's brittle and can easily crack from a sudden jolt. Carbon fiber isn't quite as strong, but it's more able to withstand impacts, so that's what I'll work with.
Carbon fiber has compressive strength and tensile strength each about 100 MPa, and shear strength over 200 MPa. I'm taking this to mean it can withstand 10^8 N of force per m^2.
Carbon fiber's density is 2000 kg/m^2. A sphere (hold this thought for a minute) of carbon fiber would produce 6*10^-5 gee (6*10^-4 m/s^2) per km of radius, and a columnar mass of 4*10^6 kg/m^2 per km of radius (2 km of diameter). Naively multiplying mass * gravity, we get 2.4*10^3 Pa per km of radius. 10^8 / 2.4*10^3 = 4*10^4 km. 40000 km?
Working with a cube instead of a sphere is harder, because the corners are under a lot of pressure while the middle of the edges and faces are being pushed outward. Dividing by 2 or even 4 for a margin of safety still leaves us with a cube 20000 km across. And we haven't even considered structural engineering yet, using hollow girders and other mass-saving techniques.
Wow, it's looking like @Alex Trounev's formula might be right. Insane aliens might be able to build a near-perfect cube much larger than the Earth.
Answer: Believe the question is too broad - we have different states of matter with different behaviours  - plasma, gas, liquid, solid.
If one considers solids (rocks) one of the hardest known substances is diamond. If we were to imagine a diamond as big as the earth (with a diameter more than 1000 km as mentioned in other answers), if the structure holds for the first few minutes after creation (lets say we simply managed to drop it somewhere in space just like that) then don't see it degrading it to a sphere.
Update 1
PS:

Am assuming that other forces such as centrifugal force experienced by a spinning object in space are not in scope.
If liquids were to be considered then the force caused by surface-tension would be a factor as well.
There could be other states of matter with more density - such as neutron stars. However not sure if we understand the inter-molecular bonds (or its equivalent for neutrons).
The reason I said "if it does not degrade in the first few minutes" is that since it would be possible that the weight of the structure could still be very high that it collapses on itself. Apparently the density of earth's core is around 13 gm/cm3 where as its 3.51 gm/cm3 for diamond. So the earth's core is definitely denser than a diamond and if it turns out that the pressure is higher (especially at the core) than the inter-molecular bonding between the carbon-atoms of the diamond, then what it is that we'd have - the core may collapse but not sure what it will become after collapsing.
The earth's radius is 6371km on an average.

So guessing  4117km as the maximum radius based on diamond's and earth core's density before the structure collapses on itself.
<code>Given :
Earth's-Radius = 6371
Earth's-Volume = 1.08×10^12
Earth's core density = 13
Diamond's density = 3.51
Ratio of diamond's density to that of earth's core : 0.27
Max-volume of diamond-based-cube : 292.465*10^9 (ratio*earth_volume)
Length of one side of the cube : 6637
Radius of the cube if it were a sphere (same volume): 4117
</code>
Regards,
Ravindra
Answer: This is probably a moot question anyway, since what objects are around it will greatly alter the formula. The moon, for example, has the gravity of the Earth to contend with which will cause more friction within the rock of the moon. If an object was orbiting Jupiter with all of its moons, it would have many gravitational factors which would not be present if it was in deep space, away from other bodies. These would greatly accelerate the "rounding" process making the possible size of a cube relative to its placement.


What is best practice for securing access to GMail for an enterprise?

Question: Is there any way to restrict access to Gmail accounts from certain IP/MAC addresses ? For instance, can I setup Google Apps so that my users can access their GMail account from within the corporate firewall or from outside the firewall on a known machine, but not from a public browser or public machine.
Or what would be best practice to prevent unauthorized access to corporate GMail accounts?
Answer: GMail has no IP or region restrictions. What you could do though is enable 2-step verification to add further protection?
This requires two steps in setting up, one at the domain level:

Go to your Google Apps administrator control panel.
Click the Advanced tools tab.
Under Authentication > 2-step verification, check Allow users to turn on 2-factor authentication.

And the other on a per user basis:
Settings -> Accounts and Import -> Change Account Settings -> Other Google account settings -> Using 2-step verification
NOTE: The users have to manually opt-in even if you have this enabled at the domain level.
Comment: Is there any way of restricting when a user would need to use 2 step vs not? otherwise my users will never put up with it.
Comment: Appears not. Also even if you "switch it on" at the domain level, your users still have to manually opt-in themselves. And if they are anything like my users, that just isn't going to happen. Link to Google help: http://www.google.com/support/a/bin/answer.py?hl=en&answer=184711


How can i use the HTTP_REFERER to come from a specified domain name

Question: I know the HTTP_REFERER method has a security loop, but it most cases it works fine. How can i use it, to limit how a user see other pages on my website, instead of just directly clicking on the link or pasting it on the browser. Specifically, i want the referer to only work if the referred url came from the same domain name? And not from another source.
Comment: I hope you are not using it to keep a user logged in instead of using sessions or protected directories.
Answer: With Apache, to protect a directory (e.g. your /images directory) something like this in a .htaccess file works:
RewriteEngine On

RewriteCond %{HTTP_HOST};%{HTTP_REFERER} !^([^;]+);http://\1(/.*)?$
RewriteRule .* /please_dont_hotlink.html [R]


Usage of the abbreviation resp. in scientific writing

Question: Is it a good practice to use the abbreviation resp. for respectively in scientific writing ? Let consider the following sentence as example.
"The word size (resp., word length) is defined as the number of different values (resp., significant digits) that one word can store (resp., align)."
Comment: I have never ever seen the abbreviation "resp." in writing which I believe to be from a native English speaker. I think it is a habit which speakers of certain foreign languages introduce into their English writing.
Comment: To the overarching question, yes, using *resp.* is fine and not unusual in scientific writing. In re: the specific example, no, that's overusing it. Find some other way to express that set of alternatives; having that many parens interrupts the prose and the reader's flow.
Comment: @TimWard It is about Computer Science.
Comment: The flow is indeed broken by the  parentheses if we read sequentially, but not if we read in parallel: on the contrary.
Comment: I know this sounds like I'm being obtuse, but try coming up with a way that you can say it without thinking you have to explain what you just meant. I agree with the answer and comments below; too many parenthetical remarks interrupts the flow of the reader, and if you meant to say those things in the first place, why not just say them? But saying "The word length is defined as the number of significant digits that one word can align" doesn't make any more sense to me offhand than the first way. Is this about programming, or database management?
Comment: See also [this question on ELL](https://ell.stackexchange.com/questions/6491/what-does-resp-mean-in-these-sentences).
Answer: It's not about the abbreviation. Your use of the word respectively is wrong.
'Respectively' is used to say that items in a list correspond with each other in order. For example:

Alice and Bob live in apartments 1 and 2, respectively.

This means Alice lives in apartment 1 and Bob lives in apartment 2. Without the word 'respectively' we know only that both Alice and Bob live in either apartment 1 or apartment 2.
A useful word that people sometimes mean when using 'respectively' is  'specifically'. It means we qualify a general term with a specific one. For example:

If you sort a list of countries by size (specifically land area) Russia is at the top.

The vague word 'size' is explained to mean the more specific term 'land area', rather than other possibilities such as land and sea area, or population.
However none of the examples you quote are really appropriate for either 'respectively' or 'specifically'

'word length' is not a more specific term for 'word size', it's just another name for the same thing.
The 'number of different values' is not the same as the 'number of significant digits. The 'number of different values' of a byte is 256, whereas the number of significant digits is 8 (binary) or 3 (decimal). The word length of a byte is of course 8.
The word 'align' does not appear to have any relationship to the word 'store'.

I suggest:

The word size (also called word length) is defined as the number of significant digits (in the appropriate base) that a word can store.
Comment: The context is scientific writing, more precisely mathematics writing. In Mathematics, the word respectively is often use in this way.
Comment: The writer should just use the specific terms instead of using general terms and the specifying."The word length is defined as the number of different significant digits that one word can align." This still doesn't make sense, because significant digits don't have to be different, and I can't see what you mean by "align."
Comment: TAoCP 1 (third edn), p 652 : "Word size, for MIX: The number of different values that might be stored in five bytes." TAoCP 2 (third edn), p 746: "Word length: Logarithm of word size." Distinct is more appropriate than different here, I am agree.
Comment: @DJClayworth I don't think your assessment of correctness is correct.  'word size' and 'word length' are not interchangeable, 'resp.' signifies the pairings 'word size, different values' and 'word length, significant digits'.

"The word size (resp., word length) is defined as the number of different values (resp., significant digits) that one word can store (resp., align)."
Answer: The examples and the abbreviation appear to reflect the way the conjunction "respektiv(e)" is used, and abbreviated, in German. So no, it is not good practice to use it in English, as it may mystify non-German-speaking readers. As noted above, this is not at all how "respectively" is used in English.
The correct use is modelled in the "Alice and Bob" example above. German "respektive" means "or" or (not resp.!) "or else/rather". It's a mistake German L1 users of English often, and understandably, make. (This observation is based on 35 years of teaching academic English in Germany and on the Cambridge defintions of respektive and respectively.


Linked List Simple Code eexception handling error comes and program fails

Question: I am trying to implement very simple code of Linked List but unhandled exception error occurred. I want to access 2nd element data from first
I have an error in printing it it the visual studio. An exception handling error comes and program stops working.
Error is:
0
Unhandled exception at 0x00105485 in LinkedList.exe: 0xC0000005: Access violation reading location 0x00000000
class Node{
public:
    int data;
    Node *next;

};

int main() {
    Node *p = new Node();
    p->data = 10;
    p->next = NULL;

    Node *q = new Node();
    q->data = 9;
    q->next = NULL;
    //now print this
 p->next->data
    system("pause");

}

Answer: You are defining p->next = NULL and then trying to read p->next->data. Which means that you are trying to read data from NULL. If you want to create a linked list from your nodes, you need to link them yourself, I.E. do something like this:
Node *p = new Node();
p->data = 10;
p->next = NULL;

Node *q = new Node();
q->data = 9;
q->next = NULL;

p->next = q;  // Link the two nodes

//now print this
std::cout <
next->data;
system("pause");


What is the best length of time to practice for a clarinet?

Question: I play clarinet. I am not that great, but can play a high range. I use a plastic clarinet with #3 reeds, and don't have too many of them. I want to get better, yet not play for more than 45 minutes because I can't fit that into my schedule. What would be the best about of time to practice clarinet between 15 and 50 minutes?
EDIT: I have a few songs that I want to get better at. I know all the notes in the songs, and can play them reasonably at a fast pace.
Answer:
I want to get better, yet not play for more than 45 minutes because I
  can't fit that into my schedule. What would be the best about of time
  to practice clarinet between 15 and 50 minutes?

45 minutes per day is plenty for a non-professional player. There are a few points you would want to take into account when planning your session.
How to spend the time
Practicing correctly is often boring, sorry, that's how it is. You would do well to follow something similar to this plan:

Long notes

Duration: ~5 minutes
What to do: holding long notes in the middle register area: start with middle (open) G, go up to C# (by semitones), then go back to G and go down to C#. Start each note at pp, go up to f, and back to pp, then hold it at that stably for as long a you can. Fade it out when you run out of air.
What to listen to: starting notes in pp is difficult, so make sure they starts clearly and not mushy. If it's hard, start at mp instead. Also, try not to vary the pitch too much when changing dynamics. It will change a bit, but you can minimize the effect. you can use a tuner for real-time feedback (recommended).
What it works on: the most important thing for a player - sound production. This is your bread and butter, air control.

Big intervals (octaves to 4ths)

Duration: ~5 minutes. Pick one interval per day.
What to do: start from low E with a comfortable sound for you, plan the jump to the next note, and when you are ready, jump. You might need to give a bit more air before some jumps A 5ths exercise will look like this:

E0 - B0 - E1 - B1 - E2 - B2 - E3
F0 - C0 - F1 - C1 - F2 - C2 - F3
F#0 ...

Breathe when you need, but repeat the note after which you breathed to create continuity.
What to listen to: try to hit the correct pitch (use a tuner) and the same volume level as before. For octaves this won't be easy since the different registers behave very differently. For example, if you jump from middle (open) E to the E above and don't correct for the volume, the higher E will scream, for sure.
What it works on: note transitions, ear training, air control.

Chromatic scale

Duration: ~2-3 minutes
What do do: chromatic scale up and down at whatever speed is comfortable, try to go faster and higher (G4).
What to listen to: clean quick transitions (middle Bb - B), check that you're not slowing down at the more difficult places (use a metronome if needed), uniformity.
What it works on: chromatic passages, technique.

Scales - arpeggios and small intervals

Duration: ~10 minutes. Pick one scale per day.
What do do: there a lot of exercises you can do here. Start slowly then go faster as you can.

Go up and down the scale with different articulations (regular, legato - staccato - staccato, staccato - staccato - legato etc.).
3rds up and down: (Cmaj/Amin) E - G - F - A - G - B - A - C...
Break chords (arpeggios). For exmple, in C: Maj (E0 - G0 - C0 - G0 - C0 - E1 - C0 - E1 - G1...), 7th, Maj7, 6th (inverted minor 7th, so I would say not mandatory), dim, half-dim (also shared with other scales).

What to listen to: clean transitions, uniformity in tempo and sound.
What it works on: scales and chords, ear training.

Book exercise and etudes: I assume you don't have the time and/or the books. Basically, these are small passages that you need to play 10-20 times each, or follow the instructions.
Pieces

Duration: ~20-30 minutes. 1 or 2 pieces per day depending on length (a movement in a concerto counts as 1 piece, not the whole concerto).
What to do: play it. Work on the technically difficult parts. Give it a musical meaning (interpretation). Have fun finally?
What to listen to: mistakes of any kind - transitions, dynamics, articulations, sound, notes etc.
What it works on: phrasing and interpretation, make the music say what it's supposed to say - the 2nd most important thing for a player. The rest depends on the piece.

I use a plastic clarinet with #3 reeds, and don't have too many of them.

Plastic reeds last longer so you don't need many. Their sound quality is lacking, but it's probably good enough. Make sure they are not too hard for you.

I have a few songs that I want to get better at. I know all the notes in the songs, and can play them reasonably at a fast pace.

By "songs" I hope you mean pieces. If it's popular songs you won't get much out of them except for entertaining your friends. If you need recommendations for good pieces for you level ask a question. IMSLP will have them.
Don't try to play fast for the sake of it, play comfortably and increase the speed slowly. It will come with time.
Comment: @Iguanodon_Bubbles7777777 He says he doesn't have many reeds, so I  brought up the option of plastic reeds which last longer. Having a wood or plastic clarinet doesn't change anything for the player.
Comment: not plastic reeds!!!!! plastic clarinet!!!!
Comment: Do plastic reeds withstand accidentally kicking them?
Comment: @Iguanodon_Bubbles7777777 No idea.
Answer: I play the piano, not the clarinet. However, length of practise is always the subject of different opinions.
Generally, it's not about the length of practise, it's the quality of your practice. You can spend hours practising, just going through the motions without engaging your brain, ears and general senses to achieve very little.
Or,
You can concentrate and engage all that is necessary to achieve progress and improvement in very little time, which would fit better with your schedule.
I spend a lot of time with the piano but I do not value the length of practise, just the quality.
It's not uncommon for me to spend time on a very specific bar or even a few notes to improve on a difficult or technical passage.
I love to practise because of that. I make my practise interesting. I change things all the time to keep it fun.
Here's a good article:
http://www.paythepiper.co.uk/practice.asp
Passage on practise from piano technique bye L.H Phillip but true for all instrument practise.
Answer: Practice, and practice time are very much personal, therefore pretty subjective - more a matter of opinion that this is what you should do.Some like to pressurise themselves, and have something done and dusted by a certain time/day. This may mean a lot of practice because there is a deadline. If I have an important gig, with only a certain amount of 'free' time, I could fill it - maybe a couple of hours at each sitting, or more, to get something sorted. The converse is that I may be working on something with no timescale, so I may do 5 mins at a time, when I go past the particular instrument. Often, that's more productive in the long term, as there's the intervening time for things to sink in, away from the music.
Another important factor is frame of mind, state of brain, etc. Just 'practising' for an hour when you've come in after a hard day is a waste for most folks. And then, when you've dutifully done your 'practice', how do you know when you don't need to 'practise' that piece any more? For some, it's playing it perfectly 10 times on the trot, others, it's without the dots, others, it's ah, but can I now play it in another key? The list is pretty well endless. So, there is no absolute answer, but in this one, there are a few criteria to ponder.
Comment: This clearly doesn't say because there is no clearly obvious answer, as I tried to explain here. The fact that there are as yet only two answers highlights the point that there will never be an exact - or even approximate - period of time to practise. If you want an answer like that, let's say 30 minutes. But then 25 could be better. Or 35. Each day may well be different.
Comment: This doesn't clearly say how long to practice, and I said between 15 and 45 minutes.
Answer: I don't think there is a best length of time for practicing. Normally, I have to take a break after practicing continuously for 30 to 35 minutes. Sometimes, I just practice for ten to twenty five minutes, then take a break.


Random permutation of a vector with a fixed expected sample correlation to the original?

Question: Suppose you have an $n$-vector $X$. For a fixed real number, $r$ between $-1$ and $1$, can one generate a random permutation of the integers $1,2,\ldots,n$, call it $i_1,i_2,\ldots,i_n$ such that the vector $X$ and the vector $\tilde{X}$ defined by $\tilde{X_j} = X_{i_j}$ have expected sample correlation of $r$?  I am looking for a process that generates such permutations. Without loss of generality, I believe one may assume $X$ has zero sample mean, and unit sample standard deviation.
Comment: @kwak Concerning your deleted response: I see vaguely that there is some kind of limited permuting going on until somehow a correlation coefficient below 0.5 (e.g.) is attained, but I cannot quite connect that with the conditions of the original question.  Are you saying you just keep applying "small" random permutations until you obtain a correlation within a targeted range of correlations?  If that's so, I think it's a really creative idea but some analysis is needed to show it can actually work.  Regardless, thanks for sharing it (however briefly!).
Answer: The answers are no, not for all $r$ in general; yes, for a restricted range of $r$ that is readily computed; but there remain a wide set of choices to be made.
I will use a standard notation where the action of a permutation $\sigma$ is written $ X^\sigma_i = X_{\sigma (i)}$ and the set of all permutations of the $n$ coordinates is $S_n$.
As you note in the question, upon standardizing $X$ it suffices to investigate $\mathbb{E}[{X^\sigma}'X]$.  Because $X'X = 1$, a correlation of $r = 1$ is certainly attainable by means of the identity permutation $\epsilon$ (where $\epsilon(i) = i$ for all $i$).  However, for any given $X$ there is a minimum attainable correlation: it is realized by associating the $k^\text{th}$ smallest component of $X^\sigma$ with the $k^\text{th}$ largest component of $X$.  For example, with $X = (-2,1,1)/\sqrt{6}$ the smallest possible correlation of $-1/2$ is achieved by $X^\sigma = (1,1,-2)/\sqrt{6}$.  Let's call this minimum correlation $r_{min}(X)$ and let $\sigma_{min}(X)$ be any permutation achieving this minimum value.
Every possible expected correlation of value between $r_{min}(X)$ and $1$ is attainable by means of a distribution supported on just $\sigma_{min}$ and $\epsilon$.  Specifically, set
$$p = \frac{r - r_{min}}{1 - r_{min}}$$
and generate the permutation $\sigma_{min}$ with probability $1 - p$ and the permutation $\epsilon$ with probability $p$.  (If $r_{min} = 1$ this formula is undefined but there's nothing to do anyway.)
I suspect you would like a more "interesting" distribution of permutations than this.  To create this you will need to add more conditions.  Here's one way to frame your problem: to every permutation $\sigma$ corresponds the number $f(\sigma) = {X^\sigma}'X$. An arbitrary probability distribution over the permutations assigns a non-negative value $p(\sigma)$ to each permutation according to the axioms of probability.  The expectation of $f$, which is the expected correlation between $X$ and $X^\sigma$, of course equals
$$\sum_{\sigma \in S_n}{p(\sigma)f(\sigma)}.$$
Given a desired expected correlation $r$, you therefore have freedom to choose the $n!$ values $p(\sigma)$ subject to the conditions
$$\sum_{\sigma \in S_n}{p(\sigma)} = 1,$$
$$\sum_{\sigma \in S_n}{p(\sigma)f(\sigma)} = r,$$
$$p(\sigma) \ge 0 \text{ for all } \sigma \in S_n.$$
I have merely demonstrated that this linear program is feasible if and only if $r_{min} \le r \le 1$.  You are free to choose among the solutions (a convex set of distributions) in any way you like.  For instance, you might prefer to use as uniform a choice of permutations as possible, in which case you might seek to minimize the variance of the $p(\sigma)$ (thought of just as a set of numbers) subject to the preceding conditions.  That's a quadratic program, for which there are many good solution methods and much available software.  Solving this (exactly) will become problematic once $n$ exceeds about $8$ or so, because it involves $n!$ variables and you'll just overwhelm the software.  In such cases you might want to restrict the distributions further, such as requiring them to be only cyclic and anti-cyclic permutations of the sorted coordinates (just $2n$ variables).  Another possibility is to choose a bunch of permutations randomly--making sure to include the order-reversing permutation among them so the minimum correlation can be included--and then finding an approximately uniform distribution among them.
Comment: @shabbychef Then you might want to give some thought to achieving a desired *variance* in the correlation coefficients that will be generated.  You can include that within the constraints and, provided the desired variance is neither too great nor too small, you should still have a nonempty feasible set.  For this application it might be wise to achieve as uniform a distribution as possible.  Alternatively, you can impose a desired variance by means of a penalty term in the objective function, seeking a balance between uniformity and achieving the target values of variance and expectation.
Comment: @qed It is an *expectation,* not a sample correlation. For instance, the expectation of a Bernoulli$(p)$ variate is $p$ but the only values that variable can attain are $0$ and $1$.
Comment: I had suspected there was a 'trivial' algorithm, which generated the identity permutation with probability $r$, and was uniform on all permutations with probability $1-r$, for the case $r > 0$. It looks like that is not exactly correct, and your "uninteresting" solution fixes my error.
Comment: @shabbychef You have a fine intuition: picking a permutation uniformly at random gives an expected correlation of zero. To achieve an expectation of r > 0, then, select the identity with probability r and otherwise select any uniformly random permutation (*including* the identity) with probability 1-r. A similar approach (using the reversal of ranks) will yield any expectation down to the minimum possible value for the data (which depends on the data, not just on how many there are). These solutions don't yield the most uniform distributions overall, though: one permutation clearly is favored.
Comment: @whuber yes, I had mistakenly thought that I could also achieve any negative $r$ by this trivial method, by 'reversing' the indices with probability $|r|$. I guess I was tacitly assuming the vector $X$ was symmetric about $0$. The trivial algorithm is unsatisfying, though, as you suspected.
Comment: @shabbychef I believe these permutation methods tend to be used more with Spearman (rank) correlation coefficients, where all values between -1 and 1 are attainable.
Comment: @whuber: you read my mind! A solution to this problem could be used to generate a bootstrap sample from a vector with a fixed level of Spearman correlation to any other vector of the same length (modulo degeneracies in that other vector.) In that case, it suffices to think of $X_i = i$ up to location and scaling shifts.
Comment: Why is every possible expected correlation of value between rmin(X) and 1 is attainable? The number of permutations is finite, while the choice of correlation coefficient is infinite.


Is it possible to pass the record type of a lightning page into the lwc that's being referenced on that page?

Question: So I have a Case lightning record page. Then I created a LWC to display some text depending on the record type of the page and put that LWC into the lightning record page. The text that is displayed is controlled by a property in the LWC. I can only pass in a constant string into the property from the lightning record page. I don't know how to pass in a variable (record type). Does anyone know if this is possible?
Comment: You can pass the record Id to LWC and then query the recordtype using getRecord adapter. https://salesforce.stackexchange.com/questions/294471/how-to-pass-the-record-id-to-controller-method-from-lwc
Answer: You can't pass it in directly. What you're expected to do is to call LDS (Lightning Data Service). You do this by importing the method and then using the magic api attribute recordId:
<code>import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import { LightningElement, wire, api } from 'lwc';
import RECORDTYPEFIELD from '@salesforce/schema/ObjectName/RecordTypeId';

export default class MyComponent extends LightningElement {
  @api recordId;
  @wire(getRecord, { recordId: '$recordId', fields: [RECORDTYPEFIELD] })
  record({data,error}) {
    console.log(getFieldValue(data,RECORDTYPEFIELD));
  }
}
</code>


Which Union General identified the defensive value of Cemetery Hill?

Question: Who was the first Union general to realize the significance of Cemetery Hill during the battle of Gettysburg (1863) as a defensive position: Buford, Reynolds, Howard, or Hancock? They each claim to be that general.
Comment: I disagree with the VtC. If any of the above listed generals left dehind diaries, we might be able to place a time. If not, the answer might be we don't know. This can be done leaving the amount of opinion at a minimum. If someone answers with opinion or conjecture, down-vote it. This is a specific (fairly) well written question. It doesn't appear to have any preliminary research, but that's not a (current) reason to VtC. I'll say it again: _we need questions to broaden our readership._
Comment: Hat tip to @BOB who edited the question to fix the problems I whinged about before I finished whinging.  Well played!!
Comment: Reynolds claimed no such thing, being too dead.
Comment: As neither of those eminent gentlemen was incompetent, it seems very likely that they all independently reached that conclusion immediately upon arriving on the battlefield. As the battle was a meeting engagement, not a set-piece battle, you take the terrain you are given, and Cemetery Ridge was the most prominent terrain available to the Union side without a significant retreat. As they all claimed to reach this (rather obvious) conclusion quickly, I see no reason to dispute that.
Comment: I agree with your answer and feel it must have been Buford. Howard only occupied the hill under orders from Reynolds via messenger.
Answer: Howard has priority - he was the commander on the field after Reynolds was dead and before Hancock.  He, unlike the others, actually occupied the hill with troops, keeping first a division and later a brigade there while the fighting was taking place on the north.
That said, like many of these "choose the field" controversies, it doesn't take much genius to see that that fishhook position was a good one from attacks coming from the north and west, where the Rebels were.  These things were fought out in the 1880s more than they deserved.  No need to bring them up now.
Comment: Since, as you say, these things have been fought out in the 1880's. Then there should be ample sources that discuss the matter, care to share them? I would hazard that Westpoint's library has a few treatises on the subject.
Comment: Battles and Leaders of the Civil War was the "stack exchange" of the time.


Why does Kuroko call Misaka "onee-sama"?

Question: I just watched Toaru Kagaku no Railgun. It seems like Kuroko is in love with Misaka (?) and calls her "onee-sama", but when did it start? And why/how did this happen?
Answer: Onee-sama is commonly used in an idol-follower relationship between women, usually signifying extreme adoration on the part of the follower so on the surface it can look like Kuroko idolized Misaka because she's a Level 5.
However, we see that Kuroko sees Misaka as something than an Idol ie. groping her in the showers, getting jealous of any man being with her or wanting to see her, stealing her underwear,

 she has obviously done this before as she knew that the real Misaka would attack her if she stole her underwear using her Esper powers proving the one she was with was the real Misaka

this would indicate that Kuroko has feelings for Misaka which are ignored by Misaka possibly passing it off as just Kuroko's personality.
This would be a subset of the idol-follower type of relationship, signalling a lesbian relationship with the youngest of the couple referring to the oldest one as "Onee-sama", this is common in Shoujo Ai/Yuri where the youngest adores her older partner and the term is used to demonstrate how strong they feel as wanting to be a family with them.
However there are times where the oldest in the couple find this as a sort of "turn on", in the first Sono Hanabira game Yuuna gets Nanami to call her Onee-sama and the moment Nanami does we can see the euphoria in Yuuna as Yuuna keeps requesting Nanami to "say it again" and tries to get her to use it in conjunction with some lewd talk (to which Nanami releaises what she is about to say and stops it), Yuuna also tried to get Sara in the second game call Kaede Onee-sama but after a couple of uses Sara chooses not to.
Now as for the second part to your question, while i have yet to read the light novels, given Kuroko's personality it may have started when Misaka and her first met being "love at first sight", i remember Kuroko mentioning she had to "pull some strings" to get her and Misaka to share the same room and given how Misaka is used to Kuroko actions and how Kuroko is used to being "punished" it would indicate it's been going on for quite a while
Comment: This answer is correct, but also note that the use of sama is strictly an anime thing. This isn't how people actually address each other in real life.
Answer: In traditional Asian countries (like in Southeast Asia, China, Japan, etc.), you can address someone close to you as "older sibling" or "younger sibling" if their age is not far from yours, but if they are much older than you, sometimes you can address them as "Uncle" or "Aunt" even if they are not actually your family.
This applies to many anime due to Japanese tradition. Kuroko gives respect to Misaka as someone older than her, but calling such people "X-sama" primarily only happens in fiction. However, sometimes this term of address is actually used in family that have a perspective based in ancient tradition (like yakuza families, etc.), but this is not too common.
Note that calling someone "Uncle"/"Aunt" sometimes may not be polite (especially if the age difference is not substantial), because it makes it seem as you are treating them as old. Most of the time, in Asian tradition, we use just a word meaning "older/younger sibling" instead.


How does a rising bubble take a dome-like shape?

Question: Since I have swam on the swim team for most of my life, I am very familiar with bubbles. I know a raindrop falling through the sky gets its shape because it is the most aerodynamic shape, but how come a bubble rising through water has a different, rather jellyfish-like or dome shape?

 is an example of what I am referencing. (As a side note, I have found this property to be shown mostly in larger bubbles.)
Comment: Have a look at [this article from Nature](http://www.nature.com/ncomms/2015/150217/ncomms7268/full/ncomms7268.html) and in particular figure 1. Sadly the full article is behind a paywall.
Comment: No, raindrops do not take an aerodynamic shape.  They wobble and jiggle due to complicated interactions with local atmospheric phenomenon (and their shape history).
Comment: @JohnRennie thank you, that was a great article.   [It looks like this is a public pre-print](http://www.iith.ac.in/~ksahu/2015_Tripathi_Nature.pdf)
Answer: As the bubble rises it pushes the water above it out of the way, so we get a water flow created around the bubble. With a large bubble the flow velocities will be relatively high because a large bubble has to push aside a large volume of water.
Water flowing around a bubble will pull it out of shape. the obvious simple example is a bubble in a shear flow, that gets pulled out into an ellipsoid:

For a bubble rising through water the flow is going to be complicated and there is no simple way to calculate it. We have to reach for a finite element analysis program and a large computer. I did some Googling and managed to find this paper reporting calculations of this type$^1$. If you look at for example figure 3 in the paper it shows the hemisphere bubble shape that you show in your photo.
The trouble with the computer modelling is that it can be hard to get an intuitive feel for what is going on, so I've attempted to draw my own diagram of how the bubble is pulled out of shape by the water flow:

You shouldn't take this too literally as it's just an illustration of the flow. The arrows show the water flow, and how it pulls the bubble out of shape. There are more detailed (if more confusing!) diagras of the flow in figure 15 of the paper I have linked.

$^1$ Jinsong Hua and Jing Lou, Numerical simulation of bubble rising in viscous liquid, Journal of Computational Physics 222 (2007) 769–795
Comment: Your answer talks about the cause, without elaborating on the principle, which defines the phenomenon. It's like introducing the concept of friction, without taking the time to distinguish between static and kinetic friction. An oversimplification of a complex process, isn't exactly the way forward, right?
Comment: Minor comment to the post (v1): Please consider to mention explicitly author, title, etc. of link, so it is possible to reconstruct link in case of link rot.
Answer: The bubble maintains a spherical shape, because of surface tension, which I am sure you are aware of. It does so , because it wants to store maximum volume of the fluid involved, using minimum surface area, which can be done using a spherical shape. Thus, the layer of the bubble acts like a stretched membrane. When the pressure inside the bubble, for whatever reason, increases more than what the surface tension can balance, it breaks apart into a semi-spherical, or dome like structure. Now, even though it is not a complete bubble, it still has surface tension, and thus possesses some concavity.
The reason behind the bubble's desire to minimise it's surface area, is that all objects want to stay at the lowest energy possible. When you increase the surface area of the bubble, you increase the number of particles being affected by adhesive forces of the surrounding, and thus increasing it's energy( surface potential energy).
Comment: I don't see how this answers the question. The "bowl" shape is going to be some balance between surface tension and the hydrodynamic forces created as the bubble rises.
Comment: @JohnRennie If you read the last line of the first paragraph, you might just learn something.
Comment: @Garvit: It isn't obvious to me how your first paragraph's conclusion follows from its predicates.
Comment: @RedGrittyBrick The first paragraph talks about the reason behind the spherical shape, i.e., surface tension. The last line suggests that there isn't sufficient surface tension to balance the external pressure, hence it's shape changes. But, since surface tension still acts, we continue to see an incomplete spherical shape. My answer is a direct answer to why do bubbles get their spherical shape and not any other.
Comment: I find this answer to lack directness, too.  Sorry.  Probably you are being too generalistic — i.e. a bubble *does not* maintain spherical shape under all situations, so you cannot lead with that 'bare' assertion.


What exactly is wave particle duality?

Question: I am a 12th grade student I want to clarify some fundamentals about waves.It's clear to me when some one says sound propagates
As a wave(the variations of air densities as a function of distance from the source at an instant of time represent a sinusoidal function.).But what does it mean when someone says electron behaves as a wave?Does it mean it's trajectory represents a wave?
Answer: The "wave" of the electron is a probability wave used to describe quantum effects. For quantum-scale particles that have not had any effects measured (e.g. spin, momentum, position), the "particle" cannot be described as a discrete object in one spot/state, but as a wave existing in and moving through multiple states at once. This wave is described by the wavefunction, and by taking the absolute value and then squaring it, you get the probability distribution. This $|\psi|^2$ tells you where you are most likely to find the electron upon measurement.
It's a very weird and intriguing phenomenon that has no classical analogue.
Comment: So reading through the answers down here and one provided through the link I have come to the opinion that if there is light beam passing through a region,we can't know the exact position of the photons constituting it so we can only represent the probability of finding them in region i.e. the probability of finding the photon in a given space(probability density)therefore at that instant we say it is behaving as a wave.Is this correct?
Comment: Yes, in that case the photon would be behaving more like a wave. The photoelectric effect would be a time it acts like a particle.

Look up the electron double slit experiment. That explains a lot about what WPD means
Answer: I am explaining my understanding: The wave particle effect is the momenta effect of a wave packet describing an energetic identity. So a photon is neither a wave nor a particle, it is not a wave sometimes and a particle some other times; it is a wave packet. Due to its momenta effect it may have some particle behavior, and as defining momentum in particles is mass x velocity: mass is an intrinsic property and speed is extrinsic, the momentum is a whole one intrinsic property in massless particles like photons.
Answer: Wave-particle duality only exists in quantum mechanics, not in acoustics.
In the QM realm, that duality refers to the fact that very very very small objects can either manifest themselves as particles or as waves, depending on what type of measuring device you are using on them. So for a huge number of photons traveling through a prism, they act like waves, but for single photons striking a metal surface in a vacuum, they act instead like particles.
Similarly, electrons being boiled off a hot metal object in a vacuum behave like miniature machine gun bullets, but when beamed through a single crystal of a metal like nickel they diffract just as if they were waves instead.
Answer: I am actually a 7th grade student interesting of your level... but let us get to the fundamentals in quantum mechanics when we speak of wave-function you can interpret the Doppler effect which applies to sound and general particles if someone claims an electron behaves in a wave and as a particle you can infer that both of those are correct and scientifically tenable... Furthermore  lets prolong the common example of the electron it behaves as a particle on a plane not an asymptote but just a sinusoidal wave it also oscillates continually and because it is a particle you can detect the absolute in Brownian momentum with the wave, hence we can derive some fascinating properties but back to the corroboration it has been proven with the double-slit experiment in 1801 which was attempted by Thomas Young to prove the nature of light which was shown and it links to one of the most perhaps prominent theories that quickly graduated to the possible theory of the universe string theorem which describes every elementary particle from the standard model a standing wave, furthermore each wave has a specific probability to there amplitude in space in there quantum system propagation could change the magnitude in multiple ways at any given point. Thus I believe it is more than safe to say that the electron varies in the vibration of a wave given the function (I hope that helps) Also if you are interested in things like these topics perhaps you would enjoy a book I just read by Tim James titled Fundamentals on the cover it states how quantum mechanics and particle physics explains absolutely everything!
Comment: Excellent answer from a 7th grader. However, the answer to this question cannot be complete with addressing probability waves / matter waves and how they differ from physical waves such as sound waves or gravity waves (not to be confused with gravitational waves). Namely, the matter waves of quantum mechanics are oscillations in the probability amplitude of the particle, not in the trajectory of the particle (which is the case in the classical examples of waves mentioned).
Comment: True... I will fix it.
Comment: @electronpusher I covered probability amplitude in my response it was whimsical of me I was thing about Feynman's lectures the other day terribly sorry.

What exactly is wave particle duality?


Should users be asked to increase their accept rates?

Question: I've noticed from time to time, users leave comments requesting other users increase their accept rate.  I've seen this done in the original SE trilogy communities, so I guess it's accepted behavior there.  Is this behavior accepted in our community?  If users don't feel they've received an "acceptable" answer on questions, should they be punished in future questions for not accepting an answer on previous questions?  Are folks really not answering questions because of low accept rates?
Comment: @Steven To help people.
Comment: As to your question, "Are folks really not answering questions because of low accept rates?", yes, that would be right - what's the point in answering if the user never accepts or responds with comments?
Comment: It goes two ways. From my perspective, if they never comment, upvote or accept, then they are not participating in the community and the evidence suggests that I'm not even helping.  I know what user this is about and he had a 0% accept rate over a number of questions...
Answer: Please don't badger users to accept answers.
While it happens on the original trilogy it's not universally accepted and if you flag a "(please) improve your accept rate" comment it gets deleted immediately with no moderator involvement.
All acceptance means is that the OP found that answer the most helpful. If there isn't an answer that fits then there is no obligation on the OP to accept any answer.
If the OP comments that the answer helped but hasn't actually accepted then perhaps adding a comment linking to the Meta Stack Overflow post on how acceptance works might be in  order, but please don't do it in a accusatory way.
Comment: When flagging these comments, what should the flag reason be?
Comment: @Tester101 - "not constructive / off-topic"
Comment: Going through old posts with no accepted answers. If the user is active, I ask how they solved it. Should I not? Should I suggest they answer their own question, then?


Do mortgage lenders in the UK consider stock grants or sign on bonuses?

Question: I am employed as a software engineer in a company that grants shares and a sign on bonus. Do mortgage lenders in the UK take into consideration stock grants and annual sign on bonus (sign on bonus but given over 2 years for example) when lending? If yes, are they high street lenders or private brokers?
Comment: Ultimately, this is a question you need to ask your lender. Anecdotally, I've found that lenders tend to be very conservative and risk-averse, so may take nothing more than your salary as evidence of income. They're interested in your regular, contractual, monthly income. Annual or one-off discretionary awards tend not to count.
Comment: If you're relying on a sign-on bonus that lasts 2 years to gain finance a mortgage that lasts 20 to 30 years, then you may be over-stretching your finances.
Comment: Simon B, how so? , so if your sign on bonus + base allows you to afford a house worth £500k on which you pay say £1300 pm mortgage how is that different from renting in London which costs the same? The only difference being, if you don't count the bonus, you can borrow less.
Comment: @SamerTufail because interests might swing +/- 5%. If you had to rely on a sign on bonus to get the mortgage, you are likely pushing the limit of what you can handle IF interests should climb.(and the banks know it, which is why they seldom calculate with windfall money)
Comment: @Stian Yttervik, at that point you probably sell. I did check with 1 mainstream lender and they said they need last 3 month payslips and whatever is on it, forms part of how much they would lend. For stocks I did not get a good answer.
Comment: @Stian Yttervik, at that point you probably sell. I did check with 1 mainstream lender and they said they need last 3 month payslips and whatever is on it, forms part of how much they would lend. For stocks I did not get a good answer.
Answer: In short, no.
Anything that sits within volatile income (of which sign on bonuses, golden parachutes, stock grants, annual bonuses etc etc all most definitely are), lenders tend to discount because what they care about is your ability to make stable payments for long periods - none of which is impacted much by methods of bonus like this (if anything - it can often be a sign of instability, showing people jumping jobs often, working for risky, start up style companies with a high risk of failure or other higher risk employment actions etc).
If you get a large number of these types of payments you're generally better off aggressively saving the ones you get now and add to the initial deposit (to reduce your interest and payments later), and to be mindful of mortgage products that allow early payments so when you get them later you can aggressively pay down your mortgage.
If you want to have your cake and eat it and factor in all these volatile payments as the same as income, then sadly lenders have far too long a track record of these types of people blowing up and typically won't go near it.


Interpreting direction of torque

Question: The direction of torque is along axis of rotation. What does this actually mean? Suppose a body is rotating anticlockwise and along its axis we placed someting. Would the material placed on axis experience a torque effect or force along upward direction as body is rotating anticlockwise? Or is there no effect on its state whatsoever?
Comment: Is your first sentence a quote? if yes, then place it under quotation marks and denote where it is from. Also, please clarify the situation with a sketch or something. How is the "up" direction in relation to the rotation axis? What do you mean by "placing something on the body?" If the torque due to motion a result of friction or some other bonding mechanism?
Answer: Given torque, what is the direction of motion? - The answers for this question may give you an answer to the first part of your question. The direction of torque only gives an idea about the axis (whether rotation is clockwise or anticlockwise) and is not the direction in which the force causes rotation of the body.
Mathematically, torque is the vector cross product of the force and the distance (from axis to the object) vectors. For a body placed on the axis, the distance from axis is zero and hence there is no torque acting on it.
Comment: What I am thinking of is celing fan.As it rotates the air moves down as it were pulled from center where axis is located.Is my thinking wrong?
Comment: Ceiling fan blades can be angled either way so the same direction of spin, and torque, can either push the air up or down. I seem to recall there is even a design of fan that allows the blades to be angled as desired.
Answer: Your question isn't very clear. But I feel there is some confusion as to what the equations of motion are, and what they mean.
First some definitions:

The linear velocity vector at a point is typically a result of the rotation about an axis not through the point. The amount of velocity gives us an idea of how far is the center of mass from the axis of rotation. The direction of the velocity vector is perpendicular to the direction of rotation. You can use the right hand rule to find which way something is moving when it is rotating about an axis.
$$ \boldsymbol{v} = \boldsymbol{r} \times \boldsymbol{\omega} $$

Similarly the torque at a location is a result of a force being applied along a line (the line of action) not through that point. The direction of torque vector is perpendicular to the line of action. You can use the right hand rule to find which way something twists when a force is applied along an axis.
$$ \boldsymbol{\tau} = \boldsymbol{r} \times \boldsymbol{F} $$

Linear momentum vector is the mass times the velocity vector of the center of mass. Regardless of how an object is rotating or moving, it the only the motion of the center of mass that defines the momentum vector $$ \boldsymbol{p} = m \, \boldsymbol{v}_C $$

Force vector if the rate of change of linear momentum. Regardless loading conditions and motions, the net force on an object relates only to the motion of its center of mass. The direction of force is the same as the direction of the linear acceleration of the center of mass.
$$ \boldsymbol{F} = \frac{{\rm d} \boldsymbol{p}}{{\rm d}t} = m \,\boldsymbol{a}_C $$

Angular momentum vector about the center of mass is calculated from the rotational motion about the center of mass. This rotation is shared with the entire body. Regardless of the motion of the center of mass, it is only the rotation about the center of mass that defines angular momentum. If the rotation is only about a fixed axis, then the scalar factor between rotation and angular momentum is the mass moment of inertia. For general motion the mass moment of inertia is 3×3 matrix that depends on the orientation of the body
$$\boldsymbol{L}_C = \mathrm{I}_C \boldsymbol{\omega} $$

Torque vector about the center of mass is the rate of change of angular momentum about the center of mass. Torque only affects the rotation of a body. The direction of torque is generally not the direction angular acceleration because the mass moment of inertia is not a scalar value causing some complex motion.
$$ \boldsymbol{\tau} = \frac{{\rm d} \boldsymbol{L}_C }{{\rm d}t } = \mathrm{I}_C \boldsymbol{\alpha} + \boldsymbol{\omega} \times \mathrm{I}_C  \boldsymbol{\omega} $$

In summary, a torque causes a body to rotate about its center of mass and a force to translate the center of mass. Their directions indicate where the rotation axis is and where the line of action is.

Interpreting direction of torque


Why does DES use a block size of 64 bit?

Question: Why do we use 64 bit as block size for the DES algorithm? Is there a reason not to use another block size, for instance 72 bits?
Answer: A minimum block size is required for a block cipher mode of operation to be considered secure. If the block size is too small then issues may arise.
Many modes of operation for instance use an IV that has the same size as the block size. If the block size would be smaller then a randomly generated IV could repeat. This will happen quickly especially if many messages are encrypted using the same key.
Worse, a mode such as CBC uses the last ciphertext as vector for the next step, so the ciphertext could repeat as well, which means that the ciphertext could leak information about the plaintext. For counter (CTR) mode the counter could start to repeat, which could lead to a complete loss of confidentiality of the plaintext message.
So using a block cipher with a small block size will lead to security issues, even if the block cipher itself is considered secure.

On the other hand a block should not be too big. Larger block sizes require a more complex cipher and likely require more internal state. This is especially a problem if space is an issue, and space always is for hardware implementations of the block cipher.
Also note that modes of operation always require at least one operation of the full block cipher for the last bytes of the message. So if 1 byte is encrypted the full block cipher still needs to be executed for that single byte. Many modes of operation output a multiple of the block size, so there may be additional storage / communication overhead for larger block sizes (on top of the larger IV).
So using a block cipher with a larger block size will increase the memory requirements and as well as the CPU and storage overhead required for the ciphertext.

To simplify calculations, enhance memory efficiency (alignment) and so forth, many computer algorithms perform operations using powers of two. Although it would probably be possible to specify a block cipher as an algorithm of 65 bits the algorithm and implementation would be tricky to design correctly. Ciphers are generally specifies using byte boundaries and preferably using powers of two.
Furthermore, it makes sense to make the (encoded) key size and the block size match up. That way it is easy to encrypt one key with the other. A DES key consists of 56 bits and 8 parity bits. That means that a 64 bit DES key can be directly encrypted (wrapped) by another DES key, without requiring any mode of operation.
AES-192 - which has a key size of 192 bits and a block size of 128 bits - is awkward to correctly use because 192 is not a multiple of the block size of 128 bits.

In the end the block size is selected by the designers with the above three points in mind. The block size is therefore a compromise between security and efficiency.

Modern ciphers do not use a block size of 64 bits anymore; most cryptographers would consider 64-bit block ciphers outdated. They may not be broken, but the 64 bit block size makes them insecure in many situations. Single DES is of course considered broken, mainly because of the small effective key size.
AES has a block size of 128 bits, as this was mandatory for every AES candidate during the AES competition. But even 128 bits is sometimes considered not that secure anymore. Counter mode encryption and many authenticated ciphers that rely on it have limitations, mainly when the 128 bits are used for different purposes (a 64 bit random nonce and 64 bit counter, for instance).
So other block ciphers even use a larger block size. Threefish (which is part of Skein, one of the SHA-3 candidates) uses a block size of 256 bits. This helps it being used as a tweakable block cipher within the Skein hash algorithm.
With Blowfish using 64 bit block size, Twofish using 128 bits and Threefish using 256 I guess you can see where we're heading. That said, a block size of 256 / 512 bits may be large enough for most purposes, so this trend to larger block sizes will likely not continue forever.

Note that many modern CPU's have been designed with 64 bit and SIMD operations and may be more efficient for larger block sizes and / or larger internal state. So a smaller block size may not always be more efficient; for instance SHA-512 is commonly both more secure and faster than SHA-256 on a CPU with an AMD64 instruction set, especially for large messages.
Comment: `a larger block size will decrease the efficiency both the calculations as well as the overhead required for the ciphertext.` - there is a sweet spot between large and small, at least in software. A cipher with 128 bits of state will struggle to compete with a cipher with 256/384/512 bits of state on the throughput front, assuming that the larger ciphers use SIMD.
Comment: @EllaRose ,Maarten, one example of a cipher where a larger block size leads to better throughput is Skein / Threefish in the 256 vs the 512 bit variants where the latter is slightly better.
Comment: I'm a bit struggling with this comment. Inner state isn't *quite* the same as the block size. But sure, if the cipher can use SIMD or at least 64 bit ops then the cipher may be able to use that to its advantage. As always, when I'm struggling to include it in my answer, I'll leave the comment to fight for it's own merit; it's got my upvote...
Comment: I guess it should have read "block size" instead of "state", as "state" could include things such as the round counter. But basically, with a nicely designed permutation, SIMD will act like a multiplier for the throughput. So smaller is not necessarily faster. Another way to look at it is to imagine the inverse of the statement in question: `a *smaller* block size will *increase* the efficiency both the calculations as well as the overhead required for the ciphertext.`, which is certainly not true.
Comment: OK, thanks for the clarification; I've changed the section you're referring to and added a final section. Edit if it is still incorrect - but please keep the answer at the same technical level as it is now if you do decide to edit.


Exporting a shape from Illustrator in multiple colours at once?

Question: I'm creating assets for a game using Illustrator. I have created a bunch of shapes, and i want to export each shape in 24 different colours (which i've made swatches of, if that helps)
I was wondering if there's a way of doing this in some kind of batch process? (rather than copy and pasting the symbols a bunch of times and changing the colour then manually saving them)
Comment: Hi tackyvillain, welcome to GDSE and thanks for your question. If you want to know more about the site, please see the [help] or ping one of us in the [chat] once your reputation is sufficient (20). Keep contributing and enjoy the site!
Answer: If you made swatches which are in each such document, you can use the Actions panel to record an action which has the following effect: select your shape, set the fill (and/or) stroke to your desired swatch and export the file- repeat as many times as there are swatches.
This while I am assuming you have a folder full of individual files which have a shape in each one, and each file will produce 24 separate files.
After recording the action, use the Batch... command in the fly-out menu of the Actions panel.
In case you do not have every one of your swatches in all of the separate documents, you can use a trick to instantly place all the swatches by saving a file with all of your swatches saved as spot-colors displayed as shapes on the artboard, and recording a Place command to place this file as the first step in your batch action. When a file is placed and contains spot color inks, the swatches are instantly added to the current document.
While batching actions can make your work faster, most of the time such work can greatly benefit from custom scripts!
UPDATE:
See my article and referenced scripts to use variable data and a re-coloring command system to accomplish your task.
Illustrator Variable Data Advanced Techniques: Recoloring Artwork based on data