Somebody sells at 4k instead of 40k. Who gets it?

Question: If somebody sells x amount of BTC (or any other crypto) mistakenly at 4k instead of the current 40k (assumption), who will get it and for how much? Will somebody just be the happy one?
Comment: Related: https://bitcoin.stackexchange.com/a/20759/5406
Comment: This comes under "questions I have but feel will make me look stupid if I ask" - I'm glad someone did :)
Answer: TLDR: The highest bidder on the exchange will get it.
One of the main jobs of an exchange is to match sellers with buyers. The exchange will help users sell for the highest price possible, and buy for the lowest price possible. If the price you want is lower than the highest bidder (buyer), the exchange will tell the buyer, "hey, we found someone that wants to sell you bitcoin at your price!". The buyer does not know that you were willing to sell for 4000.
Noone will be lucky. All reputable exchanges have several people wanting to buy at a price higher than 4000 when the current price is 40 000.
You can figure out the price you're going going to sell for if you take a look in the orderbook. There you can see people wanting to both buy and sell bitcoin for different prices.
In the picture, green orders are buyers, and red orders are sellers. The price you're going to get when you sell bitcoin is the top green one.

You can try it for yourself! Add a limit sell order with 4000 as the price. Depending on the exchange it will tell you that by placing the order, 100% of the order will be filled. The final price is not going to be 4000, but probably very close to 33 828.
Comment: your answer says "The final price is not going to be 4000, but probably very close to 40 000."... do you mean very close to 33828?
Comment: Yes! Very close to 33828 using my image an example.
Comment: So basically, you can't place a REAL mistake-sell, only a quite bad one?! Or in other words - and that's why i asked in the first place - it does not make sense to just place a 4k-order and hope somebody mistakenly sells at this price? Because that would be quite cool, wouldn't it :) (or bad for the person who makes the mistake). Thanks for the response!
Comment: yes, I think you can try it by buying $1 or $10 worth of bitcoin on Robinhood or Coinbase Pro, so it is not going to hurt you for that $1 or $10
Comment: Yes, pretty much impossible! It's only possible in order books with very low liquidity. As long as you use a reputable exchange and trade bitcoin, you won't find that.

No, it does not make sense to do that. Every single buyer willing to pay more than 4k will get filled before you.
Answer: AFAIK, if it is the same as stocks, then it is "The person who entered it first", meaning:
If somebody put in the limit order to Buy At $33,000, before you, then your $4000 will be matched to his limit order, but because he entered it first, then the transaction between you and him will be $33,000.  That's the rule.
There are tons of buy orders to buy at $33,000 or $32,999, so the $4000 will be matched by those numbers first. (and it will be sold at $33,000 or whatever the highest bidder is).


How would I train like Bobby Fischer did?

Question: As the title suggests, I want to know how to train like Bobby Fischer did, along with what books he read during his chess training. Remember, keyword is TRAIN. I don't want to be like him, as that is impossible, but I merely want to know how to train like him.
Comment: Step 1 is developing an uncontrollable obsession with chess.
Answer: This question may be better suited for Worldbuilding Exchange, but as Bobby's training system you are asking for started at the precise second Bobby met the game at a young age, you will need to:

Return with a time machine to five years old and develop Asperger
disorder.
Buy not only one but a dozen of chess boards.
Develop an uncontrollable obsession with chess as said, forgetting
everything is not chess. Your mother can do those tasks and the
school is totally unnecessary for you. You know modals and how the law
rules, not to enter in troubles not related with chess.
Play millions of games with yourself. Play chess every minute you
don't have to eat, sleep or waste your time with adults. Use those
books only to follow master moves and remaster the games on your
dozen of chess board that have colonized your home (you will need to
convince your mother for that).
Go to the tournaments and destroy all those poor players that read
the text of those chess books you will take a look later to see if
they are correct or not.
Continue enjoying and learning at FIDE circuit your hole life.
Comment: @Rewan Demontay The question invites to joke a bit but if I read correctly Bobby's history that's what he did. He played simultaneous at home with himself and followed masters games. For poster I have asperger disorder myself and obsession is important. Also you need to start at a young age to understand Bobby's chess knowledge. Because of neurology a kid learns much more quickly how a game rules than an adult.


Iphone 6s, question about recovering photos from iCloud on to the new phone. Please help.

Question: I got a new phone and I have everything backed up on iCloud. Everything restored (apps, phone contacts, etc.) exceptfor the photos. How do I get them from iCloud on to my new phone? Thanks
Answer: If you did a restore from iCloud backup, your photos should appear.
If not, go to settings -> Your name -> iCloud -> Photos and turn on the following:
iCloud Photo Library & Keep and Download Originals
If the photos dont show, check your iCloud storage for photo backup size and iCloud backups. If you have an iCloud backup that has a favorable date, then restoring that could be in your favor.


How to set up a CSS switcher

Question: I'm working on a website that will switch to a new style on a set date. The site's built-in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content updates in the current look as well as design progress on the new look.
I'm planning to use a magic querystring value and/or a javascript link in the footer which writes out a cookie to select the new CSS page. We're working in ASP.NET 3.5. Any recommendations?
I should mention that we're using IE Conditional Comments for IE8, 7, and 6 support. I may create a function that does a replacement:
<link href="Style/<% GetCssRoot() %>.css" rel="stylesheet" type="text/css" />

Answer: In Asp.net 3.5, you should be able to set up the Link tag in the header as a server tag. Then in the codebehind you can set the href property for the link element, based on a cookie value, querystring, date, etc.
In your aspx file:

  <link id="linkStyles" rel="stylesheet" type="text/css" runat="server" />

And in the Code behind:
protected void Page_Load(object sender, EventArgs e) {
  string stylesheetAddress = // logic to determine stylesheet
  linkStyles.Href = stylesheetAddress;
}

Comment: Thanks, didn't think of this, but .NET wasn't playing nice with this:
Answer: You should look into ASP.NET themes, that's exactly what they're used for. They also allow you to skin controls, which means give them a set of default attributes.
Answer: I would suggest storing the stylesheet selection in the session so you don't have to rely on the querystring key being present all the time. You can check the session in Page_Load and add the appropriate stylesheet reference. It sounds like this is a temporary/development situation, so go with whatever is easy and works.
if (!String.IsNullOrEmpty(Request.QueryString["css"]))
  Session.Add("CSS",Request.QueryString["css"]);

Answer: I would do the following:
www.website.com/?stylesheet=new.css
Then in your ASP.NET code:
if (Request.Querystring["stylesheet"] != null) {
    Response.Cookies["stylesheet"].Value = Request.QueryString["stylesheet"];
    Response.Redirect(<Current Page>);
}

Then where you define your stylesheets:
if (Request.Cookies["stylesheet"] != null) {
    // New Stylesheet
} else {
    // Default
}

Comment: what do you do when the user navigates to another page? comes in from an outside link?

How to set up a CSS switcher


How to expand elliptic curve public key from compressed form?

Question: Following this page https://en.bitcoin.it/wiki/Secp256k1, secp256k1 curve's equation is
$$y^2=x^3+7$$
Does this mean that I can substitute $G_x$ in the equation to get $G_y$?
I think yes and that's how public key compression works, since we don't actually need to store $y$ value because we can compute it at run-time. But after substitution of the generator point of secp256k1 I get wrong equation:
$$G_x = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798$$
$$G_y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8$$
$$G_y^2=G_x^3+7$$
$$106736222501650227577219490950371...=1.66977061698153803977729810299616665e230 + 7$$
The equation is wrong. Where am I going wrong?
Answer:
Where am I going wrong?

The two sides are computed modulo a prime $p$.
For Secp256k1, we have $p = 2^{256}−2^{32}−977 = 115792089237316195423570985008687907853269984665640564039457584007908834671663$
Computing them as integers or reals gives the wrong result, as you have seen.
And, to answer the question you have not asked, to compute $G_y$ from $G_x$, you need to do a modular square-root of $G_x^3 + 7$.  It turns out to not be that bad; because $p \equiv 3 \pmod 4$, the modular square roots of $z$ are $z^{(p+1)/4} \bmod p$ and $p - z^{(p+1)/4} \bmod p$, the latter sometimes is expressed as $- z^{(p+1)/4} \bmod p$.
As so, we have $G_y = \pm (G_x^3 + 7)^{(p+1)/4} \bmod p$ (and the compressed point should contain a bit that determines which of the two $G_y$ values to take).
Answer: In ECC, all base arithmetic is performed on the $\mathbb F_p$. Secp256k1 used a prime so $\mod p$ is enough for these kind of operations. One needs a big integer library to calculate the arithmetic correctly. Here is a sample code from Sagemath
#secp256k1
p = Integer("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F")

a = Integer("0x0000000000000000000000000000000000000000000000000000000000000000")
b = Integer("0x0000000000000000000000000000000000000000000000000000000000000007")

K = GF(p)
E = EllipticCurve(K,[a,b])

