How do I turn off the light that comes out of my moto droid's usb port?

Question: When I plug my moto droid into a charger a bright white light comes from the micro usb port. It is super bright when its on my nightstand and the lights are out.  It drives me nuts.
Answer: Simple hack: cover it with a small strip of black sticker. Or, cover the nightstand with a handkerchief.
Complex hack: Find if the USB port driver allows you to turn the light off; I think that's quite unlikely, as it may be hardwired to the hardware itself.
Comment: Its hard to cover the light because it emits around the radius of the micro-usb plug.  I  could cover the whole phone with a handkerchief but I was hoping for a more elegant solution, that hopefully just as easy.
Comment: @Matt: an alternative to black sticker is a black permanent marker; I personally wouldn't do it that way though. A probably more elegant solution would be to find a charging/multimedia dock that would cover the USB port.


Who decides about text usability, the ux person or the technical writer?

Question: A technical writer wants to change a label of a table column. He says it is not clear. I, a usability expert, am against it. Who should have the last word?
Comment: the users or product owner
Comment: Forget the technical writer, hire a content writer.  The difference being, one writes for Engineers to understand, the other focused on "consumers".  Generally I have found that the quality of help and UI text is better from those who lean towards "content writing" rather than traditional "technical writing".
Answer: Ultimately, your instincts should be supported by data extracted from your users. That's not always the case, so why not A/B both of your theories and see which is better received?
I run into this a lot - it is mostly assumptions by one entity on behalf of the user. In my case, it's usually "our users want an iPhone app" - these unqualified statements can be really damaging in the long run. If someone were to say "This is not clear," I'd ask for the opinion of others (or the person saying it to demonstrate that it directly impacts the user). If they feel so strongly about it, they should back it up.
On the flip side, I wouldn't say that just because you're the usability expert, you know that it is right - you are allowed to follow your instincts, but I think it is unfair to ask someone else to produce evidence without you putting in the same effort. Ultimately, I think it is best settled by an A/B with both findings.
Answer: Per Chad's comment, the product owner is the arbiter of such decisions. It is up to you and the technical writer to make your case for the change; vice versa it is up to the product owner to gather the evidence from you two and any other sources.
Answer: Neither of you.
Instead, try to collect empirical data by doing research. Tie the results of your research to formal KPIs for the product's project. And be prepared to step back if the results don't go your way.
Answer: Test It.
Go and wander around the shops at lunchtime (ie do not ask people in your company - who will be too close to the jargon) and ask random people what the two alternate label words mean to them.
Answer: I agree that user testing is great, however I have found that there's almost never the time or resources to test UI text formally. The "last word" is typically (for better or worse) the product owner, but all parties should have the opportunity to make their cases.
There's info you haven't provided in the question... such as, WHY does the writer think it's not clear? Is it possible that you're too close to the functionality and are  making assumptions about the user's knowledge that the writer can see more objectively? Does the term in question make sense with the other text on the screen? Are there style guidelines that the writer wants to adhere to that the other term breaks?


matlab fix slicing to execute parfor

Question: Just beginning with parallel stuff...
I have a code that boils down to filling the columns of a matrix A (which is preallocated with NaNs) with an array of variable length:
A = nan(100);
for ii=1:100
    hmy = randi([1,100]); %lenght of the array
    A(1:hmy,ii) = rand(hmy,1); %array
end

Simply transforming the for in a parfor does not even run
parfor ii=1:100
    hmy = randi([1,100]); %how many not NaN values to put in
    A(1:hmy,ii) = rand(hmy,1);
end

because the parfor does not like the indexing:

MATLAB runs loops in parfor functions by dividing the loop iterations
  into groups, and then sending them to MATLAB workers where they run in
  parallel. For MATLAB to do this in a repeatable, reliable manner, it
  must be able to classify all the variables used in the loop. The code
  uses the indicated variable in a way that is incompatible with
  classification.

I thought that this was due to the indexing on the first dimension and tried a workaround that did not work (same error message as before):
parfor ii=1:100
    hmy = randi([1,100]);
    tmp = [rand(hmy,1); NaN(size(A,1)-hmy,1)];
    A(:,ii) = tmp;
end

How can I index A in order to store the array?
Answer: You cant partially change the row or column data in A. You have to do either a full row or full column inside parfor. Here is the updated code.
A = nan(100);
parfor ii=1:100
    hmy = randi([1,100]); %lenght of the array
    temp = nan(1,100);
    temp(1:hmy) = rand(hmy,1); %array
    A(:,ii) = temp; %updating full row of iith column
end

Answer: First of all, the output variable (A in this case) will be a sliced variable in case of parfor. Which means this variable will be sliced in different part for parallel calculation. The form of indexing in the sliced variable should be same for all incident. Here, you are creating a random number(hmy) and using (1:hmy) as a index which is changing every now and then. That's why your output variable can't be sliced and you have the error.
If you try with a fixed hmy, then it will be alright.

matlab fix slicing to execute parfor


Flash Flooding on Titan?

Question: From what I've researched, Saturn's moon Titan is believed to have a methane cycle throughout its seasons. Particularly, during the winter season, methane rain falls, filling Titan's lakes and rivers. However, between low wind speeds and gravity, the storms generally seem relatively tame, assuming one is already equipped against Titan's cold and darkness. Could these rainstorms be powerful or unexpected enough to directly threaten a base of astronauts living on Titan? Could Titan's lakes rise fast enough to catch someone off guard or swamp a campsite? I know there's still very much we don't know about Titan, but I was thinking of a monsoon/flash flooding scenario and do not know if that is vaguely realistic. If it helps, assume the resident humans are somehow hopelessly ignorant of Titan's weather.
Answer:
Could these rainstorms be powerful or unexpected enough to directly threaten a base of astronauts living on Titan?

Sure. On Earth we are used to expect certain weather because today we have a large network of observatories monitoring it and in the past we had a large collective memory of empirical observations helping us forecasting the local weather.
Of course both of these will be missing on Titan upon arrival and will take time to build up. Apart from "common sense" advice, like not setting a camp in the bottom of what looks like a flow valley, colonist on Titan will be blissfully ignorant and at the mercy of the elements, and almost by definition the weather will be unexpected. To further increase the danger, we are not talking about liquid water, in which more or less we can manage or fight to float, but liquid methane, which is a tad colder and therefore more dangerous.
Answer:
Base is built in a wadi.

source
It is a great place for a base because the natural walls can help take some of the pressure for the pressurized interior of the base.

Wadi floods!

It is scary!  The methane rolls down the wadi.  It covers the base.  It could have been predicted but the builders were planetary scientists and did not recognize what the wadi was.

Base freezes under the methane.

Built things act as a dam.  The methane pools up in the wadi and freezes.  The base is underneath.  But it is no big thing to tunnel up to the surface.

Base frozen under the methane turns out to be better than it was.

The methane is not very heavy.  The base was already overbuilt and can easily withstand the weight.  Having the base "underground" turns out to have advantages later in the story when new unexpected challenges turn up.    Engineers who did not recognize they were building in a wadi and were castigated earlier in the story now strut around, taking credit.
Answer: If they are foolish enough to establish their base on danger zones.
Now, water or any other liquid will flow to the line of the lowest resistance and signs of previous floods should exist. Even if they are not, common sense should tell them the main habitat should be on the upper ground. Be it only they'll appreciate a good comms reception, which is always better with direct line of sight. (no, I don't believe they'll carry solar panels to Titan, too much weight for too little reward, so sunlight exposure is not an issue).
This being said (by L.Dutch too), there are some circumstances that put the risk of danger from Titan's methane flooding at a lower one than Earth's water.

the density of liquid methane is 2/3s of that of water (0.657 kg/m³ more precisely)
the Titan's 0.138 g

This two mean that the energy of a methanefall will have just 9% of the energy (per volume) of a waterfall from the same height on Earth.

