Extracting intensity from an image

Question: Suppose I have an image
sampleOriginal = Import["...mySample.png"]

I then convert it to Grayscale colorspace
sample = ColorConvert[sampleOriginal, "Grayscale"]

Now
sampleDate := ImageData[sample]

gives me a matrix of image data points.
And my question is how can I create a function I[x,y] that will return the intensity of the gray-scale image at the point {x, y}.
Is there a suitable way to create this function which will later allow me to use ND and calculate the derivatives up to the second order at a given point ?
Comment: You should not need a special function for the first part of your question, since `ImageData[sample][[x,y]]` should give you the value you are looking for.  Take a look at `Interpolation` for the 2nd part of your question.
Comment: (I am very sorry if there already is an answer to this which I did not find, or maybe I found it but did not realize that it was the answer)
Answer: Using ND is not necessary, as Mathematica makes it easy to construct InterpolatingFunction objects, which can then be formally differentiated using Derivative. First, a sample image:
data = Import[
  "http://41.media.tumblr.com/bece7ed81870c8e9b904290700451eb2/tumblr_\
mv8m2sE2FW1slvzano1_400.jpg"]

Convert to grayscale, and then convert the resulting matrix into an InterpolatingFunction object:
imData = ImageData[ColorConvert[data, "Grayscale"]];
f = ListInterpolation[imData];

Plot the InterpolatingFunction using DensityPlot:
DensityPlot[f[-x, y], {y, 1, 400}, {x, -1, -398}, PlotPoints -> 300,
 ColorFunction -> GrayLevel]

Plot the first partial derivative in the $x$-direction:
g = Derivative[1, 0][f];
DensityPlot[g[-x, y], {y, 1, 400}, {x, -1, -398}, PlotPoints -> 300,
 PlotRange -> All, ColorFunction -> GrayLevel]

Plot the second partial derivative in the $x$-direction:
h = Derivative[2, 0][f];
DensityPlot[h[-x, y], {y, 1, 400}, {x, -1, -398}, PlotPoints -> 300,
 PlotRange -> All, ColorFunction -> GrayLevel]

Of course, you can get better results with even less work by using bill s's answer.
Comment: Thanks. This exactly what I was looking for. It answers the question.
Answer: You can get the values of the pixel intensities directly using the built-in functions PixelValue and/or ImageValue. For example, using DumpsterDoofus's image, the RGB pixel values at location {100,100} are easy to find, and their mean is (roughly) the intensity.
data = Import["http://41.media.tumblr.com/bece7ed81870c8e9b904290700451eb2/tumblr_mv8m2sE2FW1slvzano1_400.jpg"];
PixelValue[data, {100, 100}]
Mean[PixelValue[data, {100, 100}]]

Depending on what you want to do with the image, there may be no need to do the interpolation at all. There are many functions that deal directly with images, including GradientFilter (that does more or less what you ask for in a single command). If your goal in taking the derivatives is to detect edges, then there is Edgedetect. GradientOreintationFilter is another option.
GradientFilter[data, {2, 0.1}]

You can take the second derivative
GradientFilter[GradientFilter[data, {1, 0.1}], {1, 0.1}]

and there are numerous options to control the process.
Comment: Yeah, taking advantage of the built-in image processing tools will definitely give better results than my example of manually doing everything (I mainly wanted to show the OP how list interpolation works).

Extracting intensity from an image


"touching up" a hardwood floor

Question: We have hardwood floors and I'm unsure how they were finished. I tested by rubbing acetone on them and nothing came up. According to internet sources that may be an oil based polyurethane. But the floors are old and in spots the finish has run bare leaving exposed wood. There is no advertised product to refresh this kind of flooring polish. The water based urethane actually look nice but seem to wash up on this next mop session. Do I simply brush a thin coat of oil based over the bare spots or apply a coat to the whole floor, or entirely sand and refinish?
Comment: Usually trying to do small/medium areas will result in the whole floor looking patchy.  Doing the whole sanding/refinishing of the whole floor/room tends to look the best.
Comment: It depends upon how much you want the floor to look like..."perfect or good enough".   Sanding down the entire floor is a lot of messy work.  If it were me, I'd move the furniture/appliances out, lightly sand the entire floor to give the new finish some "teeth" to adhere to, maybe coat the bare areas first, then go over the entire floor.  Probably an oil based polyurethane would be best if a patch job.     It all depends upon how "perfect" you want the final result to be. If you take the effort to sand it down to bare wood, you have a myriad number of choices.
Answer: "I'm unsure how they were finished." If you're unsure then we can't be sure either. You can experiment by applying oil based over the bare spots but not over the whole floor. The results will more than likely be unsatisfactory but if it works for you, great. Your best bet is to sand the floor in it's entirety down to bare wood and then refinish to your liking. Depending on your living conditions, this can be done all at once or room by room. I've seen it done both ways.

"touching up" a hardwood floor


Which English phonemes can be distinguished via lip-reading?