Gx = Integer(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)
Gy = Integer(0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
G = E(Gx, Gy)

# Check the base point
assert(Gy^2 % p == (Gx^3 + a * Gx + b) % p)

#Sample public points with compressed 02
Compressed = "02b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737"
#Sample public points with compressed 03
#Compressed = "03b1e8e14e794c00c364daa5ff85258ac480a0e21e819e08d5a259553ed911cb15"

print( "Given public key\n", Compressed)

#lift to find point that has the given x coordinate
P = E.lift_x(Integer("0x"+Compressed[2:]))

#Determine the correct y-coordinate.

if (Integer(P[1]) % 2) == 0:
    print("Using compression 02\n", P)
else:
    Q = E(P[0],p-P[1])
    print("Using compression 03\n", Q)

The above code verifies the base point ( well, G = E(Gx, Gy) already has verification on SageMath), and there are two sample public keys to resolve the full point.
Keep in mind that

prefix 04 means no compression
prefix 02 means compression with $y$ coordinate is even
prefix 03 means compression with $y$ coordinate is odd

The above code only handles the cases 02 and 03 not 04.


How can I beat the final boss in Swordigo?

Question: I have been trying for hours to beat the final boss (in world's end keep) and beat the game. I can easily take out the flying boss by using dimension rift and getting him to walk around, but I just can't beat my clone. Any tips?
Answer: It's been a while since I played that game but I remember that fight.
I used to get back in the left corner and wait for him to come by. If he got too close I attacked him and then stepped back to the left corner.
Also I don't remember how it's called but you have blue magic you can throw at him you can use that while he is out of reach and you are waiting for him to come closer.
Answer: You should have the magic armour and mostly maxed all of your stats. Carry a potion with you and put the shadow trinket on your armour. The first boss you need to use dimension rift, if you manage to hit him when he it above you you can spam attack and he cant hurt you. For the final boss don't use magic bolts because he will almost always block them and reflect them back to you. make sure you have fire trinket on your sword. Jump over his head when he does his ground attack and run to the other side, keep doing this to slowly regain health with your shadow trinket. When you approach him try to get a few hits then run away. Continue to do this for a while and soon you will kill the boss.
I hope this helps.
Answer: Keep jumping over him and attack from behind. Make sure you have the fire trinket on your sword; it makes the sword stronger.
Answer: I just beat that last boss. Not sure if you still need help, but I just did jump attacks and ran away when I needed health back. I managed to beat him within 2-3 minutes quite easily and still had full health.
Mainly as long as you do jump attacks and spam the attack button, you should be fine.
Answer: Simplest way to win the final boss is provided by the developers :P .
There is a glitch in the stage. Just go to the left most corner of the stage. The evil clone can not cross the last pillar. And there is enough space that you can stand without harm. So if you are adventurous, fight the clone and when you want to regenerate, just stand there in the left most corner. Or if you are lazy, Just go to the left most corner, start hitting him at correct time with sword or shoot magic at him.
Answer: The Dragon part is a bit easy for me. When you defeat the Dragon go to the left corner and use the magic bolt to break the Ball Of Chaos then you will see your copy. Stay in the left corner as it cannot pass the last pillar. Use your Sword to hit it when he is not attacking. Hope it works though I didn't try it out.
Answer: What I did was I just jumped over the master of chaos' head and attacked him, then ran away and repeated this same process. However, I defeated him in his Bird/eagle/griffin form by hitting the blasts he threw at me right back at him, and that did A LOT of damage!
Answer: Put fire trinket on your sword for extra damage
Put shadow trinket on your magic armor for regen
Select Dragon's grasp as your magic attack ; it rarely gets blocked and ain't deflected at you
When the dialogue is over you can jump towards him hit him mid-air and then 2 ground attacks
When he is doing ground attacks hit him from above
Don't approach him with ground attacks, the bot is almost perfect in dealing with that
If you want some distance or healing time spam "jump and dragon's grape"
If he is doing a jump attack, if you aren't in his range jump after him with your own jump attack but if you are in his range jump back or dash past him whichever is faster, if you can follow it up with a ground attack or preferably a jump attack
If you can't beat it, try using a health potion or using the glitch that involves sitting at the side of the map where the AI won't be able to reach you and killing him via that.
Answer: I killed him spam attacking and jumping back. Also, I brought a health potion as I knew this would be helpful.
Comment: Hello! This is a low quality answer since 1- You basically retold what was in another answer and 2- Its not very developed. How does that strategy make it easier? Have a nice day and we will see you around!


How to write a scene where the villain meets the protagonist?

Question: The villain was, like the protagonist, a child soldier/mercenary, who served with him. The villain was captured, tortured, and snapped. He feels a burning hatred for the protagonist, believing that he left him behind. The protagonist however feels heavy guilt, blaming himself for not saving him.
Now. They meet each other, when the protagonist infiltrates a building and is then faced by the villain. Now, I don't know how to write that scene, though. Like what should I avoid? What clichés should I avoid for example?
Comment: First, is this supposed to be their first meet-up, but not their last or is this their first and final showdown? Also, does the villain still have a heart? Is this a villain that could be saved or is he now too far gone and has to be vanquished no matter what? Lastly, did they have a friendship before, like were they as close as brothers, or is being child soldiers their only common ground?
Comment: It's their first showdown. It's the latter. He has gone too far and needs to be killed no matter what. Also, yes they had a brother like relationship.
Comment: Have you read kane and Abel?
Answer: Western audiences are into heroic self sacrifices in "brother v. brother" conflicts, such as the archetypal death of Ben Kanobi at the hands of Darth Vader in Star Wars, Episode 4.
Some, like the "death" of Neo at the end of Matrix Revolutions or of Ripley at the end of Alien 3 include Christian symbolism.
The hero's journey usually entails the correcting of wrongs in some way. As such, perhaps your protagonist offers his life, soul, honor, etc., to his long-lost friend. The villain does what he will with it. Perhaps he then gets pulverized by bits of building falling on him. That's up to you.
Answer: Write it like it is.  Write what happens.  Write from the hearts of the characters.  Bring it to the end you have chosen to continue to the story.  If they don't come to the end you want, maybe something is wrong with your plot, or with your knowledge of the characters.
The more you can expose the characters through their action and dialog, spoken or internal, the more readers will understand the characters, and the more they will be emotionally bound into the result.  It will matter who lives and who dies -- and how they live or die.
I'm picturing this as the climax of the story, with creamy character development leading to this resolution.  How the actual death happens needs to be consistent with the characters.  I would be disappointed if the villain died "randomly" by stuff falling on his head.  I think, without knowing your characters, that I would prefer the protagonist to actively kill the villain.  Rocks tumbling on him seems cliche.  A third party intervening as a Judge deciding who should live, but that's probably been done to the point of cliche.
Only you know the characters.  Only you know what is proper in the story, and consistent with the lives they live and their emotional state.  Only you know the secondary characters, their loyalties, and their capabilities.
I would suggest not worrying about cliche.  Do what is real for your characters.  Write from their reality.  Don't take short cuts.  Show us all the scars and blood, physical and emotional.  Your story will be compelling.  Your villain will die as he must, and your protagonist will survive and be altered by the experience.
Answer: Personally, I'd think a few clichés to avoid are:
1) The villain does something stupid so the protagonist has no choice but to kill him, in self-defense of defense of an innocent. This relieves the protagonist of responsibility in the kill; and to me makes for a less satisfying ending.
2) The villain realizes all is lost and kills themself. Again, relieves the protagonist of responsibility.
3) Any long-winded explanation from either party.
To me, the best confrontation plays to the characters. The protagonist feels guilty and caused the antagonist. The antagonist agrees and hates the protagonist. The antagonist feels completely justified in killing the protagonist; but the protagonist does NOT feel completely justified; he feels he is responsible for turning his brother into a monster and it is unfair that his failing will now force him to act again against his brother, and actually take the life of his brother after destroying it. The antagonist is all too willing to play on this guilt and goad the protagonist, but somehow the protagonist has to choose to do the one thing he hates most in the world, and compound his own guilt, in order to save innocent lives.
Many final confrontations are too pat. The protagonist dispatches the antagonist with bravado and a clever catch-phrase. No regrets, no angst, no indecision, no emotion but vengeance satisfied. The antagonists have zero saving traits, they are psychopathic evil and care for nobody but themselves, power and money. This makes them easier to kill.
But that is cliché. Still popular, but expected; in most movies the only twist or surprise is in exactly how the beleaguered antagonist manages to trick the antagonist, or pull a rabbit out of the hat to pull off the kill.
If you want to avoid clichés, don't make it emotionally easy for the hero to make the kill, and don't let the villain relieve him of one ounce of responsibility by acting stupidly or rashly. Force the hero to make a deliberate kill he has to think about despite having a clear choice to let the villain escape.


How can words instruct machines?

Question: How words can instruct hardware to do an operations . I understand that these are converted to 0s and 1s . But still I can't intuitively understand How it works .  A detailed explanation would be appreciated .
Comment: Could you explain what exactly is it that you don't understand? Have you tried researching this (for example on Wikipedia)?
Answer: When converted to 0s and 1s, they're not words anymore, they are a configuration for the machine. In a way, they are words only as a help to our human understanding. As it often happens, we end up confusing our own conceptions with reality.
Computer networks, distributed systems and interactive computing add other layers of complexity to this picture. Since you cannot consider standalone computer as closed systems of hardware and software, it becomes even more tempting to see programs as transcendent writings, whose meaning commands the machines were they run.
It is definitely not the case. Words are aids, nothing more.
To put it differently: a program, or any kind of source code, is already given to the compiler as a sequence of 0s and 1s. Even if not directly composed of machine instructions, this sequence of bits can be deterministically converted to machine code. That's what a program translator (compiler, interpreter, emulator, etc.) does.

How can words instruct machines?


Can I refresh the thumbnails programmatically?

Question: I would like to be able to refresh the thumbnail cache programmatically, not sure where to hook it, but at present any design changes mean re-uploading loads of images!
Answer: You may want to look at the plugin Regenerate Thumbnails by Viper007Bond.
Basically, this is how to do it:
<code>function regenerateThumbnails() {

    $images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%'" );

    foreach ( $images as $image ) {
        $id = $image->ID;
        $fullsizepath = get_attached_file( $id );

        if ( false === $fullsizepath || !file_exists($fullsizepath) )
            return;

        if ( wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $fullsizepath ) ) )
            return true;
        else
            return false;
    }
}
</code>
Note: This function is not very scalable. It will loop through all the images and regenerate thumbnails one by one, which may consume a large amount of memory. So, you may want to enhance it.
Comment: how might we scale it?
Comment: @MildFuzz: The plugin now does this in an Ajax loop, so only one image is resized per request. You just leave the browser window open while it processes each image in sequence. If you do it in one request (as the plugin used to do), you run into memory and time limits.
Comment: what would be good is if we could write a function that could hook into the loading of the attachment, and if the right one is not present, create it.
Comment: *@Mild Fuzz*: By *"loading of the attachment"*, do you mean when the file is requested by the browser? If so, you'd end up putting a significant performance drain on the server because currently Apache serves images, WordPress never handles them. You could try hook the 404 template and try to figure out what to generate from there but there might but unexpected incompatibilities. Wish I had time to fiddle with it but sadly I don't right now. Maybe you could tell us a bit more about your situation and use-case? Why is the standard approach not working for you?
Comment: @*Mild Fuzz* - You could also run code similar to the code *@sorich87* provided on a pseudo-cron task: http://bit.ly/wp-pseudo-cron


Newtonian limit of kinetic energy in general relativity