When you are out in the open, if you're skilled enough on hop-running (kangaroo style), you may get out of the way of a flash flooding (or even race in front of it in the same direction without getting caught. I don't know for sure, I should check what height is required for the methane to flood from to get to the speed a human can attain in low-g).
Even more, jumping or climbing on higher ground should be less of a problem for the capabilities of an average human (assuming they didn't stay on couch-potato position long enough for the muscular atrophy to set in).

Now, concerning silt, mud or rocks that a flash flood tends to dislocate on Earth and try to pile on you.One of the NASA pages informs that the liquid water is lava, the dunes are made of solid hydrocarbon (with a coffee ground like size), and the tectonic plates are likely made of water ice.
All of those hydrocarbons are less dense than water, so if you survive under a 3m snow set on top of you by an avalanche on Earth, you should be able to survive uncrushed under... say hydrocarbons with 0.8 density of water at 0.138g... with about 27 meters of typical Titanian solids on top of you and you will be in a risky-but-maybe-survivable situation (assuming you have enough air to breath and the thick coat your using to fend off the -180C worth its money)

Falling into a liquid methane pool? Maybe we got you covered (that is, if you don't take a plunge covered with just your swimsuit)
Most of the hydrocarbons (liquid methane included) are non-polar and hydrophobic. Which means that a 100% cotton towel you always carry a towel is space, don't you? will likely not get liquid-methane-wet (awww, no fooling around with wet T-shirt contests or the like in college).
Now, don't take the thing with the cotton towel literally, but... I'm pretty sure one can micro/nano structure the surface of the suit for outside activities in such a way that, with minimal heating across (BTW, the latent heat of evaporation for liquid methane is 8.17kJ/kM which is only 20% of water's) will create a layer of gaseous methane trapped into a the nanostructure and keeping the liquid methane away from your suit - such nanostructures can stay dry underwater for days on Earth, I'm pretty sure the same trick can be pulled for liquid methane too.
That should take care of your survival would you be to fall into a liquid methane pool or have it dumped on you by a flash flooding.
Answer: I suspect that it's not that likely but is possible. For a story it should be easily possible to suspend disbelief. To increase the believability I would have a large more distant lake over top with methane. Assuming the methane can erode some of the sediment it should be possible to imagine a catastrophic failure moving a lot of methane like this:
https://www.youtube.com/watch?v=BNFQ1EJX4h0
Not going to be as rapid or as dramatic but could still be deadly.

Flash Flooding on Titan?


Path Integral Evaluation

Question: I've seen the path integral formulation now in a couple contexts (propagator in quantum mechanics, and coherent state functional integral in many body physics). I'm now struggling with how to actually compute path integrals. It seems that for Gaussian actions it is a kind of continuous generalization of Gaussian integration. I was wondering if anyone had any references that explain computing path integrals in this context and perhaps offer practice in evaluating them.
Comment: Well, except for the Gaussian case (where it works *exactly* as for ordinary Gaussian integrals), one rarely explicitly computes the path integral. (And in the cases I know, the trick to evaluate it is usually to get around actually performing the integration)
Comment: I don't like to give book recommendations, but Hagen Kleinert has made a cottage industry out of the explicit solution of path integrals and has published a number of editions of his textbook "Path Integrals in Quantum Mechanics, Statistics, Polymer Physics, and Financial Markets" with an ever increasing number of applications. I would agree with the others here that a good look at Kleinert's book you will probably remove your interest in spending any more time on path integrals than necessary to move on to better methods.
Comment: Take a look at the "related" links on the right hand margin of the page: `----->`. Some good stuff there.
Comment: Kleinert (as well as Grosche's big handbook of path integral solutions) is indeed quite a nice book to have, but from what I can remember none of them or close to none are QFT path integrals, it's mostly QM path integrals.
Answer: You can refer to chap 9 of "An introduction to quantum field theory" of Peskin & Scroeder, which includes a detailed calculation of path integral using the original physical definition of path integral. After the brutal treatment, they will show you  more modern treatment using generating functional.
Answer: Another good source on path integrals and in particular their computation is A.Zee's book "Quantum field theory in a nutshell". Path integrals are introduced in the first chapter, so the prerequisite for reading the first chapter (and actually most of the rest of the book) are basics in theoretical mechanics (Lagrange and Hamilton's formalism) and basic knowledge about quantum mechanics. Furthermore Zee claims that one only needs to know to compute Gaussian integrals in all variations to do a path integral.
He also shows that by developing Z(J) of an interacting QFT as double Taylor series in $J$ and the coupling constant of the chosen theory one is led to the introduction of Feynman diagrams which is really nice. Zee's book is rather intuitive, but less rigorous. For a more rigorous formalism Srednicki's book on QFT would be better. But the latter has less computation examples and requires a higher level of understanding (i.e. is more abstract).

Path Integral Evaluation


Restoring all contacts from Time Machine

Question: My contacts on my iMac, OS 10.11.3 and iPad and iPhone are presently messed up beyond repair.  There are hundred of duplicated contacts and a number of duplicate groups.  I'd like to go back in my TIME MACHINE and restore all of my contacts for both my Mac and iCloud.   I can see 2 weeks back everything was good.  I do not know what to do from there.   RESTORE?
Answer: You have a backup - that's good, and it's got valid data which is even better.
First, I suggest taking a quick backup of your contacts as they stand right now.  It might not be required, but in case you mess up the restore, or even if you subsequently realise you now have recent updates missing, it's wise to have a safe copy.
Firstly, take a fresh Time Machine backup, and then we will make a local extra backup archive just of your contacts:
Contacts Menu > File > Export > Export Contacts Archive - stick the backup file whateveryoucallit.abbu anywhere, like your desktop for now
Now you have multiple safe copies, you can go into Contacts, and just delete everyone.  All your groups, all your contacts.  You can get them all back from your export you just made.
To restore your contacts, you need to follow these steps:

1 Open Contacts
2 Enter Time Machine
3 Go back in time to find your good data

You've already got this far, now you need to actually perform the restore...  The remaining steps are:

4 Select what you want to restore, there are various ways to do this, one at a time (no thanks, or click on the top entry, then shift click on the bottom entry in a list to select the whole list etc.  Try it a group at a time perhaps, and then go back onto Contacts to show it has arrived.
5 Click the restore button
Comment: I appreciate the instructions.  They make sense and I will be working on it tomorrow the way you instructed. Once I've completed I will let you know how it worked.  I appreciate your explanation.
Comment: Thank you- this saved me!!! Worked like a charm.


Cronjob based on system time or its own time elapse

Question: Cronjob is based on the system time or its own time elapse? If it is system time, when I change the system time manually, will cronjob follow the new set up time accordingly?
Answer: If you move your clock from e.g. 12:04 to 12:06 and you have jobs scheduled for 12:05, these will not run.
If you have to run a job at 12:05 each day or at the earliest opportunity after that (after a power up, or system clock), then run that job every minute (or with a longer interval if that is acceptable) and have its script check if it was last run for this day based on some status file. If that status file is there and up to date, the script should exit immediately (i.e. it ran at 12:05 or the earliest opportunity it had after that to run). If not, set the status file and run the rest of the script, so any further invocations won't do anything until the clock reaches 12:05 the next day.
Especially if the job takes longer, it is important to update the status file first and then continue running, otherwise the 12:06 check will not find an updated status and start running another job in parallel.
Answer: cron uses the system clock, which it checks every minute. For changes to the system clock, the following extract from the man page might be useful:

Special considerations exist when the clock is changed by less
  than  3    hours,  for  example at the beginning and end of daylight
  savings time.    If the time has moved forwards, those jobs which
  would have run in  the    time  that  was skipped will be run soon
  after the change.  Conversely,    if the time has moved backwards by
  less than 3 hours, those  jobs  that    fall into the repeated time
  will not be re-run.
Comment: Good to know the 3 hours constraints. Not sure where do you read this, I couldn't find it on my MacOSx unix man cron.
Comment: This is from the man page for Vixie Cron, running on Ubuntu 15.04. A similar message is shown on CentOS 7 systems.


How can I convert a mathematically defined shape into a 3D printable G-code file?

Question: Suppose I have the X, Y, and Z coordinates (either in a list or a function z = f(x,y)) that defines a shape as the one provided and I want to 3D print it with a solid bottom, is there an easy way to do this? If not, how can a functionally well-defined shape be put into a 3D modeling software like FreeCAD?
Answer: For stuff like this, OpenSCAD is your friend. There are several different approaches you could take:

Generate an image file with grayscale color representing the height of the function on an XY grid, and use the surface feature to import it as a heightmap.

Write the function as a mathematical expression in OpenSCAD language, and write a module to generate a polyhedron by iterating over a sufficiently fine coordiante grid, sampling the function, and producing points and triangles.

Use a library someone else has already written for this purpose. I'm not aware of specific ones but pretty sure there are quite a few.
Comment: I try to use OpenSCAD when designing and it was my first thought when seeing the question. I have insufficient brain cells to contribute in the manner you did, however.
Answer: Another option is to use Full Control Designer where you can define the path using Excel formulas and it will generate the GCode for you.
Answer: You may generate a .stl file from your mathematical definition. You may write a program using a language of your choice to compute the .stl file.
Your image shows a lot of rectangles, each rectangle may be described as two triangles. The .stl file is a (very long) list of all that triangles. Each triangle is defined by the X, Y, and Z coordinates of the three corners.
solid name

facet normal ni nj nk
    outer loop
        vertex v1x v1y v1z
        vertex v2x v2y v2z
        vertex v3x v3y v3z
    endloop
endfacet

endsolid name

Each n or v is a floating-point number in sign-mantissa-"e"-sign-exponent format, e.g., "2.648000e-002". The triangle vertices should be sorted using the "right-hand rule", i.e. the vertices are listed in counter-clockwise order from outside.
The normal vector ni nj nk is set to zero.
The G-code file is generated from the .stl file using the slicing software for your 3D printer.
See https://en.wikipedia.org/wiki/STL_(file_format) for details.
Answer: Not sure what you're asking exactly, but you can use this workflow:

SideFX Houdini: math function + STL file generation

(optional) FreeCAD: Import STL as mesh, do whatever you need to do in FreeCAD, export to STL

a slicer: import the STL and slice it.


Factory reset my RCA Viking Neptune 10 tablet

Question: Trying to factory reset my RCA Viking Neptune 10 tablet it has no volume button, no home button, only a power on button and detachable keyboard. Any suggestions are truly appreciated!
Comment: Do you have a home button?
Comment: Or a pinhole with "reset" printed near it?
Comment: Thank you helper, there is no home button on the tablet. There are some holes on the back of the tablet but none are marked. If I find which one is the reset what would I do please?
Comment: Would reading the user manual tell you this? RCA publishes pdf files for their models.
Answer: As wbogacz suggested i found the user manual and found out that there is a reset button which can be located at number 9 of the following image of the backside of the device:

Press that button to reset the tablet (then press and hold the
Power button for 4~5 seconds to turn on the
unit).
Hope this solved your query.
Comment: Thank you so much everyone! It is so strange I tried to press the reset button with a pin and then turn on the power and I still see the same message - "to start android enter your password" How long do you need to press the reset button? Maybe there is something I am missing. Thank you so much!!!


from where we send json payload when using APNs?

Question: i want to know that when we want to use push notification service.From where we send json payload, from our app or it may be generated on server? if it has to be sent from our app then how do we send json payload+device token to our own web server?
Answer: It can't be sent from your app. First off that would make no sense, if your app is running why would you have it send a push notification to itself.
Second, in order to communicate with the APNS servers you need a per app cert file to sign requests. You cannot distribute it without compromising the security of your applications push service.
Answer: Louis is absolutely right that you can't send messages from your phone, and his reasons are spot on.  You'll definitely need to communicate to your own server, which will then send things on to Apple.
To send messages to your own server, look at ASIHTTPRequest - it's a fantastic package that makes it really easy to send HTTP requests.
On your server, you'll need to keep open a persistent connection to Apple's push service from your own servers and translate the JSON from the phone into a message to deliver to Apple.
There are at least two services out there that take care of the heavy lifting for you:

Urban Airship (full disclaimer, I work at Urban Airship)
iLime

You might want to look at one of these services to help you implement this.  Again, I work at one, so take this with a huge grain of salt.
If you want to see some examples of how to use ASIHTTPRequest to send a device token to a server, you can look at our push sample application on bitbucket.


Can the additive and the multiplicative inverses to an element in $Z_p$ be the same?

Question: Does it contradict the axioms of a field? I think not.
If not so there need to be $a \in Z_7$ and so $3+a=0$ and $3\cdot a=1$ but I can not find this $a \in Z_7.$
Answer: If $a+b=0$, then $b=-a$. If simultaneously $1=ab$, then $1=-a^2$ which is equivalent to $a^2=-1$. This is possible in $\Bbb{Z}_p$, if and only if $p=2$ or $p\equiv1\pmod4$.
So you're right. This cannot happen in $\Bbb{Z}_7$.
Comment: @gbox: You were discussing field axioms. Therefore I assumed that you are only interested in the case, where $\Bbb{Z}_p$ is a field. In other words I assume that $p$ is a prime. Kaj's extra examples (+1) concern the cases where that is not the case. If $m$ is not a prime, there is an element $a$ such that $a^2=-1$ if and only if $m$ is not divisible by four, and all its odd prime factors are $\equiv1\pmod4$.
Comment: Multiply the previous equation by $-1$. Ahh. It is phrased a bit oddly. Let me clarify.
Comment: What do you say about: http://math.stackexchange.com/a/863700/103441/
Thanks
Comment: Thanks a lot! I understood your proof for  $1=-a^2$ but where did $a^2=-1$ came from?
Answer: Absolutely!  I wrote a Python program a while ago to generate some examples for general quotient rings $\mathbb{Z}_n$.  Here are some:
$2$ and $3$ $\pmod{5}$
$3$ and $7$ $\pmod{10}$
$5$ and $8$ $\pmod{13}$
$4$ and $13$ $\pmod{17}$
Anyone interested can find my Python code here.  In general, let's suppose a pair of such elements exists in the ring $\mathbb{Z}_m$.  They will satisfy the system $x+y \equiv 0 \pmod{m}$ and $xy \equiv 1 \pmod{m}$, and from this we discover that such a pair exists if and only if there exists an $x \in \mathbb{Z}_m$ such that $x^2 \equiv -1 \pmod{m}$.

To expand on your specific question regarding $\mathbb{Z}_p$ when $p$ is prime, note that if there is an element $x$ such that $x^2 \equiv -1 \pmod{p}$, then in particular $x^4 \equiv 1 \pmod{p}$.  That is, there must exist an element of order $4$ in the multiplicative group $\mathbb{Z}_p^\times$.  Now, it is a theorem that $\mathbb{Z}_p^\times \cong \mathbb{Z}_{p-1}$ when $p$ is prime.  Finally, since $\mathbb{Z}_{p-1}$ is cyclic, it will contain an element of order $4$ $\iff$ $4|(p-1)$.  So this phenomenon occurs in $\mathbb{Z}_p \iff$ $p \equiv 1 \pmod{4}$.
Comment: @gbox, the claim is that there will exist two elements that are each others additive and multiplicative inverse in $\mathbb{Z}_m$ whenever $m = a^2 + 1$.  This is a sufficient condition, but not a necessary condition (useful for generating examples).  I edited my response with a necessary and sufficient condition.
Comment: @gbox, I added some detail to my response so that, hopefully, it ties in with Jyrki's response and makes a bit more sense.
Comment: Thanks! I do not know Python. but I did not understand your question


Sale of apps on AppExchange

Question: Can the customer buy the apps on App Exchange platform without subscribing to sales force?
Answer: Yes, you can build OEM apps that customers pay you for and then you pay Salesforce for the licensing.
Technically, you can market something on the AppExchange that has nothing to do with Salesforce, but my guess is your listing will get taken down.
Answer: @Abhi,
The following thread has the necessary answer that would help you understand the differences between Salesforce's ISV and OEM Appexchange Partnership Models.
Salesforce OEM license restrictions for end users
Also, watch this video to understand more about the Partnership models - https://www.youtube.com/watch?v=_oV9LthQ5O0

Sale of apps on AppExchange


Instalment interest calculation in Canada for individuals

Question: I made no instalments payments in 2023 as I thought my net tax owing in 2023 would be below $3000. I received instalment reminders from CRA and I ignored the emails. Now, I believe my net tax will be $3600.I am trying to calculate the instalment interest I will be paying when I file my 2023 T1 (personal tax return). I cannot reduce my taxes as I am over 71 years old and have no RRSP deductions to claim.  If the instalment interest is high, I am thinking of opening a spousal RRSP as my spouse is 69 years old. I have no other avenues of reducing my 2023 taxes. Can someone help me in the calculations and determine my instalment interest charge?
Answer: After reviewing many CRA websites I believe I have an answer to my own question.
For 2023, instalment reminders were all due March, June, Sept and Dec 15. My amounts due were $1000 for both March and June and $1500 for both Sept and Dec. Since I made no instalments in 2023, I will be charged the prescribed CRA interest of 9% up to date of due date of filing the T1 tax return April 30, 2024 or earlier. Calculated as follows:
Days from March 15- April 30, 2024: 405 x $1000 x 9% /365= $100
Days from June 15 - April 30, 2024: 315 x $1000 x 9% / 365= $78
Days from Sept 15-  April 30, 2024: 225 x $1500 x 9% / 365= $83
Days from Dec 15 -  April 30, 2024: 135 x $1500 x 9% / 365= $50
So, the instalment interest charge will be approximately $100+78+83+50= $311*

the $311 will be lower if I file my T1 return earlier than April 30, 2024


How do gull wings help?

Question: I know that gull wings are shaped how they are for maximum help with a decrease in induced drag and increase in lift, but how do they do it? This is my homework!!!
Comment: I think they were more to get the engine higher off the ground for prop clearance. https://en.wikipedia.org/wiki/Vought_F4U_Corsair
Comment: The wings on the Navy 4FU Corsair are actually REVERSE gull wings.  Gliders and real seagulls have them the other way around.  For birds, the anhedralled wing tips would give better roll control in side gusts and make the wing stronger to positive G loading, helping them work the wind to stay aloft.  Possible benefit to a sinking glider may be to "trap" a bit more high pressure under the wing.  They are seen on the Fafnir of Dr. Alexander Lippisch in the early 1930s.  Dr. Lippisch knew a thing or two about gliding.
Answer: Aside from the ground clearance thing Crossroads mentioned, the main aerodynamic benefit of gullwings is to achieve a clean 90 degree intersection with the fuselage, which eliminates the need for a big wing root fillet fairing.
Answer: Gull wings are a solution to two problems.
Requirement for increased speed will require a big propeller. The problem would be the propeller tips would hit the ground. You can solve this by either having longer landing gear (aircraft sits higher) or pushing the engine further out infront.
The problem with longer landing-gear is it needs to be heavier to ensure sufficient strength. Pushing the engine out further increases the overall length of the fuselage, good for stability but not in a fighter which needs to make tight turns.
Looking at the corsair you can see how the forward part of the fuselage is quite long with the engine stuck on the end. I believe this was the most they could do without sacrificing maneuverability. To get additional clearance without a heavy landing gear the gull-wing brought the gear height to a more manageable length.
The second issue is the fact that the Corsair was intended for carrier landings, which meant the landing gear had to be strong. A long landing gear would need to be very heavy to have the required strength. The gull-wing allowed a shorter (lighter) landing-gear.

How do gull wings help?


What happened to Dorian at the end of The Mask?

Question: At the end of The Mask Dorian gets flushed down a toilet that the Mask just conjured up by painting a flushing handle on a wall nearby. I never quite got what is supposed to have happened with him. Was he just flushed out of the building and thrown out somewhere? Did he drown? I don't think he was shown in the later scene where all his people were getting arrested. So what ended up happening to Dorian?
Comment: The same thing that happened to Captain Hook at the end of Hook when the stuffed crocodile fell on him…
Comment: I seem to remember him being collected after, but maybe that's a mental retcon.
Answer: Dorian died (probably).
In the original script, he's wearing the Mask at sunrise. It falls off of his face and he's killed (literally 'blown to smithereens') by the TNT stick that he's been juggling.

DORIAN/MASK (CONT.) Do you hear? I'm immortal!
[The sun's rays hit the Mask. In an instant, he transforms back to
regular Dorian. The mask pops off Dorian's face -- useless.
Dorian stares dumbfounded at the TNT stick in his hand as it --
KA-BOOM! Dorian is blown to smithereens.]

The novelisation (and movie) are rather more coy, setting up the possibility that he might have somehow survived. We're supposed to just accept that he got flushed away and isn't a problem any more.

Kellaway might not be the smartest cop in world, but he knew better than to disagree with the man who hired the Chief of Police. He shook his head.
"Okay. Whatever you say. Ipkiss is a hero and Tyrel is The Mask. Where is Mr. Tyrel anyway?"
Stanley smiled. "I wouldn't worry about him. I think all his plans ... went down the drain"
Comment: So the original script had a darker ending for dorian and final movie decided to just leave it ambiguous. I guess that also explains why the mask does not work for Ipkiss when he wears it in Dr Neumann's office
Comment: @user13267 - Dorian also killed a bunch of extra people in the script. At the end of the day this is a family film, so you can't be too violent.
Comment: They should have gone with the style of the comics just to see what would happen
Answer: It's not clear, but we can discern some good ideas.
It's appears (at least to me) that the Mask affects the world in real ways:

When the bank was robbed, it really had a lot of money missing from its safe.
When the crooked mechanics were punished, they really were impaled on muffler pipes -- but not killed.

So something unpleasant really happened to Dorian. But what? Another factor to consider is that the Mask appears to amplify the personality of the wearer. When Dorian wore it, murder and terror followed. But Stanley is a hopeless romantic with a massive streak of ironic humor. When he was confronted with force while wearing the Mask, at another time in the movie, he danced with them -- without hurting anybody. So some thoughts on Dorian's disposition:

He did not die.
He is no longer able to hurt anyone at the moment.
As Stanley knows enough about Dorian's nature, I would posit that Dorian is no longer able to hurt anyone in the future.
Stanley knows Dorian is a career criminal. So where would an ironically humorous hopeless romantic send a career criminal? My answer would be a chain gang of some sort.

My guess, which is only as good (or bad) as anyone else's, is that Dorian was flushed to a place where he is in chains. He is somewhere unpleasant like a Russian Gulag.
Alive and in a prison of sorts; And in a position to not hurt anyone now or in the future.


Wife created her own SNAP/EBT (Kentucky) case while on my mother-in-laws case, can this really lead to an investigation?

Question: I'm not overly familiar with SNAP/EBT policies, my girlfriend and daughter were on my mother in law's case(we live on the same property) but after a disagreement my wife called and removed herself from the case and created her own. The representative she spoke with told her it would not affect my mother-in-laws benefits and that next month my wife would receive her own separate benefits. Since this my mother in law has been in a rage claiming they've opened an investigation into her case over it and is worried about getting in trouble and insists that I make my wife and daughter leave for putting her freedom in jeopardy. After some digging I've come to the understanding that this is a highly unlikely scenario because her case worker to was informed after my wife left the SNAP group. I feel like she is lying out of spite and I can't seem to locate any in-depth written policies about this.
Comment: Is she your wife, or your girlfriend? I'm confused, is that two different people (wife / girlfriend) or the same person?
Comment: There is a lot of information that is not clear here, especially about the household composition, ages, and how everyone is related to everyone else-- it tends to make a big different for public benefit eligibility if someone is your girlfriend or wife, for example. There isn't enough of that information here to inform an answer. Calling a county case worker (your wife's would be a good start) will probably be the best way for you to get definitive answers.
Answer: There could absolutely be an investigation of some sort, but transferring benefits is unlikely to cause a serious investigation on its own
No one is ever guaranteed that their case won't be subject to an investigation or audit, but if there is no underlying issue then there isn't much risk of consequences arising from the investigation. It's also not clear, from the second-hand report of your mother-in-law's interpretation of what is happening, what the "investigation" actually is.
In my experience helping people determine their eligibility and apply for public benefits, the "investigation" could be anything from a full audit of your mother-in-law's application, finances, and benefit disbursements, or it could have been a single phone call or letter requesting clarification on something. I saw that sort of thing happen a lot with inconsistent application details, like one person listing another member of their household as a spouse when previous information indicates that they are not married, or one application's list of financial assets conflicts with other information the benefits office has. Those would usually be very minor issues to sort out, but they generally do need to be sorted out to continue receiving benefits.
If your mother-in-law misrepresented her household in some way on her application for benefits, or did not provide updated information when her circumstances changed, and so there is a problem for an investigation to find then an investigation might be an issue for her. It's not likely, in my experience, for someone's "freedom" to be at risk as a result of an investigation like this, though it's hard to say what, specifically, your mother-in-law meant by "freedom".
However, if there was relatively large-scale and/or long-term fraud, the risks might be much greater. The most substantial risk (again, in my experience) is that she received more money than she was supposed to-- penalties could range from paying the excess back to prison, depending on the severity of any overpayments.
There are a lot of rules, which vary by state, which govern what is considered to be one household for determining benefit eligibility and amount. I imagine you've already checked out this page for some details. Without a full roster of people living in the house, their relationships with each other (and particularly your mother-in-law), their ages, incomes, assets, and so on, no one is going to be able to give you precise information on this situation. Contacting the DCBS office in your county of residence is the best way to get specifics on public benefit policies in Kentucky for a specific household.

I'm not sure I 100% understand what you mean by

After some digging I've come to the understanding that this is a highly unlikely scenario because her case worker to was informed after my wife left the SNAP group

but I can't think of any way to read it that suggests the conclusion you've reached. It doesn't matter when a given case worker found out about something, or even necessarily what happened to prompt a review of the case. If there is something that would trigger an investigation, and that thing comes to the attention of the agency that oversees the benefits, there will likely be an investigation.


What's the optimal number of neighbors for a full node?

Question: When running a full node, what's the optimal number of neighbors? Does it depend on the server's specs?
Answer: The official IOTA cli-app has a health command that checks the health of the node. One of the checks is whether the node has between 4-9 neighbors. From Slack and everything published, that is as close to an official number as is currently available.
https://github.com/iotaledger/cli-app/blob/master/lib/commands/health.js#L27
Answer: Early docs suggest 7-9 high quality neighbors. I've been running full nodes for a while and this number works reasonably well.
Comment: Hi ralf, you could improve your answer by providing a link to those "early docs"
Comment: Source: https://www.iotasupport.com/gui-addneighbors.shtml
Comment: Note that the link is not pointing to an official IOTA outlet.


Javascript Logging

Question: This is a noob question.
What if I want to add logging to the java script application, which is running in a browser (IE, FF, etc.) ? As I understand I can not save log files in the client host. So, I have only two options: display my logging information in a new browser window (like "blackbird") or send the logging to the server.
Is it correct? What kind of logging do they usually use?
Answer: You can't "store" log files on client host. You can open a window and visualize it, but you (assuming you are running the Web Application) will never see it.
If you absolutely must get client side logs, you need to send them back to the server using AJAX. Here's a blog post I really liked about it.
Comment: I think he absolutely must get them or he wouldnt ask =) Its not a bad concept tbh and the technique in that post is flawless ^^ Modern browsers actually do allow writing files and ActiveX components has allways been there; if the client accepts running it
Answer: Another possibility is the jsnlog library http://js.jsnlog.com/
It will let you send client side logs to the server.
Answer: Take a look at https://log4sure.com (disclosure: I created it) - but it is really useful, check it out and decide for yourself. It allows you to log errors/event and also lets you create your custom log table. It stores everything on its own server so you don't have to. It also allows you to monitor your logs real-time. And the best part, its free.
You can also use bower to install it, use bower install log4sure
The set up code is really easy too:

<code>// setup
var _logServer;

(function() {
  var ls = document.createElement('script');
  ls.type = 'text/javascript';
  ls.async = true;
  ls.src = 'https://log4sure.com/ScriptsExt/log4sure.min.js';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(ls, s);
  ls.onload = function() {
    // use your token here.
    _logServer = new LogServer("use-your-token-here");
  };
})();

//  example for logging text
_logServer.logText("your log message goes here.")

//example for logging error
divide = function(numerator, divisor) {
    try {
      if (parseFloat(value) && parseFloat(divisor)) {
        throw new TypeError("Invalid input", "myfile.js", 12, {
          value: value,
          divisor: divisor
        });
      } else {
        if (divisor == 0) {
          throw new RangeError("Divide by 0", "myfile.js", 15, {
            value: value,
            divisor: divisor
          });
        }
      }
    } catch (e) {
      _logServer.logError(e.name, e.message, e.stack);

    }
  }
  // another use of logError in window.onerror
  // must be careful with window.onerror as you might be overwriting some one else's window.onerror functionality
  // also someone else can overwrite window.onerror.
window.onerror = function(msg, url, line, column, err) {
  // may want to check if url belongs to your javascript file
  var data = {
    url: url,
    line: line,
    column: column,

  }
  _logServer.logError(err.name, err.message, err.stack, data);

};

// example for custom logs
var foo = "some variable value";
var bar = "another variable value";
var flag = "false";
var temp = "yet another variable value";

_logServer.log(foo, bar, flag, temp);</code>

Javascript Logging


Boost audio performance on old Windows 7 laptop

Question: I've recently dug out some tracks I produced on the tracker Jeskola Buzz. I have installed the latest version of the software from Jeskola.net on an old Sony Vaio PCG-7164M. However,  I now remember back to the days I used to make the track, that I needed an upgraded sound card. At the time I had a desktop with an M-audio card in it. But now I am using this laptop, I am not sure what I need. Specifically what happens is that anything that starts to need more resources from the computer in Jeskola Buzz, such as more tracks, more complicated sounds, more effects and generators I start to hear clicks, pops and stutters.
Answer: This should be a Memory Problem, the pops and clicks etc. are memory overruns.
Turning up your Buffer Size/ Sample Rate or deactivating some Costy effects while producing because when you render/export your audio file these clicks and pops will not be happening anymore.
If ur PC has a very low ram to use (4 or maybe 8 gigs) having 30+ effects is mostly not handable.
Stuff like the Apollo Twin (whole apollo series) are good examples how extern hardware could delete this problem as it will let processing be happening in the interface itself and not your pc/daw.
Summary:
Turn up your Buffer Size and/or Sample Rate.
Deactive some other effects while working on something, as in the end putting it together and rendering it will Sound fine.
Upgrade ur RAM.
Upgrade / Buy a processing audio interface / mixer.
Greets
Edit : Before i forget it, soundcards arent normaly happening anymore. I asked multiple Producers/ Technicians on their opinion. a USB interface will basicly work as a extern sound card and handle it. USB will transfer lossless so a standart onboard/ motherboard soundcard will mostly/(anything 2015+) always be sufficent.
Comment: great information thanks!


Who owns the laptop bought with funding for student training etc. in a fully funded PhD project?

Question: I am a PhD student at a UK university and the project is a collaboration between the University and an industrial partner. My question is when the laptop is bought using the extra money allocated for training etc., who owns the laptop?
Comment: it is likely a case specific thing. Did you check the conditions on the funding? Although, I have heard people buying high end computers with funding and keeping them.
Answer: If it isn't specified in the collaboration contract, ask the funding agency for clarification - this may be determined on a case-to-case basis.

Single data point: I had funding as PhD student via a sholarship that also had an expenses budget.

When I bought stuff that was in between consumables and small instruments (to be precise, VUV-quality CaF2 slides). At reimbursement, the funding agency stipulated that they should become property of the institute.
In contrast, there was no such stipulation for some books I bought from the same budget.
Comment: +1. For $n = 2$, my fellowship [said](https://nepis.epa.gov/Exe/ZyPURL.cgi?Dockey=P1003HAB.TXT) computers belonged to the fellow. One day, university IT decided to stick a property tag on my workstation bought with my fellowship. I emailed IT and cc'd my program coordinator who let the university know they were in the wrong and the computer clearly belonged to me.
Answer: As other answers suggest, the identity of the owner may vary. However, I will venture a common-sense guess for the benefit of future readers:

If the laptop was not provided with the industrial partner, not bought by it for you, then it's probably not intended to be owned-by-them.
From my limited experience (not in the UK), Ph.D. candidates don't get to keep laptops they are bought for use during their Ph.D; they hand them in what they leave the university/research institute.

so with no additional information I would assume it is the university's.
But really, in your specific case - just ask whoever gave you the laptop.
Comment: throwaway comment, sorry, but I just wanted to say that I've seen you on this forum for over six years and I just realized that your username is a transliteration of "אין פה כלום". I'm feeling rather silly right now.
Comment: @eykanal: It's not like I was expecting this to be acknowledged or anything...
Comment: Nah, nothing on you, just a slow realization for me. The name makes a lot more sense now.
Answer: I don't think there's a global rule for this. Institutions could have their standard rules for this, but then enter in an agreement with a particular industrial partner to do it differently for that project, for example. Likewise, it could be different for small and large sums of money, or for items very specific to the project that would be hard to re-purpose, or generic things like a laptop.
So whenever a nontrivial amount of money or work is involved, always get agreements in writing. That way everyone knows what to expect.
If you already have the laptop but don't have in writing what happens to it, make sure you get it in writing. Don't count on keeping the laptop until you do.
It's entirely possible you get to keep the laptop, if it's a long-running project. It's probably not the same standard model the company uses, so if they took it back, supporting it would be more work. Also, companies write off laptops after some years. As a piece of equipment that's exposed to travel wear and tear, it ages faster than a desktop machine. After a certain amount of years, the hardware will be dated and prone to defects so keeping it is not economical. The same business logic applies to the university, although they may be more used to supporting a diverse array of research laptops.
Given these reasons you should not be too shy to suggest that you get to keep the laptop and make it "your problem".
Answer: With UK universities, the most common rule would be that it belonged to the University. Research costs on a UKRI studentship are paid to the university to cover the costs of your research. This money to supposed to be spent on enabling you to complete your research and training, but it is the university's money, not yours. Laptops are an interesting one, because in theory, unless you have special requirements, UKRI research funds are not supposed to be used to buy ordinary computers.
Now that's what happens with UKRI. Things might be a little different for a research contract with a industrial partner, but my expectation is that the industrial partner will have a contract with the university to provide the research - once again, note that the contract is between the funder and the university, not the student.
That said, many universities have schemes that allow you to buy computing off them when you leave if they are over a certain number of years old at a nominal cost.


How can I modify edmx and reflect changes in the domainservice automatically?

Question: I have a silverlight business application created with vs2010 and it is RIA service enabled, I added new table in the database and updated the edmx using (update model from database option), but I want to update the domain service class as well to include the new tables, how can I do that?
Answer: I haven't found a way to do this automatically, but this blog seems helpful.
EDIT: If you use partial classes as suggested, then you can delete the DomainService1.cs class and use add new item to add the class again. Then using the built in wizard, re-check the entities you want to expose. The partial classes will hold your custom logic.
Answer: Unfortunately I have not found nothing better than:

Add new DomainService that will work with new table;
Copy generated code into existing(main) service (Get*, Insert, Update, Delete etc.);
Copy metadata;
Delete "new" DomainService and "new" metadata files;

After these steps you'll get access to your table.
NOTE:

*-without Get- method client will not recognize any changes;


How to avoid Decimal values in input type number

Question: How to avoid Decimal values from input of Number in HTML5. Currently it allows user to type decimal value.
Comment: This question has been aswered already: [html5 number input type that takes only integers](https://stackoverflow.com/questions/8808590/html5-number-input-type-that-takes-only-integers)
Comment: I tried the pattern method, But i would like to have behaviour same as number field. in case of using pattern it doesn't validate until the value is submitted. Just like a number field doesn't allow user to type alphabets, is there any way i could stop period value too.
Answer: An alternative to the supplied answers is to monitor the keypress while in the input. I personally like leaving the type="number" as an attribute. Here's a JSFiddle
<form action="#" method="post">
  Numbers: <input name="num"
                  type="number"
                  min="1"
                  step="1"
                  onkeypress="return event.charCode >= 48 && event.charCode <= 57"
                  title="Numbers only">
  <input type="submit">
</form>

Comment: It looks like this also disables backspace and delete keys in FireFox which isnt ideal when editing the input field.
Comment: you can still right-click paste to inject other inputs.
Comment: This solution works great to avoid inputs other than numbers [0-9]. Perfect.
Comment: This solution isn't working on Android. Did anyone find a way to fix this on Android?
Answer: I ended up checking to see if a user types in a period then preventing the event from propagating.
Edit: A better approach. The key press event has been deprecated. Also added in a regex to strip out everything but numbers [0-9] on paste.

<input type="number" onkeydown="if(event.key==='.'){event.preventDefault();}"  oninput="event.target.value = event.target.value.replace(/[^0-9]*/g,'');">

Caution Experimental. Only partially works on chrome:
Wanted to look at a great way to grab the pasted value strip everything out then have it placed in input as normal. With the above method you are relying on the event order to correct the input, then any event listeners will ideally fire after. The onpaste method will fire before the input event fires so you keep the flow of events correct. However when replacing the string with only numbers the decimal point would still sneak in. Looking to update this when I find a better solution.

<input type="number" onkeydown="if(event.key==='.'){event.preventDefault();}" onpaste="let pasteData = event.clipboardData.getData('text'); if(pasteData){pasteData.replace(/[^0-9]*/g,'');} " >
Comment: This is a perfect solution. Anyway, just a tip for Angular developers. onpaste is not allowed on input field, you have to use (paste) which does the same stuff as onpaste. Moreover, do not use event.* into onkeydown because, as Steven as said, is deprecaded. Instead i suggest to use $event on Angular application that should act as the same of event
Comment: Not sure if I'd want "3.14" to be pasted as "314".
Comment: You could just as easily set it to blank (or a default value) if that behavior is desired
Answer: Use pattern attribute
<input type="number" name="num" pattern="[0-9]" title="Numbers only">

For more details http://www.w3schools.com/tags/att_input_pattern.asp
FIDDLE
Comment: Just a note: This seems to only validate on submit of the form that the input is in; it doesn't prevent decimal input, nor does it indicate that the field is in error before the form is submitted.
Comment: Secondary note: 1.0 will return as valid which may or may not correct depending on your what you want.
Comment: does not work as I want to check for decimals to be not included when user is typing.
Answer: Just plain example using parseInt()

<input type="number" oninput="this.value=(parseInt(this.value)||0)" placeholder="0-9" autofocus='' value='0' />
Comment: works well. still allows the user to enter a 'fullstop' or 'period' character because `parseInt(0.)` returns `0`. but that makes sense mathematically, because when you enter `0.` without a number after the decimal, the assumption is that it's zero, so `0.` == `0.0`, which equals `0 ` when parsed to an integer. makes sense to me anyway...
Comment: This works well but not actual since html5. Only if old browsers support is critical
Comment: this does not help as it can save `3` as `3.`
Comment: This works but then keep in mind the user won't be able to enter a dash `-` which means they cannot enter negative numbers
Answer: Based on other answers here, I tried this:

<input id="storeId" min="0" pattern="[0-9]" onkeypress="return !(event.charCode == 46)" step="1" title="Must be an integer number" type="number" >

I just blocked input of dot, but again this does not block paste.
ASCII DOT . character is 46
Answer: <input type="number" onkeydown="return event.keyCode !== 190">

This will Restrict period(.) input.For any Key restriction:
https://css-tricks.com/snippets/javascript/javascript-keycodes/
Comment: On my side, if the use the dot on my numpad, the keyCode is 110. If I use the one with the letters, it's 190. I think both should be restricted.
Answer: event.key and event.charCode are deprecated features and don't work well with mobile virtual keyboards. I've done some research and this seems to be the easiest way to make it work.
Tested in Chrome and Firefox on Windows, in Chrome on Android and in Safari on iOS and seems to be working perfectly.

document.getElementById("myInput").addEventListener('beforeinput', e => {
  if (!(Number(e.data) >= 0 && Number(e.data) <= 9)) {
    e.preventDefault();
  }
});
/* unnecessary */
#myInput {
width: 24ch;
}
<input type="number" inputmode="numeric" placeholder="only a number can go here" id="myInput">

By the way, this is my first post here, so please tell me if I'm doing anything wrong.
Comment: on mobile, this is the only solution that worked for me
Answer: You guys can try this
This function does not allow user to paste unwanted characters and also disallow user to enter .+-E

var inputBox = document.getElementById("inputBox");

                var invalidChars = [
                    "-",
                    "+",
                    "e",
                    "."
                ];

                inputBox.addEventListener("input", function() {
                    this.value = this.value.replace(/[e\+\-\.]/gi, "");
                });

                inputBox.addEventListener("keydown", function(e) {
                    if (invalidChars.includes(e.key)) {
                        e.preventDefault();
                    }
                });

<input type="number" id="inputBox" >

`
If error occured in your JS. You can add this
`$(document).ready(function() { code });
Answer: Try this :
<input type="number"  value=""  min="0" oninput="this.value=(parseInt(this.value)||0)" onkeypress="return !(event.charCode == 45||event.charCode == 46||event.charCode == 43)"  class="form-control" step="any" />

Answer: <input type="number" onkeypress="return event.charCode >= 48 && event.charCode <= 57"  name="quantity">

Answer: A simple regex can help sort with this issue .
var re = new regExp('[.]+) ;
if(!re.test(num)){listOfNumbers.push(num)};

not letting the user type in a '.' on the input might not be a viable option when you are dealing with multiple cultures and interpretations of '.'.
Answer: function isNumberKey(evt){
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57 || charCode==46))
        return false;
    return true;
}

Comment: If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/31249995)
Answer: In case anyone still wondering a solution, here's a workaround I came up with:
const val = 33.15;

console.log(String(val).includes(".")) // true

if(String(val).includes(".")){
   // the number is decimal
} else {
  // the number is not decimal
}

Answer: This solution let user insert only numbers from 0 to 9
<input type="number" name="intero" oninput="this.value = this.value.replace(/[^0-9]/g, '')" />

Comment: Please [edit] your answer to provide more information as to how the code you've provided works, what you have changed, etc. Code-only answers might solve the problem of the original asker but they don't help future readers understand the solution.
Answer: This worked for me for Angular 16, the sample rejects negative numbers also
 <input matInput type="number" placeholder="Price" required
                   onkeydown="if(this.key==='.'){this.preventDefault();}"
                   oninput="this.value = Math.abs(this.value.replace(/[^0-9]*/g,''))">

if you want it to accept negative number you can use
 <input matInput type="number" placeholder="Price" required formControlName="LimitPrice"
                   onkeydown="if(this.key==='.'){this.preventDefault();}"
                  >

Answer: I encountered the same challenge and a combination of answers here helped me to get it to work on Android, iOS and Chrome and Firefox on the desktop. I needed the input field to only accept numeric values without decimals. This is what I came up with:
<input id="inputField" type="number" inputmode="numeric" pattern="[0-9]*" />

document.getElementById("inputField").addEventListener('beforeinput', event => {
  const char = event.data;
  if (char != null && char !== '' && !/^[0-9]*$/.test(char)) {
    event.preventDefault();
  }
});

It's pretty similar to the solution proposed by TyphousCrane654. The differences are that it does not allow for decimal numbers and it also allows for the backspace button being pressed. It's also good to mention that it supports pasting in valid values, but not invalid values. I hope it helps someone else (or at least myself in the future).
You can test it yourself in this JSFiddle.
Answer: Not pretty but seems to work.
Allows free edit, corrects on lose focus.
For range between -100 to 100

<input
onblur="val = parseInt(this.value.replace(/[^-0-9]/g, '')) || ''; this.value = Math.min(Math.max(val, -100), 100);"
oninput="val = parseInt(this.value.replace(/[^-0-9]/g, '')) || ''; this.value = val ? Math.min(Math.max(val, -100), 100) : '';">
Answer: You should post what you have tried when asking questions.
To use integers only, change the following attribute.
step="any"

to
step="1"

Comment: using step attribute still allows user to type decimal value. Just like number field doesn't allow user to type alphabets, is there any way that i could restrict user to type float values
Answer:  For Angular Developers:

    <input type="number" min="1" (keydown)="keyDown($event)">

    keyDown(event) {
        if (event.key === '.' || 'e' || 'E') {
          event.preventDefault();
        }
      }

Answer: @Html.TextBoxFor(model => model.num, new { @class = "form-control input-sm",@maxlength = 5 ,@oninput = "this.value = this.value.replace(/[^0-9]/g, '');"})
In MVC, above solution works.
Comment: Please provide more detail and context to this answer.
Comment: in addition to @Beefster comment, please also read the comments under the question, you would see that Kumar already rejected the regex approach
Comment: @NimaNr But for this form submission is not required


Differentiation: Vectors or scalars

Question: As you know, we can geometrically interpret the set of all reals $\Bbb R$: every point on the line can be uniquely expressed by a real number x (it's coordinate). However, we could go a step further and use the line to geometrically express operations between real numbers, such as addition. In order for us to do this we introduce vectors and now every point on the line and every coordinate associated with that point represent a vector starting from the origin and ending at the given point. Thus every real number either represents a point on the line or a vector on the line. Now, in the definition of the derivative$$ \frac{{\rm d} }{{\rm d}x} y(x) =\lim_{h\rightarrow0} \frac{1}{h}( y(x+h)-y(x)) $$ we have x+h, which only makes sense geometrically if x and h are both vectors (addition of points on the line makes no sense). My question is: In order to have a meaningful definiton of the derivative, should the function y(x) be geometrically interpreted as mapping vectors to vectors?
Comment: @James, the distinction is actually pretty useful in clearing things up. In the 1-dimensional space of time, specific times (like dates) are like points and signed time intervals (e.g. +3 days, -4 hours) are like vectors. You can take the difference of dates to get a time interval, and you can add a time interval to a date, but you can't add dates together. See the answers to http://math.stackexchange.com/questions/645672/what-is-the-difference-between-a-point-and-a-vector for more info.
Comment: Why do you think addition of points makes no sense? Personally, I don't observe that much of a difference between vectors and points.
Comment: @James, if you're saying don't bring this stuff up to first year calculus students (and perhaps students learning multivariable calculus for the first time) who aren't already thinking about it, then I would agree. I was merely responding to "Why do you think addition of points makes no sense?" with an explanation about why it can be considered in some contexts to make no sense.
Comment: Maybe you should try to think of that limit in the $\epsilon$, $\delta$ sense and then decide whether vectors should be used or not?
Comment: @MarkS. I'm sure there are situations in which it is helpful, but in the main, we only try to draw distinctions between very similar objects when that distinction is pertinent. For calculus, it can be decidedly unhelpful to confuse students by trying to draw distinctions between the complete ordered field, the dimension 1 vector space over that field, and the set of equivalence classes of pairs of points in that field, under the equivalence $(a,b)\sim (c,d)$ iff $d - c = b- a$.
Comment: @MarkS. Ah, then I think we agree. I wasn't trying to say that one can always add points, indeed, if you just think of a point as a member of a set of interest, there is no reason to suppose we can add them. I was reading the OP, in particular, as defining points to be the coordinate of a vector based at the origin (with no particular interpretation of vector). My question was directed at that particular interpretation
Answer: You seem to be regarding $\mathbb{R}$ as an affine space that includes both points and vectors. With this view of the world, points and vectors are two different things, and it doesn't make sense to add together two points, as you say.
The Wikipedia article on affine spaces says:
In an affine space, there is no distinguished point that serves as an origin. Hence, no vector has a fixed origin and no vector can be uniquely associated to a point. In an affine space, there are instead displacement vectors, also called translation vectors or simply translations, between two points of the space. Thus it makes sense to subtract two points of the space, giving a translation vector, but it does not make sense to add two points of the space. Likewise, it makes sense to add a vector to a point of an affine space, resulting in a new point translated from the starting point by that vector.
In your definition of the derivative, I think $x$ should be regarded as a point, and $h$ as a vector. The function $x \mapsto y(x)$ should be regarded as mapping points to points. Then

$x+ h$ is a point (adding a vector to a point)
$y(x+h)$ is a point (a value of the function $y$)
$y(x+h) - y(x)$ is a vector (difference of two points)
$y'(x)$ is a vector

This point of view makes sense (I think), and it's consistent with the concept of directional derivative in higher dimensions.
As mentioned in one of the comments, there is a very good discussion of the point-versus-vector issue in the answers to this question.
Answer: While others have pointed out that an addition of points can be defined (and it is of course defined to be the same as when you interpret them as vectors), I do think that your line is morally right. (BTW: points of more general spaces, topological spaces, can not always be added. So being able to add two entities is indeed something specific, though not unique, to vectors.)
Even when derivatives are generalized to functions between geometric objects, say from a circle to a donut shaped thing, this is done by first approximating the domain and co-domain by vector spaces near the point where the derivative is desired. However, here you already see that the domain and codomain need not really consist of vectors, but it suffices that small changes in the inputs or outputs can be expressed via (tangential) vectors.
In summary, derivatives answer the question: If I change the input a bit in direction X, in which direction do the function values go. And vectors are the mathematical formalization of direction. In your question, the $h$ should arguable be thought as a vector, as well as the value of the derivative. But not necessarily the input $x$ and the output $f(x)$.
Answer: In a nitpicking sense, the derivative
$$
f'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}
$$
of a function $f$ is indeed a scaling map that specifies how a (small) displacement (vector) $h$ at a point $x$ gets stretched into a displacement vector $f'(x)\, h$ at $y = f(x)$.
Commonly this relationship is expressed in terms of points as $f(x + h) \approx f(x) + f'(x)\, h$. The derivative itself, $f'(x)$, is neither a point nor a vector.
In more general settings (such as coordinate-free formulations of mechanics), "points" live in a space $M$ (a "manifold"). To formulate differential calculus, one introduces an entirely new space $TM$ (the "tangent bundle"), whose elements may be viewed as pairs $(x, h)$ consisting of a point $x$ of $M$ and a displacement $h$ at $x$.
In this setting, if $f:M \to N$ is a differentiable mapping, its "(total) derivative" is a mapping $f_{*}:TM \to TN$ defined by
$$
f_{*}(x, h) = \bigl(f(x), f'(x)\, h\bigr).
$$
The derivative $f'(x):T_{x} M \to T_{f(x)} N$ is a "linear transformation" between tangent spaces, a generalization of a scaling map.
The conceptual asymmetry between points and vectors becomes starkly visible in this setting. Adding points makes no sense at all. The sum "$x + h$" of a point and a vector cannot be viewed as a point of $M$. It can be viewed as a point of $TM$, but doing so doesn't have much use. Instead, one "probes the infinitesimal structure of $M$" with "paths through $x$ whose velocity is $h$".

Differentiation: Vectors or scalars


How increased potassium intake increases sodium excretion?

Question: "K+ antagonises the biological effects of Na+". I have been reading the same many times without any explanation. How actually (mechanism) K+ helps excretion of Na+?, their interactions? And eventually lowers blood pressure?
Answer: That's because cell membrane could have a protein, called Na/K pump who's able to regulate the level of Sodium/Calcium using the energy gained by the hydrolysis of a phosphate bond from ATP.


Best exact method to solve TSP

Question: What is currently the exact method to solve the TSP which performs best on average regarding computation time?
Comment: The Concorde solver is the best there is: https://www.math.uwaterloo.ca/tsp/concorde/index.html. It uses a combination of heuristics, cuts, branching, and smart relaxations.
Comment: @mtanneau Thanks, I also stumbled about Concorde. What is the general strategy they are using? What MIP model do they base their solution mechanism on?
Answer: I would say "it depends". If the instances you want to solve are small (up to, say, 10-12 nodes) then dynamic programming works wonders. If the problem is up to 30-40 nodes, you can get by using a general IP solver using a good model formulation. Above that, you need to either design your own branch and cut algorithm using problem specific cuts or figure out how to use Concorde.
Concorde is without a doubt the champion when it comes to large scale TSPs.
Answer: For small instances, i think the branch and cut will works well. You can try localsolver or concorde to prove optimality for bigger instances in reasonable time.

Best exact method to solve TSP


Avenir Next: odd 'u' height

Question: I've recently inherited a brand which uses Avenir Next as its primary font. Looking through previous documents I have noticed the height of certain characters seem to be off, with the u being the most noticable.
Comment: What software are you using?  Which software did you use to render that image?
Comment: And, more importantly, at what zoom size? Drawing text on the screen *always* distorts the font. (Unless your font happens to be drawn as a bitmap to start with. But even then it might.) If this is to be printed: do not worry about it at all. It's your screen.
Comment: Not only the u is affected. The strokes for the e and t appear too bold. The stem of the s is irregular. Most likely, the font has become corrupt and should be refreshed. Introduce yourself to the Monotype support team. – Stan 1 min ago    edit
Comment: Possible duplicate of [Why do some letters look odd at 100% but not 200%?](https://graphicdesign.stackexchange.com/questions/3555/why-do-some-letters-look-odd-at-100-but-not-200)
Comment: Is the u definitely in the same font as the other letters? Not a character with an unusual accent or something that has defaulted? You can test this by re-typing the word and seeing if it looks different.
Comment: Response to all - The font is Avenir, same size etc. This happens when zooming out in some software (InDesign, Acrobat). Retyping the word doesnt change the character. This is a screenshot.
Comment: Did you ever come to a conclusion on this OP?
Answer: Avenir is a professional typeface family used by many, so its very likely that your copy may have been corrupted in some way. If the copy has been legally purchased this will not happen. You should check with whoever paid for this and make sure you have the right files.
Comment: Still very unlikely to have this happening on Monotype. Make sure its not a preview issue or something related to your software. The font looks fine on their web preview: https://catalog.monotype.com/family/linotype/avenir-next. Ultimately, contact their support team.
Comment: We have a Monotype library subscription, so this copy was legally obtained :)
Answer: Adobe apps often use custom font rendering algorithms intended to work very fast to cope with complex documents. Unfortunately, they aren't always completely accurate. If this is the issue, a fix is to select View ▸ Display Performance ▸ High Quality Display. Although this will slow your computer down a bit, on modern computers for simple documents it's actually not much of an issue.
Answer: Use font-size unit pt instead of px and you'll get a more consistent and crisp result
Comment: Hi user129735, here at GDSE we like longer answers, that don't just explain _how_ but also _why_. Could you [edit] your answer to include more information, and maybe a screenshot comparing points and pixels as verification? Thanks! Feel free to browse the site, leave more answers, upvote quality content and maybe ask a question of your own.

Avenir Next: odd 'u' height


How can we determine which subgroup remains unbroken after spontaneous symmetry breaking for $SU(2)\times U(1)$ symmetry?

Question: Consider an $SU(2)$ doublet of bosons $\Phi = (\phi^+, \phi^0)^T$, where the complex scalar field $\phi^+$ destroys positively charged particles and creates negatively charged ones, and the complex scalar field $\phi^0$ destroys neutral particles and creates neutral anti-particles. The theory has $SU(2)\times U(1)$ symmetry, with Lagrangian
$$
\mathcal L = (\partial_\mu\Phi^\dagger)(\partial^\mu\Phi)+\mu^2\Phi^\dagger\Phi-\frac{\lambda}{4}(\Phi^\dagger\Phi)^2
$$
I saw another example with $SU(2)$ triplet of real scalar fields $\Phi = (\phi_1, \phi_2, \phi_3)^T$, with symmetry $SU(2)\times U(1)_Y, Y=0$ and it has a similar scalar potential,
$$
V(\Phi) = -\frac{m^2}{2}\Phi^\dagger\Phi-\lambda(\Phi^T\Phi)^2
$$
Are there physical interpretations of those scalar fields $\phi_1, \phi_2, \phi_3$ like those in the doublet case (so we can adjust the notation for $V(\Phi)$? Should we expect to obtain the same Lagrangian density as the doublet case? Also, how can we determine which subgroup remains unbroken after spontaneous symmetry breaking?
Comment: Your latter, real triplet Higgs model, is called the Georgi Glashow model. Convince yourself as taught that the v.e.v. can be chosen in one of the 3 components, and so the SU(2)~SO(3) breaks down to a U(1)~O(2), so one generator survives. Such a model lacks neutral currents, so it is useless for the electroweak interactions.
Comment: [G-G SU(2) model](https://physics.stackexchange.com/questions/196109/georgi-glashow-model-and-the-vev-of-the-scalar-field).
Answer: If some of symmetries of theory are spontaneously broken, we expect some charge operator will satisfy $\hat Q|0\rangle\neq 0$. However, because of the existence of NG mode, $\hat Q|0\rangle$ has a divergent norm so the condition above is ill-defined statement. Instead of this statement, usually we use a following statement as an indicator of the spontaneous symmetry broken (SSB):
$$^\exists \hat O(x)\  s.t. [\hat Q, \hat O(x)]=-i\delta_Q\hat O(x)\ \mathrm{and}\  \langle 0| \delta_Q\hat O(x) |0\rangle\neq 0.$$
In your example of the Higgs model, $O(x)$ corresponds to $\Phi(x)$.
In general, unbroken symmetry ${H}$, which is sub group of spontaneously broken symmetry $ G$, is characterized by the vacuum expectation above: $\langle 0| \delta_Q\hat O(x) |0\rangle$.
I mean, if $H$ is unbroken, its charge operator and a vacuum  of theory must satisfy $\langle 0|[\hat Q, \hat O(x)]|0\rangle=0,$ for arbitrary $\hat O(x)$. In the other hand, from the discussion above, some of charge operators of $G$ is not satisfies this relation. Thus, we can say that if we use a label $a$ for generators of $G-H$ and a label $i$ for generators of $H$ , $\hat Q_a$ and $\hat Q_i$ must satisfy the following relation:
$$\langle 0| \delta_{Q_i}\hat O(x) |0\rangle =0,$$
$$\langle 0| \delta_{Q_a}\hat O(x) |0\rangle \neq0.$$
This is how we know the unbroken symmetry. In principle, what we should do is to observe $\langle 0| \delta_Q\hat O_i(x) |0\rangle$  and to find specific generators of $G$ which satisfies $\langle 0| \delta_Q\hat O_i(x) |0\rangle =0 .$
In your example, you can check $\langle 0|\Phi(x)|0\rangle$ is invariant only $U(1)_{\mathrm{em}}$. To show this, one should notice that we can choose the following Ansatz indefinitely:
$$\langle 0|\Phi(x)|0\rangle = (0,v)^{\mathsf T}.$$
Roughly speaking, elements of $SU(2)\times U(1)_Y$ are the unitary $2\times 2$ matrices. Thus, all that needs to be done is to let this $2\times 2$ matrix act on the vacuum expectation value above to find the condition that satisfies $\langle 0|\delta_i\Phi(x)|0\rangle=0$.
This is essentially all that needs to be done, but its looking becomes a bit more complicated to try to develop a general theory. For more details: see Weinberg's QFT.
Comment: What if $\delta_Q \hat O(x) |0\rangle \neq 0$? Isn't that sufficient to say that $Q$ is (or generates) a spontaneously broken symmetry?
Comment: We would like an indicator of SSB that distinguishes a broken symmetry and unbroken symmetry, but clearly your indicator is not a good one because it does not have to be zero, even if it is unbroken symmetry. (i.e. $\hat Q_i \hat O(x)|0\rangle$ is not necessarily zero)
Comment: I thought SSB was when the vacuum state is not invariant under the transformation? What if $\langle 0| \delta_Q \hat O(x)|0\rangle = 0$, but $\langle v| \delta_Q \hat O(x)|0\rangle \neq 0$?
Comment: If we are considering ordinary symmetry, then it is expected that some field (in general, it is composite operator) has a vacuum expectation value from the shape of the potential if SSB happens. On the other hand, if there is this vacuum expectation value, can we say that spontaneous symmetry breaking is taking place? That is what the above discussion complements; it states that if $\langle 0|\delta_Q O| 0\rangle\neq 0$ for some operator, then SSB is taking place.
Comment: Ah I see, thank you.


Drupal event registration and attendance recording

Question: I am building a Drupal 6 site, with event managing feature, in particular:

Selling events participation
Recording events attendances: once the event is concluded, administrator can review attendances indicating which users have really participated

I have searched a lot, already seen different similar posts and considered different possibilities before posting,
including signup module and ubercart uc_signup module, but none seem to fit my requirements.
For payment I am using Ubercart.
My strategy is the following:

Create a content-type "event", which holds all information about the event, including the date of the event, description, etc.
   This is also an Ubercart product.
   This is easily accomplished via CCK and Ubercart (either creating directly the product in Ubercart or creating the content-type with CCK and a product with the same machine name in Ubercart)

 Create an "event participation" content-type which has a field holding a reference to event node, a field holding reference to user subscribing the event, a field for "payment status" (paid or not) , a field for "attendance status" (attended or not)
   This can be easily done with CCK.

When an user want to attend an event, she creates a node of type "event partecipation":

the field referencing event should be automatically filled with the event

the field referencing the user should be automatically filled with the current user

the creation of the node should be possible only if no node of this type exists for this particular event and user.
  if a node of this kind already exists for this event and user it should be deleted

The newly created node has the payment field set to "not paid" and the attendance field set to "not attended" (defaults for new node)

I think all this points can be accomplished with hook_form_alter(). Is it possible?

Once the "event participation has been created" the user is presented with a link to pay the participation.
   This is done adding the referenced event to Ubercart cart and redirecting user to checkout page
   I think this point can be accomplished with hook_form_alter() and Ubercart API. Is it possible?

When the user fulfills payment, an action is triggered to set the "payment status" field of the "event participation node" referencing the bought product and the buying user is set to "paid".
   I think this can be achieved with Ubercart conditional actions. Is it possible?

At this point, we have the possibility to create a view showing all user participating to an event, looking at "event participations" with "payment field" equals "paid"
   The event "participation nodes" are still there so, after event has occurred, administrators can set user attendances and present them in a view (probably the same view)
   This is simply done with views.

What do you think, is it feasible?
I'd like to go in details of some of the above steps, but for now I am interested in discussing the overall strategy.
Thanks a lot for your attention and for any suggestion.
Answer: This seems like 90% exactly what your looking for:
http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart


it is possible to define a topology on particular vector space

Question: If i take $V$ a finte dimensional vector space on the real number (or complex number). Setting $n=dim_{\mathbb{R}}(V)$, i know that there is a isomorphism of vector spaces so $V \simeq \mathbb{R}^n$. So can i define a topology on $V$ via this idenification? is $V$ with this topology a differential manifold as $\mathbb{R}^n$?
Answer: Fix a topology $(\mathbb R^n, \mathcal T)$ and let $f$ be an isomorphism $V\to\mathbb R^n$. Then you can define a topology on $V$ via $$\mathcal T_V = \{ f^{-1}(O): O \in \mathcal T\}$$
Take $\{(V,f)\}$ as an atlas (i.e. $(V,f)$ as the only chart). The only transition map, you have to consider, is $\operatorname{id}:\mathbb R^n\to \mathbb R^n$. $\operatorname{id}$ is differentiable under each topology (due to $\operatorname{id}(x+\epsilon)=\operatorname{id}(x)+\operatorname{id}(\epsilon)=\operatorname{id}(x)+\epsilon\cdot I$). So $V$ is a differential manifold.
Comment: The problem is that if i take $V=T_{m_0}M$, that is the tangent space to a differential variety in $m_0$, this is a vector space but can i say that the tangent space is a differential manifold? this because i want to define an application between an open subset of the tangent space and an open subset of $M$ and i would like to say when this application is differentiable
Comment: ok now is clear thanks


What is the fastest algorithm to check if a number has only 3 divisors?

Question: Which is the fastest way to check if a number has only 3 unique factors ?
Any help will be highly appreciated?
Comment: check it's a square of another prime?
Comment: @PatrickLi: another?
Comment: @MarcvanLeeuwen check it's the square of a prime number. :)
Answer: Supposing that by "only 3 divisors" you mean "exactly 3 divisors", the only such numbers are numbers of the form $p^2$, where $p$ is prime; they are divisible by $1, p, $ and $p^2$.  So the first thing to try is to test if the number $n$ is a perfect square, which you can do efficiently by calculating the integer square root $i = \lfloor \sqrt n\rfloor$ and then checking to see if $i^2=n$.  If not, $n$ fails. If so, $n$ has the desired property if and only if $i$ is prime, which you can check using any of the usual primality tests.
Answer: The fastest method will depend on the types of numbers you intend to check and how you are running the tests (pencil and paper, x86_64, etc.). But basically, check if the number has any small prime factors (say, the first 25: 2, 3, 5, ..., 97). If so, the number has exactly 3 divisors if and only if the number is the square of that prime. Otherwise you have a number with no tiny prime factors; now check if the number is a square. You can first test mod some promising moduli, like 63, 64, and 65. If it passes that test, take the integer square root $s$ and test if that, squared, gives the number. If not, the number has more than 3 divisors. If so, test if the remaining number is prime. The first step is using a probable-prime test, maybe checking if the number is a b-strong pseudoprime for some randomly-chosen $1 < b < s-1.$ If that fails the number is composite and so $s^2$ has more than three divisors. Otherwise apply a primality-proving test to $s$.


How to transform column with lists of strings into a new column of unique identifiers

Question: Apologies if a similar question has been asked before, I was unable to find one, possibly because of wording of the question.
Some current sample data looks like this, where the first column is a list of identifiers (genes) and the second column is a set of descriptors (gene ontology IDs):
Gene    Gene_Ontology_ID
Gene1   GO1, GO2, GO4, GO6
Gene2   GO2, GO3, GO4
Gene3   GO5, GO7

I am wondering if there is an efficient way to transform a large table formatted similarly so that the "Gene_Ontology_ID" column now serves as the indentifying column, and the "Gene" column is now a list of genes with that Gene_Ontology_ID, like this:
Gene_Ontology_ID    Gene
GO1                 Gene1
GO2                 Gene1,Gene2
GO3                 Gene2
GO4                 Gene1,Gene2
GO5                 Gene3
GO6                 Gene1
GO7                 Gene3

Is there a solution to this, preferably using Unix, Python, or R? Any help would be greatly appreciated, thank you.
Answer: library(dplyr)
library(tidyr)
out <- df %>% separate(Gene_Ontology_ID, into=paste("genes", 1:7, sep = "_"),sep =", ",fill="right") %>%
  gather(key,Gene_Ontology_ID, -Gene,na.rm=TRUE) %>%
  arrange(Gene_Ontology_ID,Gene) %>%
  group_by(Gene_Ontology_ID) %>%
  summarise(Gene= paste(Gene,collapse =", "))

out
# A tibble: 7 x 2
  Gene_Ontology_ID         Gene
             <chr>        <chr>
1              GO1        Gene1
2              GO2 Gene1, Gene2
3              GO3        Gene2
4              GO4 Gene1, Gene2
5              GO5        Gene3
6              GO6        Gene1
7              GO7        Gene3

Answer: A similar option with strsplit and unnest:
library(dplyr)
library(tidyr)

df %>%
  mutate(Gene_Ontology_ID = strsplit(Gene_Ontology_ID, ", ")) %>%
  unnest(Gene_Ontology_ID) %>%
  group_by(Gene_Ontology_ID) %>%
  summarise(Gene = paste(Gene, collapse = ", "))

# A tibble: 7 x 2
  Gene_Ontology_ID Gene
  <chr>            <chr>
1 GO1              Gene1
2 GO2              Gene1, Gene2
3 GO3              Gene2
4 GO4              Gene1, Gene2
5 GO5              Gene3
6 GO6              Gene1
7 GO7              Gene3

Answer: Using data.table and cSplit from splitstackshape:-
library(data.table)
library(splitstackshape)
df <- data.frame(Gene = c("Gene1", "Gene2", "Gene3"), Gene_Ontology_ID = c("GO1, GO2, GO4, GO6", "GO2, GO3, GO4", "GO5, GO7"))
df <- cSplit(df, 'Gene_Ontology_ID', ',', 'long', drop = FALSE)
setDT(df)
df[, Gene := as.character(Gene)]
df[, Gene := paste0(Gene, collapse = ", "), by = Gene_Ontology_ID]
setcolorder(df, c("Gene_Ontology_ID", "Gene"))
df <- unique(df)

You'll get:-
 Gene_Ontology_ID         Gene
1:              GO1        Gene1
2:              GO2 Gene1, Gene2
3:              GO4 Gene1, Gene2
4:              GO6        Gene1
5:              GO3        Gene2
6:              GO5        Gene3
7:              GO7        Gene3

Answer: Here is a solution using only base R (probably not the most efficient):
# Obtain a vector of unique "gene ontology ids"
all_genes_id <- paste0(df$Gene_Ontology_ID, collapse = ", ")
all_genes_id <- unique(strsplit(all_genes_id, ", ")[[1]])

# Initalize and fill vector of genes per each "gene ontology ids"
genes_per_id <- vector(mode = "character", length(all_genes_id))
for(i in 1:length(all_genes_id)) {
  rows_df <- grepl(all_genes_id[i], df$Gene_Ontology_ID)
  genes_per_id[i] <- paste0(df$Gene[rows_df], collapse = ",")
}

# New data frame
df2 <- data.frame(Gene_Ontology_ID = all_genes_id,
                  Gene = genes_per_id)
df2
# Result
  Gene_Ontology_ID        Gene
1              GO1       Gene1
2              GO2 Gene1,Gene2
3              GO4 Gene1,Gene2
4              GO6       Gene1
5              GO3       Gene2
6              GO5       Gene3
7              GO7       Gene3


Newbie Question: How to use `form_tag` helper in Rails 3 to create a simple Contact Us form?

Question: How would I use form_tag (because I don't have a model) to create a contact us form with a name, email, and message field. Then on submit I would like to call a controller action that would send an email to an email account. Sorry I'm new to Rails, but can someone point me in the right direction? Thanks!
Answer: you could check here , i have googled to it and read briefly , but seems to be all OK!
http://www.railsmine.net/2010/03/rails-3-action-mailer-example.html
Have a nice day!
edit: ... in this example they use a model to store support message , it's a good idea , you have strong activerecord validation , a restfull action and an history of every message sent.
sorry for my english.
Comment: Thanks for the link, it helped a lot! (And your English is fine lol).
Answer: I've written a Rails Engine https://github.com/jdutil/contact_us that you can easily drop into any Rails 3+ application.  I didn't add a Name field to the form, but you could fork the repo then modify it to suit your needs.  Or you can simply review the code to snag any relevant pieces you are stuck on for making your own form.  It does require the Formtastic gem since I wanted an easy way to hook into peoples existing form styles though.
To install the Engine add the contact_us gem to your Gemfile:
gem 'contact_us', '~> 0.0.8'

Run bundle and the install rake task:
$ bundle
$ bundle exec rake contact_us:install

Then just modify the generated initializer in /config/initializers/contact_us.rb to have the email you want the form submissions sent to.


CV and personal statement mutually exclusive?

Question: Should the CV and statement of purpose for grad school be mutually exclusive, in particular if something is already in my CV, is it not necessary to mention it in the statement of purpose? For example, for a paper that I published, and I already included it in my CV, then I wouldn't need to say I published this paper in so-and-so journal in my statement of purpose?
Comment: Related (to the specific example): [Should I link my research in my SOP?](http://academia.stackexchange.com/questions/14166/should-i-link-my-research-in-my-sop)
Answer: Your CV is a straightforward and concise list of your academic credentials. Your statement of purpose is a chance for you to expand on your credentials (specifically those that make you an especially strong candidate, or to explain things that might seem to weaken your application) and also give some insight into your future plans.
They are not mutually exclusive, nor should they overlap entirely; they serve completely different purposes.

in particular if something is already in my CV, is it not necessary to mention it in the statement of purpose?

If you have something more to say about it that strengthens your application, go ahead and say it in your statement of purpose.
Comment: Can you be more specific? For example, I published a paper. How should I talk about that in my statement of purpose? Should I talk more about what was the motivation of the project instead of what I did exactly?
Comment: @user1250125 Your SOP is supposed to make a case for your ability to succeed in the program you are applying for. If the publication is related to your planned course of studies and helps make that case, then it should be part of that "story." What, specifically, to say about it depends on the publication and how it makes your case stronger.


Grub does not load up even after running boot-repair

Question: I had a successfully running computer with dual booting Windows 8 and Ubuntu 13.04 until I made the drastic decision to upgrade Windows 8 to 8.1.
The upgrade to Windows 8.1 was fine but I discovered that Grub was not loading.
So using a live CD I managed to run boot-repair to repair the EFI partition (just like when I first installed Ubuntu about few months ago).
However this time even after running boot-repair with recommended settings, Windows 8.1 keeps booting rather than Grub.
Cheers
Answer: Turn off secure boot and run boot-repair.


Sharing Active Directory between 2 SharePoint Farms

Question: Can I create 2 different SharePoint farms using the same Active Directory
Comment: as short answer Yes, please provide more scenario if you need more details
Comment: @M.Qassas, thanks, I just want that short answer and when I googled it all results referred to shared DB server, that's why I posted the question here
Answer: As mentioned in the above comment, Yes you can, I have already two farm that uses the same shared Active directory ,
but it's preferred to isolate the service accounts for each farm to a specific  group.

Farm1 Service Account Group (that contains for example SP_farm1)
Farm2 Service Account Group (that contains for example SP_farm2)
Answer: Multiple applications can connect to the same Active Directory. This also applies to Sharepoint.
So in short, the answer is yes. But it is advisable to NOT share service accounts across environments/farms.


The proper way to compute the posterior distribution of a distribution

Question: Suppose I am a Bayesian working with multi-level data, $j$ and $t$.
I run a model using $t$ that calculates the posterior distribution of a parameter $\theta_j$ for each $j$, which I then use to calculate the posterior distribution a function $g(\theta_j)$ for each $j$.   Thus, afterwards, if I ran $R$ draws in my MCMC, I end up with:
$\{g(\theta_j^r)\}_{r=1}^{R}$ for each $j$.
Now, I am interested in the variation in $E_{\theta_j}[g(\theta_j)]$ across $j$ units, which can be characterized by a distribution, which I will call $f(g)$.
Of course, my best guess of $f$ would be to plot the empirical distribution of the $E_{\theta_j}[g(\theta_j)]$'s.  However, I want to characterize the uncertainty in $f$. How can I do this empirically given all my draws?  A bootstrap?
Here is what I tried before I realized this was vastly over-estimating uncertainty:
Basically, I plotted the distribution of $g$'s at each value of $\theta$.  Then took the credible intervals vertically.  However, I think this over-estimates the uncertainty and actually gives an incorrect distribution.   For instance, I know this because in my problem, the $E_{\theta_j}[g(\theta_j)]$ must be strictly positive, and when I plot their empirical distribution, they are.  However, when I use the single-draw-at-a-time approach, we get a lot of negative mass with too much precision.  Sure, maybe some of the draws might turn out negative, but not the expectation itself.  Maybe a bootstrap would solve this?  But I was hoping for a more bayesian-theoretically guided approach here.
Answer: The problem with this question, upon further reflection, is that there is not a posterior distribution of $E_{\theta_j}[g(\theta_j))]$.   If you are a true Bayesian, the expectation is just a number at this point.  Therefore, it doesn't make sense fo try to characterize uncertainty for each expectation (and by extension, the distribution of the expectations).