Question: Is there a comprehensive list about which phonemes in the English language can be distinguished via lip-reading and which can't?
Comment: I am no expert on lip reading, but if there is such a resource, it's not just going to be a flat list. [m] and [b] can both be distinguished from [a] but not from each other. And it's going to be speaker-dependent, since the same phone may be articulated by different speakers in different ways. Even for a specific speaker, "readability" is surely dependent on many linguistic factors, such as speech rate, degree of enunciation, etc., and many non-linguistic factors, such as how close a view of the mouth the lip reader has, what kind of lighting there is, etc.
Comment: Oh, and if the resource knows what it's talking about, it's going to list phones, not phonemes. I know someone who pronounces /l/ as [l] in certain environments but as [ɫ] in others, and I reckon the former is easier to distinguish from other phones than the latter, since the front of her tongue is active in the articulation of the former but completely uninvolved in the articulation of the latter.
Comment: The phones that you can see, which are generally the labial ones and the rounded ones. Interdental fricatives might qualify, too. Open versus close vowel height can probly be determined from jaw placement, but it's unlikely front, central or mid vowels can be distinguished visually. And syllables will be hard to distinguish and may easily be missed, especially if reduced. Not to mention that different people talk differently, and look different while talking.
Answer: Have a look into visemes. These are like phonemes, but relate to what the face is doing (esp. the mouth) for each phoneme. More than one phoneme can map to a viseme (e.g. voiced and voiceless consonants have the same viseme as the distinction is due to the vibration of the vocal chords, not the shape of the mouth).
As far as I can tell, although there was earlier research into confusion of similar phonemes, the visemes were first created by early Disney animators. They defined 12/13 facial shapes for the 45 or so English phonemes. They are also used in text-to-speech applications.
Other classifications can have a different number of visemes,, for example the Microsoft Speech Application Programming Interface (SAPI) defines 21 visemes.
There does not appear to be any clear consensus on the phoneme to viseme classification. I'm not sure what it is like in the lip reading field (a Gamasutra article mentioned there were 18 lip reading visemes, but I was not able to find a reference to this in my brief search, although visemes were mentioned in connection to lip reading in other results).
There is the problem of context, where the shape of the mouth is influenced by the previous and next phoneme.
In addition to this, the simplified viseme model does not account for the shape of the cheeks and jaws, nor the position of the tongue, which can all be visual clues.
The ability to lip read will take the movement of the facial features into account and make inferences based on context (e.g. a t/d shape after [shi:] could be sheet or she'd). This is similar to how speech recognition software works, but that operates on the acoustic (audio) signal.


what is burning smell off a new power strip?

Question: Got a new power strip, I detect a very faint burning smell kind of distinct when I stick my nose near it, 2 cm away. The smell is there whether it's connected or not, but amplifies when its working. I don't think that smell was there before and I've been using it for 2 weeks. The brand is Brennenstuhl, from Germany 3m long cable. It's like 20$, I connect desktop pc on it.
Answer: Defective power strip.  Return it to the store and demand a replacement, before it causes a fire.
Comment: Has it caused damage already? Shouldn't a surge protector just allow current through, whats it doing to create a fire? Whats to say the problem is in my wall socket, and that this surge protector is more sensitive?
Comment: You should never smell smoke from a power strip. If you do, the power strip was overheating. That won't happen unless you are overloading it or it was defective -- and the circuit breaker or fuse in the power strip should have blown before an overload could hurt it. So there is an electrical problem inside the power strip, anu it should not be used in this condition. Return it if you can, discard it if you can't ... Or repair it, but if you could do that you wouldn't be asking this question.


How does a monkey head touch a cube

Question: How does a monkey head touch a cube
Answer: Add a Store Named Attribute in a simulation zone. I called it status. Store  a boolean with the value $1$ on it.
The selection, to which this attribute is applied, is driven by a mesh boolean between the cube and the monkey head.
We can determine, if the meshes intersect, by examining the point count of the resulting mesh. If it is larger than 0 they intersect. Thanks to auto-casting we can insert the point count of the boolean mesh directly into the selection input of the Store Named Attribute node.
Make sure to set the material and read the status attribute from the material nodes.

Left: Material Setup, Right: Geometry Node setup on the cube
You need to play the animation starting on the first frame or cache the simulation zone to properly see the attribute change.
Comment: Thank you very much

How does a monkey head touch a cube


How to find memory leaking apps in OSX 10.6.8?

Question: I have an old 2008 MacBook with 4GB of memory. (Memory from About this Mac, everymac.com gave me a different number.) I know it's old, but it almost seems like it's slower than it should be. I have a lot of software so I was wondering, how could I easily find memory leaking processes?
Answer: Activity Monitor.app indicates how much memory each process running on your Mac is using.
Comment: I know, but some are supposed to use that much memory. Some of them I need as well. Even after quitting them, it just gets worse again. I need to find specific apps that aren't handling memory well.
Answer: To find apps which are using the most memory, try the following command in Terminal:
ps -awxm -o %mem,rss,comm | sort -nr | head

Also top command may help to monitor suspicious processes in real time.
In general OS X kernel (similar to others) is designed to use up all the available memory. See: Isn't Inactive memory a waste of resources? for more details.
If you've limited amount of memory, consider quitting apps or closing browser tabs which you're not using. You can also find some Memory Clean apps which will try free up some memory when it's full.


Pass an index on event trigger in javascript

Question: I have a small custom plugin that I am building inside which I am triggering an event when I click on a certain item. When the item in clicked with left mouse, the following is triggered:
Holder.KeyboardPlugin.prototype.triggerExpansion = function() {
if(this.expandedItem){
    var changedGroupSource = null;
    Holder.events.trigger(this, 'groupselect', function(changedGroup){
    changedGroupSource = changedGroup;
    });
  }
};

Holder.events.trigger has the following code :
function (object, event, properties) {
        var index = this.indexOf(object);
        var listener = this.listeners[index];
        if (listener) {
            var callbacks = listener.events[event];
            if (callbacks) {
                for (var i = 0, iMax = callbacks.length; i < iMax; i++) {
                    callbacks[i](properties);
                }
            }
        }

The problem here is that the in my triggerExpansion() method above, functionally everything is fine right now. I am passing a class function to triggerProperties and through that callback function, I am modifying the plugin internal changedSource variable.
However, along with this, I also want to pass the index (a certain number) of the selected group to the listener in my html (that uses plugin). Since, I have already passed the callback function, I am not able to resolve on how I should be passing a certain index along with the callback function as well here. Any suggestions?
Answer: Maybe you can do something like:
Holder.events.trigger(this, 'groupselect', {
    index: theIndex,
    callback: function(changedGroup){...}
});

so in the event listener you will have event.index and event.callback.
Is that what you need?


Can I transfer enchantments from one item to another?

Question: I currently have a thaumium pickaxe with Efficiency IV, Unbreaking III, and Repair II. What I would like to transfer these enchantments to a thaumium sword (not crafted yet) and hopefully get the thaumium from the pickaxe back as well. Is this possible? If so, how? I am using the Feed The Beast Ultimate pack, if that makes any difference.
Answer: This may be possible using the Uncrafting Table added by the Twilight Forest mod, although I'm not sure if it works with regards to converting from one type of tool/weapon to a different type (i.e. pick to sword). The relevant excerpt from the wiki:

The Uncrafting Table also allows you to recraft items, which is often used to keep a rare enchantment on an item. The Uncrafting Table can also swap enchantments from one item to another. For example,an Ironwood Sword with Knockback 2 and Smite V can be recrafted into a diamond sword with more durability for the cost of 27 levels of experience. The experience levels are generated with the amount which the enchantment is roughly created at, meaning the rarest enchantments will cost the most experience levels.
Answer: As of version 1.5.1, MineFactory Reloaded has an Auto Dis-Enchanter, which unenchants anything put in it. according to the post on the Minecraft Forums:

This machine has two input and two output slots. Enchanted items and books are placed in the inputs. When it completes, it will remove one enchantment at random from the item and install it on the book. The item will then be damaged - if this would destroy the tool, it will be lost.
Answer: i don't think its possible to transfer an enchantment from one item to another but its very possible to combine enchantments Via an anvil,Combining duplicate items with different existing enchantments into a single item that has the enchantments of both.This costs experience points.in this process, you will be sacrificing one item in exchange for the other, and i think they have to be items of the same kind for example iron sword and iron pickaxe so this should certainly work for you.
Comment: You are unable to merge Swords with Pickaxes.
Comment: you don't actually combine them, you destroy one, take the enchantment and move it to another item with the same material
Comment: Please explain this process in your answer.


When distance between the plates is increased, what will happen to the value of the capacitance

Question: When distance between the plates is increased, what will happen to the value of the capacitance. (a) Increases (b) decreases
Comment: Before coming here what have you done to find your answer?
Comment: Do your own homework.
Answer: From Wikipedia:

In a parallel plate capacitor, capacitance is directly proportional to the surface area of the conductor plates and inversely proportional to the separation distance between the plates.

where
C is the capacitance;
A is the area of overlap of the two plates;
εr is the relative static permittivity (sometimes called the dielectric constant) of the material between the plates (for a vacuum, εr = 1);
ε0 is the electric constant (ε0 ≈ 8.854×10−12 F m–1); and
d is the separation between the plates.


How do academic minors work?

Question: How much in practice would someone minoring in a subject end up knowing about the subject as opposed to somebody majoring in it?  How much extra work does it take to get a minor?
Comment: Vote to close as "Need more focus"
Comment: You always have so many "?" in your question. I always try to use at most 2 in any question.
Comment: @Pikachu피카츄 Are you suggesting writing longer sentences or creating more threads?
Comment: @EarlGrey Useful as in any of the following: improves you chances of finding a job; makes it easier to perform your job; increases you salary; helps career growth.
Comment: I am not sure why you want to ask every question as a separate thread but if you insist here you go: I have moved the usefulness aspect of my question to a different question.
Comment: I am asking in general, not for a specific program
Comment: On one hand, I'm sorry to see the downvotes, these are straightforward questions that our site benefits from having.  On the other hand, I agree that you should really show more research effort. Even this site already has some posts about (for example) college minors; showing that you've read those and didn't understand something would probably help your questions be better received here.
Comment: I tend to structure a question this way (paragraph1) ... (paragraphn) summarizing my situation or what I know + ending with 1-2 questions. So it does not look like there are so many questions
Comment: Just split your blob of questions in separate questions. Then try to answer each one of these separate questions. Then come back to SE:Academia asking for answers. And then get the first and last of the questions presented here closed because they are based on personal opinions.
Comment: Please define useful: +5% in the starting salary? some additional technical knowledge? some insights in another topic?
Comment: I don't understand the question. Can you not find the answers in the program booklet? It should spell out exactly what is needed to get a minor, as well as exactly what is needed to get a major; comparing the two then answers the question.
Answer:
How much in practice would someone minoring in a subject end up knowing about the subject as opposed to somebody majoring in it?

Things vary of course. But a minor is maybe 5 classes whereas a major is 10+. So, about half as much. This can be useful if you only care about certain parts of a subject -- get a chemistry minor by taking physical chemistry + inorganic; you can skip organic and biochem.
It's also sometimes true that if you major in science and minor in certain humanities subjects (or vice versa), you can cover almost all of your gen eds this way. So some people can get a minor "for free" by choosing classes strategically.
As for how useful this is in practice: probably not much. It's a good way to document an interest; i.e., anyone can say "I'm interested in writing," but having a minor in writing shows that you mean it. And of course if your minor means you take more classes than you would have taken otherwise, then you'll know more stuff, and that is usually good at some level. But I suspect that few hiring or admissions decisions would have gone the other way but for the presence/absence of a minor.
Comment: My understanding is that a minor could be very useful to augment your major. Such as a programming or an economics minor to augment ... I was actually trying to figure out how it might work and I was thinking of chemistry as an example: if you wanted to take physical chemistry I assume you would need to have taken thermodynamics and differential equations. And for differential equations you would need calculus I and II, so unless you need  take those classes for your major would your minor turn into a giant undertaking? Or is that how it is supposed to work?
Comment: Also, is a "minor" any different from simply doing things you like in a particular field i.e. where does it actually say that you have a minor? AFAIK the diploma doesn't mention your minor nor does you transcript specifically spell out that you minored in something?
Comment: The transcript may say it. You can also put it on your resume / CV. As for physical chemistry: my memory is that it required only univariate calculus. Thermo and separation of variables were covered in the course, and the multivariate stuff was simplified or skipped. But many chemistry majors are not mathematically inclined, so even this level of rigor caused considerable angst. Students probably wouldn't do a minor that involves physical chemistry unless they already had the math background; as you say, a fresh-off-the-boat literature major would need many prereqs to succeed.
Comment: So would the transcript outright say it? Because in the other case, I can't see how you can prove it.
Comment: Often yes. The process for proving a minor is the same as for a major, a certificate, or any other formally-issued credential. And saying you have a minor when the university didn't actually issue one is fraud.
Answer: There are at least two reasons to minor. One is to get some background in a field complementary to the major: say, chemistry for a biology major. Math and philosophy might actually go well together.
The second reason is just because you have an outside interest in something: literature for a biology major.
Some people get a minor because the required courses at a liberal arts college already contain most of it any way, so, why not. My philosophy minor was like that.
Some people take more than one minor. Actually double majoring is also possible many places.
The requirements for a minor might be approximately half of what they are for a major and might include a few upper level courses.
Some people just want a broad education. This has been true since the Renaissance, I'd guess.

Background on the US undergrad system.
A bachelors in the US is almost always four years, doable by a few in less and a few other students requiring more if they have difficulties.
Things are measured in "credit hours" and a credit is (most, not all places) about 15 hours of instruction, or an hour a week for fifteen weeks. Courses vary in how much they count, with three credits being typical but with variations in every program. Labs might require two hours per credit. Some courses are just one credit. There is no standard, but the above is common.
Students take about 15-16 credits per term for 8 terms (semesters), so the requirements for a degree are around 8*15 = 120 or so credits, maybe a bit more.
A major is usually a bit less than 60 credits and the rest of the courses/credits are general education requirements: history and such in a chem major.
So, it doesn't take "four years" for the major, but four years for the degree. But the prerequisite structure of the courses implies that the major courses are spread out with two or three taken per term.
A minor, on the other hand might be 30 or so credits, but the prerequisite structure spreads them out, but perhaps ten courses of 3 credits each taken over 8 terms, or 4 years. Some of the courses in a minor, indeed some in a major, might be required for a bachelor's in any case. So, science is required for many (most?) degree programs and so a chem major can do those in chemistry and get some of their "major courses" by taking the entry level science in chemistry.
Squeezing in two minors in addition to a major is a bit hard, as are double majors. It probably requires overloads and hard work. I once successfully completed 21 credits in a term where 15 was the norm. But I tried 20 in the following term and had to drop one as it was too intense and wound up with 17 that term.
Note that in both the major and in the gen ed requirements there is room for some choice of courses. They aren't rigidly prescribed. Some requirements are just to come up to the total successful credit hour requirement. So, using these options you can take courses in your minor or your major or (for some) whatever you like. There is a lot of flexibility. So, two student math majors might overlap in only the core required math courses and the core required gen ed courses, normally taken early on.

A few places like Dartmouth are on a quarter system with four quarters spread over the entire year. Most students there study for three of the four terms/quarters. The individual terms look different but the totals come out to be pretty equivalent. It is just in how you slice the apple. Since the summer quarter is just like the others, it makes better use of campus facilities overall. Faculty likewise normally teach in only some of the quarters, but when I was a visitor there (long ago) the standard was four courses per year.
Comment: @EarlGrey, I personally value my philosophy minor quite highly. It was a good complement to math.
Comment: "The requirements for a minor might be approximately half of what they are for a major and might include a few upper level courses." How much is that in practice? Does it include the gen-eds? Surely it doesn't take an extra 2 years to complete, right? How much more coursework would someone with a minor take compared to someone without one?
Comment: I like that from this answer it is clear that minor >> negligible :)

How do academic minors work?


Interior Sobolev regularity of parabolic solutions

Question: In Evans book (and many others) there are a classic result about interior regularity in Sobolev spaces for solutions to uniformly elliptic problem (Theorem 1, p. 309). That is, let $\Omega\subset\mathbb{R}^n$ be an open bounded set, $L$ a divergence form operator, that is, for the sake of simplicity
$$Lu=-\rm{div}(A(x)\nabla u),$$
where
$A=(a_{ij})$ is a symmetric matrix, uniformly elliptic ($\Lambda^{-1}|\xi|^2\le A(x)\xi\cdot\xi\le \Lambda|\xi|^2$ for a.e. $x\in\Omega$ and a constant $\Lambda>0$), with enough regularity of the coefficients $(a_{ij})$. If $u\in H^1(\Omega)$ is a weak solution to $Lu=f$, whit $f\in L^2(\Omega)$ then $u\in H^2(\omega)$ for all $\omega\subset\subset\Omega$ compactly contained, whit the following estimate
$$\|u\|_{H^2(\omega)}\le C(\|f\|_{L^2(\Omega)}+\|u\|_{L^2(\Omega)}).$$
I want a reference for an analogous result for a parabolic PDE. In Evans book there is the following theorem (Thm. 5, p. 360) which guarantees higher regularity of solutions up to the boundary, assuming certain hypotheses on the initial data:
Let $u\in L^2(0,1;H_0^1(\Omega))$, whit $\partial_t u\in L^2(0,1;H^{-1}(\Omega))$ a weak solution to
\begin{cases}u_t+Lu=f &\rm{in }\hspace{0.3cm}\Omega\times(0,1)\\
u=0 & \rm{on }\hspace{0.3cm}\partial \Omega\times(0,1)\\u=g & \rm{on }\hspace{0.3cm}\Omega\times\{0\},\end{cases}
where $f\in L^2(0,1;L^2(\Omega))$ and $g\in L^2(\Omega)$. Then we have $u\in L^2(0,1;H^2(\Omega))\cap L^\infty(0,1;H^1_0(\Omega))$, whit $\partial_t u\in L^2(0,1;L^2(\Omega))$ and an estimate of $u$ and $\partial_t u$ in these spaces depending only on the initial data.
I want interior regularity without fixing a boundary condition and initial condition in the spirit of the elliptic theorem, that is considering a compact subset $\omega\subset\subset\Omega$ being able to get estimates in better Sobolev spaces for the solution.
I tried to find this in many other books, but nowhere is this result stated (maybe it's not true, but I don't think so). Any suggestions or references are welcome.
Answer: You can find such results in Chapter 2, Section 4 of N. Krylov "Lectures on Elliptic and Parabolic equations in Sobolev Spaces" and also in Chapter 5, Section 2 in the $L^p$ setting. Krylov assumes non-divergence operators but this does not matter since your coefficients are regular. However, he starts from strong solutions rather than variational ones and this perhaps requires some adjustment.


What does it mean to parameterise a policy in policy gradient methods?

Question: Can you explain policy gradient methods and what it means for the policy to be parameterised? I am reading Sutton and Barto book on reinforcement learning and didn't understand well what it is, can you give some examples?
Answer: In the context of RL, for a policy to be parameterised it typically means we explicitly model the policy and is common in policy gradient methods.
Consider value based methods such as Q-learning where our policy is usually something like $\epsilon$-greedy where we choose our action using the following policy
\begin{align}
\pi(a|s) = \left\{ \begin{array}{ll}
\arg \max_a Q(s,a) & \text{with probability } 1-\epsilon\;; \\ \text{random action} & \text{with probability } \epsilon\;.
\end{array}\right.
\end{align}
Here we have parameterised the policy with $\epsilon$ but the learning is done by learning the Q-functions. When we parameterise a policy we will explicitly model $\pi$ by the following:
$$\pi(s|a,\boldsymbol{\theta}) = \mathbb{P}(A_t = a | S_t=s, \boldsymbol{\theta}_t = \boldsymbol{\theta})\;.$$
Learning is now done by learning the parameter $\boldsymbol{\theta}$ that maximise some performance measure $J(\boldsymbol{\theta})$ by doing approximate gradient ascent updates of the form
$$\boldsymbol{\theta}_{t+1} = \boldsymbol{\theta}_t + \alpha \hat{\Delta J(\boldsymbol{\theta}_t)}. $$
Note that, as per the Sutton and Barto textbook, $\hat{\Delta J(\boldsymbol{\theta}_t)}$ is a noisy, stochastic estimate of $\Delta J(\boldsymbol{\theta}_t)$ where the former approximates the latter in expectation.
The policy can be parameterised in any way as long as it is differentiable with respect to the parameters. Commonly in Deep RL the policy is parameterised as a neural network so $\boldsymbol{\theta}$ would be the weights of the network.


Coreldraw Suite #7 - Colour Graphics

Question: I am using Coreldraw Suite # 7 and it's not printing my graphics in colour can anyone please advise what setting I need to adjust to change to colour?  It is displayed as colour on screen but not in print preview.  Thank you Pip
Answer: Have you checked your printer's default preferences? When you open the "Print" dialog box, click on "Print Preview" at the bottom left. This should show you rough estimation of what your print output will be. I mention this so that you don't end up printing a bunch of documents, wasting your expensive ink/toner.
If it's greyscale, then it's definitely a printer setting. Now, it's difficult to judge because each printer will generally have its own driver installed, so the screen you see when you go to your printing preferences will be different to what I see. But in there you will have to define the output as either colour or greyscale/black & white.

Coreldraw Suite #7 - Colour Graphics


Is there a standard size for smiley icons?

Question: I would like to know if there is a standard size I can follow when designing smiley icons.
Comment: There is no stadard-size for icons afaik. Can you specify what platform, app or programm you want the smileys for?
Answer: This question is very broad but I'l try to answer it as best as I can.  As already mentioned there are no "standard sizes" for icons and you should edit your question to include what you're targeting.  Are you:
Creating an app for Apple?
App icon required for all apps:

180 x 180
120 x 120
152 x 152
76 x 76

App required icon for the App store:

1024 x 1024

Source: IOS Developer Library
Creating an icon to be used by Android?

So, to create an icon for different densities, you should follow the 2:3:4:6:8 scaling ratio between the five primary densities (medium, high, x-high, xx-high, and xxx-high respectively). For example, consider that the size for a launcher icon is specified to be 48x48 dp. This means the baseline (MDPI) asset is 48x48 px, and the high-density(HDPI) asset should be 1.5x the baseline at 72x72 px, and the x-high density (XHDPI) asset should be 2x the baseline at 96x96 px, and so on.
Source: Iconography
Creating an icon for the web?
You could go with some common sizes:

12 x 12
16 x 16
32 x 32
64 x 64
128 x 128
256 x 256

If you are thinking of a favicon.ico:

Source: favicon-cheat-sheet
As stated though there is not a master standard size but I would suggest reading an excellent post called "Finger-Friendly Design: Ideal Mobile Touchscreen Target Sizes" that talks about size and finger functionality:

An MIT Touch Lab study of Human Fingertips to investigate the
  Mechanics of Tactile Sense found that the average width of the index
  finger is 1.6 to 2 cm (16 – 20 mm) for most adults. This converts to
  45 – 57 pixels, which is wider than what most mobile guidelines
  suggest.

Additional sources:

Create a favicon for your site in 8 steps
Favicon dimensions?

If you're looking for other ways to use an icon within a font you could always use something like Iconmoon which are considered icon fonts.  If you want to know more about icon fonts we do have other questions.  Just looking through the premium section they have some that may help you:

So additional help in regards to icon fonts:

How do you create Icon Fonts?
A Guide To: Better And Sharper UI Icons With Web Fonts
Answer: As @pute said there is not such thing like "standard size", but you have to use multiple of 4px and any size beyond 16x16 or 96x96 usually have no utility at all.
Is up to you to chose one  taking into account this  reasonably  sizes


Using line integrals to find total surface area

Question: I am given the equation for the height of a fence, which is h(x,y,z) = 4 + ((sinx)/2) + (y/3) +z. The line integral of this function will give the lateral surface area of one side of the fence. However, I need to find the total surface area of the fence; does that mean that I will have to double the line integral, or do I need to do more to take into account the top of the fence too?
Comment: The problem as stated is not clear.  Ask your teacher.  I would simply answer:  "area of one side = xx, area of two sides = 2 xx$ and compute xx.  The problem certainly cannot involve the top of the fence because that information isn't given.
Answer: Your problem is much bigger than the one/two faces. The line integral of a function
$$h:\Bbb R^3\longrightarrow\Bbb R$$
without more information doesn't makes any sense. And the same $h$ as the height of the curve doesn't makes any sense.
More information is required. Namely, the projection on the plane $XY$, say
$$\gamma:[a,b]\longrightarrow\Bbb R^2.$$
Now, the (scalar) line integral of
$$h:\Bbb R^2\longrightarrow\Bbb R.$$
makes sense and will be...


How does a flyback work when there is no output load?

Question: From what I understand, when the MOSFET is ON, the output diode (D1) is reverse biased. Then when the MOSFET turns off, the magnetic field of the transformer collapses and provides power through the output diode and into the load. However if there is no load at the output, then when the MOSFET is off, the magnetic field in the inductor has no where to go, and so it would build up an extremely high voltage across the MOSFET. Wouldn't this then damage the MOSFET? How do power supplies prevent this from happening?
Comment: Potentially yes. But see R0 on the other secondary.
Comment: *and so it would build up an extremely high voltage across the MOSFET. Wouldn't this then damage the MOSFET?* Of course it would. So the MOSFET will need protection. All MOSFETs have a Drain-Source (actually not Source but Bulk, which is shorted to the Source) diode which will limit the voltage as the polarity of the voltage will reverse (the \$V_{DS}\$ of the MOSFET will be negative. Also there will be a snubber network.
Comment: In additi0n to R0 mentioned above, if the converter is designed to withstand open output (I would hope so), then the caps will slow the rise in voltage enough that the controller has time to react before the voltage rises too much.
Comment: Another things is that the system has **feedback**, it will sense through the feedback winding (the one connected to D2) that there is less load at the output (\$V_{om}\$ will increase) so less energy will be pumped into the transformer by making the pulses on Q1 shorter.
Comment: Without feedback and duty high enough the output voltage will extremely rise. With feedback the control loop decreases the duty to sufficient value to keep the output regulated (like in loaded state).
Comment: To prevent Mosfet damage there should be placed a RCD snubber across primary winding to dump this high voltage spikes. Decreasing the duty by control loop I mention above also help.
Answer:
However if there is no load at the output, then when the MOSFET is
off, the magnetic field in the inductor has no where to go, and so it
would build up an extremely high voltage across the MOSFET

Nearly there.
The inductor charges the output capacitor to a higher voltage and, if something doesn't take control of the duty cycle (such as the control loop shown in your picture formed by the error amplifier), then it ends in tears.

How do power supplies prevent this from happening?

The error amplifier and feedback prevent this from happening by reducing the duty cycle to zero. Now, the output stays at the target voltage and the MOSFET stops switching until a load is reconnected to the output.
Comment: @willieb3 capacitors don't saturate. The feedback loop must have enough bandwidth to cope with the situation. Current can't go to the MOSFET from the capacitor because of the diode.
Comment: So if the output capacitor is undersized, then could it saturate before the feedback loops kicks in to reduce the duty cycle? Also, if the ESR on the output capacitor is high, would this "redirect" current back onto the MOSFET?
Comment: @Andyaka in case of no feedback loop the MOSFET should burn out due to the high voltage but what's happening in this case.         https://youtu.be/okzxk1almeA?si=wR9PUqzSN3zFAIIz.           In this tutorial can see a very high voltage at the output side but still the MOSFET is working fine....how?
Answer: A so-called indirect energy transfer converter cannot operate without load. This is true for a boost, buck-boost or flyback converter. This is because at each turn-on event, you store energy in the primary inductance of the flyback transformer and, at the switch opening, this energy has to go somewhere. If there is no load to absorb the power generated cycle-by-cycle, then the output voltage increases until something breaks. It can be the output capacitor venting out, the primary-side MOSFET blowing up because you exceed its \$BV_{DSS}\$ or the secondary-side diode whose breakdown voltage is violated. This is a typical case when the converter runs in open-loop, for instance if the optocoupler is destroyed.
In a true no-load condition, the converter will try to reduce its duty ratio as much as it can. However, in current-mode control which is the most popular control method, the minimum pulse width is constrained to the sum \$t_{prop}+t_{LEB}\$ which can be as high as 150 ns + 250 ns = 400 ns. \$t_{prop}\$ represents the time to shut down the power switch when the CS comparator detects the peak value and \$t_{LEB}\$ designates the leading-edge blanking time needed to cleanse the current spike. For a 100-kHz converter, it can amount to a minimum duty ratio of 0.4/10 = 4% which is not that high but still large. So if a converter is left in a no-load condition with such a minimum duty ratio, what is going on? Well, if you are lucky enough that the natural output load (the optocoupler bias current, the resistive divider, a potential bleeder) absorbs the energy in this mode, you are safe. If not, then the voltage will inexorably increase, going back to the situation I described before.
Some controllers can go down to true 0% duty ratio and the venerable UC384x is one of them. For the other ones, one very simple mechanism is called skip cycle. An extra comparator is installed in the circuit, observing the feedback voltage (FB). When the feedback voltage is high enough, the skip comparator is silent. When the FB voltage decreases too much (300 mV typically) and tends to impose too low a peak current, approaching the minimum pulse width, then the skip comparator kicks in and resets the PWM latch, stopping all pulses:

This technique is now very popular and found in almost all ac-dc offline controllers. New techniques have emerged to reduce the acoustic noise as pulse bunches can excite the transformer which becomes a transducer. Typical operating waveforms are shown below:

With this technique, you can safely operate down to 0 A and reduce the standby power to the lowest value, typically below 100 mW at a 230-V rms voltage.
Comment: @Ultra67 thanks for chasing the typo!


Stator rewind for 1929 motor

Question: I'm trying to fix an old (1929?) AC, 60 Hz fan motor.  None of what I've found is this simple (or old). It needs the stator rewound. It has only 4 posts and I'm copying the orginal windings. I could not tell from the old winding if the poles alternate polarity. Physically, I'm winding them all clockwise but can alternate, if need be, by connecting adjacent coils head-to-head & tail-to-tail. Right hand rule would reverse the N-pole. I presume the 60 Hz house current provides the modulation to actually make the motor spin. I've attached a photo.
Comment: Be careful! Make sure that your windings don't spread out at the ends to the point where they interfere with your ability to later insert the rotor. That first one looks iffy.
Comment: Hi there and welcome to EE SE. There are votes to close your question, because it's about repairing. However, if you put more info about the research you've done into your question and broaden the focus in a way that goes more towards general motor design and less towards just one particular problem, this might become a really interesting Q&A. There's already a good answer attracting many upvotes. Please show your research effort and edit more info into the question... Much can be learned while repairing stuff, and I'd like your question very much not to be closed.
Answer: Looks like a pretty simplistic shaded-pole induction motor. Here's a schematic that's almost identical to your photo:
(second one from a Google search)

As shown in that diagram, you'll want to reverse the connections on you winding coils.

Stator rewind for 1929 motor


What physiological tools would a humanoid need to generate ultra-low frequencies?

Question: I'm interested that some ULF (ultra-low frequencies, especially the 17 HZ zone) can cause humans to experience sensations of fear, trembling, or even claims of seeing ghostly apparitions. What an interesting ability to grant a fantasy or sci-fi race. But what physiological tools would a humanoid need to actually generate and hear those frequencies for an extended time?
Answer: Fairly easily done.
You need a long neck and a barrel chest.  It just needs to be long enough and shaped to create the necessary resonance.
Humans can create a very broad range of pitches with a more or less standard set of apparatus (chest cavity, throat, vocal chords, and mouth).  Ever noticed how a tall guy tends to have a deeper voice than the shorter person?  Same apparatus, just different pitch resonance based on size.
The deeper the pitch, the longer the wave length.  The larger and longer the resonance chamber needs to be.  So, long neck and a big chest cavity.
Comment: Or the big glottis diameter which means longer vocal cords, like in whales that have a short neck but are very big, with all the organs bigger.
Comment: @YellowSky that would do it too!


Can we add [love-chunibyo-and-other-delusions] as a synonym of [chuunibyou-demo-koi-ga-shitai]?

Question: The tag chuunibyou-demo-koi-ga-shitai currently has the synonym love-chunibyo-delusions, most probably due to the old 25 character limit on tag names. Since the limit has been upped to 35 characters, the full English title of the series now fits within the limit. So, could we have love-chunibyo-and-other-delusions as a synonym? If yes, we could also remove the old synonym, I expect.
Answer: The main tag has been changed to love-chunibyo-and-other-delusions with chuunibyou-demo-koi-ga-shitai as a synonym. 'love-chunibyo-delusions' has been removed from the synonym.
This is according to the 2021 Policy Review: How do we want to name series tags?.

If the title has official English localized name, use that. Meaning take the official English name over the Japanese name were available. Both should be synonyms.
Comment: Would you prefer similar requests to be made in new Meta posts, or just informally in chat? If the former, is it more convenient for you if I compile multiple requests into a single post, or would you prefer separate posts for each request (or is either fine)?
Comment: @Namaskaram personally, I prefer to have separate posts on the meta for each request so that each can be discussed independently. Chat is hard for documentation.
Comment: Noted! I spotted maybe a couple of tags that might need similar synonymization. I'll write up the requests into individual Meta posts, when I get time tomorrow.


Configuring Ghidra to use the Keil 8051 ABI for analysis

Question: I am trying to reverse engineer a raw binary image from an nrf24le1 SoC that (I think) has been compiled with the Keil toolchain.  Specifically, I see that C functions in this image usually expect their arguments in r7/r5/r3 as described here and that the return value lives in r7.  The behavior I'm seeing is:

Ghidra thinks that every function in this image takes 0 parameters, even if it's obvious that the function is immediately looking at r7 for its first argument
Ghidra thinks the return value lives in ACC

I have to manually override this for every function.  I would like for Ghidra to automatically figure out when a function has arguments based on the Keil ABI.
By contrast, when I run Ghidra on a raw arm32 binary, it notices when a function looks for arguments in r0/r1/r2/... and it adjusts the function declaration accordingly.  So Ghidra behaves correctly for arm32, but incorrectly for 8051.
Is there a way to fix this (or is there a better tool I should be using instead of Ghidra)?
Answer: You need to use the mx51 variant of the 8051 processor when loading the binary.
The file in the link uses the calling convention found in your link.


Tips for making LFE

Question: We all know and love the LFE and we can feel it in our bones when it shows itself.  Does anybody have some tips on making Low Frequency Effects?
Answer: Main techniques I use are:

choosing the right source material
worldising
using subharmonic synth
varying frequency

re worldising, on a couple of films I've made seriously freaky sub sounds for earthquakes etc by playing pure bass tones on one of my analog synths and lieing my subwoofer on its back and putting objects on top of it (eg wood, metal, glass etc) By doing pitch bends & varying the frequency you can pass through the resonance of any object! For a film last year I did this with a lot of different objects and made the earthquake appear to pass through different parts of the house (eg lounge -> kitchen -> hallway -> bedroom) by rattling objects/walls/wood etc from each room.... Funnily enough I tried the same process with my bass guitar amp and it wasn't half an effective - must be too much distortion, my JBL LSR sub is a far cleaner beast than my Trace Elliot bass rig...
re subharmonic synths
I use a dbx120 outboard and sometimes the lowender plugin.. the dbx is the best I've used by far - if you havent used one, it models sub bass sine waves an octave below your source material & you then have control over filling in the spectrum between -1octave & zero with harmonics - too much and it sounds like playing 5ths on bass guitar! The important part is that its generating sub, not just filtering or boosting EQ etc! I've used it on pitch shifted breathing to make large creature breaths too. The dbx is a VERY good affordable bit of outboard that any sound designer should own, if you can find one.. Many dub stages have them in the rack, but I like to print them on to split tracks so I can can cut them in sync with the source material...
Like all sounds, moving/shifting frequencies where appropriate rates best as we notice change, whereas a constant rumble stops contributing fairly rapidly & just takes up headroom/energy...
A note of caution: like any effect, overuse or inappropriate use is a real danger eg "here goes another boys movie with loud overt sound effects... boooom...."
Answer: Sub-Harmonizers are good fun eg. BigBottom. They're good because you're creating harmonically related material as well. Pretty much any Impulse Response can be manipulated to give you weight too. Something to try is a Big IR (eg. a metallic space) but with a reduced reverb time, giving you something big and heavy but restrained at the same time.  J
Answer: It is obvious but I'll share it: I once read that making LFE's is as simple as low-passing a regular SFX. For the Dynamic Interference first challenge, I did just this with crashing waves for the building falling down.
I also find that more radical (than usual) compression makes this nastier in the low end.
Answer: Contact mics and hydrophones have excellent low end response. I've done some impact recording with them buried under the sand / dirt and gotten great sub sweeteners.
Comment: can you reccomend a contact mic?
Comment: Two companies that are making amazing, affordable mics: Trance Audio and Aquarian Audio.

Tips for making LFE


How do I let Google know of a problem so they can fix it?

Question: My husband signed in to his gmail account on my laptop and when we tried to sign him out through his icon photo the drop screen wouldn't pop down to allow us to hit the sign out button. How do I let Google know of this problem so they can fix it?
Answer: Short answer

Use Google Feedback

Explanation
Google Feedback is the tool that Google includes on many of their web applications to make easier for users send feedback directly to the engineers in charge of the corresponding web application.

Picture taken from Google Feedback
On some applications, like old Gmail, click on the cog button, then on Send Feedback, just as it's shown on the above picture.


When to consider motional emf and when not to?

Question: In this configuration(given in picture) ,the magnetic flux through the loop is changing(which causes an induced electric field,which causes an induced emf) and for the perpendicular rods AB and CD(if we consider them to be not a part of the loop and moving with velocity v on their own(just for visualization) then shouldn't we consider motional emf for them and add both induced and motional emfs to give resultant emf in loop?
I was told that I could do only one of them at a time not both.The explanation given to me was not satisfactory please help
the configuration:
Comment: If I understand what you're saying correctly. If the loop is moving. Then the total instantaneous emf in the Loop  is  the sums of the line integral of all of the sides, (provided that we perform the line integrals connected with eachother, ie, (A->D) + (D->C) + (C->B) + (B->A). What do you mean " add induced and notional emfs"? there are only induced motional emfs here.
Comment: @jensenpaull  Doesn't faraday law state that if in a loop magnetic flux changes then there is an induced emf in the loop?(acc to what my instructor said this will cause an induced electric field(non conservative one)but acc to some books which I read, that happens only if there is time varing magnetic field does it. And yes you understood me correctly.
Comment: What is correct
Comment: Acc to wiki pedia any change in magnetic flux causes an induced emf:https://en.wikipedia.org/wiki/Faraday%27s_law_of_induction in the mathematical description section which makes we think why not add that induced emf with motional emf too??
Comment: In your given scenario, no transformer emf is present. There is no electric field. This doesn't mean there can't be an emf
Comment: Another way to analyze this, is to observe that there is an electric field in the co-moving frame of the loop (which has the effect the Lorentz force has in the lab frame).
Answer: Comment answer:
There is a subtle difference in Faradays law compared to the maxwell-faraday quation( you may not have known there are 2 to begin with)
Faraday law:
$\epsilon = -\frac{d\phi_{B}}{dt}$
$\epsilon = -\frac{d}{dt}\int \vec{B} \cdot \vec{da}$
describes both  motional emf and transformer emf, ANY change in magnetic flux on a surface causes an EMF. this doesn't necessarily say whether or not the EMF is caused by an induced electric field, or if it is caused by  the magnetic lorentz force. This equation COULD give rise to an emf( changing magnetic flux), due to a change in the boundary of the surface in question, or due to a changing B field($\frac{\partial \vec{B}}{\partial t})$ within that boundary
Whereas the maxwell-faraday equation
$\int \vec{E} \cdot \vec{dl} = -\int \frac{\partial \vec{B}}{\partial t} \cdot \vec{da}$
only describes transformer emf, aka an emf caused by an induced electric field as a result of a changing magnetic field
In this situation there is only  motional emf, as there is a NON changing  magnetic field as its the field of a static wire. But, there is a moving loop, aka a changing magnetic flux caused by a change in the boundary of my surface. In this situation there is NO induced electric field. The EMF generated in this situation is  not described by the maxwell-faraday equation. It is instead described by faradays law. With the physical mechanism for this  EMF being the magnetic lorentz force on the charges in the boundary of my surface.
To find the emf I could compute  the changing magnetic flux in my loop using FARADAYS law, to find the EMF. Or... as you have suggested. I Could use the lorentz force to calculate seperately the line integrals of all of the sides to find the total emf in the loop
Where
$\epsilon_{i} = \int_{a}^{b}  (\vec{V}×\vec{B} ) \cdot \vec{dl}_{i}$
To mathematically understand why there is a difference between faradays  law and the  maxwell faradays equation. Is that the time derivative is in the inside of the integral. This forces the equation to completely ignore any change to the surface boundary
Comment: brilliantly cleared now. Thankyou so so much for this god bless you bro. So that means an induced emf(transformer one) comes into picture only when magnetic field is time varying.. otherwise its always going to be due to motional emf right or changes in the shape of my loop
Comment: Yup! This is also seen from the differential form that $$\nabla × \vec{E} = - \frac{\partial\vec{B}}{\partial t}  $$if $  \frac{\partial\vec{B}}{\partial t} $ is zero, then the induced electric field must also be zero, and thus any emf is caused by the magnetic lorentz force on charges in my wire!
Comment: Look at the derivation of the motional emf from that same Wikipedia page it explains more clearly how we can explicitly extract motional emf from faradays law!
Comment: ok thankyou so much.
Comment: (^^ technically emfs can be also be caused by static E fields actually, not just B fields, when no changing B fields are present)**


EEPROM in beaglebone black

Question: I want to disable EEPROM in beaglebone black by unloading i2c-omap driver. Will it create problem in hardware or any other software support? What should I expect ?
Comment: Your question really is: What devices are attached on the I2C busses. Do you have the circuit diagram of BBB and board documentation?
Comment: Are there any resistors you could lift off to disconnect the EEPROM from I2C? If this disabling is a security matter, a physical barrier is probably more secure than a missing driver
Answer: BeagleBone Black System Reference Manual

5.3.2: A single 32KB EEPROM is provided on I2C0 th
  at holds the board information. This
  information includes board name, serial number, and revision information

If you search for I²C in that document:

6.9.1: HDMI Framer The TDA19988 is a High-Definition Multimedia Interface (HDMI) 1.4a transmitter.
6.1.1: TPS65217C PMIC The main Power Management IC (PMIC) in the system
8.1: EEPROM Each cape must have its own EEPROM containing information that will allow the SW to identify the board and to configure the expansion headers pins as needed.

Whether or not you'll be running into problems is a matter if are you using any of these devices or a I²C device you wired up yourself.
Comment: IIRC, the TPS65217C is crucial to the device working... without it the device won't turn on (all power to the processor is routed through it).
Comment: @helloworld922 I really don't know. The system should be able to bootstrap without writing / reading to the device, otherwise it would never power up. I didn't read the entire chapter.
Comment: hmm... true, it would be kind of hard to power on if communication from the device you're suppose to power is required.

EEPROM in beaglebone black


How to understand the sentence and who is the pianist here?

Question: I come up with the sentence "I don't like him as a pianist, but as a judge" when considering "him" as a pianist. But can this sentence have two meanings when "as a pianist" refer to both "I" and "him"? Or can it only refer to the closer "him"?
Answer: Yes, without further context, it's ambiguous, and you should re-write it to reflect what you really want to say. It's doubly ambiguous, because you can't tell whether "judge" or "pianist" refers to you or to him.
As noted in the comment, a context could be made up where the sentence isn't ambiguous.
Examples:
"He took points off for my pedaling, so I, as a pianist, don't like him as a judge."
"As a judge, I don't like him as a pianist."
"I don't like his piano playing, but his competition judging is excellent."
Comment: I've upvoted this answer, but I would note that the ambiguity might be resolved by the context, in which case it would not necessarily be necessary to rewrite the sentence under discussion.
Comment: @phoog I agree, the context might make it clear; I will note that  in the answer.


View multiple Mamp Pro websites on local network

Question: Using Mamp Pro 2.1.1 I have 3 Wordpress websites running that I would like to view via mobile devices (iPhone, iPad, etc.) for testing AND allow for my team to edit simultaneously before publishing live over my office LAN.
By appending port 8888 to my IP (mylocalIP:8888) I can access the first website via phone or other computer. However I have not been able to figure out how to view any of the other websites easily.
I have tried setting different port numbers for each of the other websites which all, rather than going where I want, redirect to the mylocalIP:8888 which is quite frustrating.

What I'm looking for is something simple like mylocalIP:5555 to go to the correct website. What I'm not looking for is installing another program and/or tweaking settings on every persons computer that is working on the website or wants to preview/approve it.
Any thoughts? I've read of the possibility of an Apache conflict from the native Mac and MAMP installations, could this be the problem? I am running OSX 10.8.2 if that helps.
Thanks.
Answer: I've successfully used at setup which includes the name of my computer, e.g. myMacBookPro.
In your case it would look like this:

IP / Port = * / 5555
Add 'theNameOfYourComputer.local' as alias (e.g. myMacBookPro.local)
Other persons on your LAN should now be able to access your site via http://theNameOfYourComputer.local:5555

Hope it works for you.


Filter for landscape format images in views

Question: I am working with Views 3 and Drupal 7 and created a view to display a list of images from a given content type in a slideshow. For layout reasons, images in portrait format don't work. Is there any way to filter for "width > height"?
Answer: One simple solution
in given content type, add a CCK (select list) field having  option "width > height". select this field when the image is landscape. then in views add this filter too.  by doing this, only images that are "width > height" will be shown
Comment: thanks for your reply. this would be a solution i am not really happy with. someone would need to go through all the existing content and select this field.
it is possible to select a filter for given widths or heights in views. i just thought i've missed the part where you can have the filter working for both fields, since the values are already stored in the database if you upload an image.


How can I make it so materials are linked to objects instead of data, with Python?

Question: How to add material to selected objects via python?
Material must be linked to Object (not Data).
Answer: If you hover your mouse over a button, it will often tell you the python binding that can be used to invoke similar actions to the button. In this case:

So first you assign it a material, and then go and, from the object, change the data link.
To set all materials to 'object' for a single material:
obj = an_object
for mat_slot in obj.material_slots:
    mat = mat_slot.material
    mat_slot.link = 'OBJECT'
    mat_slot.material = mat

I am not sure why re-assigning the material is necessary, but hey, it works!
To set a single material slot (untested):
obj = an_object
mat = a_material
mat_slot = [m for m in obj.material_slots if material_slot.material == mat][0]
mat = mat_slot.material
mat_slot.link = 'OBJECT'
mat_slot.material = mat

To assign a material, something like this could be written (untested):
def applyMaterial(obj, mat, mat_slot=0):
    obj.material_slots[mat_slot].link = 'OBJECT'
    obj.material_slots[mat_slot].material = mat

Comment: thank you. It works great.

I need to change several materials (but not all) of the scene which is a copy of another (_New Scene - Link Objects_). I decided to change it using the script :)
Of course, first I used _U - Object_


anyone attempted a multiple p2sh(multisig) send (ideally using python)?

Question: I attempted to use pycoin to do a "create_signed_tx" in python, but had no joy: Do you think it might be technically possible to use spendables(UTXOs) from multiple source P2SH wallets in a single push to the network ? Anyone done this successfully yet(ideally using python)?
Comment: what is a "multiple source p2sh wallet"?
Comment: sorry if that was unclear: I mean sending bitcoin from "more than one" P2SH wallet in one transaction(push) transmit. By saying "multiple source" I didn't imply a special case. P2SH(pay to script hash) is like a multisig wallet(most "multisig" transactions these days are actually P2SH). Multisig wallet: one where more than one private key is required to spend coins.
Answer: answer is yes, its possible: I was merely doing it wrong in my earlier attempt(s):
have posted a gist to illustrate how I got it working using a few python libraries on the testnet: https://gist.github.com/kumrzz/111f8ea12af3528f496cbe678d153fc0


Thread bumping in the Stack Exchange universe

Question: Just wondering how people feel about thread bumping on the stack exchange sites. I personally think it is a time honored way to get feed back on a subject that is not receiving enough attention, but I got lambasted the other day for bumping one me my questions (which was a pretty good one I think).
Comment: Link to your question?
Comment: Related - http://meta.stackexchange.com/questions/7046/how-to-get-attention-for-your-old-unanswered-questions
Comment: i did not link to my question because i am not looking to have it judged specifically, but rather the pratice of thread bumping.
Answer: It is not completely discouraged.  If you would like to bump a question, try to add some value with your edit.
Continually bumping a question though can be frowned upon, as it looks like you are just looking to get more votes.
Comment: @typo, Meh, people can downvote whatever they want.  If they think its annoying to see that question every day, you may get an downvote.
Comment: I agree, over bumping is just annoying, but a bump every day or two for in a thread with little or no activity doesn't seem like that big of a deal, certainly not warranting a down vote.
Answer: As it says in https://stackoverflow.com/faq

In order to get good answers, you have to put some effort into your question. Edit your question to provide status and progress updates. Document your own continued efforts to answer your question. This will naturally bump your question and get more people interested in it.

The key thing here is add value with your edit.
Answer: It's perfectly acceptable behaviour - as long as you don't overdo it.
In fact the Community user bumps a few unanswered (no upvoted answers) questions each day.
Comment: Yeah, I don't like to see a bunch of bumps in a thread either, but I think one every day or two (if the thread has no replies) is acceptable.
Answer: If you want more attention given to your question, try adding a bounty. That will generate more views and responses.
Comment: Point taken.  The person who got all bent out of shape for me bumping said the same thing.


What's the first non-planar graph of the first $n$ numbers where edges show divisibility?

Question: Let $G_n$
be a graph with vertices $v_1, v_2, v_3,\dots, v_n$,
where there is an edge between $v_i$
and $v_j$
if and only if either $v_i$
divides $v_j$
or vice versa.
Is there a value $n$
such that $G_n$
is non-planar,
ie cannot be drawn in the plane without intersecting edges?
If so, what is the least value of $n$
for which this happens?
By way of example,
the drawing below shows that
$G_{12}$ is planar.
Answer: $G_{14}$ is planar: From your $G_{12}$ sketch, relocate $7$ into the $1{-}2{-}6$ triangle. This allows you to add $14$ with edges to $1$, $2$, an $7$. And the prime $13$ can be placed anywhere in the outer region.
One readily sees that the five numbers $1,2,4,8,16$ form a $K_5$, hence $G_{16}$ is not planar.
So what about $G_{15}$? It turns out, we would have a $K_{3,3}$ with vertices $1,2,3$ and $6,12,m$ if there were another common multiple of $2 $ and $3$ available. While there is no such $m$, we have $5$, which is indirectly linked to $3$ via $15$ and to $2$ via $10$.  Therefore $G_{15}$ is not planar.
Comment: Very nice proof. We're going to mess around with this with some 3rd and 4th graders next week and see if they can figure this out. (Of course, their answer won't look quite like yours!) If they like the problem, we'll dip deeper into graph theory later in the program.
Comment: @j0equ1nn but you will be able to show how they could isolate subsets to show a graph is non-planar by considering a subgraph.
Comment: @MarkBennet I'm thinking similarly. It will take them a while to develop the notion of looking for small non-planar graphs, and then looking for instances of it as a subgraph. But they will be discovering all this from scratch. It is really fun to watch that happen, one just has to know what to say and especially what not to say!
Comment: @j0equ1nn I think it is a great idea.


How to write Arduino API code in VL53L1X?

Question: I'm trying write code for the VL53L1X on Arduino,  but I didn't get the VL53L1X registers. How to access them and how to measure the data in VL53L1X? Can anyone help me?
Comment: And the datasheet says what?
Comment: what model of arduino is the `VL53L1X Arduino`?  ... which manufacturer makes it?
Answer: He's not asking about a VL53L1X Arduino. He's asking for code to support the VL53L1X (which is an ST distance sensor) that runs on an arduino.
ST have provided a library, but it's huge with many large buffers and doesn't run on an arduino as distributed. They've also forbidden anonymous distribution of a corrected version, presumably because they don't want to make it easy to run on 16-bit processors. It might run easily on a Teensy 3.
Sparkfun have just released a library. It's much smaller but, like the Polulu library for the  VL53L0X, it's full of magic numbers where they've stripped the structure out and just write the end result into the registers - so it will be difficult to get the best from the sensors.
https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library/blob/master/src/SparkFun_VL53L1X_Arduino_Library.cpp
There is a good case for writing something halfway : without the overcomplicated code typical of ST's Cube environment but with a bit more content than Sparkfun's version.
It's a boring job unless you have something you need from it. Worthwhile only if you have a good case to support it on AVR. If you try to build the ST sources, look carefully at the maximum write size on I2C (135 bytes) and compile with maximum warnings enable (it will pick up several 16/32 bit wordsize errors, mostly critical).
Comment: Majenko, there is no proper data sheet. The programming details are described in the code. Partially.


Can't install USB driver for Zopo ZP300+ on Windows 7 64-bit

Question: When I enabled USB debugging in settings for Zopo ZP300+, an unrecognized device appeared in device manager: H9000+.
Then I followed this: https://web.archive.org/web/20160918125953/http://www.zopomobileshop.com:80/zopo-rom/how-to-install-driver-for-zopo-mobile-phone-step-by-step-instruction/. MT65XX Preloader replaced with "MediaTek PreLoader USB VCOM Port (COM3)", then it disappeared. I unplugged the USB, turned on the phone, and plugged it back in. No new drivers were installed. H9000+ is still unrecognized. Eclipse says: No compatible targets were found.
Comment: You might want to try Koush's [Universal ADB driver](http://adbdriver.com/).
Answer: I used the wrong driver. H9000+ means you need ZOPO MTK6577 DRIVER.


Minimum length of salt and info for HKDF

Question: Hi newbie here is there any minimum length for salt and info passed to hkdf based key derivation or is using 32 byte randomly generated bits for salt and info can be used for all hkdf
Answer: There is no minimum length for either the salt or the info string in HKDF. In fact, they can both be omitted if your particular application does not need them.
The only real requirement is that the pair (salt, info) should be unique for each derived subkey — since, if it is not, then identical input keying material (which could occur for reasons outside your control, e.g. due to an insufficiently random password used to generate the IKM) will produce identical output, which is generally not desired.
More specifically, for HKDF, you can think of the salt as something that ensures that (accidentally or deliberately) reusing the same IKM for two applications (or two instances of the same application) will still yield different PRKs, and thus different OKM. Meanwhile, the info string allows several distinct and quasi-independent OKMs (such as separate keys for encryption and authentication, or a separate key for each of several messages, etc.) can be derived from one PRK, which is useful for many applications and makes the KDF more versatile.
For a typical application, the salt might be randomly generated, while the info string might be fixed for each distinct type of OKM needed by the application (e.g. "enc" and "auth") or it could be a unique message/file/account identifier, or perhaps a combination of the two.
For a randomly generated salt, you'll want to make it long enough to assign a unique salt to each IKM/PRK, and then — due to the birthday paradox — make it twice as long.  This will, with high probability, ensure that all your salts will be unique.  So, for example, a 32-bit salt would be enough if you only expect to need to derive at most $2^{16} = 65536$ different PRKs, while a 64-bit salt would be good for up to $2^{32} \approx$ 4 billion uses.
In practice, you can just use a random 128-bit salt (or e.g. a version 4 UUID) and not worry about salt uniqueness.
For further information, see sections 3.1 ("To Salt or not to Salt") and 3.2 ("The 'info' Input to HKDF") in RFC 5869.
Comment: Ironically, the `salt` parameter should be a constant for domain separation or null, and the `info` parameter [should](https://soatok.blog/2021/11/17/understanding-hkdf/) actually contain the randomness/salt to get the standard KDF security definition. HKDF is messy. You're meant to use a [single salt](https://github.com/paseto-standard/paseto-spec/blob/dfd1115170724b056b3c1ac722239cf7084755a8/docs/Rationale-V3-V4.md#better-use-of-hkdf-salts-change) for many contexts.


How does the Higgss field change with the expanding universe?

Question: Does the expanding universe really have an effect on the Higgs field? Say, is it like the matter getting diluted with the expanding universe? Or does the expansion does not have any effect on the Higgs field, just like the Dark Energy maintaining its energy uniform even if the universe is expanding?
Comment: This needs an answer by a theorist.Have a look at http://hyperphysics.phy-astr.gsu.edu/hbase/forces/unify.html
Answer: At the moment there does not exist a quantized  unified theory of gravitation and the standard model. The only candidate to date is string theories which are at a research level, and in which I am not able to form an answer.
There exist effective quantizations of gravity and effective models including the standard model in the studies of cosmology and the Big Bang model. In these models the continuing expansion of the universe is not affecting the bound states of the universe, atoms, molecules, gravitational masses, galaxies , clusters. Even the gravitational field  is much stronger then the effective "force" of expansion. ( the raisin bread analogue for the expansion and the stability of bound states).
The Higgs field, once the energies became low enough to break the symmetry which gives zero masses at very high energies during the original expansion, belongs to the set of fields which defines the bound states of atoms and molecules, together with the strong weak and electromagnetic fields. Thus the Higgs field will also not be affected by the continuing expansion of the universe.
This is a hand waving explanation within the known theories, which needs a theorist's input , imo. See one such by Lubos Motl .
Comment: I will definitely have a look in the links mentioned here. And revert back if i get some info @anna v .. Ty


Does starting my story in the middle of the plot and then going back count as having a flash back or flash forward?

Question: I am doing a writing assignment and I need to include either a flashback or a flash forward. I am starting my story in the middle of the plot and then going back and giving detail about what happened before that moment. Does that count as having either a flash back or flash forward?
Comment: We can answer this question for what most people think, but if you want to know what your teacher thinks (assuming this is a graded class assignment) you should ask them.
Comment: Related: [Flash-forward as Prologue and then Flashbacks too complicated?](https://writing.stackexchange.com/q/30486/22990)
Answer: I don't think so. What you are doing is a "teaser", you see that in TV series once in a while: The opening scene is a character doing something dramatically out of character or surprising, like lying in a coffin, or a cop firing on other cops.
But then the freeze and put up a Super that says "48 hours ago..." and all is normal with that same character. That first scene is a "teaser".
And it turns out they weren't dead in that coffin, or the cops they were firing on were imposters, or whatever.
A flashback is when a character is clearly remembering something; e.g. I have a scene I wrote in which a woman begins telling a story from her childhood to her young daughter; and we change the scene and there she is as a child; we have a few words of narrative and then it is live action. We end that the same way; the live action stops, we return to the woman and her daughter, and she finishes the last few lines of the story.
I think your teacher would like something that is more clearly a flashback; specifically somebody is remembering some incident, then you write that as live present action, then break that off and come back to the person narrating it: "And that was the last I ever saw of ol' Bill, but I heard he made it all the way 'cross to San Francisco with that money and opened himself a nice burger joint."
Comment: Imho this kind of "teaser" is caller "flash forward"
Comment: @Alexander Okay. But after the "flash forward" is not a flashback.
Answer: I think it'll depend how it is executed. I believe if you move the whole of the narrative into 'real time' in the past, that will flash the reader back. Alternatively, if you weave in the past through memory, introspection, contextualization, and associations, it will not.
To illustrate:

Nacio threw the glock down. "I ain't a murderer." His thoughts flashed
back to an incident twenty years earlier. His father had just told him
to put the dog out of its misery. "No, Dad, I don't want to." "It's part of
growing up, son. Taking care of others, helping them through their
pain. Now this dog of yours is counting on you." (etc)...

Compare that to:

Nacio threw the glock down. "I ain't a murderer." He never had been,
and he knew full well he never would be. Even when his father would
talk about good deaths and bad deaths; even when he insist Nacio put
his own dog down, to end Charcoal's misery, he had refused. His father
had almost disowned him over it, but he would never have a hand in any
creature's death. "I don't kill," he repeated.

That's not a flashback, because it's couched as memory in the moment.
Comment: This is AS.
Thanks so much for everybody's comments! I asked my teacher about it and she agreed with Alexander and SFWriter if I read y'all's answers right. Here is what she said: "Sounds like a genuine flashback to me " Well, thanks again for y'alls help! And by the way, @Alexander: Thanks for the article reference. It was real helpful!


Detect how long it takes for a file to upload (PHP)

Question: Is it possible to know (serverside) the time it took for a file to upload? I have an image upload API and in my response I'd like to return the upload time (not including script execution time).
Comment: show us the code youre using to upload the file
Comment: a file is uploaded by posting it to my api url as multipart/form-data
Answer: I think yes, there is $_SERVER['REQUEST_TIME'] variable that indicates the start of HTTP request, so on the very beginning of your script:
$upload_time = time() - $_SERVER['REQUEST_TIME'];

Result will be in seconds.
Comment: As you said, did turn out to be a bad server configuration. However, I got some useful answers too. The Apache header solution on the other question actually allows for the use of microtime, which is of a finer granularity than `REQUEST_TIME`. I'm going to request the two questions be merged.
Comment: Sad to hear that, but please note that it is problem with your server configuration, not the answer.
Comment: At the moment yes, but from php 5.4 onward `REQUEST_TIME` will also contain microseconds, so it should be independent from web server.
Answer: Seems this method works pretty OK actually:

Send off an ajax request (right before form posts) to the server which stores a session timestamp
Post the form
Check difference in the receiving end :)

HTML
<?php session_start(); // must be at the top ?>

<form id="upload-form" enctype="multipart/form-data" method="post">
    <input type="file" name="datafile" size="40">
    <input type="submit" value="Send">
</form>

start-timer.php
<?php session_start();
$_SESSION['time'] = microtime(true);

upload.php
<?php
session_start();
header('content-type: text/plain; charset=utf-8');

if( ! isset($_FILES['file'])
||  ! isset($_SESSION['time'])
||  $_FILES['file']['error'] !== UPLOAD_ERR_OK
||  ! is_uploaded_file($_FILES['file']['tmp_name']))
{
    exit('stuff went wrong...');
}

$time = microtime(true) - $_SESSION['time'];
unset($_SESSION['time']);
echo round($time, 3).'s';

Working sample: http://samples.geekality.net/upload-timer
Comment: Looks promising. I'll see if I can make it work, and edit your answer when I do.
Comment: @GustavBertram Got curious, so tested it out at home, and got it working. Updated the answer and created a working sample as well :)
Comment: Hi. I actually got it working myself, and I did submit an update to your answer, but I guess your update overwrote that. :) Your answer works very nicely, but the bigger surprise is that I got the Apache header answer working.
Comment: @Svish I took your code but didn't get it working, always get a "stuff went wrong...", no matter what file I upload.I realised, that in your code above was missing a ```action="upload.php"```, but even with it, no success on different servers. I would be grateful if you could check your code once more, maybe you find the reason (Unfortunately, I am not savvy enough in PHP programming).
Answer: You simply can't measure anything inside the receiving script.
Just because it is started right after the upload (handled by the web-server) ends.
So, as Svish said, the AJAX call and timestamp in the session would be easiest solution.
Comment: @iWantSimpleLife has proven this wrong. His Apache header solution is pure PHP, and it actually works.
Comment: You either don't understand this solution or didn't read my answer. **Nothing** wrong in it. "Apache header" solution clearly says that measurement is done by the **Apache webserver**, NOT php script. But the receiving script itself CANNOT measure anything, for the reason I wrote. It can only get the result done by someone else. Not to mention that Apache header is NOT "pure PHP solution" but session approach **IS indeed pure php** as it involves nothing else. NOTHING in my answer contradicts with accepted answer. May be you need better understanding of how PHP works. Don't hesitate to ask.
Comment: Then what about this solution? http://stackoverflow.com/questions/2931959/detect-how-long-it-takes-for-a-file-to-upload-php It does not even require changes to Apache. You are only correct in a very technical and limited sense. While the measurement cannot start and end inside the PHP script, there are at least three ways to measure the time it takes to upload a file to a PHP script. Your answer may be technically correct, but it is not useful.
Comment: My answer has 2 points. 1. It correcting your wrong assumption that anything can be measured inside of receiving script - a very important point of understanding the underlaying mechanisms. 2. It has an outline of practical solution which you confirmed as a working one. If I were you, I wouldn't call it useless. It seems it's something personal.
Answer: Look at the link.
http://prefetch.net/blog/index.php/2007/01/02/measuring-apache-request-processing-time/
It shows how to configure apache to log time time the request is receieved by apache.
Then you can use the apache_request_headers fundtion in PHP and extract out that time.
http://php.net/manual/en/function.apache-request-headers.php
Maybe this way, you can figure out the time between when apache starts recieving the file, and when it passes processing to php?
Might need to do some testing, as I have not tried this. Let me know if it works... :)
UPDATE BY @GustavBertram:
Note: I edited the answer instead of my own question, since I want to document the attempt separately for each answer.
I enabled mod_headers in Apache, and added the following config file:
#/etc/apache2/mods-available/headers.conf
RequestHeader set X-Request-Received: %t

