Change of name in Megillat Esther from Hegeh to Hegai?

Question: In Megillat Esther, the Pasuk (2:3) says that Achashverosh gathered the girls and placed them in the women's house, and the one who guarded them was הגא (ending with an א and with a segol under the ג). In Pasuk 8, his name suddenly changes to הגי (ending with a י and with a kamatz under the ג). I assumed this was just a matter of grammar, since the second name has an אתנח under the word, which would normally change a segol to a kamatz. But I'm a little skeptical of that answer, since the last letter was also changed to a י. Is that also just a matter of grammar? If anyone has another explanation (sourced, please) to the change of name or can verify my own answer with sources, please do so.
Comment: There's also two instances of הגי with a patach under the ג in 2:8 and 2:15
Answer:
Rabbi Levi Yitzchok Shneerson explains this discrepancy Kabbalistically (Likkutey Levi Yitzchok (Pesukey Tanach Umamareh Chazal pg. 95, see Sefer Ha'erchin Chabad (Mareches Ha'osyos vol. 1 pg. 369)). The main idea is as follows: There is a concept in Kabbalah known as the "18 Women of Leah" (which is why a king may marry a maximum of 18 wives). This is comprised of "9 Women of Gadlus" (big), and "9 Women of Katnus" (small). Since he was the "Keeper of the Woman", he was named הגי which has the numerical value of 18. However, at first he had only attained the level of the "Nine Women of Katnus", and was then known as הגא which is only equal to 9.
The Rokeach (2:8) writes that he was first known as הגא which in א"ת ב"ש becomes צר"ת ("rival of") since each women was a rival to the next. However once Esther came, he became הגי, which in א"ת ב"ש is צר"ם – (their rival) - because she was the challenger to all the others.
In the commentary written by R' Nessanel ben Yeshaya to Megilas Ester (on Esther 2:3, printed in Sefer Zikaron Leharav Yitzchok Nissim vol. 3 pg. 349) he explains that he was originally called הגא because he would not talk allot. After he became "The Keeper of the Woman", he became influenced by the "שיחת נשים" (abundant women chatter) and was thereafter known as הגי.
The Sefer Ir Mivtzar writes in the name of the Alshich that the miracle of Purim happened through the Divine Name of Yud-Kay. Based on this he explains that חרבונא was later changed to חרבונה, and הגא to הגי to symbolize the Yud and Hay.
Comment: Re. explanation #3, the women would say "Hey, guy!" and start conversations with him. Hence the name.
Comment: @Michoel, Please source this: 'There is a concept in Kabbalah known as the "18 Women of Leah" (which is why a king may marry a maximum of 18 wives).'


Brian Aldiss short story about caveats of advanced military technology

Question: I'm trying to remember a short story I read many years ago about the negative side of developing and deploying advanced weapons technology in an SF setting. It was about some intergalactic power that was trying to crush an adversary by using multiple new military technologies and how each one in turn caused this power so much grief it was defeated by the adversary. I think it was also required reading for military strategists at some schools here in the US, at least at the time I read it. I think the story was written by Brian Aldiss.
Comment: Are you thinking of Arthur C. Clarke's "Superiority?"  See https://scifi.stackexchange.com/questions/857/process-management-and-high-technology-weapon-novel-name-and-author
Comment: You should edit that into the question, anything extra helps.
Comment: Can you remember anything else about the actual story itself?
Comment: @TheLethalCarrot - Yes, vaguely. It was about some intergalactic power that was trying to crush an adversary by using multiple new military technologies and how each one in turn caused this power so much grief it was defeated by the adversary. I think it was also required reading for military strategists at some schools here in the US, at least at the time I read it.
Comment: Was there a field that resulted in (originally) identical fasteners becoming non-interchangeable within the same ship?
Comment: @DavidW - That sounds like it might be the one. I'll have to read it to be sure. Thank you. Confused on my authors. It was many years ago. I'm 70 and it was in my 20's that I read it, but the story stuck with me to this day.
Answer: I will suggest that this is actually the classic story "Superiority" by Arthur C. Clarke, first published in The Magazine of Fantasy and Science Fiction, August 1951.  You can read it at the Internet Archive.
The advanced civilization is menaced by a more vigorous, but in every other way inferior enemy, but at every stage they are convinced to wait for yet another advance that will fix the problems of the previous advance and make victory even more assured.  But nothing ever works well enough to make up for the delay, and ultimately the war is lost because no ship is ever available and in shape to fight.

The ultimate cause of our failure was a simple one: despite all statements to the contrary, it was not due to lack of bravery on the part of our men, or to any fault of the Fleet's. We were defeated by one thing only - by the inferior science of our enemies. I repeat - by the inferior science of our enemies.

It was Professor-General Norden who kept seducing the high command with the prospect of ever-better weapons and tactics in the future:

Norden's words left an uncomfortable impression, as he had no doubt intended. He quickly pressed home the attack.
"What we want are new weapons - weapons totally different from any that have been employed before. Such weapons can be made: it will take time, of course, but since assuming charge I have replaced some of the older scientists with young men and have directed research into several unexplored fields which show great promise. I believe, in fact, that a revolution in warfare may soon be upon us."

His "Sphere of Annihilation" destroys the projector, so it has to be turned into missiles, at great cost and expense of time.  And then there are problems with the new weapon, so it still can't be deployed.
The "Battle Analyzer" is too big, and too man-power intensive and ultimately too fragile in battle.
Finally the "Exponential Field" destroys the entire fleet; it never returns to exactly the same starting point, so after every use, everything goes out of adjustment, and parts don't even work between ships.  No standard spares are possible, and the fleet falls apart.
Comment: There it is, the "Exponential Field" is the one I recall where two same-size screws from different parts of the ship will no longer interchange.
Comment: @ZeissIkon "Not a single component of one ship could be expected with certainty to work aboard another. The very nuts and bolts were no longer interchangeable, and the supply position became quite impossible. [...] Our magnificent Fleet, crippled by our own science, fought on as best it could until it was overwhelmed and forced to surrender."


Does Salesforce support the Client Credentials Grant for OAuth?

Question: For every API I'm consuming from Salesforce so far, I'm using the Client Credentials Grant for everything that's just between servers (= no user involved). It seems that Salesforce itself does not support the Client Credentials Grant at all. If so, why? And is my assumption even correct? What would be an alternative - and why?
Answer: It's correct that you cannot perform a Client Credentials grant, but headless authentication, scoped to a user, is pretty easy. You can accomplish this with the OAuth 2.0 JWT Bearer Token Flow
Simplified steps...

Create a Connected App
Generate an X509 Cert and upload the cert to the Connected App
Set the connected app policy to Admin approved users are pre-authorized
Give one or more of your users access to the app via Permission Sets or Profiles.
Make sure your external application has access to the X509 private key. Take care to store this securely with your application.
Generate a JWT using the user you'd like to authenticate with. You'll set their username to the sub property. You'll sign it with the X509 private key.
Post it to the token endpoint with grant_type equal to urn:ietf:params:oauth:grant-type:jwt-bearer

This will return you an access token. Find a library in your preferred language to help with the construction and signing of your JWT. More details in the link above.
Comment: This adds a lot of useful information. Thanks!
Comment: This is one of the things that really baffles me - we seem to have tons of ways to connect to Salesforce but if I want to consume another API from Salesforce I find myself writing code from scratch.
Comment: Regarding "Find a library in your preferred language to help with the construction and signing of your JWT." -> https://jwt.io lists tons of libraries per tech stack.
Answer: All transactions in Salesforce are user-based. User access determines field level and record level access, page layouts, and so on. There's absolutely no way to perform an action as an anonymous "non-user." Even automated processes use an "Automated User" user for logging actions against. This is related to the auditing capabilities of Salesforce. The typical alternative is to log in as an admin or integration user.
Comment: You do have a point there. Still I'm wondering why Salesforce is having an "Automated User" while there's no way for us to do so - without wasting a license for a dedicated user that is. I mean - it does make sense since Salesforce is so user centric but then again - why having something that you won't give to your users? On the other hand - that wouldn't be the first feature that is only available to Salesforce and not to its users. Thanks for the clarification.
Comment: @sfdcfox I don't see anything that identifies the running integration user for the M2M JWT Bearer Flow based on a read-through [the documentation](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_jwt_flow.htm&type=5).  It appears the "sub" property that would identify a particular SF user is only needed in Exp Cloud scenarios.  Am I missing something?
Comment: (Unless the "prn" property is required in absence of the "sub" property; confusing language about the "sub" property only being required in Exp Cloud scenarios)
Comment: @Bow-chicawow-ers I'm pretty sure that prn is required. Again, every transaction in Salesforce is logged against *some* kind of user, even if it's a hidden or system user. I don't know a lot about JWT, but presumably there must be a way for it to identify the running user (or maybe it really just runs as automated user without a sub property?)
Answer: The JWT Bearer Token Flow is still a very valid alternative for server-to-server communication, but since the Winter '23 release the Client Credential Flow is now also supported by Salesforce.
The Client Credential Flow is safer than the Username-Password flow because it doesn't transmit actual user credentials, and is simpler than the JWT Bearer Token Flow because it doesn't need key management.
The call would be a simple POST to the token endpoint, providing the client id and secret and client_credentials as grant type in the body:
POST /services/oauth2/token HTTP/1.1
Host: MyDomainName.my.salesforce.com
grant_type=client_credentials&
client_id=*******************&
client_secret=*******************