Question: Rindler's Relativity (2nd ed.) implies on p.239, Eq. 11.34, that the kinetic energy of a body falling radially into a black hole is the square of the derivative of $r$ with respect to $s$. But in the Newtonian limit this becomes $v^2$, not half of that, as it should be. What is the reason for this apparent contradiction?
Comment: If you like this question you may also enjoy reading [this](https://physics.stackexchange.com/q/466656/2451) Phys.SE post.
Answer: Start with the Schwarzschild metric
$$
ds^2~=~\left(1~-~\frac{2GM}{r}\right)dt^2~-~\left(1~-~\frac{2GM}{r}\right)^{-1}dr^2~-~r^2d\Omega^2,
$$
where $c~=~1$. Now multiply by the particle mass or $m^2$ and divide by ds^2
$$
m^2~=~m^2\left(1~-~\frac{2GM}{r}\right)\left(\frac{dt}{ds}\right)^2~-~m^2\left(1~-~\frac{2GM}{r}\right)^{-1}\left(\frac{dr}{ds}\right)^2~-~m^2r^2\left(\frac{d\Omega}{ds}\right)^2.
$$
We have a radial moving particle that
$$
m^2~=~\left(1~-~\frac{2GM}{r}\right)p_t^2~-~\left(1~-~\frac{2GM}{r}\right)^{-1}p_r^2.
$$
We now explore the weak field limit for $1~>>~\frac{2GM}{rc^2}$ so that
$$
m^2~=~\left(1~-~\frac{2GM}{r}\right)p_t^2~-~\left(1~+~\frac{2GM}{r}\right)p_r^2.
$$
In the limit that $r~\rightarrow~\infty$ or $M~=~0$ this is the momentum invariant in special relativity
$$
m^2~=~p_t^2~-~p_r^2,
$$
where $p_t~=~E$.
This limit is different from the limit that recovers nonrelativistic Newtonian mechanics. The energy is
$$
E~=~\sqrt{m^2~+~p_r^2}.
$$
The nonrelativistc limit is then where $m^2~>>~p_r$ and so with binomial theorem the energy is
$$
E~=~m\left(1~+~\frac{p_2}{2m^2}\right)~=~m~+~\frac{1}{2}mv_r^2,
$$
where the momentum $p_r~=~mv_r$. This is the standard Newtonian kinetic energy with the $E~=~mc^2$ added in.
Answer: I was always in agreement with your calculation. But you haven't addressed my question: what is the formula for KE in GR? Rindler says, which wd seem incorrect in my view, that alpha=1-2m/r (he uses natural units) is the PE, which makes the PE nonzero at infinity. He calls alpha + p^2 sub r the total energy, and p^2 sub r the KE. He includes the rest energy in the PE, but even with this unusual formulation, his figures don't add up properly to the law of conservation of energy. He is off by a factor of 2. p^2 sub r gives mv^2 as Newtonian limit.
Using E=mc^2 =(m sub 0) gamma c^2, I finally figured out that, if
alpha=(1 − 2GM/r) the formula shd be, for c=1:
<code>                                        KE=1/2 p^2 sub r)=(m sub 0)(gamma-1)
                                        PE=(alpha-1)/2=M/r
                                        E sub 0 = 1
</code>
Now KE + E sub 0 + PE = total energy, but it is important to be clear in what frame one is measuring v and KE.
and these qties reduce correctly in the Newtonian limit. By the way, where are the instructions for the markup language?


How do I install FreeBSD on my MacBook Pro?