I then updated my script:
<form action="#" enctype="multipart/form-data" method="post">
Upload:<input type="file" name="datafile" size="40">
<input type="submit" value="Send">
</form>
<?php

// Get the request headers
$REQUEST_HEADERS = apache_request_headers();

// Extract $t value from header
parse_str($REQUEST_HEADERS['X-Request-Received']);

// Massage string to get float in seconds
$received_time = substr_replace($t, '.', 10, 0);

// Get the current microtime as float in seconds
$current_time = microtime(1);

$upload_time = $current_time - $received_time;

echo $received_time . " \n
";
echo $current_time . " \n
";

echo $upload_time;

I tested it both on my local machine, and on a remote machine in the network, with a 700MB file.
Comment: I managed to get this answer working after updating the php.ini values as indicated in the question. This is actually a very nice solution, especially since it only uses PHP.
Answer: At Apache 2.2.22 and PHP 5.2.17, I use apache_response_headers() lead with flush() command, another way it does not work, i receive header with one variable. ob_end_flush() did not help me.
REQUEST_TIME variable of $_SSERVER is elegant equivalent but pay attention this works from PHP 5.1.
Answer: I have a simple logic in mind
when image is posted for upload
save starting time in a variable and set another variable for e.g. uploadStatus =0, then when upload is done set the variable to uploadStatus = 1  and also save the end time in another variable.
On upload check if uploadStatus == 1, then subtract the starting time from end time and you will get the upload time.
Comment: Then please, modify my example script to show your solution, and put it in your answer.