Another option would be to Base64 encode the client id and secret in a Basic Authentication header:
POST /services/oauth2/token HTTP/1.1
Host: MyDomainName.my.salesforce.com
Header: Authorization: Basic
TXlDbGllbnRJRDpNeUNsaWVudFNlY3JldA==
grant_type=client_credentials

Salesforce returns an access token based on the executing user and the scopes that you configure in the Connected App
The documentation can be found here: OAuth 2.0 Client Credentials Flow for Server-to-Server Integration
Comment: Something to add: The user that you set as executing user needs to have an api only profile, so it cannot be just any user, so you are encouraged to use a special integration user with only the relevant permissions for this connected app.
Comment: Interesting! I'll have a look at this and my specific use cases. Maybe other people can share their experience with this here as well. Thanks!


How to modify dependency for Jersey projects built on Gradle?

Question: I was attempting to solve problems of MessageBodyWriter not found in a Jersey project I created. I got a lot of recommendations fixing the dependency, some of which mention changing pom.xml, but since the project I got was built and compiled in Gradle, there are not similar xml like that. What are the similar files I need to look into in terms of checking dependency?
Comment: https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html
Answer:
Maven → Gradle == <groupId>:<artifactId>:<version>

So
<dependency>
  <groupId>org.glassfish.jersey.media</groupId>
  <artifactId>jersey-media-json-jackson</artifactId>
  <version>${jersey2.version}</version>
  <scope>runtime</scope>
</dependency>

in Gradle would be
compile org.glassfish.jersey.media:jersey-media-json-jackson:${jersey2.version}

${jersey2.version} is whatever Jersey 2.x version you are using.
See Also:

Jersey RESTful web service gradle setup

Note: The above solution is for if you are getting a "MessageBodyReader nor found for application/json". Any other type, then you would need to show us the stacktrace. I am just stating the most common one (and that's what you have linked to), since you have not provided the exact stacktrace message. It could really be for any type, in which case this answer would be irrelevant. You might also find this useful. Just some general information about MessageBodyReaders and MessageBodyWriters
Answer: Take the data that you add to your pom and add it like this top your build file...
dependencies {
    compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
}

You can copy the text of your pom file exactly.


Can I use garam masala instead of curry powder?

Question: When I don't have curry powder can I use garam masala as a substitute? Can it give the same taste as curry powder or not? If use garam masala how much should be added?
Answer: No, you won't get the same flavor or color. Curry powder is a blend of turmeric, cumin, coriander, and sometimes fenugreek, black pepper, mustard or cardamom. Curry powder is generally added towards the beginning of a recipe and cooked with the food.
Garam masala is a finishing spice blend shares some of the ingredients of curry powder (cumin and coriander) but is significantly different in that generally has cinnamon, bay leaves, fennel seed and cloves. Garam masala has many aromatic spices in it, and it is generally added towards the end of a recipe to give it an aromatic punch.
Comment: Especially, some garam masala recipes might completely miss out on adding any of the red chile pepper expected of a curry powder, or they might have far less turmeric. The kind of recipe where garam masala is typically used will add either of these at other points in the cooking process!
Comment: Absolutely @rackandboneman, it's common to have both.
Comment: Was thinking of classic "mustard -> cumin,bay leaf,whole spices -> onions -> green chili,ginger,garlic->turmeric,lal mirch,coriander powder, a bit garam masala -> tomatoes -> ...... -> more garam masal" workflow....
Answer: Yes, you can add garam masala  in curry. Its taste is not like curry powder but adding in curry it gives delicious taste. I used garam masala in curry at my home. you can add 1 tble spoon of grinded garam masala in curry before adding yogurt in it.


Testing load of a highchart using python and selenium

Question: I am writing a program that must screen some charts, the issue is that I do not know how much time a graph expends to load, it could be seconds or minutes.
How can I make an appropriate wait, that only continues executing whenever the chart is fully loaded?
I have thought about waiting for the load event, but I am not sure how to approach that.
Comment: Can you give some code examples of the charts and what you tried? You probably gonna need to simply make an explicit wait.
Answer: To wait for a chart to be fully loaded before continuing with your program, you can use techniques like polling or waiting for specific events. Here's an approach using JavaScript and the load event to wait for a chart to be fully loaded:
Add an Event Listener: You can add an event listener to the chart element to listen for the load event. This event is triggered when the chart is fully loaded and ready for interaction.
Assuming you have a chart element with an id attribute like this:

You can add an event listener in your JavaScript code as follows:
const chartElement = document.getElementById('chart');

chartElement.addEventListener('load', function() {
    // This code will be executed when the chart is fully loaded.
    // You can continue with your program here.
});

Polling Approach: If the chart doesn't have a built-in load event, you can use a polling approach to continuously check whether the chart is loaded. You can use setInterval to check the chart's status at regular intervals until it's fully loaded. Here's an example:
function checkChartLoaded() {
    const chartElement = document.getElementById('chart');

    if (chartElement.complete) {
        // The chart is fully loaded.
        // You can continue with your program here.
    } else {
        // The chart is not fully loaded yet.
        // You can set the polling interval to your desired value (e.g., 1000ms).
        setTimeout(checkChartLoaded, 1000);
    }
}

// Start the polling process
checkChartLoaded();

This code will keep checking whether the chart is fully loaded at 1-second intervals. Once it's fully loaded, it will continue with your program.


Move Magento currency switcher to the left of the product price

Question: My store runs on Magento 1.942
I want to move the currency switcher from the top to the left of the product price. I tried searching on google for a long time and couldn't find a way. Please help me?
Answer: Magento 1 header currency drop-down shown from file app/design/frontend/THEME/default/layout/directory.xml <reference name="header">
    <block type="directory/currency" name="currency" as="currency_switcher" template="directory/currency.phtml"/>
</reference>so if you want to show that in product view page than just put below block in app/design/frontend/THEME/default/layout/catalog.xml file as (add block in product.info block)<catalog_product_view translate="label">
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            <block type="directory/currency" name="currency" as="currency_switcher" template="directory/currency.phtml"/>
        </block>
    </reference>
</catalog_product_view>now call this block in phtml file where you want to show in product view page app/design/frontend/rwd/default/template/catalog/product/view.phtml as <?php echo $this->getChildHtml('currency_switcher');?>


media folder suddenly empty

Question: I'm trying to upload some images in my wordpress backend, but it fails every time. It could be permission issues because I have had trouble with that earlier in the project. But the weirdest thing is that I see on my server that the media folder is suddenly empty, while all the media in the wordpress backend is still there and the website is running fine. Anybody got an idea how this could have happened?
Answer: Try to edit one of the picture in the media on admin dashboard, there will be a text field titled 'File URL' on the right side.
Paste that into address bar and see if the browser loads it correctly. If yes then the problem is on the folder permission (or you might have opened the wrong directory), if not, you might wanna try to clear the browser cache or use another platform to open it.
Hope it helps!

media folder suddenly empty


What's special about Cobb–Douglas utility relative to the rest of the CES family?

Question: My question concerns CES utility functions, which have the form
$$u(x) = \left(\sum_{j=1}^n a_j x_j^{\rho} \right)^{1/\rho}$$
for utility parameters $a_j$, an elasticity parameter $\rho$, and some allocation of goods given by $x$.
When $\rho=1$ we have linear utility,  or perfect substitution, with $$u(x) = a^T x$$ The level sets of $u$ are straight lines, and it is always possible to achieve the same utility by exchanging one good for another in some fixed ratio. I can see this arising in real life: Two bags of flour are perfectly interchangeable, and the only thing that matters to the buyer is their size and cost.
When $\rho \to -\infty$ we have Leontief utility, or perfect complementarity, with $$u(x) = \min_j a_j x_j$$ The level sets of $u$ are L-shaped, and  optimal utility is always achieved by purchasing goods in a  target ratio given by $a$. This also makes sense: If I am making a recipe that calls for two units of egg for every unit of sugar, having twice as much sugar makes no difference unless I also have twice as much egg.
Most situations are more complicated than this, however, and the nice thing about the CES form and its $\rho$ parameter is that it lets us capture situations that don't sit at one of these extremes. A baker can replace sugar with brown sugar, but not arbitrarily. Setting $\rho$ to some value between $1$ and $-\infty$ captures this imperfect substitutability. But the precise value of $\rho$ depends on the situation at hand: if the ingredients are pretty good substitutes, maybe $\rho = 0.8$; if they are fairly poor substitutes, maybe $\rho = -10$.
If we take the limit as $\rho \to 0$, we get a utility function that has a nice name,
the Cobb–Douglas utility function. It also has a nice form:
$$u(x) = \prod_j x_j^{a_j}$$
But is there anything that's truly special about this case?
From my standpoint, it looks like the Cobb–Douglas utility is just one arbitrary point along the continuum running from linear to Leontief. Perhaps it gets a name because it was discovered before the generalized CES family, but I can't see why there's anything especially meaningful about it beyond the simplicity of the form. Is this argument fair?
Is there a reason why we might assume $\rho$ is close to zero if we have ruled out the linear and Leontief cases?
Does Cobb–Douglas utility correspond to an "idealized" situation like the flour or egg/sugar examples above?
Answer: This is not supposed to be an answer, just a comment: Cobb-Douglas function is named after the paper https://www.jstor.org/stable/1811556 (1928).
Most cases of production functions have returns to scale equal to one, which is the Cobb-Douglas form. It is not special, it is common.
CES function was generalized by Dixit and Stiglitz in the paper https://www.jstor.org/stable/1831401 (1977).


Conservation of Angular momentum during inversion of a rotating wheel

Question: in the picture the person is sitting with a wheel rotating. He just reverses the wheel so that the angular velocity and angular momentum too are inverted. Then according to conservation law the system's angular momentum must be conserved and the man must have an angular momentum. Then what applies the required torque to him and how ? Can this be explained using Newton's laws?
Answer:
Then what applies the required torque to him and how ? Can this be
  explained using Newton's laws?

For the rotation of the wheel to change the direction, a torque has to be applied to it by the person's hand. According to the Newton's third law for rotation, the opposite torque will be applied by the wheel to the person's hand, which will cause the angular acceleration of the person.
Answer: The first thing to note is that if the angular momentum of the flywheel was large then it is unlikely that the inversion of the flywheel could be done one-handed.
Such demonstrations are often done with lead loaded bicycle wheel with two handles held by hands on either side of the wheel.
There are a number of forces involved in a 3D space so I have had to annotate two diagrams to try and explain what is happening.
First of all the axis of rotation of the flywheel has to be moved from the vertical.
This is done by applying a torque (forces $F1$ and $F2$) to the flywheel as shown in the left hand diagram.
The anticlockwise angular momentum of the flywheel (and person) is changed because the turntable on which the person is standing is not allowed to tip from the horizontal and the ground on which the turntable stands exerts an external torque on the person-flywheel system.

What is conserved is the vertical angular momentum of the person-flywheel system because the turntable with low-friction bearing cannot exert a torque in the vertical direction.
Considering the person-flywheel system forces $G1,\,G2,\,H1$ and $H2$ are all internal forces with $G1$ and $H1$ being Newton third law pairs and likewise with forces $G2$ and $H2$.
The vertical torque on the flywheel due to the hand is equal in magnitude but opposite in direction to the vertical torque on the hand due to the flywheel.
So whatever vertical angular momentum the flywheel loses the person gains ie the vertical angular momentum of the person-flywheel system is conserved.
The actual system of forces is more complicated but I hope you understand the general picture of what is happening?
Comment: Great explanation.


Discrete convolution equation

Question: Let $x_1 = (x_1^k)_{k =-\infty}^{+\infty}$, $x_2 = (x_2^k)_{k=-\infty}^{+\infty}$, $x_3 = (x_3^k)_{k=-\infty}^{+\infty}$ be three sequences of real numbers such that $x_j^k = 0$ for $k < -m_j < 0$. Then the convolution $x_i * x_j$ is correctly defined:
$$
   [x_i * x_j]^k = \sum_{k_1 + k_2 = k} x_i^{k_1} x_j^{k_2}.
$$
Suppose that $x_i^k$ are known for $k \geq 0$ and are unknown for $k < 0$ and consider the following convolution-type equation:
$$
   x_3 + A \cdot x_1 * x_2 + B \cdot x_1 * x_1 * x_1 = 0
$$
with known $A$ and $B$. My question is whether there is some literature considering the equations of this type? What is the natural approach to solve such equations? Of course we can consider this equation as an infinite system of the second order algebraic equations but in such a way it is too difficult for me to obtain the conditions when the solution to this problem exists and is unique.
Answer: One of natural approaches would be to work with the spaces $\ell_p$, $p\in [1,\infty]$, because the Young's inequality works:
$$\|x\ast y,\ell_r\|\le \|x,\ell_p\|\|y,\ell_q\|,\quad p,q,r\in [1,\infty],\quad \frac 1p+\frac 1q=1+\frac 1r.$$
For example, if you have the equation of the type (it arises in theory of difference equations, for example) $$x=B\ast x+f,$$ then for sufficiently small  norm of $B$ and for all $f\in\ell_p$ you have the uniqueness of the solution $x\in\ell_p$. You just define a bounded linear operator $\mathcal B:\ell_p\to\ell_p$, $\mathcal By=B\ast y$. Clearly, $\|\mathcal B\|\le \|B,\ell_1\|$. Then if $ \|B,\ell_1\|<1$ you write $x=(Id-\mathcal B)^{-1}f$.
However, the explicit forms of solutions, their support, etc can be a much trickier question.

Discrete convolution equation


Creating an MJPEG video stream in c#

Question: I have images being sent to my database from a remote video source at about 5 frames per second as JPEG images. I am trying to figure out how to get those images into a video format so I can stream a live video feed to Silverlight.
It seems to make sense to create a MJPEG stream but I'm having a few problems. Firstly I was trying to stream via an HTTP request so I didn't have a deal with sockets but maybe this is breaking my code.
If I try surf to my stream from QT I get a video error, Media player shows the first frame image and Silverlight crashes :)
Here is the code that streams - since I content type used this way can only be sent once I know that it isn't ideal and might be the root cause. All images are coming in via a LINQ2SQL object.
I did already try simply updating the image source of an image control in Silverlight but the flicker isn't acceptable. If Silverlight doesn't support MJPEG then no point even continuing but it looks like it does. I do have access to the h.264 frames coming in but that seemed more complicated via MP4.
<code>    Response.Clear();
    Response.ContentType = "multipart/x-mixed-replace; boundary=--myboundary";
    ASCIIEncoding ae = new ASCIIEncoding();
    HCData data = new HCData();
    var videos = (from v in data.Videos
                 select v).Take(50); // sample the first 50 frames
    foreach (Video frame in videos)
    {
        byte[] boundary = ae.GetBytes("\r\n--myboundary\r\nContent-Type: image/jpeg\r\nContent-Length:" + frame.VideoData.ToArray().Length + "\r\n\r\n");
        var mem = new MemoryStream(boundary);
        mem.WriteTo(Response.OutputStream);
        mem = new MemoryStream(frame.VideoData.ToArray());
        mem.WriteTo(Response.OutputStream);
        Response.Flush();
        Thread.Sleep(200);
    }