Question: It's my first time ever reformatting and I want to do this right. A friend of mine gave me the 8.1 disc1 iso file and said that's all I need, but I'm a little confused on how to reboot with it. Also, I'm not exactly sure what I should do before reformatting to make sure that all of my files are going to be readable. Does anyone know of any simple beginner guides that could get me through this tonight?
Comment: This seems pretty dangerous... If you don't know any more about what you're doing than that, maybe you'd better stick with Mac OS X. You can do just about everything in OS X that you can in FreeBSD, but with a *much* nicer GUI. Remember that **formatting your hard drive will cause you to lose everything that's stored on it.**
Answer: Mac OS X is built on a BSD platform.  Have you thought about installing MacPorts or Fink?
Answer: Installing a new operating system, especially on a MacBook, is an extremely dangerous operation. You are risking losing all of your data and rendering your computer inoperable.
You state that you do not know how to boot from a CD, and you seem to misunderstand what the process of formatting does, or how it relates to re-OSing your computer.
I would recommend using the existing MacOS X install, and looking at the built in unix features. The operating system is much prettier, and nicer to the end user - and it includes almost all of the FreeBSD functionality out of the box (what's not there, you can easily obtain from the web).
Comment: Not really sure why you think installing a new operating system is *more* dangerous on a MacBook. It's not going to break if you run something other than OS X. The dangerous part is that an inexperienced user might not know what he or she is getting into. (But yeah, I agree with you otherwise.)
Comment: Google FreeBSD MacBook drivers; you'll get an idea of what I'm talking about.
Answer: I attempted to install PC-BSD on my Macbook Pro 13" Early 2011 Intel Sandy Bridge/HD 3000 i3. PC-BSD is in fact FreeBSD 7.2 in disguise with a GUI installer and features applications that can be downloaded as pre-compiled binaries (PBI). Installation was unsuccessful due to the motherboard and other components not being supported by the kernel. But Mac OS X is after all a certified (BSD-based)UNIX built on closed and open source components. The open source part is the Darwin kernel which contains FreeBSD code among other things. The aqua interface and quartz graphics layers are pure Apple.
I would recommended using MacPorts to port over yours favourite FreeBSD applications to OS X. It's a simple command-line tool that will compile and build applications for you. I found this to be the best solution for me anyway.
Answer: Is it not true that I can transfer backed up files back to to my computer and reboot Snow Leopard from an external drive if I change my mind? I understand that these two operating systems are fundamentally similar but I am learning GNU right now and I want to get more involved with Open Source software. My next computer will not be a macintosh, so I would like to get familiar with other GUIs. Plus I really like the aesthetic qualities of KDE. I am asking for help finding the resources to do this without damaging my computer. I was not born knowing how to externally boot a computer.
Sorry for posting this as an answer, I don't have commenting privileges on this board.
PS: Using time machine will store all of my files correct? Is there anything else I should do to be safe?
Comment: you need to associate your Stack Overflow and Super User accounts, and then you will own this question and reputation will be credited to you...


In NYC is there sales tax on services like computer / cell phone repair?

Question: I run a small cell phone repair store and we fix many phones. Many times it's bricked phones or cracked screens. But what I want to know, do we have to charge sales tax on repair services such as these? Technically we are not selling thing anything tangible.
Comment: Replacing a cracked screen is certainly a tangible item, though the time spent installing it isn't... I don't remember how/whether NYC taxes labor
Answer: According to the New York State Department of Taxation and Finance, your service is not exempt from taxes. Service and repair of tangible personal property are specifically itemized on this page as taxable services.

Sales of tangible personal property are subject to New York sales tax unless they are specifically exempt.
The term tangible personal property means any kind of physical personal property that has a material existence and is perceptible to the human senses (in other words, something you can see and touch).
Examples of taxable tangible personal property, services, and transactions that are subject to sales tax are:

tangible personal property:

furniture, appliances, and light fixtures;
certain clothing and footwear;
machinery and equipment, parts, tools, and supplies;
computers;
...

maintaining, installing, servicing, and repairing of tangible personal property;

According to the NYC Department of Finance, the total Sales and Use tax on most tangible personal property and their associated services in New York City appears to be 8.875% in 2018:

The State and City charge sales tax on many services and on retail sales for most goods.
The total sales and use tax rate in New York City is 8.875%.
This includes:

New York City local sales and use tax rate of 4.5%
New York State sales and use tax rate of 4%
Metropolitan Commuter Transportation District surcharge of 0.375%

The NYC page also lists some exempt goods and services, but mobile phone repair is not in the list of exempt services.
Answer: According to the New York State Department of Taxation and Finance, your service would appear to be exempt from taxes.  However, if you are charging for tangible items, those would incur a sales tax.
Comment: The tax ought to be on what you are charging for the parts, not what you paid for them.  On the bill you provide the customer, if you do not separate the cost for the labor and parts, I suspect you may need to collect sales tax on the total bill amount.
Comment: @duckx If you bill your labor separately from the material, you only need to collect tax on the material price.  The top of the website states "Sales of services are generally exempt from New York sales tax unless they are specifically taxable." Near the bottom, the taxable services are primarily limited to health and beauty type services.
Answer: The following link says servicing of any tangible property is not tax exempt:
https://www.tax.ny.gov/pubs_and_bulls/tg_bulletins/st/quick_reference_guide_for_taxable_and_exempt_property_and_services.htm

But, if the device you are "troubleshooting" or "servicing" is a software issue, it is exempt, see: https://www.tax.ny.gov/pubs_and_bulls/tg_bulletins/st/computer_software.htm

As we can see it is a contradiction in how to charge for a "software" only repair. If a customer calls you and you "troubleshoot" the software issue remotely, it is technically tax exempt according the "computer software" tax code. The question differs when the customer brings that software issue to you in person in a physical device.


downvotes and voters

Question: I understand dvs are part and parcel of the site - and a lot of you know my thoughts about their use. Today (so far!) I've had four, and feel there may be a serial dver on the loose. (It won't be the first time for me). How can mods get involved - can they alone be allowed to check on who it may be. As in, if all of them emanated from the same source, could they know?
Answer: (I'm interested to hear what my more experienced colleagues say about this, but here's my response.)
We can't see where these votes are from, nor can we reverse any votes; the only things we can see are the rep changes that you see and a little bit of extra data on voting statistics. You had four in a row in a very short time span, which certainly looks suspicious. (Like you, I'd bet money on those coming from the same user.) It wasn't enough for the system to catch any kind of downvoting spree, so there's not much we can do currently. If it continues happening, let us know, and we may need to get a community manager involved if it gets serious enough.
You may also be interested in Random Downvoting over on Meta.SE.
Comment: I just made a quick survey of the downvotes I've received so far this year. Although nobody took explicit create for any of them, around 2/3 to 3/4 I could at least come up with some rationalization for -- more or less vague -- and the rest were entirely mysterious. I wonder what's typical in that regard: downvotes that at least kind of make sense to the OP versus those that are wholly baffling. Just idle wondering.
Comment: There's a couple more tools we have to check for serial and targeted down voting, but if the system does not catch it and it's not a majority of the user's votes it's really hard for mods alone to see. Another factor that complicates this is the sheer amount of post you have so it's harder to see a breakdown since there's so much content collated together without a timeline.
Comment: Thanks Richard. Last time it happened the result was a suspesion, so someone has access to persons responsible, I'd have thought. All rather peurile, and adds to my 'campaign' regarding dvs...I don't even have access to when they were given. You, it seems, do.
Comment: Thanks again. So what was the exact problem?
Comment: @Tim looks like the system reversed 3 of the 4 downvotes automatically due to target voting. In general, try to wait about 24 hours for the system to correct it as it only runs the target voting checks nightly. If it's still an issue after that period, you can ping the mods in chat or bring it up in meta. Most likely we will do a quick dig based on our tools and if we feel there's more going on we'd need to escalate it. In the past that has taken a while, but CMs have been getting back to mods faster recently so we'll see.
Comment: @Dom - so why are the mods denied this access? It's hardly going to be used maliciously, so who is protecting what?
Comment: @Tim The general idea is to make voting anonymous so even mods having info who votes what way on what question would be a little too much power for a mod. The tools we have are for general patterns rather than specifics to protect that anonymity. Even CMs only do it on a last resort.
Comment: And that's where it rankles for me. Anonimity, lack of respect, absolutely no chance of being caught out, and not having to reason why. Total immunity. You must know I love this site, but that to me is a rather large carbuncle, with, it seems, very little thought behind that part, leaving opportunities for mischief and more.
Comment: I thought "normal users" can only downvote a question *once*. So I don't think one user downvoted the same question multiple times.
Comment: @U.Windl All users can only downvote a question once. In this particular instance, it looks like a user may hae downvoted four separate questions/answers all in a row.
Comment: See also [Why isn't providing feedback mandatory on downvotes, and why are ideas suggesting such negatively received?](https://meta.stackexchange.com/q/325416/388437).

downvotes and voters


Insert SVG code (not img) in HTML block

Question: I want to insert svg code in a Guttenberg HTML block. I don't want it as an image because I want to manipulate it with CSS.
If I insert svg, all tag diseappears and I have only the text which was inside svg tags.
Thanks.
Answer: I tried this code on a clean install of WordPress
<code><svg width="100" height="100">
  <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
</code>
and used 'Custom HTML' in Guttenberg in a new post. This worked fine for me.
The same code displayed in the DOM without deleting any tags or adding any
Maybe you cant edit the SVG with HTML because WordpPress doesn't generate the code until the page is called.
Comment: That's strange, it doesn't work for me. Even your code is stripped...

Insert SVG code (not img) in HTML block


No WI-FI adapter found after restarting

Question: I have successfully installed ubuntu 18.04.3 LTS, and at the beginning i've successfully connected to my wireless network, but after restarting the wifi adapter was not found. I've connected to the internet through lan cable and installed successfully wifi drivers. After that the wifi was fully functional, but after restarting there was the same issue- no wifi adapter. It was really annoying to install wifi drivers on every restart, and if you can help me i will be very grateful.
Network adapter is: Intel(R) Wireless-AC 9462
Thanks for helping.
Comment: Had a similar issue on Dell XPS 15 9575, but reboot fixed it.
Comment: Thanks for your respond, but restarting is causing the issue. After restart i have to reinstall driver for wifi.
Comment: Please [edit] your question and add output of `lspci -knn | grep Net -A3; rfkill list` terminal command.
Answer: I had the same problem, but the solution was really different. When you install OS on your computer, secure boot is on. This means that your OS is going to have less abilities including connecting to WiFi.
- HOW TO TURN OFF SECURE BOOT?
Go to BIOS system. For doing that, you will need to turn off a PC. Every computer developer has its own way to go to BIOS. For example, I have HP laptop. When I start it, I press esc button and get the menu, then press F10 and go to BIOS. So look for your way to get there. Then look through BIOS menu options until you will see "Secure boot" one. Change the value to "Disabled" and save the settings. Then start Ubuntu. That may work, I am not sure, but anyway, try it. Secure boot is default on so it can block your WiFi driver.
Comment: Thanks friend it's working, you've really saved me time and patience.
Answer: Not yet supported in linux kernel shipped with Ubuntu 18.04.
You Need to install backport like this to support latest Intel wifi :
<code>sudo apt update
sudo apt install git build-essential
git clone https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/backport-iwlwifi.git
cd backport-iwlwifi/
make defconfig-iwlwifi-public
sed -i 's/CPTCFG_IWLMVM_VENDOR_CMDS=y/# CPTCFG_IWLMVM_VENDOR_CMDS is not set/' .config
make -j4
sudo make install
sudo modprobe iwlwifi
</code>
Answer: Found a similar issue here, maybe it will help you https://askubuntu.com/a/1089238/268965.
Looks like the problem is that wl driver loads and replaces a correct driver. Try doing
<code># update-initramfs -k all # update all initramfs images
# update-grub
</code>
This should load a correct driver to initramfs and problem should be gone
Comment: I have tryed your solution and i really appreciate your help, but sadly it doesn't work.

No WI-FI adapter found after restarting


Why is there so much oil in Saudi Arabia, Venezuela and Canada, but almost none in Europe?

Question:
Why do some countries have a lot of oil reserves, while some others don't?
Comment: Europe is small.  Is the amount of oil per unit area in Europe smaller than in Asia or North America?  Colouring per the political unit of a country is not useful.
Comment: [Klemmse & Ulmishek 1991](http://archives.datapages.com/data/bulletns/1990-91/data/pg/0075/0012/0000/1809.htm) should be a good starting point.
Comment: @gerrit, yes a BAD choropleth map! Makes Russia and Canada look especially prominent. Average reserves per unit km would be much better...
Comment: @winwaed well what did you expect from the CIA factbook?
Answer: I wouldn't say there's 'almost none' in Europe, but the global distribution of petroleum is uneven. The reason is that petroleum systems need a convergence of conditions that is relatively rare.
For a start, the comment about the inappropriateness of a political map for this purpose is spot on. This USGS map of global petroleum systems, and non-petroleum-rich basins, is much better — apart from the fact that it perversely omits the USA's substantial endowment:

These 'petroleum systems' are essentially modern or ancient sedimentary basins with a particular combination of features. I'll refer to a previous answer about a specific region: Why would there be no hydrocarbons in the Sveconorwegian belt? Paraphrasing, and self-plagiarizing, here's what you need for a hydrocarbon (oil or gas) accumulation:

A kerogen-rich source rock that has been 'cooked' to thermal maturity. So you need lots of organic matter, burial, and time.
A migration pathway from the source to a trapping configuration, and time for this to have happened.
A structural or stratigraphic trap, such as an anticline, and the geological conditions that have preserved it since filling.
A reservoir rock — a porous and permeable rock. Usually this is a sedimentary rock (like sandstone, which there's lots of in Saudi!).

Only 'conventional' hydrocarbon deposits, such as you might find in
  the North Sea, Saudi Arabia, or the Gulf of Mexico, need all these
  conditions. 'Shale gas' is basically just a mature source rock — we
  can extract hydrocarbons from it by fracking, for example.

So the map of global petroleum resources is a map of places where these criteria converge. Certain deltas are prolific (Mississippi, Niger), because you have rapid burial of sand and organic material. In other places, one or more of the conditions has not been met. Much of Canada, for example, is exposed basement granite: none of the components are there.
The unevenness is exacerbated by the Pareto distribution of system productivity — as with most natural things, we have a few giants, and a long tail. So the WCSB and Saudi stick out as anomalous, making the distribution even more 'lumpy'.
Answer: The map shown in the question is of proven oil reserves that can be extracted under current conditions.  However, it is really showing you the distribution of oil reserves in a political sense, which is not fundamental to the source of petroleum reserves.  Instead, you should look at the geology that is responsible for oil reserves.  I like the description here:  http://large.stanford.edu/courses/2013/ph240/malyshev2/

Regions where the ancient precambrian igneous rocks are exposed at the surface of the Earth are called shields. The world oil reserves are not found in the shields but in orogens which are regions between tectonic plates that experience deformation forces due to the motion of the plates. These forces create basins: areas of deep sedimentary rocks which are necessary to produce the oil. The forces also deform the sedimentary rocks which leads to creation of traps necessary for oil and gas accumulation. The basins and orogens coincide with many oil reach regions: east and west costs of America, around the Persian gulf, along the Ural mountains, across the Caspian sea, in Siberia, in the north of Africa.

More information on the origin of petroleum reserves is also found here  http://en.wikipedia.org/wiki/Petroleum#Formation

Petroleum is a fossil fuel derived from ancient fossilized organic materials, such as zooplankton and algae. Vast quantities of these remains settled to sea or lake bottoms, mixing with sediments and being buried under anoxic conditions. As further layers settled to the sea or lake bed, intense heat and pressure build up in the lower regions. This process caused the organic matter to change, first into a waxy material known as kerogen, which is found in various oil shales around the world, and then with more heat into liquid and gaseous hydrocarbons via a process known as catagenesis. Formation of petroleum occurs from hydrocarbon pyrolysis in a variety of mainly endothermic reactions at high temperature and/or pressure.  There were certain warm nutrient-rich environments such as the Gulf of Mexico and the ancient Tethys Sea where the large amounts of organic material falling to the ocean floor exceeded the rate at which it could decompose. This resulted in large masses of organic material being buried under subsequent deposits such as shale formed from mud. This massive organic deposit later became heated and transformed under pressure into oil.
Three conditions must be present for oil reservoirs to form: a source rock rich in hydrocarbon material buried deep enough for subterranean heat to cook it into oil, a porous and permeable reservoir rock for it to accumulate in, and a cap rock (seal) or other mechanism that prevents it from escaping to the surface. Within these reservoirs, fluids will typically organize themselves like a three-layer cake with a layer of water below the oil layer and a layer of gas above it, although the different layers vary in size between reservoirs. Because most hydrocarbons are less dense than rock or water, they often migrate upward through adjacent rock layers until either reaching the surface or becoming trapped within porous rocks (known as reservoirs) by impermeable rocks above. However, the process is influenced by underground water flows, causing oil to migrate hundreds of kilometres horizontally or even short distances downward before becoming trapped in a reservoir. When hydrocarbons are concentrated in a trap, an oil field forms, from which the liquid can be extracted by drilling and pumping.
Comment: The map in this answer is only showing estimated UNDISCOVERED oil.  It is not showing the known oil, such as in Alaska, Texas, North Dakota.  The biggest oil producer (USA) is shown as having zero oil.
Comment: Good point, it's been removed.
Answer: The amount of oil in the ground is an indicator of how much life used to be there. So, we can conclude that those areas that have a large amount of oil were those that had more vegetation millions of years ago.
Comment: Having past vegetation is a necessary, but *not* sufficient, condition for oil.


Shared workbook hangs when opening and saving

Question: I have a shared Excel file with 14 people having access. The spreadsheet has been fine for a while, however, in the last 2 weeks, opening and saving the spreadsheet hangs for a good 4 to 5 minutes. Any ideas how to solve this problem?
Answer: Shared excel sheets tend to grow to significant size as more and more revisions get put in. I've had success in shrinking them back to a manageable size by turning off shared edit mode and saving and then turning shared edit mode back on.
Answer: I have resolved this problem with a macro here. I also have my sheets force macro use by hiding the sheets unless macros are enabled.
How do you prevent corruption of shared Excel files?


Windows: what is the difference between DEP always on and DEP opt-out with no exceptions?

Question:
What is the difference between DEP always
on ("/NoExecute=AlwaysOn" in boot.ini) and DEP opt-out
( "/NoExecute=OptOut" in boot.ini) with no exceptions?
"no exceptions" = empty list of programs for which DEP does not apply.
DEP = Data Execution Prevention (hardware).
One would expect it to work the same way, but it makes a
difference for some applications:
E.g. for all versions
of UltraEdit 14 (14.2). It crashes at startup for DEP
always on, at least on Microsoft Windows XP Professional
Edition x64 edition. (Update 2010-03-11: this problem has been
fixed with UltraEdit 15.2 and later.)
Update 2010-07-12:  Mozilla Thunderbird 22.214.171.124 also crashes
at startup for DEP set to the highest level (as UltraEdit used to do).
Is there a difference between Windows XP, Windows Vista and
Windows 7?
Is there a difference between 32 bit and 64 bit versions of
Windows?
Answer: Configuration Description
OptIn This setting is the default configuration. On systems with processors that can implement hardware-enforced DEP, DEP is enabled by default for limited system binaries and programs that "opt-in." With this option, only Windows system binaries are covered by DEP by default.
OptOut DEP is enabled by default for all processes. You can manually create a list of specific programs that do not have DEP applied by using the System dialog box in Control Panel. Information technology (IT) professionals can use the Application Compatibility Toolkit to "opt-out" one or more programs from DEP protection. System compatibility fixes, or shims, for DEP do take effect.
AlwaysOn This setting provides full DEP coverage for the whole system. All processes always run with DEP applied. The exceptions list to exempt specific programs from DEP protection is not available. System compatibility fixes for DEP do not take effect. Programs that have been opted-out by using the Application Compatibility Toolkit run with DEP applied.
AlwaysOff This setting does not provide any DEP coverage for any part of the system, regardless of hardware DEP support. The processor does not run in PAE mode unless the /PAE option is present in the Boot.ini file.
Answer: For question 1: I think this difference is caused by the backdoors that Microsoft has put into hardware DEP for OptOut, according to Fabrice Roux (see below). In the case of IrfanView, for which Steve Gibson observed the same difference as I did for UltraEdit (see the question), the difference is caused by a non-DEP aware EXE packer (ASPack) that Microsoft coded a backdoor for.
Sources:
From
http://blog.fabriceroux.com/index.php/2007/02/26/hardware_dep_has_a_backdoor?blog=1,
  "Hardware DEP has a backdoor" by Fabrice Roux.
  2007-02-26.
  "IrfanView was not using any trick to evade DEP ...
    Microsoft just coded a backdoor used only in OPTOUT.
    Bascially Microsoft checks the executable header for a
    section matching one of the 3 strings. If one these
    strings is found, DEP will be turned OFF for this
    application by windows. ... 'aspack', 'pcle', 'sforce'"
From http://www.grc.com/sn/sn-078.htm,
  by Steve Gibson.
  "I can't find any documentation on Microsoft's site
    anywhere, because we're seeing a difference between
    always-on and opt-out.  That is, you would imagine that
    always-on mode would be the same as opting out if you
    weren't having any opt-out programs.  It turns out it's
    not the case.  For example ... the IrfanView file viewer
    ... runs fine in opt-out mode, even if it has not been
    opted out.  But it won't launch, Windows blocks it from
    launching ... in always-on mode."
From http://www.grc.com/sn/sn-083.htm,
  by Steve Gibson.
  "... IrfanView ... won't run with DEP turned on. It's
    because it uses an EXE packer, an executable compression
    program called ASPack. And it makes sense that it
    wouldn't because naturally an executable compressor has
    got to decompress the executable, so it allocates a
    bunch of data memory into which it decompresses the
    compressed executable, and then it runs it. Well, it's
    running a data allocation, which is exactly what DEP is
    designed to stop. On the other hand, UPX, which is
    actually the leading and most popular EXE compressor,
    it's DEP- compatible because those guys realized, hey,
    when we allocate this memory, we should mark the pages
    as executable."
Answer: Setting the System DEP Policy level to OptOut allows for any 32bit thread to call SetSystemDEPPolicy(0) which will disable DEP protection for the memory space allocated to that process.  If the system's DEP Policy is set to AlwaysOn, invocations of SetSystemDEPPolicy will throw an error.
Answer: KB 875352 is actually the one: OptOut lets you specify a list of programs for which DEP does not apply, AlwaysOn will apply DEP to everything always.
Comment: But then OptOut with **no*** exceptions (empty list of programs for which DEP does not apply) should be equivalent to AlwaysOn. This has been observed to ***not*** be the case on Windows XP 64 bit. UltraEdit 14 crashes on startup for AlwaysOn, but not for OptOut with no exceptions. I agree: the official documentation suggest the two cases to be equivalent. But they are not. The only change is to the boot.ini line and the problem is reproduciple. I would like to know the underlying reason for this behavior. Regards, Peter.
Comment: That's interesting... I know that there is a DEP-aware option in Visual Studio, but what it does seems poorly documented.  Perhaps if the app was compiled with this option switched on or off it may also be a contributing factor (in which case there's not too much you can really do about it).
Comment: The DEP-aware option in Visual Studio merely shows that the developer claims that his code works with DEP turned on. It's explicit opt-in for that app.
Answer: A detailed description of the Data Execution Prevention (DEP) feature in Windows XP Service Pack 2, Windows XP Tablet PC Edition 2005, and Windows Server 2003
The shorter, snappier title is MS KB 875352 ;-)
More than your ever needed to know...
Comment: I knew about this document. It does not answer question 1 (except perhaps for "AlwaysOn ... System compatibility fixes for DEP do not take effect" - I am not sure how to interpret that). Regards, Peter.
Answer: There's a fairly big discussion about this on Steve Gibson's securable homepage. Also, they've discussed it quite often in the security now podcast. You can find the transcripts also on grc.com
Comment: I have listened to all the "Security Now!" podcasts regarding DEP. It does not, I far as I know, answer question 1: why is there a difference between AlwaysOn and OptOut with no exceptions.
Comment: That's unfortunate... I didn't recall it in that detail. Just one more chance: You also mean it has not been discussed in the listener q&a episodes coming after the "official" DEP episodes, right? (the transcripts help to browse quickly through them)
Comment: OK, Steve Gibson actually observed the same difference as I did (episode 78 and episode 83). I am not sure if he found the reason or not. But I think Fabrice Roux did! - see beginning of this page. Regards, Peter.
Answer: I know this is an old thread, but I got asked this again today and want to put this to rest.  AlwaysOn is going to enable DEP on all programs.  OptOut means simply that User can specify applications that would be OptOut of DEP.  If application is not listed in Exceptions then DEP is enabled for that application.


What are the differences between Rust's `String` and `str`?

Question: Why does Rust have both String and str? What are the differences between them, and when should one be used over the other? Is one of them getting deprecated?
Answer: String is the dynamic heap string type, like Vec: use it when you need to own or modify your string data.
str is an immutable1 sequence of UTF-8 bytes of dynamic length somewhere in memory. Since the size is unknown, one can only handle it behind a pointer. This means that str most commonly2 appears as &str: a reference to some UTF-8 data, normally called a "string slice" or just a "slice". A slice is just a view onto some data, and that data can be anywhere, e.g.

In static storage: a string literal "foo" is a &'static str. The data is hardcoded into the executable and loaded into memory when the program runs.

Inside a heap allocated String: String dereferences to a &str view of the String's data.

On the stack: e.g. the following creates a stack-allocated byte array, and then gets a view of that data as a &str:
use std::str;

let x: [u8; 3] = [b'a', b'b', b'c'];
let stack_str: &str = str::from_utf8(&x).unwrap();

In summary, use String if you need owned string data (like passing strings to other threads, or building them at runtime), and use &str if you only need a view of a string.
This is identical to the relationship between a vector Vec<T> and a slice &[T], and is similar to the relationship between by-value T and by-reference &T for general types.

1 A str is fixed-length; you cannot write bytes beyond the end, or leave trailing invalid bytes. Since UTF-8 is a variable-width encoding, this effectively forces all strs to be immutable in many cases. In general, mutation requires writing more or fewer bytes than there were before (e.g. replacing an a (1 byte) with an ä (2+ bytes) would require making more room in the str). There are specific methods that can modify a &mut str in place, mostly those that handle only ASCII characters, like make_ascii_uppercase.
2 Dynamically sized types allow things like Rc<str> for a sequence of reference counted UTF-8 bytes since Rust 1.2. Rust 1.21 allows easily creating these types.
Comment: It's not out of date (that representation has been fairly stable), just a little imprecise: it isn't statically known, unlike, say, `[u8; N]`.
Comment: "sequence of UTF-8 bytes (**of unknown length**)" - is this out of date? The [docs](https://doc.rust-lang.org/nightly/std/primitive.str.html) say "A `&str` is made up of two components: a pointer to some bytes, and a length."
Comment: @mrec it's unknown at compile time, assumptions about it size can not be made, for example, when creating a stack frame.

Thus why it's often treated as a reference, which a reference is a known size at compile time, which is the size of a pointer.
Comment: @cjohansson Statically allocated objects are normally stored neither on the heap, nor the stack, but in their own region of memory.
Comment: @lxx, no, Rust's ownership and borrowing kicks in: the compiler won't let you hold a `&str` slice pointing into a `String` that goes out of scope and is deallocated. In a garbage collected language the slice can exist after the main owner disappears, but in Rust it cannot: the compiler forces the programmer to explicitly choose how to handle it, e.g. don't share memory (by using `.to_owned()` to make a separate `String`), or share memory like you say (by using something like http://kimundi.github.io/owning-ref-rs/owning_ref/index.html#caching-a-subslice-of-a-string ).
Comment: Update: `Rc` and `Arc` are now usable via the standard library.
Comment: > "In static storage: a string literal "foo" is a &'static str. The data is hardcoded into the executable and loaded into memory when the program runs." --- should explain in what memory it is loaded. Like if it's stored on the heap or stack or somewhere else
Comment: If I keep a reference to a string slice and the original `String` gets out of scope, the slice keeps the entire original string value in memory, right? (the question probably makes more sense when thinking of a slice as a substring).
Comment: "an immutable sequence of dynamic length" sounds a bit contradictory for me. It seems dynamic means here something that opposed to such types as u32, etc., i.e. we always know the length of every u32 value, but not every str . Have I got it right?
Comment: How it comes out we don't know a str length but is aware of a length of data which a pointer points to? Btw, why can't a program get str length information run-time?
Comment: @Mergasov yeah, you're right. The "dynamic" means that it's only known at runtime in general (the `.len()` method returns it). The opposite of dynamic is "static", which you are right about too: a type like `u32` has a statically known size of 4, while the type `str` does not (there's know way to know how many bytes are in an arbitrary value of type `str`)
Answer: I have a C++ background and I found it very useful to think about String and &str in C++ terms:

A Rust String is like a std::string; it owns the memory and does the dirty job of managing memory.
A Rust &str is like a char* (but a little more sophisticated); it points us to the beginning of a chunk in the same way you can get a pointer to the contents of std::string.

Are either of them going to disappear? I do not think so. They serve two purposes:
String keeps the buffer and is very practical to use. &str is lightweight and should be used to "look" into strings. You can search, split, parse, and even replace chunks without needing to allocate new memory.
&str can look inside of a String as it can point to some string literal. The following code needs to copy the literal string into the String managed memory:
let a: String = "hello rust".into();

The following code lets you use the literal itself without a copy (read-only though):
let a: &str = "hello rust";

Comment: like a string_view?
Comment: Yes like string_view but intrinsic to the language and properly borrow checked.
Comment: `string_view` is an abomination. Imagine `auto_ptr` level bad.
Comment: @IsaacD.Cohen I guess that you mean why must the format string of println! be a literal and not a pointer/slice or any other reference to an existing string?
I guess the answer is rather philosophical, but there are good reasons to do so: you may want to keep the format string static so that the compiler can verify things like the number of arguments, and avoid runtime surprises. Notice that C allows it because the format string is a pointer to char. This is not an advantage, it is a flaw resulting from C being semi-strongly typed and other typing issues. After all, C is universal assembly.
Comment: Why can't I println!() a &str without formatting it into a literal? In C I can do printf(name_of_c_string);
Answer: It is str that is analogous to String, not the slice of it.
An str is a string literal, basically a pre-allocated text:
"Hello World"

This text has to be stored somewhere, so it is stored in the data section of the executable file along with the program's machine code, as sequence of bytes ([u8]).
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│  H  │  e  │  l  │  l  │  o  │     │  W  │  o  │  r  │  l  │  d  │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│  72 │ 101 │ 108 │ 108 │ 111 │  32 │  87 │ 111 │ 114 │ 108 │ 100 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘

Since text can be of any length, they are dynamically-sized.
Now that we stored the text, we need a way to access it and that is where the slice comes in.
A slice,[T], is a view into a block of memory. Whether mutable or not, a slice always borrows and that is why it is always behind a pointer, &.
Lets explain the meaning of being dynamically sized.
Some programming languages, like C, appends a zero byte (\0) at the end of its strings and keeps a record of the starting address. To determine a string's length, program has to walk through the raw bytes from starting position until finding this zero byte.
However Rust takes a different approach: It uses a slice. A slice stores the address where a str starts and how many byte it takes. It is better than appending zero byte because calculation is done in advance during compilation.
The text size can be known in advance but still changes with the underlying data which makes it dynamically sized.
If we go back to "Hello World" expression, it returns a fat pointer, containing both the address of the actual data and its length. This pointer will be our handle to the actual data and it will also be stored in our program. Now data is behind a pointer and the compiler knows its size at compile time.
Since text is stored in the source code, it will be valid for the entire lifetime of the running program, hence will have the static lifetime.
So, return value of "Hello Word" expression should reflect these two characteristics, and it does:
let s: &'static str = "Hello World";

You may ask why its type is written as str but not as [u8], it is because data is always guaranteed to be a valid UTF-8 sequence. Not all UTF-8 characters are single byte, some take 4 bytes. So [u8] would be inaccurate.
If you disassemble a compiled Rust program and inspect the executable file, you will see multiple strs are stored adjacent to each other in the data section without any indication where one starts and the other ends.
Compiler takes this one step further: If identical static text is used at multiple locations in the program, Rust compiler will optimize the program by creating a single binary block for all duplicate values.
For example, compiler creates a single continuous binary with the content of "Hello World" for the following code even though we use three different literals with "Hello World":
let x: &'static str = "Hello World";
let y: &'static str = "Hello World";
let z: &'static str = "Hello World";

String, on the other hand, is a specialized type that stores its value as vector of u8. Take a look at how String type is defined in the source code:
pub struct String {
    vec: Vec<u8>,
}

Being vector means it is heap allocated and resizable like any other vector value.
However, if you look carefully you will see vec field is kept private. Being private means, we can not create a String instance directly but through provided methods. Why it is kept private is because not all stream of bytes produce a valid utf-8 characters and direct interaction with the underlying bytes may corrupt the data. Through this controlled access compiler enforces data is valid and remains valid.
The word specialized in the type definition refers to this feature, feature of not permitting arbitrary access but enforcing certain checks on the data through controlled access in order to provide certain guarantees. Other than that, it is just a vector.
In summary, a String is a resizable buffer holding UTF-8 text. This buffer is allocated on the heap, so it can grow as needed or requested. We can fill this buffer or can change its content anyway we see fit.
There are several methods defined on String type to create String instance, new is one of them:
pub const fn new() -> String {
  String { vec: Vec::new() }
}

We can use it to create a valid String.
let s = String::new();
println("{}", s);

Unfortunately it does not accept input parameter. So result will be valid but an empty string but it will grow like any other vector when capacity is not enough to hold the assigned value. But application performance will take a hit, as growing requires re-allocation.
We can fill the underlying vector with initial values from different sources:
From a string literal
let a = "Hello World";
let s = String::from(a);

Please note that an str is still created and its content is copied to the heap allocated vector via String.from. If we check the executable binary we will see raw bytes in data section with the content "Hello World". This is very important detail some people miss.
From raw parts
let ptr = s.as_mut_ptr();
let len = s.len();
let capacity = s.capacity();

let s = String::from_raw_parts(ptr, len, capacity);

From a character
let ch = 'c';
let s = ch.to_string();

From vector of bytes
let hello_world = vec![72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100];
// We know it is valid sequence, so we can use unwrap
let hello_world = String::from_utf8(hello_world).unwrap();
println!("{}", hello_world); // Hello World

Here we have another important detail. A vector might have any value, there is no guarantee its content will be a valid UTF-8, so Rust forces us to take this into consideration by returning a Result<String, FromUtf8Error> rather than a String.
From input buffer
use std::io::{self, Read};

fn main() -> io::Result<()> {
    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();

    handle.read_to_string(&mut buffer)?;
    Ok(())
}

Or from any other type that implements ToString trait
Since String is a vector under the hood, it will exhibit some vector characteristics:

a pointer: The pointer points to an internal buffer that stores the data.
length: The length is the number of bytes currently stored in the buffer.
capacity: The capacity is the size of the buffer in bytes. So, the length will always be less than or equal to the capacity.

And it delegates some properties and methods to vectors:
pub fn capacity(&self) -> usize {
  self.vec.capacity()
}

Most of the examples uses String::from, which makes people get confused thinking why create String from another string.
It is a long read, hope it helps.
Comment: TL;GR => too long but great read, thanks.  I feel like I understand more about strings in rust.  I hope I actually do!
Comment: @snnsnn Thanks for this informative answer. I am an experienced frontend dev. Now, trying to learn rust, but don't know of any good resources. Can you please help me by providing some resources to learn rust. Even, I do not have any background in C/C++. So, I would like to understand hardware level concepts as well.
Comment: @Vishal What do you mean by not knowing any good resource? You could not find any or you did not find them helpful enough because even a simple search returns many resources. If you like the text, it was a part of the book I was writing, I've completed about 8 chapters but did not have time to finish.
Comment: @snnsnn I mean, I found many resources, but none of the resources goes in deep to the hardware level and the resources that takes me deeper are assuming that I already have some level of knowledge in rust. So, I am a bit confused on which path to go. So, I was requesting you to share any good resources if you have. I like the text that you shared, very eager to buy your book when it is available, till then I will keep learning from resources that I find.
Answer: str, only used as &str, is a string slice, a reference to a UTF-8 byte array.
String is what used to be ~str, a growable, owned UTF-8 byte array.
Comment: @jv110: no, because `~str` was growable while `Box` is not growable. (That `~str` and `~[T]` were magically growable, unlike any other `~`-object, was exactly why `String` and `Vec` were introduced, so that the rules were all straightforward and consistent.)
Comment: I also enjoyed [your blog post](https://chrismorgan.info/blog/rust-fizzbuzz/), "Two types of strings? What is this?" In particular: "`String` is an *owned* type... it has exclusive ownership of the contents of the string; and when it passes out of scope, the memory for the contents of the string will be freed immediately. For this reason, any substring can't be of the type `String`... [otherwise]... when one passed out of scope, the other would become invalid... And so instead it is that slices (substrings) use a type which is a reference to the contents that something else owns—`&str`..."
Comment: Technically, what used to be `~str` is now `Box`
Answer: They are actually completely different. First off, a str is nothing but a type level thing; it can only be reasoned about at the type level because it's a so-called dynamically-sized type (DST). The size the str takes up cannot be known at compile time and depends on runtime information — it cannot be stored in a variable because the compiler needs to know at compile time what the size of each variable is. A str is conceptually just a row of u8 bytes with the guarantee that it forms valid UTF-8. How large is the row? No one knows until runtime hence it can't be stored in a variable.
The interesting thing is that a &str or any other pointer to a str like Box<str> does exist at runtime. This is a so-called "fat pointer"; it's a pointer with extra information (in this case the size of the thing it's pointing at) so it's twice as large. In fact, a &str is quite close to a String (but not to a &String). A &str is two words; one pointer to a the first byte of a str and another number that describes how many bytes long the the str is.
Contrary to what is said, a str does not need to be immutable. If you can get a &mut str as an exclusive pointer to the str, you can mutate it and all the safe functions that mutate it guarantee that the UTF-8 constraint is upheld because if that is violated then we have undefined behaviour as the library assumes this constraint is true and does not check for it.
So what is a String? That's three words; two are the same as for &str but it adds a third word which is the capacity of the str buffer on the heap, always on the heap (a str is not necessarily on the heap) it manages before it's filled and has to re-allocate. the String basically owns a str as they say; it controls it and can resize it and reallocate it when it sees fit. So a String is as said closer to a &str than to a str.
Another thing is a Box<str>; this also owns a str and its runtime representation is the same as a &str but it also owns the str unlike the &str but it cannot resize it because it does not know its capacity so basically a Box<str> can be seen as a fixed-length String that cannot be resized (you can always convert it into a String if you want to resize it).
A very similar relationship exists between [T] and Vec<T> except there is no UTF-8 constraint and it can hold any type whose size is not dynamic.
The use of str on the type level is mostly to create generic abstractions with &str; it exists on the type level to be able to conveniently write traits. In theory str as a type thing didn't need to exist and only &str but that would mean a lot of extra code would have to be written that can now be generic.
&str is super useful to be able to to have multiple different substrings of a String without having to copy; as said a String owns the str on the heap it manages and if you could only create a substring of a String with a new String it would have to be copied because everything in Rust can only have one single owner to deal with memory safety. So for instance you can slice a string:
let string: String   = "a string".to_string();
let substring1: &str = &string[1..3];
let substring2: &str = &string[2..4];

We have two different substring strs of the same string. string is the one that owns the actual full str buffer on the heap and the &str substrings are just fat pointers to that buffer on the heap.
Comment: "it cannot be stored in a variable because the compiler needs to know at compile time what the size of each variable is" > Can you explain why can't the compilier produce a binary code which uses run-time information about a string length, please? Is it kind of Rust design constraint?
Comment: @Mergasov It could, but this would be extremely inefficient performance wise, and would completely alter the function calling convention which relies upon this information being known. That the size of a function call stack, and the location of each variable thereon is known at compile time, is very important to producing efficient programs and is the reason why the stack is orders of magnitude faster than the heap. It's far easier in that case to simply put it on the heap behind a pointer; it would essentially be turning the stack into a second heap.
Answer: Rust &str and String

String:

Rust's owned String type, the string itself lives on the heap and therefore is mutable and can alter its size and contents.
Because String is owned when the variables which owns the string goes out of scope the memory on the heap will be freed.
Variables of type String are fat pointers (pointer + associated metadata)
The fat pointer is 3 * 8 bytes (wordsize) long and consists of the following 3 elements:

Pointer to actual data on the heap, it points to the first character
Length of the string (# of characters)
Capacity of the string on the heap

&str:

Rust's non-owned String type, it's immutable by default. The string itself lives somewhere else in memory usually on the heap or in 'static memory.
Because String is non-owned when &str variables go out of scope the memory of the string will not be freed.
Variables of type &str are fat pointers (pointer + associated metadata)
The fat pointer is 2 * 8 bytes (wordsize) long and consists of the following 2 elements:

Pointer to actual data on the heap, it points to the first character
Length of the string (# of characters)

Example:
use std::mem;

fn main() {
    // on 64 bit architecture:
    println!("{}", mem::size_of::<&str>()); // 16
    println!("{}", mem::size_of::<String>()); // 24

    let string1: &'static str = "abc";
    // string will point to 'static memory which lives throughout the whole program

    let ptr = string1.as_ptr();
    let len = string1.len();

    println!("{}, {}", unsafe { *ptr as char }, len); // a, 3
    // len is 3 characters long so 3
    // pointer to the first character points to letter a

    {
        let mut string2: String = "def".to_string();

        let ptr = string2.as_ptr();
        let len = string2.len();
        let capacity = string2.capacity();
        println!("{}, {}, {}", unsafe { *ptr as char }, len, capacity); // d, 3, 3
        // pointer to the first character points to letter d
        // len is 3 characters long so 3
        // string has now 3 bytes of space on the heap

        string2.push_str("ghijk"); // we can mutate String type, capacity and length will also change
        println!("{}, {}", string2, string2.capacity()); // defghijk, 8

    } // memory of string2 on the heap will be freed here because owner goes out of scope

}

Answer: std::String is simply a vector of u8. You can find its definition in source code . It's heap-allocated and growable.
#[derive(PartialOrd, Eq, Ord)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct String {
    vec: Vec<u8>,
}

str is a primitive type, also called string slice. A string slice has fixed size. A literal string like let test = "hello world" has &'static str type. test is a reference to this statically allocated string.
&str cannot be modified, for example,
let mut word = "hello world";
word[0] = 's';
word.push('\n');

str does have mutable slice &mut str, for example:
pub fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str)
let mut s = "Per Martin-Löf".to_string();
{
    let (first, last) = s.split_at_mut(3);
    first.make_ascii_uppercase();
    assert_eq!("PER", first);
    assert_eq!(" Martin-Löf", last);
}
assert_eq!("PER Martin-Löf", s);

But a small change to UTF-8 can change its byte length, and a slice cannot reallocate its referent.
Comment: The opening sentence makes `String` sound redundant with `Vec`. The difference between the two is that a `String` always contains valid UTF-8 encoded text while a `Vec` can hold any sequence of bytes.
Comment: Thanks. I was looking for a `&mut str` that did not rely on a `String`, that is, without `to_string()`, because why bother with str if you have String already. This works: `let mut s: Box = "Per Martin-Löf".into(); let (first, last) = s.split_at_mut(3); first.make_ascii_uppercase(); assert_eq!("PER Martin-Löf", &*s);`
Answer: In easy words, String is datatype stored on heap (just like Vec), and you have access to that location.
&str is a slice type. That means it is just reference to an already present String somewhere in the heap.
&str doesn't do any allocation at runtime. So, for memory reasons, you can use &str over String. But, keep in mind that when using &str you might have to deal with explicit lifetimes.
Comment: I understand that's what you meant, and I'm saying that isn't completely accurate. The "heap" isn't a required part of the statement.
Comment: *somewhere in heap* — that is not completely accurate.
Comment: What I meant was that `str` is `view` of already present `String` in heap.
Answer:
In these 3 different types
let noodles = "noodles".to_string();
let oodles = &noodles[1..];
let poodles = "ಠ_ಠ"; // this is string literal

A String has a resizable buffer holding UTF-8 text. The buffer is allocated on the heap, so it can resize its buffer as needed or
requested. In the example, "noodles" is a String that owns an
eight-byte buffer, of which seven are in use. You can think of a
String as a Vec that is guaranteed to hold well-formed UTF-8; in
fact, this is how String is implemented.

A &str is a reference to a run of UTF-8 text owned by someone else: it "borrows" the text. In the example, oodles is a &str
referring to the last six bytes of the text belonging to "noodles", so
it represents the text "oodles." Like other slice references, a &str
is a fat pointer, containing both the address of the actual data and
its length. You can think of a &str as being nothing more than a
&[u8] that is guaranteed to hold well-formed UTF-8.

A string literal is a &str that refers to preallocated text, typically stored in read-only memory along with the program's machine
code. In the preceding example, poodles is a string literal, pointing
to seven bytes that are created when the program begins execution and
that last until it exits.

This is how they are stored in memory

Reference:Programming Rust,by Jim Blandy, Jason Orendorff, Leonora F . S. Tindall
Answer: Some Usages
example_1.rs
fn main(){
  let hello = String::("hello");
  let any_char = hello[0];//error
}

example_2.rs
fn main(){
  let hello = String::("hello");
  for c in hello.chars() {
    println!("{}",c);
  }
}

example_3.rs
fn main(){
  let hello = String::("String are cool");
  let any_char = &hello[5..6]; // = let any_char: &str = &hello[5..6];
  println!("{:?}",any_char);
}

Shadowing
fn main() {
  let s: &str = "hello"; // &str
  let s: String = s.to_uppercase(); // String
  println!("{}", s) // HELLO
}

function
fn say_hello(to_whom: &str) { //type coercion
     println!("Hey {}!", to_whom)
 }

fn main(){
  let string_slice: &'static str = "you";
  let string: String = string_slice.into(); // &str => String
  say_hello(string_slice);
  say_hello(&string);// &String
 }

Concat
 // String is at heap, and can be increase or decrease in its size
// The size of &str is fixed.
fn main(){
  let a = "Foo";
  let b = "Bar";
  let c = a + b; //error
  // let c = a.to_string + b;
}

Note that String and &str are different types and for 99% of the time, you only should care about &str.
Answer: String is an Object.
&str is a pointer at a part of object.
Comment: When people say "`&str` is like a *view* (slice) of data", it can sometimes sound confusing; This graphic shows it very well. The only thing that this answer doesn't really help with is that `String` is owned and mutable, whereas `&str` is immutable and non-owned.
Answer: For C# and Java people:

Rust' String === StringBuilder
Rust's &str  === (immutable) string

I like to think of a &str as a view on a string, like an interned string in Java / C# where you can't change it, only create a new one.
Comment: The biggest difference between Java/C# strings and Rust strings is that Rust guarentees the string to be correct unicode, as such getting the third charactor in a string requires more thought than just "abc"[2]. (Given we live in a multi-lingual world, this is a good thing.)
Comment: [This is incorrect](https://doc.rust-lang.org/std/string/struct.String.html#method.as_mut_str). The topic of mutability is already addressed in the top-voted answer; please read it to learn more.
Comment: &mut str is pretty uncommon and is different from &str.
Answer: In Rust, str is a primitive type that represents a sequence of Unicode scalar values, also known as a string slice. This means that it is a read-only view into a string, and it does not own the memory that it points to. On the other hand, String is a growable, mutable, owned string type. This means that when you create a String, it will allocate memory on the heap to store the contents of the string, and it will deallocate this memory when the String goes out of scope. Because String is growable and mutable, you can change the contents of a String after you have created it.
In general, str is used when you want to refer to a string slice that is stored in another data structure, such as a String. String is used when you want to create and own a string value.
Answer: String:

A String is a dynamic, heap-allocated, grow-able sequence of
characters.
Used for storing and manipulating text data that can change in size.
Represents owned string data.

Example:
let s: String = String::from("Hello");
println!("{}", s);
// Output: Hello

&str (String Slice):

A &str is an immutable reference to a sequence of characters (a
slice) stored in memory.
Used for working with string data without taking ownership.
Can be used with string literals or borrow from String.

Example:
fn print_length(s: &str) {
    println!("Length: {}", s.len());
}

let greeting = "Hello";
print_length(greeting);
// Output: Length: 5

Keep in mind that String and &str are related, but they serve different purposes and have different ownership characteristics in Rust.
Answer: Here is a quick and easy explanation.
String - A growable, ownable heap-allocated data structure. It can be coerced to a &str.
str - is (now, as Rust evolves) mutable, fixed-length string that lives on the heap or in the binary. You can only interact with str as a borrowed type via a string slice view, such as &str.
Usage considerations:
Prefer String if you want to own or mutate a string - such as passing the string to another thread, etc.
Prefer &str if you want to have a read-only view of a string.
Comment: [This is incorrect](https://doc.rust-lang.org/std/string/struct.String.html#method.as_mut_str). The topic of mutability is already addressed in the top-voted answer; please read it to learn more.
Comment: @Shepmaster You are equivocating `&str` and `&mut str` in all the replies. Two different things.


How to remove a tub drain with no spokes?

Question: I attempted to use my tub drain removal wrench to remove a bath tub drain. Unfortunately the spokes of the drain broke and the drain flange cracked. Not being terribly skilled at plumbing I am now unsure of how to remove this tub drain. How do you remove a tub drain with no spokes and therefore no removal wrench?
Comment: It might be your best option at this point to avoid damaging the tub while trying to remove it.
Comment: Can you access under the drain?
Comment: @Steven there is a plumbing access panel so I can get under the drain, but not easily.
Answer: You could try putting an expanding plug into the drain which should give you something to grab hold of with a pair of vice grips. I would replace the wing nut with a regular nut so that you have better access to the stud.

Expanding plugs from McMaster-Carr
Answer: If the other ideas don't work out, these internal pipe wrenchs are fantastic. I've got an old set that are older than me.
Here's an example of them
Www.amazon.com
They work forward and reverse and are indispensable when you need them.
Answer: Another approach is use a large pipe extractor, which looks similar to a large left handed screw, and bite into the drain trim, and back it out.  You will get more torque with this approach, but the pipe extractors are pricey, especially in that size. One brand product is called EZ-out.
You can also use expanding pliers. I once saw a pair of arc joint pliers which were ground with DIY jaws on the back side, to accomplish the same.
Answer: Tub drain extractor home depot sells them
Comment: Actually this is very similar to the EZ-out product.  Probably cheaper as the EZ-outs are significantly hardened.  This is probably less expensive.


Accessing friend's friend's data using facebook api

Question: Is it possible to access data from one friend's friend profile using facebook application?
Answer: I think at the moment that is not possible, because the whole concept that an user has to grant your application before you can get his/her information, would fall apart.
Although, you could get a friend's friend, to see if they are related to each other.
friends.areFriends


Can you use 1 large SSD device for booting and data (2 partitions) on Pi4?

Question: I want to use one partition for booting (RASPIOS) and one for the data files. The reasons I have are: 1- cost per GB on SSD devices is less and 2-separate devices causes more heat along with increased load on the power supply. Any booting problems using 2 partitions on one SSD?
Comment: What do you mean by 'capture 2 partitions'?
Comment: Have one for RASPIOS and one for the data files. I was unable to partition my SD card to do this and wondered if I would have the same problem.
Comment: What have you tried, how has it failed? Are you using a tool like gparted to help you do what you want?
Answer: You wrote:

I want to use one partition for booting (RASPIOS) and one for the data files.

The Raspberry Pi OS uses two partitions by default: one for booting, formatted as fat32, and one as root filesystem, formatted as ext4, containing all modules and programs to run the operating system. With a default Raspberry Pi OS the second partition is expanded to its maximum size on first bootup of the image. If using a big SSD device there is a lot of free space available on the second partition you want to store data files. Just create a directory:
<code>rpi ~$ sudo mkdir /data
</code>
and use this directory as storage for the data files.
Answer: Yes, you can partition an SSD.
If you're using Windows you can use this guide to partition your SSD: https://www.wikihow.com/Partition-a-Drive-on-Windows
You can then use a tool like Etcher to flash the .iso to the partition you created for your OS.
You can use the other partition for normal storage.
Comment: Have you tested that method? AFAIK Etcher writes to a disk, not a partition, meaning you will lose all existing partition info. There are other methods that *will* work
Comment: Thanks aklingam but let me apologize for the stupid way I asked my question. The real issue is when you are using the new booting process (using a device on Pi's USB), how does Pi4 know to go to the partition that has RASPIOS? I thought that Pi's boot level is at the device and not a particular entity on that devise. Thanks for any help you can give me.
Comment: Thanks, @Dirk you'd have to create the partition after you flash the .iso
Comment: @tomd Thanks a lot for the clarification I'm not familiar with how the boot order works on the Pi. Here is some documentation that might help you in case nobody else answers: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/bootflow.md


Where do you get a travel adaptor in Ireland?

Question: You arrive in Ireland and realise, oh no, you forgot to pack your travel adaptor. Unfortunately you are going to need one while you're here. That is the situation I'm in.
Where can I get a new one that fits my plugs? Are there any electronic stores that might carry some (so far, I haven't seen any)? Or perhaps, my best bet is to order online?
Comment: Where are you at? What type of plugs do you have?
Comment: @JonathanReez - Looks like there are some significant caveats from the info in the description here https://www.youtube.com/watch?v=uUu1anFXjUc
Comment: I don't reccomend plugging europlugs into british sockets but if you must do it then you should at least use an extension lead so that a fuse is present and so that if the plug does get stuck you aren't left with your appliance permanently attatched to the wall.
Comment: Euro plugs can be plugged in without a travel adaptor.
Comment: If you're staying in a hotel, you can start by asking the front desk. It's common for them to have a variety around, either as a service for their guests, or simply because people leave them behind and they wind up with a big box of unclaimed adapters in the lost and found.
Answer: Tourist-junk shops will normally carry them. So, anywhere you see selling Shamrock-themed tat and big green Leprechaun hats are worth a shot.
Homeware and electricals stores are also an option - as can be DIY stores.
Particular places I found that advertise them online and might have a store near you:

Boots (A pharmacy chain)
Argos (hard to describe - like a warehouse you can go to and people bring stuff to you from out back)
Currys (an electricals chain that may also go by the name PC World)
DID Electricals (another electricals chain)

All these I found by searching "travel adapter" on google.ie. (Although most of the linked chains I know from the UK).
Important Safety Notice:
Be careful if your device needs earthing, that the adapter you use properly passes the earth through. Many of the adapters shown either don't, or only do for some types of plug (and Europe has many slightly different types)
Comment: You can also add [Eurogiant](http://www.eurogeneral.ie/) discount stores and the likes. There are plenty of these in Dublin downtown, and they usually have the adaptors. Also, if one happens to be outside of downtown, most of mentioned options might be quite far, but big Tesco stores may have these
Comment: I bought a rather fancy one, so-called "universal," in one of the airport shops in Manchester.
Comment: I lost mine in Galway, and bought another in Dunnes.  And I'm now in the Dublin airport where3 several shops have them.
Answer: I don't have experiance with ireland but I do live in the UK and I expect the situation is similar.
In the UK one commonly sees generic "visitor" adaptors. These are widely available in most supermarkets and many other shops. They will look something like this:

http://www.argos.co.uk/static/Product/partNumber/9827590.htm
Typically they will accept american plugs, australian plugs and most European plugs. They may also accept 5A BS546 plugs (often listed as indian plugs). They will almost certainly NOT accept 15A BS546 plugs (often listed as south african plugs).
German/French plugs will typically be accepted but will not be earthed.
Unfortunately while the generic adaptors are as common as muck (at least in the UK but from the other answer it seems similar in ireland) if you need something that they don't cover you are likely to struggle. You might find earthed adaptors for German Shuko plugs with some searching. Anything else will probablly have to be ordered online.
Rewirable plugs should also be fairly widely available so if you are really stuck then changing the plug may be an option.
For computer gear getting a new power cord may also be an option.


s-wave, p-wave or d-wave collisions in scattering theory

Question: In scattering theory, what is a good intuitive picture to think of s-wave, p-wave or d-wave collisions ? What is their importance and what are the examples where a particular one is assumed to be the only important one and rest are taken as negligible ?
Comment: A good rule of thumb is to remember these quantum numbers correspond to angular momentum. S wave is the zero angular momentum  quantum number , l=0, and will correspond to a classical head on collision. P is l=1 and d l=2 which means higher angular momentum between scatterer and incoming. The atomic orbitals would give some intuition about functional shapes of the Y_l_m functions http://en.wikipedia.org/wiki/Atomic_orbitals
Comment: This seems a very broad question. You're essentially asking for a review article on scattering. There must be something along these lines out there in Googlespace.
Answer: I found the very last paragraph of the following answer quite explanatory:
https://physics.stackexchange.com/a/8324/46100

Interpretation of the Partial Wave Expansion: In the literature, you will often come across terms such as $s$-wave scattering. The
  partial wave expansion decomposes the scattering process into the
  scattering of incoming waves with definite angular momentum quantum
  number. It explains in which way $s$-, $p$-, $d$-waves etc. are
  affected by the potential. For low energy scattering, only the first
  few $l$-quantum numbers are affected. If all but the first term are
  discarded, only the $s$-waves take part in the scattering process.
  This is an approximation that is, for example, made in the scattering
  of the atoms in a Bose-Einstein condensate.