Socket.IO sample compatible with .Net

Question: I need a Hello World! sample of socket.IO running on windows.
Client: HTML, JavaScript
Server: able to connect to .Net
Have you seen such a sample?
Answer: Node.js and Socket.io should run on windows straight out of the box. Node.js should be able to communicate with your .Net server locally or remotely.
Here is an old question of mine regarding running Node and Socket.IO on Windows 7.
Node.js + Socket.io + Windows 7 / 8?
This question should answer any questions on having the two communicate:
Communicating between Node.Js and ASP.NET MVC Application

Socket.IO sample compatible with .Net


Setup sendmail to relay to another smtp?

Question: My host provides an smtp server for sending mail. I want to setup sendmail to relay all emails to the hosts smtp server. How do you do that?
Comment: I can tell you the term you want is "smart host" but I don't know how to set it up in sendmail.
Answer: It's a little difficult to answer your question without more context on your email environment.  That being said, the general steps would be:
1) Edit /etc/mail/sendmail.cf
2) Search for "DS"
You'll find a section that looks like this:
<code># "Smart" relay host (may be null)
DSrelay:[]
</code>
3) Put the downstream mail server IP in the square brackets.
4) Save changes. Bounce sendmail service.
Again, I have to reiterate that this is a general guideline. Your mileage may vary.
-M
Comment: One thing to note though is that since this is a Debian system, the sendmail binary might actually be part of exim and not sendmail (the sendmail.org mailer).
Comment: Well normally I just point any program that needs to send email to the hosts smtp server but I didn't see an option for it in Anope and I read that it sends mail only by using sendmail.