</code>
Thanks!
EDIT: I have the stream working in firefox so if I surf to the page I see video! but nothing else accepts the format. Not IE, SL, Media player - nothing.
Comment: Did you ever get this resolved?
Comment: Not using this method - I just ended up doing background image loading using JS in the browser and then switching images out as fast as they arrived. Worked Ok.
Comment: You pretty much have the basics, there is an implementation here @ https://net7mma.codeplex.com/SourceControl/latest
Answer: I did MJPEG a long time ago (3-4 years ago) and I'm scratching my head trying to remember the details and I simply can't.  But, if its possible, I would suggest finding some kind of web site that streams MJPEG content and fire up wireshark/ethereal and see what you get over the wire.  My guess is you are missing some required HTTP headers that firefox is little more forgiving about.
If you can't find a sample MJPEG stream over the internet, a lot of web cams have software that give you an MJPEG stream.  The app I worked on it with was a console for multiple security cameras, so I know that is a common implementation for cams of all types (if they support a web interface).
Answer: I'm far from being an expert in MJPEG streaming, but looking at the source of mjpg-streamer on sourcefourge I think you should send each frame separately, writing the boundary before and after each of them. You should of course not write the content-type in the closing boundary.
Answer: First, write your mjpeg frames out to separate files. You should then be able to open these in Phototshop (this will independently verify that you are parsing the stream correctly). If this fails, by bet is that you have HTTP headers embedded in your image data.
Comment: Yes I have done that - the images get used for other things independent of the Video so I can view them and they look good.
Comment: Does that mean you've viewed the frames after they've been handled by your program?
Comment: Yes - I also have it working in Firefox and I can see perfect video but yes, I've also written the images as single jpg files to disk and they are fine.
Answer: Have you looked at various web cam setups that exist on the net?  A lot of them do some sort of low res update without flicker.  You should be able to reverse engineer these types of sites for additional clues to your problem.
Some sites create a GIF animation, maybe that is an option so that the user can see the past minute or so.
Answer: About your edit: MJPEG is supported by Firefox and Safari. However other applications do not, like Explorer or Silverlight depending on what you are doing with it.

Creating an MJPEG video stream in c#


Using OBR on Virgo 3.5

Question: I'm looking for a neat way to deploy and manage bundles on our Virgo container, but also want to ensure that should we want to move from Virgo in a few years, we're not heavily tied to it.  We're using Maven, so get OBR for free, which could save us some work having to maintain a list of the dependency chains.
With that in mind, after having read this article;- How to deploy OSGi apps and dependencies? and some the Virgo 3.5 docs, I'm slightly at odds about the best approach.
The Virgo docs suggest using the plan mechanism, but this ties our deployment descriptors to Virgo (not what I'm after).  The article suggests I can use OBR through the GoGo console, which now ships as standard with Virgo.  However, when trying to use this console to manage OBR, all I get is
<code>osgi> repos add /home/fuzzy/.m2/repository/repository.xml
No repository admin service available
</code>
I've done some more hunting through the Virgo docs, but can't find anything in reference to OBR - only bug reports suggesting that some of the OBR commands have been left in the GoGo shell, inappropriately.
I've also written to the Virgo forum, but no-one seems to really want to help there.  Before I go down the route of tying us to Virgo plans, I thought I'd have a quick go here.
Any help, greatly appreciated!  Thanks in advance.
Answer: As suggested, downloaded and installed org.apache.felix.bundlerepository-1.6.6.jar - however, get exactly the same error.  Asked the same question of the Virgo user group, and the answer that came back is that OBR is not supported.  Maybe I'm missing something here, but there's very little information about on this topic.  If you know better - please update this thread for the sake of others!
Answer: The message is quite clear - you need a repository admin service. Felix provides an implementation (download Bundle Repository).
Comment: downloaded and installed org.apache.felix.bundlerepository-1.6.6.jar - however, get exactly the same error.
Comment: Have you checked if a repository admin service is available? I have don't know about Virgo, but in Karaf or Felix the web-console offers a list of all registered services.

Using OBR on Virgo 3.5


How do I read the number of files in a folder using Python?

Question: How do I read the number of files in a specific folder using Python? Example code would be awesome!
Answer: To count files and directories non-recursively you can use os.listdir and take its length.
To count files and directories recursively you can use os.walk to iterate over the files and subdirectories in the directory.
If you only want to count files not directories you can use os.listdir and os.path.file to check if each entry is a file:
import os.path
path = '.'
num_files = len([f for f in os.listdir(path)
                if os.path.isfile(os.path.join(path, f))])

Or alternatively using a generator:
num_files = sum(os.path.isfile(os.path.join(path, f)) for f in os.listdir(path))

Or you can use os.walk as follows:
len(os.walk(path).next()[2])

I found some of these ideas from this thread.
Answer: pathlib, that is new in v. 3.4, makes like easier. The line labelled 1 makes a non-recursive list of the current folder, the one labelled 2 the recursive list.
from pathlib import Path

import os
os.chdir('c:/utilities')

print (len(list(Path('.').glob('*')))) ## 1
print (len(list(Path('.').glob('**/*')))) ## 2

There are more goodies too. With these additional lines you can see both the absolute and relative file names for those items that are files.
for item in Path('.').glob('*'):
    if item.is_file():
        print (str(item), str(item.absolute()))

Result:
boxee.py c:\utilities\boxee.py
boxee_user_catalog.sqlite c:\utilities\boxee_user_catalog.sqlite
find RSS.py c:\utilities\find RSS.py
MyVideos34.sqlite c:\utilities\MyVideos34.sqlite
newsletter-1 c:\utilities\newsletter-1
notes.txt c:\utilities\notes.txt
README c:\utilities\README
saveHighlighted.ahk c:\utilities\saveHighlighted.ahk
saveHighlighted.ahk.bak c:\utilities\saveHighlighted.ahk.bak
temp.htm c:\utilities\temp.htm
to_csv.py c:\utilities\to_csv.py

Comment: Equivalent of the `## 1` line with `iterdir` is `print( len(list(Path('.').iterdir())) )`
Answer: You can use the glob module:
>>> import glob
>>> print len(glob.glob('/tmp/*'))
10

Or, as Mark Byers suggests in his answer, if you only want files:
>>> print [f for f in glob.glob('/tmp/*') if os.path.isfile(f)]
['/tmp/foo']
>>> print sum(os.path.isfile(f) for f in glob.glob('/tmp/*'))
1

Comment: It should be said, that `os.listdir('.')` includes hidden files (starting with a single dot), whereas `glob('./*')` does not.
Comment: @lunaryorn - If you want hidden files in the current directory, use `glob('.*')`. If you want everything including hidden files, use `glob('.*') + glob('*')`.
Answer: Mark Byer's answer is simple, elegant, and goes along with the python spirit.
There's a problem, however: if you try to run that for any other directory than ".", it will fail, since os.listdir() returns the names of the files, not the full path. Those two are the same when listing the current working directory, so the error goes undetected in the source above.
For example, if you are at /home/me and you list /tmp, you'll get (say) ['flashXVA67']. You'll be testing /home/me/flashXVA67 instead of /tmp/flashXVA67 with the method above.
You can fix this using os.path.join(), like this:
import os.path
path = './whatever'
count = len([f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))])

Also, if you're going to be doing this count a lot and require performance, you may want to do it without generating additional lists. Here's a less elegant, unpythonesque yet efficient solution:
import os

def fcount(path):
    """ Counts the number of files in a directory """
    count = 0
    for f in os.listdir(path):
        if os.path.isfile(os.path.join(path, f)):
            count += 1

    return count

# The following line prints the number of files in the current directory:
path = "./whatever"
print fcount(path)

Comment: have a look at bstpierre's answer.
Comment: Indeed! Looks better than mine, and if you're reading this, check back on the first answer, an addition was made by Mark using walk() that addresses both of the problems I pointed out in a single line.
Comment: +1 for spotting the bug - I've updated my answer with your corrected version.
Answer: Try this:
import os
for dirpath, dirnames, filenames in os.walk('./your/folder/path'):
    print(f'There are {len(dirnames)} directories and {len(filenames)} images in {dirpath}.')

The result would look like this:
There are 10 directories and 0 images in ./asl_data/photos.
There are 0 directories and 32 images in ./asl_data/photos\0.
There are 0 directories and 34 images in ./asl_data/photos\1.
There are 0 directories and 32 images in ./asl_data/photos\2.
There are 0 directories and 31 images in ./asl_data/photos\3.
There are 0 directories and 34 images in ./asl_data/photos\4.
There are 0 directories and 31 images in ./asl_data/photos\5.
There are 0 directories and 40 images in ./asl_data/photos\6.
There are 0 directories and 33 images in ./asl_data/photos\7.
There are 0 directories and 30 images in ./asl_data/photos\8.
There are 0 directories and 39 images in ./asl_data/photos\9.

Answer: I think the easiest way is using pathlib and checking the length of the result of the iterdir() method. For example:
from pathlib import Path

search_path = Path('<relative or absolute path>')
n_files = len([*search_path.iterdir()])

If you want only certain types of files you can customize the list comprehension:
# only files
n_files = len([p for p in search_path.iterdir() if p.is_file()])

# only directories
n_files = len([p for p in search_path.iterdir() if p.is_dir()])

# only given extension
ext = '.png'
n_files = len([p for p in search_path.iterdir() if p.suffix==f'{ext}'])

Answer: total = len(filter(
            lambda f: os.path.isfile(os.path.join(path_to_dir, f)),
            os.listdir(path_to_dir)))