Can beautiful males wear niqab?

Question: In Quran we can see yusuf (a.s) was very beautiful and was attacked by his master's wife. Now we can see news report of women raping men, so can beautiful males wear niqaab to prevent getting attacked by women ?
Comment: I think you mean hijab, since niqaab is not a requirement even for beautiful women.
Comment: If there is risk of attack, from people, same or different gender or from micro organism like virus, niqaab can be worn, that is why some scholars said niqaab. can be worn if fitna is feared
Comment: Hijab or niqab whatever you say it, it just means a modest dress not necessarily burkha. It is applicable for both men and women. Don't take extra burden on it. Focus individual mind progress that suppress sexual attraction
Answer: All humans wear some kind of Hijab, including men. "provided you with clothing
to cover your bodies, and for luxury" (Quran 7:26), women's Hijab is branched
from a mutual origin. However, it's obviously more sever than what men's Satr
part, I think that this is due to:

Unlike men, women rarely get arousal by opposite gender naked parts
In the famous Kinsey study the majority of the women sample were not
erotically aroused by their observations.1
Kinsey's reports confirmed generally that men are much more likely to get
arousal by visuals2.
Although Gunter Schmidt and Volkmar Sigusch and Fred Klein study3 was published to contradict the data
from Kinsey's report, it reported too that women are less aroused by visuals, however, they are more aroused than men with the use of erotic literature,
this were also the same results reported by a survey study in
1977,4 in which women were reportedly aroused by text
and voice intimate media more that visuals, unlike men.
Another 1979 survey study5 showed that
the majority of women themselves report that they do not enjoy male nudity.
Here's the results from page 479:

thus; we notice that men-raping incidents are much lower than women's
According to the US' National Sexual Violence Resource
Center,6 "One in five women and one in 71 men
will be raped at some point in their lives". The difference is obvious.

Biologically, men are much more physically stronger than women
Probably this does not need citations to prove, men's abilities make them able
to defend themselves more than most mature women.

I personally believe that for those reasons women are in need of protection more than men. There will be always some odds (for example the few percent of men who get raped), however, this should not affect the general rule.
References
1 Alfred C. Kinsey et al., Sexual Behavior in the Human Female (Philadelphia: Saunders, 1953).
2 Note that Kinsey's reports had many controversies, some of which are
highly subjective
3 Gunter Schmidt, Volkmar Sigusch, and Fred Klein, "Sex Differences in Responses to Psychosexual Stimulation by Films and Slides," The Journal of Sex Research 6, no. 4 (1970): 268–83, http://www.jstor.org/stable/3811905.
4 Patricia Gillan and Christopher Frith, "Male-Female Differences in Response to Erotica," Love and Attraction, 1979, 461–64.
5 Mark Cook and Glenn Wilson (Eds.), Love and Attraction. An International Conference, 1st ed. (Pergamon Press, 1979), 479, https://libgen.li/file.php?md5=5b2523267d7af0c8edc638da72372f56.
6 M. C. Black et al., "The National Intimate Partner and Sexual Violence Survey: 2010 Summary Report" (Centers for Disease Control and Prevention, National Center for Injury Prevention and Control, 2011), http://www.cdc.gov/ViolencePrevention/pdf/NISVS_Report2010-a.pdf.
Answer: From an islamic standpoint, the reason the niqab is either recommended or required for women (depending on the interpretation) but not for men is that there is no directive from the Quran and Sunnah that instructs men to cover their faces for modesty.
There are several hadiths that indicate that the Mothers of the Believers (the Prophet ﷺ's wives) and the female companions covered their faces. In contrast, there is no such precedent among the male companions of the Prophet ﷺ.
In the Quran, Surah al-Nur (24:30-31) instructs men to lower their gaze and guard their chastity. The directive for women includes not only lowering the gaze, and guarding chastity, but also covering their charms; as Allah ta'ala says:

"Say to the believing men that they should lower their gaze and guard
their modesty: that will make for greater purity for them: And Allah
is well acquainted with all that they do. And say to the believing
women that they should lower their gaze and guard their modesty; that
they should not display their beauty and ornaments except what
appears thereof; that they should draw their veils over
their bosoms and not display their beauty except to their husbands,
their fathers..."

Of course, as is well-known, the scholars have differed regarding the extent of covering required by this verse and similar verses. Some believe the hijab should cover everything except the face and hands, while others have understood this as covering the entire body including the face and the hands. This difference in interpretation dates back to the time of the Prophet ﷺ's companions.
As to why there are stricter covering requirements for women, this could be attributed to several factors; some of which could be the following:
1. Men and women experience attraction differently. Men tend to be more visually stimulated; they are often more drawn to physical appearances. This is why the Islamic guidelines for women emphasise covering the body. Women, in contrast, tend to be attracted by a wider context that includes a man's character, behaviour, and social or material status. On average, physical attractiveness is more important to men than women.
2. Women tend to be more reserved in matters of attraction. When a woman is attracted to a man, she still prefers to be approached rather than actively pursuing the man. In contrast, when a man is attracted to a woman, it is more likely for him to pursue the woman. Therefore, in the case of a man being attracted to a woman, there is a higher likelihood of subsequent haram interaction or action than vice versa.
3. Women tend to be physically more vulnerable than men which also means they need more protection. In most cases, it is easier for a man to defend himself against harm than it is for a woman.
4. Men and women have different social roles. Men are the protectors and providers for their families; whereas women have no such responsibility. A woman's main responsibility is to take care of the home and family. Given these roles, it is more practical for women (who are expected to spend more time at home) to observe the veil than it is for men (who are expected to engage in more public and external roles).
As to whether it is permissible for a man to cover his face: Covering the face (or part of the face) is permissible in principle, especially if it is done for a practical reason; such as wearing a motorcycle helmet, or a surgical mask. However, wearing the niqab (or similar clothing that is worn customarily only by women) is not permissible for men, as this would come under men imitating women, which is in principle forbidden in Islam.
Answer: It is haram for men to wear the niqab, since that's what the women are ordered to wear by Allah. So the man who wears a niqab would be imitating women:
Jami` at-Tirmidhi 2784
Narrated Ibn 'Abbas:
"The Messenger of Allah (ﷺ) cursed the women who imitate men and the men who imitate women."
Comment: Why're people disliking me I'm right?
Answer: I did some research and I am posting my answer so it can be helpful to others.
Niqaab (a face clothing that covers nose and mouth) can be worn by any gender if he or she fears some attack, it can be from opposite gender or micro organism like virus. Now after COVID, people are used to wearing masks (just like niqaab but with more protection against micro organism) , so it is now easier for anyone to wear niqaab. I know of instances where males were touched by females without permission in crowded places and I think wearing niqaab or mask can reduce this type of attacks.

Can beautiful males wear niqab?


HTML5 inputs on the Android browser

Question: iPhone's Mobile Safari seems to recognize most new HTML5 input types, in particular the ones detailed here, such that tapping in an input declared like so:
<input type="number" id="myInput" value=""/>

presents the iPhone's numeric keypad.
However, in the Android browser, the usual text keypad is shown when tapping the same input.
Is there a workaround for the Android browser or an alternative attribute that can be set or even a library I can include to have the android browser respect this setting?
Answer: if you specify on the input element the type as "number" it will automatically open with the numeric keypad
example
<input type="number" pattern="[0-9]*" name="amount_zip" value="loading.."></input>

the pattern attribute is for iPhone,
you can also get more info on inputs here
Answer: I just tried <input type="number"> with a Xoom (Honecomb, I think) and it does cause the numeric keypad to open, which is great, but the field only appears to allow positive integers.  Hitting the '-' and '.' keys on the keypad have no effect.  Adding relevant min / max attributes or setting a proper pattern don't seem to have any effect.  In other words, if you want the keyboard to appear and your numeric field only needs to be zero or a positive integer, this will work.  Otherwise (floats, negative numbers), you'll have to use text.
(I realize I'm not answering the question here, I would like to have left this as a comment for the previous answer, but can't figure out how)

HTML5 inputs on the Android browser


Actionscript object number of properties

Question: How can I get the number of properties in a generic Actionscript Object? (Like Array length)
Answer: You will have to loop over all element to count them:
function objectLength(myObject:Object):int {
 var cnt:int=0;

 for (var s:String in myObject) cnt++;

 return cnt;
}

var o:Object={foo:"hello", bar:"world"};
trace(objectLength(o)); // output 2

Comment: Seems to call out for a better API, such as javascript's Object.keys()
Answer: Even shorter code here:
var o:Object={foo:"hello",bar:"world",cnt:2};
trace(o.cnt);  // output  2;

Just remember to update the very last argument in the object list if ever anything is added to it.  That's the main downside to this approach, I think.  And now, of course, the .cnt does not actually return the true list length, but rather it is the list length - 1.
Comment: This could get tricky. `cnt` could become inaccurate in cases where a property overwrites an already-existing property, or when a property gets deleted without existing. Thus, checks would be needed every time the object is modified.