OR
total = sum([True for f in os.listdir(path_to_dir) if os.path.isfile(os.path.join([path_to_dir, f)])

Answer: recursive solution:
sum(len(fs) for _,_,fs in os.walk(os.getcwd()))

for current directory solution:
len(os.walk(os.getcwd()).next()[2])

Answer: print(len(os.listdir(r"your path")))
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


What causes subtle cyclical changes in engine volume at cruise?

Question: A few years back, while trying to snooze on a Jet2 flight up at cruising altitude, my semi-attention wandered to the droning of the engine. I realised there was a very subtle effect of its intensity rising and falling ever so slightly in a repeating fashion.  From memory, I'd say it was doing each rise and fall cycle over around 3-4 secs.  It was consistently regular in its pattern.  I've never heard that before but it was so subtle it could be it always does it and I've just never noticed.  I was intrigued as to what the mechanism might be.  Any thoughts?
I was in the window seat a row or two in front of the wing at the time if that's relevant to what's audible.
Thanks!
Comment: I suspect that what you are hearing is the interference pattern between the two engines.  The vibration combing from the rotation of one engine is some variable X hertz and the other engine is "X+/- a few" hertz.  This creates the interference pattern like you sometimes get with stereo speakers. On many prop and turbo-prop engines you have a prop-synchronizer that lets you make tiny RPM adjustments to find a  "sweet spot" where the interference pattern isn't noticeable.
Comment: Also known as a beat frequency. https://en.wikipedia.org/wiki/Beat_(acoustics)
Comment: Many thanks for the answers!!
Answer: That is almost certainly a sound interference pattern due to a slight difference between the spool speeds of the two engines.  It's a much more common problem on reciprocating or turbopropeller powered airplanes, where it can cause considerable discomfort for the passengers, but can also happen aboard turbofan powered aircraft, especially those with high bypass engines.
Comment: You said core speed, not fan speed.
Comment: I suppose better said as "spool speed".
Comment: Well almost all the lower frequency non-white noise, which is what we are concerned with, is coming from the fan, so I would use that if I was writing it.
Comment: Many thanks for the answers!!


What is allowed to be an Arcane focus?

Question: Reading the PHB chapter 5 equipment pg. 151. It describes an arcane focus as such:

Arcane Focus. An arcane focus is a special item — an orb, a crystal, a rod, a specially constructed staff, a wand like length of wood, or some similar item — designed to channel the power of arcane spells. A sorcerer, warlock, or wizard can use such an item as a spellcasting focus, as described in chapter 10.

Now I have been coming up with a dwarven war mage character concept, and was curious to know would it be allowed to have an arcane focus as warhammer?
Comment: Related on [Can a tattoo be an arcane focus](https://rpg.stackexchange.com/questions/76168/can-a-tattoo-be-used-as-an-arcane-focus), [Can a glass eye be an arcane focus](https://rpg.stackexchange.com/questions/116094/can-a-glass-eye-be-an-arcane-focus), and [Can an elven wizard use a bow as an arcane focus](https://rpg.stackexchange.com/questions/45266/can-an-elven-wizard-use-a-bow-for-an-arcane-focus)
Answer: Arcane Focus is a Specific Item
The arcane focus is found in the Adventuring Gear section of the equipment chapter (PH page 150, SRD page 69, SRD link). Your options for arcane focus are:

Crystal
Orb
Rod
Staff
Wand

So no, you cannot use a warhammer as a focus.
Why Not1?
An arcane focus is "…an orb, a crystal, a rod, a specially constructed staff, a wand-like length of wood, or some similar item…." (emphasis mine). A warhammer or other weapon is not similar to any of the listed items.
Can A DM allow it? You Bet
That being said, if your DM says it's OK, go for it. Paladins and clerics can use a holy symbol as a focus, and that can be "…carefully engraved or inlaid as an emblem on a shield…." Using that as precedence, you can thusly allow arcane magic users to use the same rules.
Just know that in so doing, you are giving the arcane magic users an ability they didn't have before and devaluing the divine caster's unique schtik.

1 An exception that requires a common magic item

If the warhammer has a Ruby of the War Mage imbedded in it.  The Ruby of the War Mage (Xanathar's Guide to Everything) is a magical gem that can be attached to a weapon, at which point that weapon can be used as a spellcasting focus.  Things to note

it says "spellcasting focus", not "arcane" or "divine", implying that it works with all spellcasting in the same way as a component pouch
it's listed as a common item, implying that it's not considered too much of a big deal
it requires attunement
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/73754/discussion-between-kevin-burch-and-christopher).
Comment: College of Swords Bards can use a weapon as a spellcasting focus as well
Comment: There's also the Izzet arcane foci from GGtR, of which the Mizzium Apparatus is a magical example.
Comment: Also, since this answer's been posted, additional magic items that allow the use of magical spellbound as arcane foci have been added, and there's also the Hat of Wizardry that allows the use of a hat as an Arcane focus.
Answer: Action Economy
The purpose of material components (which includes a spellcasting focus) is to control action economy.
To cast a spell you need a hand free to hold the components. To hit someone you need a hand free to hold the weapon. To defend yourself you need a hand free to hold the shield.
This means that there is a limit on how many different actions you can do; namely two (four, if you are a thri-keen).
If you allow one item to be used for two purposes then you are changing the action economy.
You also remove some of the consequences of choices. For example, if you end your turn with a sword and a shield in your hands then you can't cast a spell as a reaction. Your choice has a meaningful consequence.
Item Value
A quarterstaff is 2sp. A staff focus (both the arcane one and the druidic one) is 5gp. This suggests that a focus is an ornate, crafted item, made from expensive materials (in other words, not just a big stick). I imagine that if you hit someone with your focus it will damage the item, possibly making it unsuitable to be a focus.
Inscribing a holy symbol on a shield costs 5gp, half the price of the original shield.
Not Weapons
The 12 different types of focus are listed in the Adventuring Gear section, not the Weapons section. The focus is called a "staff" or a "wooden staff", not a "quarterstaff". I think this clearly indicates that focuses are not supposed to be weapons.
Comment: +1 for the overall answer, although that last bit might not be correct: [Can the arcane/druidic focus staff double as quarterstaff?](https://rpg.stackexchange.com/q/46704/35259)
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/73757/discussion-on-answer-by-greenstone-walker-what-is-allowed-to-be-an-arcane-focus).
Comment: When comments have been moved to chat, subsequent comments not in that chat will be deleted without warning.
Answer: Nothing really says anything conclusive about that.
Jeremy Crawford answered this on twitter:

Jonh Rhyne: does an Eldritch Knight's bonded weapon count as an arcane focus?
Jeremy Crawford: It doesn't, but it wouldn't be unreasonable for a DM to allow it.

And Mike Mearls answered the following question this way:

criton volun: can a arcane focus be part of a 2 handed weapon or a single weapon , like a clerics holy focus can be part of a shield ?
Mike Mearls: I'd allow it

And about using the arcane focus (staff) as a weapon (quarterstaff), both consented as can be seen here and here.
As you can see, using an arcane focus as weapon isn't really the issue, the thing is that neither confirmed but seem to agree that it is something reasonable for a DM to agree.

Arcane Focus. An arcane focus is a special item - an orb, a crystal, a rod, a specially constructed staff, a wand like length of wood, or some similar item - designed to channel the power of arcane spells.

While not quite similar to most foci, the quarterstaff and the warhammer are both categorized as Versatile Melee Weapons. You can claim that similarity but in the end, is up to the DM to accept it.
Answer: If my top priority is playing D&D RAW, I would rule against allowing a character to use a weapon as an arcane focus, because that is an enumerated benefit of at least one subclass. The entry for the bardic college of swords in Xanathar's Guide to Everything includes "If you're proficient with a simple or martial melee weapon, you can use it as a spellcasting focus for your bard spells." That's a third level feature of the subclass. As a DM, I'd be hesitant to give player characters subclass features from a different class for free.
Now that I've said that, my top priority as a DM isn't always playing RAW. I don't think it would be a game breaking thing to give a character. I'd probably be willing to tack it onto the war caster feat or the Martial/magic adept feats. And if the rest of the table is cool with him getting a marginally better action economy than RAW, it may make sense to just let him do it.
Comment: I understand using a class or subclass feature as a benchmark for how powerful allowing arcane foci as weapons would be; however, these examples are benchmarked for allowing *any* weapon (or most conveniently, a shield) to be an arcane focus. A quarterstaff is a downgrade from any weapon or shield. By allowing a quarterstaff to serve as an arcane focus, you're demanding the player pay upfront by trading attack power. A difference of +1 or +2 damage on every attack is closer in line to a class/subclass feature, or at least is a much smaller leap in game balance for a DM to rule it as allowed.
Answer: Under specific circumstances, yes.
The Ruby of the War Mage, described in Xanathar's Guide to Everything, states:

Etched with eldritch runes, this 1-inch-diameter ruby allows you to use a simple or martial weapon as a spellcasting focus for your spells. For this property to work, you must attach the ruby to the weapon by pressing the ruby against it for at least 10 minutes. Thereafter, the ruby can't be removed unless you detach it as an action or the weapon is destroyed. Not even an Antimagic Field causes it to fall off. The ruby does fall off the weapon if your attunement to the ruby ends.

A Ruby of the War Mage attached to a warhammer would allow you to use it as a spellcasting focus.
Comment: This magic item is already mentioned in the top-voted answer.

What is allowed to be an Arcane focus?


Wiping a Macbook 2.1 clean

Question: So I am trying to wipe an old Macbook clean before giving it away to charity or recycling but I am having some issues.
For my PCs I have used DBAN successfully and I was hoping to use it here as well.
But Macbook refuses to boot from my DBAN Usb drive! When i restart and hold the "alt" button I get into the "boot menu" but I can only choose from my standard HD. Any suggestions?
Answer: The old MacBook 2,1 (White 2008) could only boot from the CD/DVD drive.  Since you didn't mention that you could see the recovery partition (where you can access Disk Utility), we have to assume it's not there.
If you want to properly wipe it to ensure that all private data has been removed, do the following:

Remove the HDD from the MacBook and connect to another computer via USB to SATA adapter
Wipe with DBAN or do a Secure Erase with Disk Utility
Reinstall OS X

You could try to "hack" together a solution to get your USB to boot with rEFInd, but the work to put in to get a USB drive bootable is (IMO) a large expenditure of time just to wipe a drive.
Comment: The HDD is super easy to remove (I just wiped two of these machines in this fashion) and it took me <5 minutes for the pair.
Answer: Firstly you need to have your USB drive formatted to HFS+ or else the Mac won't be able to see it.
You can use this MacOS disk creator to create a USB drive to boot from or depending how old the Mac is if by 2,1 you mean the white plastic unibody MacBook then you can use Internet recovery on the by holding down CMD-R during startup.
Make sure you're connected to the internet whilst doing so.
Your Mac should boot to recovery mode where you can go ahead and wipe and re-install with a clean version.
Answer: Use Lion Recovery Assistant or one of the many online guides to create USB macOS media. Then boot off of that media and wipe the system from there.

Wiping a Macbook 2.1 clean


Cocos2d: Positioning Sprites in complex layout patterns

Question: I'm wondering if anyone has suggestions for how to manage the positioning of many sprites in pre-set and complicated patterns?  Currently the brute-force method is to painstakingly code each sprite into its place.  However, ideally, I would like to not have to code it directly, but instead read the sprite positions in from a file (or some other data source).  Are there any solutions out there that do this?
Comment: [This question](http://gamedev.stackexchange.com/questions/19735/how-to-effectively-create-bullet-patterns) may be relevant.
Comment: ya, I guess the answer is no, then.  I was looking for something like the wonderful Tiled or Particle Designer.  Probably an opportunity in the market place to build a tool that does this.  Wouldn't be hard.
Comment: @GregoryJohnson Questions about which technology to use are considered off-topic here. That being said: maybe you should check out [SpriteBuilder](http://www.spritebuilder.com) (formerly CocosBuilder).
Answer: You're on iOS using Objective-C, I assume, so use PLIST files.
XCode has an excellent PLIST editor. NSDictionary lets you load a PLIST file with a single method call:
NSDictionary * plistDict = [NSDictionary dictionaryWithContentsOfFile:@"test.plist"];

From that, it is very easy to automate. Just load the dictionary and set the sprite position:
double x = [[plistDict objectForKey:@"sprite_pos_x"] doubleValue];
double y = [[plistDict objectForKey:@"sprite_pos_y"] doubleValue];

sprite.position = ccp(x,y);

If you change the sprite position in the PLIST, there is no need to recompile. With a bit of work, you can even add runtime reloading of modified files.
Comment: yes, this is the method I would go with... or actually, JSON would be better, since I would want to have the type of sprite loaded dynamically as well.  As I said above, it's probably really easy to put a GUI around this idea.  Countless side-scrolling games have this concept.  I was looking for a GUI based tool to help put the patterns together... point and click.  Apparently someone out there thinks this is a dumb question tho.  haha... dunno, seems like a good idea to me!


grub_file_filters not found after Ubuntu 19.10 upgrade

Question: I upgraded Ubuntu from 19.04 to 19.10. The upgrade went without errors but after restart grub throws an error on startup and goes into rescu mode
error: symbol 'grub_file_filters' not found.
Entering rescue mode...
grub rescue>

It's a physical machine not a virtualbox, and I have windows and linux in dual boot.
I managed to find what partition is my linux on with ls, but don't really know what to do next.
insmod normal fails with the same error
Comment: See: [How to make grub menu appear instead grub minimal bash-like in booting?](https://askubuntu.com/questions/1104855/how-to-make-grub-menu-appear-instead-grub-minimal-bash-like-in-booting/1105737#1105737)
Comment: can you try to boot your system this way https://unix.stackexchange.com/questions/148041/recovering-from-grub-rescue-crash
Comment: I tried it. Once I get to insmod command the same error pops up.
Comment: Have you an ubuntu live-session? And if so, are you familiar with to biuld a chroot?
Comment: Sadly the answer is no to both your questions
Comment: OP already has a solution but got a similar issue with a release upgrade 18.04-->20.04 on a 2 SSDs W10-Ubuntu dual boot: in addition to `grub-install`/`update-grub` to repair Ubuntu boot (cf. other answers; also starting from grub rescue), I had to convert MBR to GPT https://www.windowscentral.com/how-convert-mbr-disk-gpt-move-bios-uefi-windows-10 (BIOS to UEFI) on my W10 SSD so that another `update-grub` could re-add W10 to the grub boot menu
Answer: In my case, I had an Xubuntu 18.04 VM and after upgrading to 20.04, got the grub error. So I followed what's described here, which is for Kali, but should work for any Linux / grub installation:

Using an Ubuntu / Xubuntu ISO Live enter live mode (I used Ubuntu 20.04 since I had it already downloaded in my computer).

Once inside, I opened a terminal and ran:

# So we can run the next commands as `root`:
sudo su

# To figure which partition had my Xubuntu installation (partition type `Linux`)
# in my case it was `/dev/sda1`, we can use:
fdisk -l
# If you used a logical volume, your volume should be named `/dev/mapper/ubuntu--vg-root` and not `/dev/sdxx`

# Let's mount a few things:
mount /dev/sda1 /mnt
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

chroot /mnt

# Now let's try to fix Grub:
grub-install /dev/sda

If things went well, you should see a message saying something like:
Installation finished. No error reported

Now we can cleanup and reboot:

# To change back chroot:
exit

# And now we can umount all:
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys
umount /mnt

# Now we can reboot:
reboot

Comment: I ran into this same problem when upgrading from Ubuntu 18.04 LTS to 20.04.  Following the instructions in this answer worked perfectly for me using an Ubuntu 20.04 live flash drive.
Comment: I also upgraded my ThinkPad W520 from 18.04 to 20.04 and fallen into the same problem. following the above (I had ubuntu 18.04 ISO) and it worked. Thank you and to the video
Comment: Nearly gave me a heart attack trying to upgrade Ubuntu 18.04 to 20.04 today, but all it took was a quick grub reinstall and it was up and running.
Comment: I have an efi boot partition, do I need an extra mount in this procedure?
Comment: If you get error about `blocklists` try using `--force` option
Answer: Got the same issue, fixed by booting a 19.10 "rescue" USB key then, in terminal: (where sda is your disk and sda1 is your partition on the disk.)
$ sudo mount /dev/sda1 /mnt
$ sudo grub-install --root-directory=/mnt /dev/sda

Note - if you have more than one physical disk, your BIOS may be looking on a different one.  You may need to do this for each physical disk.
Comment: This one should be the answer. Grub just needs to be re-installed. If you get this error on a default Ubuntu upgrade from 18.04 to 20.04, boot off a live ubuntu USB stick, drop to a shell and type those commands. Fixed it for me in 3 mins.
Comment: If I do `info grub-install` I see no such option of root-directory, but there is a boot-directory option. Are you sure this info is correct?
Comment: I second that this fixed me up during an upgrade from Ubuntu 18 to 20.
Comment: Worked for me after upgrade from Ubuntu 16 to 20. Saved my afternoon. Thanks!
Comment: mine only says "/mnt doesn't look like an EFI partition."
Answer: I couldn't get boot-repair (or boot-repair-disk) working, but managed to fix this by booting from a live Ubuntu 19.10 USB, mounting the old disk, entering chroot, and running grub-install and update-grub.
There is a launchpad bug here, which recommends the chroot fix as described here.
Answer: I had exactly the same problem about a week ago. I solved it by downloading the boot-repair-disk from sourceforge. You will need to manufacture a bootable USB key or CD if you have a suitable CD drive. There are plenty of guides online about how to do this. I hope you have access to a system where you can do it. You can do it on Windows.
It may be possible to fix it from the grub rescue prompt and then the grub prompt. I tried this first but didn't have success following a guide I found online.
Good luck
Comment: I only was able to fix this with a live usb stick an boot-reapair.  as in WinEunuuchs2Unix's comment. Nothing I did in grub rescue worked
Comment: thx. Did the same and it worked. I wrote the iso to a usb with a ubuntu session from a ubuntublive cd
Answer: I too encountered the exact same problem after updating to Ubuntu 19.10. Here is how I (just now) resolved it:
First, you have two problems, not one. Both your installation is screwed up and the Grub Bootloader is messed up. And running only one fix won't fix everything. You need both the "boot-repair-disk" and the latest version of Ubuntu (both on USB boot drives. Don't use a DVD.)
If you try to do (only) a "Repair Install" from the Ubuntu Live disk first, you'll still be greeted by the "grub rescue>" prompt when done. :( So, first you must use the "boot-repair-disk". Tell it to repair your broken boot partition with Ubuntu on it. If you aren't sure of the partition ID, launch "GParted" from the "Start" menu (bottom left.)
Repair that boot partition. This should at least bring Grub back. Try to launch Ubuntu. If it works, you're done. If not, boot the Live "CD" from USB.
Double-click the "Install Ubuntu 19.10" icon on the desktop (don't worry, there will be an option to repair w/o losing your old programs/files.)
I recommend checking the boxes to download all updates during install, including 3rd party.
The Installer should detect your broken partition and give you the option to repair it (the first option.) It may need to disable some 3rd party repositories. Not a big deal, they're easy enough to get back later.
(Note: If you had to login with a password before, don't try to select "login w/o password" now. It won't let you in when you're done.)
Once done, you should have Ubuntu 19.10 installed with all/most of your existing apps still installed (though the toolbar shortcuts will be reset.) I had to reinstall a few 3rd party apps, but their configurations were still there afterwards, so nothing was lost.
Answer: I had a similar issue on a dual boot with windows. Ran a boot-repair and followed all the steps and everything became normal.
Comment: duplicate of the accepted answer
Answer: Worked for me on a fresh install of Ubuntu 20.04 where GRUB apparently did not install correctly.
$ sudo mount /dev/sda1 /mnt
$ sudo grub-install --root-directory=/mnt /dev/sda

as described above in previous post (use the values for your installation in place of /dev/sda1 and /dev/sda)
Comment: I also needed to get a working grub installation before doing this:

```
apt install grub2-common
apt-get install grub-pc-bin
```

This was using a ubuntu live server image from a virtual machine.
Answer: For readers who face this issue while upgrading a cloud-based virtual system, you can mitigate it by re-installing grub and update-grub right after the system upgrade before rebooting. Perhaps even just updating grub before rebooting into the upgraded system could have mitigated it, but I didn't want to risk, and I don't have the time to test that now.
I learnt this the hard way, but I luckily (should I say naturally?) I had a snapshot of the system from right before the attempted system upgrade, so I after reading on the possible causes I restored the snapshot, re-performed the system upgrade, then re-installed grub.
Alas, until this is documented in the cloud providers' documentation somehow or until a workaround is devised that prevents this from happening, there will be no way to guarantee that users who face this are prepared.
I also reported this in a related issue at Launchpad.
Answer: I am copying my solution to here seems that this one is more visible thread.
What DID NOT WORK

I had the same issue and above solution by @rapid3642 DID NOT WORK. The CHROOT case was not the right case for me because I could use F12 and able to log in to linux without issue. I also tried running the above commands as chroot on ubuntu system / partition directly ( without the mounting part as I had ubuntu installed and working )
Rescatux also did not work although it seems to be the utility which was supposed to be a clean gui.

I used a comment from Kristina Kovacek to get the idea of what we need to do.
What did work for me is the boot-repair-disk utility. Funnily enough it did not work in the default mode ( the Recommended Repair section ) but I had to change following
Advanced Options -> Grub location

Change OS to boot by default to the Linux ( yes you can log into windows but you need to keep linux as Master )
Untick Spearate /boot /boot/efi partition
Place grub into <your linux partition such /dev/sda>

I also removed one other option making sure that by default the GRUB looks into windows I dont remember what it was ( even though I executed the procedure just few moments ago
NOTE that there are instructions that you need to follow and commands that you need to execute manually which also involves purging the grub-install from the linux partition ( which in retrospect might have sufficed. )
I believe things can be done by other methods and specially by  @mugsy answer seems to be pretty much the same. However my answer doesnt use Gparted and any advanced stuff.
Answer: I had these same issues and could not get it resolved. I tired using Grub-Rescue but did not find success.
I booted off a Ubuntu live media (DVD or USB) and installing the boot-repair-tool resolved it for me
How to install the Boot-Repair tool in an Ubuntu live disc?
Answer: I had the same problem upgrading from ubuntu 18.04 to ubuntu 20.04 and solve the problem using boot_repair-disk
https://sourceforge.net/projects/boot-repair-cd/


What is the difference between Saddle points and Lagrangian points between Earth and the Sun?

Question: I am studying MOND bubble effects in the Solar System (Paper). In "mond habitats.." (last reference) first page, the author says MOND bubbles reside on the saddle points but I fail to understand the differences from Lagrangian points. Can anyone explain this to me?
Comment: I believe those saddle points are Lagrangian points. I think the author calls them saddle points because not all Lagrangian points are saddle points (namely L4 and L5).
Comment: He makes a direct reference to L1 not being a saddle point, though..
Comment: when using classical Newtonian physics, then those Lagrangian points are saddle points, however with MOND for example the L1 point turns into one stable point surrounded by two unstable points, see the figure on page 6.
Comment: We (NASA) have actual tests of the L1 and L2 points (from the Earth-Sun system) due to spacecraft orbits around these potential minima.  We know from experience that they are not stable orbits, they are saddle points because we need to perform station keeping maneuvers every few months or so.  So I am confused as to why one would use MOND if it gives the wrong answer.  Is there an advantage to this theory for some purpose?
Comment: Oh, one should also be careful of micron-sized dust and _nanodust_.  These particles are moving at tens of km/s and can produce accumulated damage to spacecraft.  A recent astronomy mission ran into issues with their ability to focus their images because they underestimated the amount of nanodust.  Apparently, the dust levels were high enough to produce enough vibrations to blur their images.
Answer: In case you still want to know, here is my two cents. In MOND (the paper you referenced uses TeVeS the relativistic cousin of MOND) the potential is modified due to the introduction of an acceleration parameter a0. At accelerations below this value MONDian behaviour takes over. This means that the saddle point of the potential between two bodies is shifted away from the purely Newtonian L1. See for example figure 7 in this report:
https://engineering.purdue.edu/people/andrew.d.cox.2/pubs/2016_AAS_CoxHow.pdf


Is the movement of electrons truly random?

Question: The result of rolling dice is considered pseudo-random because it depends on an almost endless list of factors (how you roll it, the terrain it lands on, etc.), but it is not TRULY random. Is the movement of electrons TRULY random or just pseudo-random? If it is just pseudo-random, what factors would typically effect it (gravity, temperature, etc.)?
Comment: what electrons? there are zillions of them in various boundary conditions.
Comment: Possible duplicates: https://physics.stackexchange.com/q/317/2451, https://physics.stackexchange.com/q/30065/2451 and links therein.
Answer: In it's current state, it's difficult (maybe impossible is a better word) to answer your question precisely because, among many other things, your definitions of the terms "random" and "pseudo-random" are not precise.  It's also difficult to answer your question because electrons don't "move" in the sense that objects are modeled to move along trajectories in classical mechanics.
Here are some facts that may allow you to answer your own question since you probably understand what you mean by random better than your descriptions let on:
Consider the electron in the hydrogen atom.  If one specifies the quantum state of the electron, then this will tell you certain probabilities that if a measurement is made on the electron, then one will measure specified values of observable parameters like it's position, or its velocity.  The fact that outcomes of such measurements are probabilistic is not a result of an ability of humans to construct precise measurement procedures and apparatuses, it's an intrinsic property of nature.  You might even be inclined to use the term "random" to describe the outcomes of such measurements, but I think that would be misleading to most people.  "Probabilistic" would probably be a better term.
Most importantly, let me emphasize that you can't escape the probabilistic nature of the measurements of physical quantities in quantum mechanics; it's simply a fact of nature that the state of a quantum system can only give these probabilities.  We're not just "missing information" about the state of such systems that's somehow "hidden" and would specify the state of the system more sharply.
Comment: In other words, it is impossible to quantify the number of "randomizing factors" in trying to measure the position or velocity of an electron because we don't know any of them, and as far as we know this randomness is just a fundamental characteristic of the universe.
Answer: The result of rolling dice is not pseudo-random because the dice is interacting with surrounds, and this is a LPS with Poincaré resonances. As a consequence of the existence of Poincaré resonances, the classical system is unpredictable even if the initial state is known with complete precision.
The same about electrons, except that their unpredictability is more important due to their small size when compared with surrounds, baths, measurement apparatus... of course, electrons are quantum particles and follow quantum laws:
"Quantum Theory of Non-integrable Systems" T. Petrosky, I. Prigogine and S. Tasaki Physica A 173, 175-242
"Extension of scattering theory for finite times: three-body scattering" T. Petrosky, G. Ordonez and T. Miyasaka Phys. Rev. A 53, 4075-4103


Confusion about a gene's description

Question: I have a very basic biology question. I am reading the description of gene FAM166A here, and I have no idea what "sequence similarity 166" means. What does 166 stand for, what is this gene's sequence "similar to"? And what does member A mean?
Comment: Family membership is probably referring to something similar to this: https://www.ebi.ac.uk/training/online/course/introduction-protein-classification-ebi/protein-classification/what-are-protein-families. I'm not sure how the sequence similarity is scored, though.
Comment: Oh okay, then this gene named FAM166A is member A of the protein family with *ID 166* where each family is determined based on sequence similarity. Thanks!
Answer: The FAM symbols are defined in the HUGO Gene Nomenclature Committee guidelines.
The FAM symbol is an anonymous and temporary identifier that is given to groups of poorly characterised genes which share more than 40% amino acid sequence identity (see Section 4.1).
There are two human genes/proteins in the sequence similarity 166 group; FAM166A and FAM166B. These have some sequence similarity (more than 40%) but  function of this similar sequence is currently unknown. Once further characterisation has been performed for any FAM group they will likely receive more meaningful names.

Confusion about a gene's description


How to process a delayed/lost baggage case? Because I lost my luggage

Question:  I left Nigeria on 30 July 2017 from Abuja airport I have stop over at Cairo from Cairo to Riyadh airport I don't find my luggage since then
Comment: Did you report the missing item at the baggage claim where you should have collected it?
Answer: As soon as you notice your baggage has not arrived, meaning you wait for everyone else to get their luggage and nothing more comes out from the carousel, proceed to the Baggage Services counter.
Nearly all airports of size have one but it is sometimes closed when you arrive very early or late. In that case, find the service desk for the airline you travelled with and file a claim there. If for some reason it is closed too, you should go to an customer service counter for your airline. This can be at the same airport you arrived at but also an office in the city.
File a claim with them. Make sure you give them as much information as possible, such as your flight info and the square sticker with the suitcase tracking code (I don't remember the specific name). They will follow up with you at a later time. If your suitcase does not arrive at all or they cannot find it then it will be considered lost and you will be able to file a claim for some compensation (on most airlines) or with your insurance.  Usually there is a limited time when you can ask for compensation which is why you must file the claim as soon as possible.


Disabling pinch zoom in Flutter team's webview

Question: Hi does flutter team's webview plugin have a function to disable pinch zoom in iOS? In the community plugin, its withZoom but I don't know how to do it in Flutter team's webview. Or is there a equivalent function to do it in the team's plugin ?
I have reasons why I want to use the official webview plugin.
Kindly help. Thanks.
Answer: I inject javascript code to replace the meta tag with name = "viewport" to disable the maximum zoom.
controller.evaluateJavascript("var meta = document.getElementsByTagName('meta');"
    "for (var i = 0; i < meta.length; i++) {"
      "if (meta[I].attribute('name') == null) continue;"
      "if (meta[i].attribute('name').includes('viewport')) {"
        "document.getElementsByTagName('meta')[i].remove();"
        "break;"
        "}"
    "}"
    "document.getElementsByTagName('head')[0].innerHTML += "
    "\"<meta name='viewport' content='initial-scale=1.0, maximum-scale=1.0'>\";"
);

Of course, you need to enable Javascript in your WebView.


Why contrast in ANOVA has one degree of freedom?

Question: I thought I understood the degree of freedom after reading Wikipedia explanation, but came across the sum of squares for contrasts $\{c_i\}$ $$SS_C = \frac{(\sum_i {c_i \bar{y_i}})^2}{\sum_i c_i^2 /n_i}$$
which the textbook said it has one degree of freedom. Why is this so? I don't think the Wikipedia explanation works here, but I don't know why.
Comment: If you have three levels of a factor, then DF for the factor is 3-1 = 2. There can be two orthogonal contrasts on factor levels, each with one DF. For example $c(-1,0,1) \perp c(-1, 2, -1).$ Orthogonal because $\sum_{j} c_{1j}c_{2j} = 0.$
Answer: While using contrasts we make the following comparisons:

Effects of two different treatment groups.
Effect of one treatment group with the effect of a set of treatment groups.
Effect of a set of treatment groups with the effect of another set of treatment groups

In each case, we tend to bundle the treatment effects into two groups, g=2, hence the degrees of freedom in case of contrasts is always, g-1 = 2-1 = 1.
For example, comparison of diet A vs diet B, comparison of diet A vs combined effect of diet B and diet C, etc.
In simpler words, if you have two groups, you only have the freedom to select one of them, the other one comes by default.
You could also refer to this video at 11:50 - https://www.youtube.com/watch?v=c9krZdM635Y&t=1052s
Comment: I think the focus of the question is captured by the comment by BruceET (2021 01 08).  If we have a one-way anova with three groups for the independent variable, the *df* for this independent variable is 2.  But we can construct single-degree-of-freedom contrasts, for example looking for a linear trend across these groups, (-1, 0, 1).


Photoshop image manipulation to round stand alone image

Question: In Photoshop I just learned to use the create clipping mask feature to create a round image for example.  The image needs to be able to be uploaded into an email design tool that I have to use (it is for work).  The trouble is when I saved it and uploaded it, the square canvas that it was on while I was creating it turned white and remained as a background.  It needs to be a freestanding round image.  What am I doing wrong?
Comment: @Cai please leave answers as answers
Answer: Images are inherently rectilinear. To be able to save a circle, the area around the circle needs to be transparent. There are a few file formats that support transparency that I will list below. Which format you choose will depend on the complexity of your image and the amount of compression you find acceptable
png or png24
Png is a lossless image format that supports transparency. Lossless meaning that you will not loose any detail in your image from compression. Png tends to lead to larger file sizes as it does not compress the image very much. If you are using a large image you might want to try a different format, especially if you are using this in an email and the load time for the image might suffer
png-8
Png 8 is another image format that supports transparency. It is named png-8 as it only supports 8 bits of color information which means that an image in this format can only have 256 colors. This format is good for simpler images and line drawings or images with a lot of solid color. If you have an image with more than 256 colors, Photoshop will automatically convert it into 256 colors. note not all browsers and email clients support png-8
gif
Gif is very similar to png-8. Pretty much does the same thing. I find that png-8 does a little bit better job of preserving details so I usually only use gif if I need something animated or am using an image where png-8 isn't supported


What is the UART TX interrupt for?

Question: I know that the RX interrupt is obviously used to save polling, but why the TX one too?
Comment: Same reason. You're often sending a long message a character at a time.
Comment: If you are asking about a UART TX interrupt on a particular type of device, then please post a link to its datasheet.
Comment: Code that needs to do very little else can block on the actual transmission.  More efficient code can drain a software buffer in the interrupt.  Yet more sophisticated code on hardware that supports it can set up a DMA engine to pump the transfer without distracting the CPU from more important work, though as serial baud rates are often fairly slow in MCU terms that may not always be important.
Comment: The interrupt that others have mentioned signals that there is buffer space available in the uart for more transmit data. The buffer may be one or more bytes in length depending on the uart hardware. There is often a different "transfer complete" interrupt that signals that all bits have been shifted out of the uart. This may be used used for other purposes such as switching a transceiver from transmit to receive.
Answer: The main goal of the TX interrupt (really an END OF TX) is to send the content of a buffer (multiple bytes) automatically. When implemented in a proper way:

Enable the TX interrupt.
The user code starts transmission by sending only the first byte in the buffer.
At the end of TX (of the first byte), an interrupt will be generated.
In the TX ISR (Interrupt Service Routine), the code must send the next byte in the buffer and update the buffer index.
At the end of this transmission, a new interrupt occurs, and so on, until the entire content of buffer is sent "automatically".
Disable the TX interrupt.

The exact behavior depends on the microcontroller. That is a general description.
Comment: An easy simplification on many platforms is to have the user code merely be responsible for putting data in the buffer and enabling the interrupt; the ISR disables the interrupt if it fires when the buffer is dry.
Comment: This answer is quite misleading - UART tx interrupts usually indicate the *holding* register is empty (or FIFO low), independently of whether there's still data being shifted out of the *shift* register. (Hence the common driver approach that enables the tx interrupt *without* having written any tx data, which will immediately generate an interrupt - such that all tx data is written by the ISR, with no special handling for the first character.)  'End of tx' is a distinct condition discussed in other answers here.
Answer: The TX interrupt is mainly for longer datagrams. You can initiate the transfer for a buffer of known length (bytecount). Now you can push your buffer pointer as often as there are bytes to send, when the TX interrupt occurs. This ensures the "as quick as possible" transfer of your buffer, without  the need to poll any "TransferComplete"-Flag/Statusbit.
Answer: Some UARTS have an internal buffer that is larger than one, the 16xxx series for one.
The procedure here was

Set a transmit window mask, for example to 4 remaining.
fill buffer positions until the UART said full or no more data need to be send
do other stuff
when only 4 buffer positions are left unsend, set TX interrupt
wait for the interrupt to be serviced
if more data needs to be send go to 2.

This decreases the CPU load by offloading some processing to the UART thus enabling slower CPU's to keep up and service other task instead of getting interrupted all the time.
Answer: The TX interrupt fires when there is space in the transmit buffer.
For devices that don't have a transmit buffer (i.e. where you write one byte, which is transferred immediately), the interrupt is asserted when the transmit register can be written with the next byte.
For devices with a buffer, the interrupt is asserted at an implementation-defined time. For some, it is when the buffer is half empty, for some it is when transmission of the last byte has started and the buffer is completely empty.
Answer: Another use case is when you connect the UART to another communication interface like RS485. The controller has to release the bus driver as soon as the last bit has been shifted out of the TX buffer. This is easy to handle in the TX interrupt, but would be cumbersome to implement without, since you would have to wait an exact time after writing the last byte to the output buffer which would also vary with baud rate.
Comment: The RS485 usage works best if there's a transmit-complete interrupt available rather than just transmit-buffer-available.  Especially on devices with big buffers, the only way to get an interrupt after the last useful byte is sent is to feed the UART unwanted additional bytes and hope one can disable the transmission before they go out.
Comment: @supercat: You are indeed right to point out that this would require a Tx **complete** interrupt. But i think this still relates to the question.
Comment: It's often possible to get by with just a buffer-available interrupt, but the tx complete interrupt is often better; I had been thinking that it might be helpful to amplify why some UARTs have separate interrupts for buffer-ready and transmit complete.
Comment: I'm mystified why so many UART designs lack a 'tx complete' interrupt.  They almost always have a status bit representing this (or equivalent) condition, but including it in interrupt generation seems to be the exception rather than the norm. Especially unforgivable in microcontroller peripherals.

What is the UART TX interrupt for?


artifacts on all my objects

Question: All my objects in all Layers have these kinds of artifacts, anyone know why that may be?, when i hit "P" to play blender game they dissapear, but its super enoying to work with when you are texturing and so on
Comment: Probably something to do with that massive end clip value, but could also be some AO setting. Could you upload the blend?
Comment: omg thanks did not think about that end clip value! I changed it down to 1000 and now it looks normal, thanks for spotting that, feel so stupid now xD
Answer: Your End Clip value (in the middle right of your screenshot) is extremely high.
Computers have trouble calculating wide ranges of floating point (decimal) numbers with extreme precision and often end up with slightly inaccurate results. If you narrow down the range it has to calculate (by decreasing the End Clip), those artifacts will disappear.

artifacts on all my objects


SLAM: Why use two cameras (stereo) if SLAM can be done using single camera (monocular)?

Question: I am aware that algorithm for monocular SLAM is complex compared to stereo SLAM. But my question is if by any means it is possible to do SLAM using one camera why one should use two cameras to do the same thing?
Answer: The most important point is the scale. If you do monocular SLAM, your map will only be accurate up to scale so that you e.g. cannot compute the length of the travelled path in meters. The scale between your map and the world is not even constant over time so that if you come back to your starting point, it's going to be difficult to match the beginning and end of you map as they have a different scale.
Comment: This can only help in fixing the scale, but never to get the correct metric scale.
Comment: If you're constrained to only one camera, it would probably make sense to use multiple frames to initialize the scale, as PTAM does: or another (fancier) way is what's called image alignment to obtain transformations: as in LSD-SLAM.
Comment: Thanks for your answer @FooBar.
But I believe that this limitation can by solved by using loop closure. Dont you think so ?
Comment: No. You can move your camera slowly over a toy city or attach it to a drone. Just by looking at the images, you are not able (no one is able!) to detect the difference. You can only add other sensors (e.g. pressure sensor from the drone) that give you the absolute scale.
Comment: How can I get the absolute scale for UGVs?
Comment: Why don't you read my comment?