Most suitable interpolation method - regridding

Question: I'm looking for guidance on the choice of interpolation method. The data I want to interpolate is air quality data, but not from stations - it is a kind of a model in a 1x1 km grid (where each point represents the average value of the respective cell) and I want to interpolate it to 50x50 m (in the fine grid, each point should represent the value at exactly that location). I tried to do it in R using bilinear (fields::interp.surface) and bicubic (akima::bicubic) methods and I've also considered kriging - but I have a feeling that that would not be suitable for regridding. There are some (not so significant) differences in results, but I would really like to know which approach is the most correct. Maybe even another method? There is just one condition, that I have to be able to do it in R (just as the rest of my code is).
Comment: Since your data is a regular lattice i would recommend coercion to a raster and then using a bilinear or cubic resampling. Kriging on a regular lattice is not advisable.
Answer: Besides reviewing the literature and figuring out which methods have been typically applied successfully to given data, I think the only way to know whether an interpolation method is the most suitable for a given data set is verify the model in the field... that is check modeled points at unsampled locations against actual field measurements. The number and distribution of measured points and the choice of parameters when applying a method all have an impact on the results. Below is a graphic from one of the classes at NCSU:

The essential message is, there is no unique solution to interpolating between points in a data set. Each line in the graphic represents either a different interpolation method or application of different parameters in same method. One can target some specific characteristics of the solution to the function such as smoothness, but whether the solution is more "correct" is a judgement call.
In your case it sounds you would like to take a model and refine it...meaning fill in the model (interpolate additional points). I don't think you necessarily get a more correct result. You will get more points in between any two measured points(measured to produce original model), but really the new points will sit along the same line as in the courser grid unless you change the parameters and in that case you are getting different solutions of the function but not necessarily more representative of the real world.
But I think if you are able to figure out the method and parameters used to get the initial model, you should be able to reproduce(re-grid) similar results on a finer grid. i.e get similar values at locations in the 50 x 50 compared to the 1km x 1km.


Multiplication of average voltage and current?

Question: Multiplication of \$V_{rms}\$ and \$I_{rms}\$ gives average power. What things we get if we multiply \$V_{avg}\$ and \$I_{avg}\$??
Comment: Quite often zero...
Comment: @kishore: In case Andy's comment is not clear, the average of a sinewave is zero.
Answer: Multiplication of Vrms and Irms gives average power into a resistive load only. Into other loads which result in out of phase waveforms, capacitive, inductive, rectifier for instance, the result is not average power.
If you multiply Iavg by Vavg, the caveats are similar. For well behaved waveforms like DC, the result is average power. It's easy however to construct other waveforms into other loads for which it's not average power.
In all cases, you get average power from averaging the product of the instantaneous voltage and the instantaneous current. In some well behaved cases, you can take short-cuts.
Answer: Multiplying \$I_{RMS}\$ by \$V_{RMS}\$ gives apparent power. This is the hypotenuse of the power triangle, where the other two sides are the real (average) power (in watts) and the complex power (in VARs). If, and only if, the load is purely resistive then the complex power is zero and the apparent power will equal the real power.
In general, multiplying \$I_{AVG}\$ and \$V_{AVG}\$ gives you nothing meaningful.
Comment: @BruceAbbott Which is why I said "in general". Only in specific cases, such as dc circuits, do you get a meaningful result. But in dc circuits we wouldn't usually even talk about average current and average voltage...there is just **the** current and **the** voltage.
Comment: "In general, multiplying IAVG and VAVG gives you nothing meaningful." - except in DC circuits, where rms current can be deceptive.


If I deleted photo from gallery made backup before flashing, will I get that photo in the backup?

Question: My phone is Samsung Galaxy Grand. If I delete a photo from the gallery and make a backup before flashing, will I get that photo in the backup?
Answer: That very much depends on the type of backup you are talking about. As the photo was deleted, none of the usual backup approaches would cover it: a backup only takes what is there, not was was deleted.
How to recover that photo (if possible) depends not at last on where it was stored:

external SDCard: safely remove it from the device, and use a card reader to check for deleted files with your computer and an application like PhotoRec
internal SDCard: not that easy. You have to clone that partition (a nandroid backup usually does this), transfer it to your computer, and analyse it with an application like TestDisk or Scalpel

Details and further hints can be found e.g. in our data-recovery tag-wiki. See e.g.:

How can I recover a deleted file on Android?
How to Restore Deleted / Formatted Files on HD Micro SD Card
Answer: Usually, flashing of the ROMs only affects files that are stored on your /system partition. Photos are stored on a SD card, and won't be deleted when you flash a ROM.
As for deleted photo, once it's deleted it can't be restored by normal methods. You could try restoring deleted files (there are many articles on the Internet regarding that, try searching for "restore deleted photos on android")


TWLauncher crashes on App installation

Question: Faced this problem, and after spending hours of time on this, got the solution.
The issue is, whenever I installed the app, the TWLauncher of the Samsung device, enters a crash loop, where it always crashes.
Answer: No idea why, but when I replaced the icon with an other one, it fixed the issue. So use a different image and try, and it will work! Just thought I would share this with all of you.

TWLauncher crashes on App installation


Is it possible to create a time based nft where there is a fixed expiry date?

Question: I'm looking to create a set where after a set period of time (a week, a month, a year) the token expires and all its value is wiped. Is it possible to do this and if so how?
Answer: Yes, this is possible. To accomplish this, you would start with your preferred NFT standard and a timestamp on creation. It also depends what you mean by having its value 'wiped'. Value is something determined by buyers and sellers in a market. So assuming 'wiped' means destroyed, you can have the NFT destroyed after your deadline has passed. One caveat is that you would need someone actually call the NFT to self-destruct after deadline is passed.
To implement a deadline of 365 days, you set the constructor to have something like:
uint _start;
constructor() {
_start = block.timestamp;
}
function checkTime() external {
if(block.timestamp >= _start + 365 days) {
selfdestruct(owner);
}
}
Then after 365 days, you or an automated script needs to call the contract "checkTime()" and the NFT will be gone.
Comment: Hi, thankyou for answering the question. I am fairly new to coding so how much do you want to teach me the basics of how to do this?


Oracle Exadata datafile distribution

Question: I'm new to Oracle and curious of how Oracle Exadata handles database files. Do we have to assign the disk to a database file as we do with Microsoft or is this handled by Exadata?
Answer: I do not know what you mean by the "Microsoft" way, but Exadata uses ASM.
Administering Oracle ASM Disk Groups on Oracle Exadata Storage Servers
http://www.oracle.com/technetwork/database/availability/maa-exadata-upgrade-asm-2339100.pdf
ASM is not specific to Exadata or any hardware, you can use it on any supported platform, even on Windows, so you handle database files just as in any other environment with ASM.
Answer: The storage interaction on Exadata is done via ASM on the database servers, that talks to the cell storage servers using an interface layer called libcell rather than the usual disk IO layer. The InfiniBand network is used for all storage interactions.
Apart from the initial setup (which is done as part of the Exadata deployement), the databases are handled exactly like you would handle a database on ASM on general-purpose hardware. It is transparent for day-to-day tasks like creating/extending/dropping datafiles or tablespaces, also transparent for backups (as long as you use RMAN).
There are a few recommendations for storage parameters that are specific to Exadata (regarding extent sizes, cache parameters), you get access to HCC compression, and you can do IO resource managements at the storage level. (Plus all the cell offloading goodies.)  But apart from that, for every-day care and maintenance, they look just like any other ASM-based databases.
This is the same for bare-metal database servers and for virtualized database servers (since X5). The virtual machines get virtualized InfiniBand connections, and ASM uses those the same way it does on bare metal.
If you want to know more details about how the cell servers themselves are configured, I encourage you to go have a look at the docs, they are pretty comprehensive. A nice starting point to get a feel of it would be the cell admin guide, the Administering Oracle ASM Disk Groups on Oracle Exadata Storage Servers has a simple diagram for how the pieces interact. There's also a section on the Oracle support site that is dedicated to Exadata topics.

Oracle Exadata datafile distribution


Permission record type specific for a Custom List button

Question: I have a custom List button(Behaviour - Execute javascript) and that needs to be accessible to a user for a particular Opportunity Record type alone. For rest of the Opportunity record types, it should not perform action/show insufficient privilege. Any idea how can this permission be given?
Answer: A configuration-only way would be to use multiple page layouts, assign the layout with the custom button to the record type where it should be available, and the other layout without the custom button for other record types. That does mean handling two different layouts, however.

Alternatively, you can modify your JavaScript and Apex Code to enforce the rule.
JavaScript
try {
  var result = sforce.apex.execute(...);
  window.top.location = '/{!Opportunity.Id}';
} catch(e) {
  alert('An error occurred during processing.\nReason: '+ (e.message || e) );
}

Apex Code
webservice static void invokeSubProductUpdates(Id oppId) {
  Opportunity record = [SELECT RecordType.Name FROM Opportunity WHERE Id = :oppId];
  if(record.RecordType.Name != 'Some Type') {
    throw new InvalidParameterValueException('This action may only be performed on "Some Type" opportunities.');
  }
  ...
}

Answer: Option 1 -- Recomended
You can assign different layouts for different record types.
That said... you can add your button on layout for a particular record type.
Option 2
In your javascript code for the button you can include follwing check even before firing any apex code
var recordType = '{!ObjectApi__c.RecordType }';
if(recordType != <RecordType expected>) alert("insufficient privilege");
//code continues ....


Function run and process on server / azure then send back to apps and display

Question: I trying to built some application with metro-UI with C# for Window 8, due to Window 8 will be running on tablet soon, and now i knew my application required a lot of processing power, thus, ideas come into my mind, what if i could make the high performance process on server; either get another VPS or Azure to process the functions then send back the processed function results to the Window 8 Metro-UI application ?
The high performance functions i mentioning about ::

face images recognition - recognize face on server then tell the result
Generate Image - some user upload image will put watermark and regenerate a new image
Crop Image - like facebook, crop the face part from big image
Edit Image - in case of the crop is not so right or the alignment got problem
Filter Data - big amount of data from user, need to filter then insert to server
and others...

What come into my minds are, WCF ? but i never learn it in details before.. any keywords to research on this issues ?? Thank you for reply. =D
Comment: please try to explain in more detail what you are trying todo
Comment: @ntziolis, Thank you for your advice and now it's updated, hope you can understand my poor english =D
Answer: Basically any technology allowing for communication between your application and a server can do what you ask as long. If you implement both sides you can define any relevant aspect like  protocol, security etc.
Regarding Azure and WCF:
Yes you can implement what you ask via WCF on Azure... Azure and WCF by itself do not know anything about images or similar things - it is up to you to implement whatever you want...
You can use WCF even without Azure... basically WCF has some support for loadbalancing/routing etc built-in so you can even go and setup some webfarm for the heavy lifting...
WCF can use different protocols - some are more portable regarding other platforms (like HTTP/SOAP which is usable with iOS or Android for example), others are more performant (like a binary TCP-based protocol...). Some are more firewall-friendly (like http) etc.
Which to choose depends really alot on what you need...
Regarding Metro:
Metro Apps can be implemented with C#, JavaScript etc. - depending on your situation it might be an option to implement this as a combination of HTML5/JavaScript client-side and WCF/C# server-side...
Regarding image editing etc.:
How to implement this depends on the functions you want to give the user... some things are achievable by using scaled-down version of the image client-side (like red-eye-correction) and some are rather complex (like high-end-color-correction) since they need several aspects (high resolution, color-management etc.).
There are several .NET based image processing libraries out there (free and commercial) which offer a wide variety of image-related function... some have cloud-specific interfaces (http and/or some UI-controls etc.). Be sure to check on licensing before using libraries in the cloud (Azure or similar)...
Edit image/Filter data is a wide field thus not specific enough... Compare image (in term of face) seems to imply that you want to do some recognition... this is a very complex and broad area but very well possible with .NET...
Since you don't give details on the use cases/scenarios it is hard to give any specific advice... feel free to add more details so the answers can be more specific...
UPDATE - as per comments the OP wants to basically implement something similar to face recognition found on facebook:
Implemeting face recognition similar to facebook is a VERY BIG project IMHO... the algorithms for recognition are complex and the "good ones" are usually developed internally and not sold/licensed to others... so you will have to find some high-quality image-processing library and develop/implement your algorithm on top of that library. There are some good starting points for such algorithms but basically you will need to do a lot of work to enhance/refine them... for this you will need a lot of test data/images etc.
As for watermarks this is another complex area... some technologies are opensource, most are not robust enough depending on what you want to achieve... security of watermark varies alot... does it need to be robust enough for someone printing and scanning it back ? or for someone taking a photo off a screen ? or just for scaling ?
Another aspect is the legal side of this... several relevant aspects of such algorithms are patented which means you might need to acquire proper licenses... privacy is another legal aspect to keep in mind when implementing this sort of application...
UPDATE 2 - as per comments:
Some general search terms for implementing a process which calls functions on a server and gets the results back are "SOAP", "WCF", "WebService", "JSON".
You can find some general information:

http://msdn.microsoft.com/en-us/netframework/aa663324
http://msdn.microsoft.com/en-us/library/dd163896.aspx
http://homepages.ius.edu/rwisman/b438/html/net.htm
Comment: @SLim no problem... I updated my answer too... from your question there are still not enough details... are you aiming for face recognition ? what exactly does "edit" mean ? something like Photoshop (professional desktop application) ? or more some minimal consumer-oriented photo-editing ?
Comment: @SLim what does "verify" mean ? technical file format check ? some sort of integrity check ? some metadata-based check (like EXIF/XMP) ? what does "crop" mean ? some rectangular area ? or something path-based (like photoshop polygon based clipping) ?
Comment: Yes, i am aiming face recognition.. but just forgot the keyword, Thx for remind =P and edit is align the image, crop the face but i dont want to use too much processor... Thank you =D
Comment: like what facebook did.. automatic look up for the face and crop the face part from a big image, verify is recognition
Comment: can you please suggest me the way to implement the process of run something on server and send back the result to application ? what is this process called and what is the tools available ?? Thank you =D
Comment: Thx, Dude =D 22 hour later only can reward you XD


Is EMF a force?

Question: I had a confusion. EMF stands for electromotive force. Is it a force? I have a short question and I can't elaborate more but this site is not allowing me to post so I am writing.
Comment: Hello! Is there anything particular that you don't understand about the [Wikipedia article](https://en.wikipedia.org/wiki/Electromotive_force)? Especially "The word 'force' in this case is not used to mean forces of interaction between bodies"
Comment: I second Jonas comment. I suggest you read the Wikipedia article and then, if you still don't understand, come back.
Comment: Does this answer your question? [What is Electromotive force (EMF)? How is it related to potential difference?](https://physics.stackexchange.com/q/102259/)
Comment: It is a very old name from about 1830, before electricity and magnetism were well understood. Today we would say it is potential difference or voltage. This is what makes a current flow in a conductor. Since it makes charges move, it was natural to think in terms of force. "Electromotive" force because it made electricity move.
Answer: Induced EMF is integral of induced electric field over some path. In the simplest case, it is the product of induced electric field and some length. This quantity can be understood as work of induced field per unit charge when it gets transported along specific path. Its unit
is Joule per Coulomb which is Volt.
It is a "force" not in the sense of mechanics, but in the sense of "driving force" behind electric current, because it can drive electric current in a circuit. In the simplest case like a circuit made of wire in changing magnetic field, current in the circuit is approximately proportional to induced EMF in the whole circuit.
Answer: Emf is not a force in the strict sense.  Nor is it an electric potential, though it has the same dimensions.  It is work per unit charge done in moving charge around a circuit.
It is commonly confused with potential because it is often the potential difference that is doing the work, so they are often equal.  For example, the potential difference across the resistor is $-IR$ by Ohm's law, and this is also equal to the emf applied to the circuit by the resistor.  However, it is also possible to apply an emf to a circuit that is not associated with a potential, for example by induction.
The relationship between emf and potential is EXACTLY the same as the relationship between work and potential energy.  Emf is work per unit charge, potential is potential energy per unit charge.  Work done on a system by a conservative force is associated with a drop in potential energy, but you can also do work on a system by nonconservative forces.
(As @Chemomechanics points out, emf can be considered a "generalized force" from a thermodynamics point of view, but otherwise the term "force" in "electromotive force" is a misnomer.)
Answer: It is not a force - it provides an electrical potential (voltage). Specifically, it has dimensions of potential energy divided by charge.
One usually thinks of an EMF in terms of something like a battery that has a voltage between its terminals. The rate of change of a spatially varying voltage is the electric field. The actual force on a particle is its charge times the electric field.
Comment: It provides voltage in some cases, but that is not its defining characteristic. For example, induced EMF in a circle may not produce any voltage if the field has line of cylindrical symmetry that is also line of symmetry of the circle.
Comment: This answer would be more accurate if "It is not a force" were changed to "It is not a mechanical force". In thermodynamics, all conjugate work pairs are treated as generalized forces and generalized displacements whose product has units of energy. Voltage is one such generalized force (charge is its conjugate generalized displacement).

Is EMF a force?


New factor levels in testing data set not present in training data in h20.randomforest

Question: In randomforest classification using h20 package, there are factor levels which are present in testing data but not in training data.There is a warning message in predicting the values of testing data, it says : test/validation dataset column 'x' has levels not trained on. Please help
Answer: This is the expected behaviour; if you cannot change your data, then just ignore the warning. (Sorry, I am not aware of any H2O option to suppress the warning.)
The better solution, and their motivation for giving you the warning, is to get better training data, and ensure that it covers all possible values you want to predict. This might mean changing the way you split your training data into train and test (e.g. group by each possible output level, and then randomly split each group 80:20, or whatever, rather than randomly splitting the whole training data 80:20).
An alternative solution is to pre-process the data to replace unusual or rare values. E.g. if you are predicting a person's favourite colour, and you have red, green, blue, yellow, purple, black all well-represented in the training data. But then you have one record each of "mauve" and "light teal". You might be better off converting them to "purple" and "green". The model is not going to learn much from just a single example.
Comment: If i ignore the warning,there is an error while : submission<-data.frame(unique_id=test$unique_id,target=predictions$predict)  ::::Error in read.table(file = file, header = header, sep = sep, quote = quote, : 'file' must be a character string or connection
Comment: @PA17 That looks like a different problem, unrelated to the factor level issue. But it is really hard to be sure, out of context. If you are sure that error only happens after ignoring the factor levels warning, can you update your question with a reproducible example (I.e. a bit like your question over on StackOverflow, but also including the data - and including only the minimum amount of data that is needed to show the problem).
Comment: to be precise : the error is:::: Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
  unused argument (optional = TRUE).....i think the test data is a h20 frame, so i think we cannot slice the unique_id column.. is that so?


Virt-manager: unable to open a connection to the libvirt management daemon

Question: I'm having a bit of trouble connecting to my virtual machine host, which is an Ubuntu server running KVM/Libvirt. I can connect to the server using an Ubuntu client and I can connect via virsh on a Fedora 16 client. Unfortunately, connecting via virt-manager fails with the error: "unable to open a connection to the libvirt management daemon".
Comment: Is *libvirtd* running on the system?
Comment: Yes: bshacklett@edo:~$ ps aux | grep libvirtd
1000      2347  0.0  0.0   7620   920 pts/0    S+   16:54   0:00 grep libvirtd
root     26368  0.0  0.0 216880  5252 ?        Sl   Sep26   0:02 /usr/sbin/libvirtd -d
Comment: I attempted to connect with virt-manager on an OpenSuse box last night and experienced the same issue. It seems to me that this is more of a server-side issue than client-side. Is there a chance that Ubuntu (or Debian) doing something strange with the Libvirt packages? I plan to take a network trace with Wireshark tonight if I don't get wrapped up in other things.
Answer: I needed to install the openssh-askpass package.


How to eliminate Kaama?

Question: Kaama is very problematic . It makes us do adharma.
How to eliminate it ? What are the ways through which we can overcome Kaama.
Comment: Generic Term Kaama referes to just desire but based  on your question context of adharma i persume that its sexsual desire.. Kanchi mahaperiyama doesnt eat food for 7 days.. without water.. only theertha.. would have controlled absoluetly. Aqgara niyamana.. Ekadhasi upavasa.. Japa. achamana.. will do.. not eating food from strangers or hotel. No onion garlic food..
Answer: Kama doesn't need to be eliminated completely. It needs to be controlled, as per the Dharma, to be followed by a householder is a must for societal order, and slowly, and slowly through penance (tapas) in the form of vows, sacrifices, charity, fasts, etc. it need to be overcome.
Even, so then Kama is difficult to vanquish or eliminate completely, for an average person, for kama (desires) is the root cause of material existence.

View 1:
In this regard, the following excerpt from the Skanda Mahā-Purāṇa maybe helpful.

Chapter 238, Tīrtha-māhātmya, Nāgara-khaṇḍa, Skanda-purāṇa

It should be understood that Śauca (purity is of two types: external and internal. Cleaning with water is th.e external one and
purification through faith is the internal one.

Curbing of the sense-organs should be practised. It is the greatest feature of Tapas. Cessation of fickleness of the senses
during Cāturmāsya will he the greatest Tapas.

By controlling the horses in the form of sense-organs, one can augment one's happiness. The same horses (sense-organs) going astray
cause one to fall into Naraka along with the vital airs.

One should curb the atrocious she-alligator in the form of Mamatā (feeling of ownership) after rebuking it. Tapas alone increases the
weightiness of men always particularly in Cāturmāsya.

This Kāma (lust) is a great enemy. One should vanquish it alone steadfastly. Those who have conquered Kama are noble-souled ones. The
entire universe is conquered by them.

The conquest of Kāma, the victory over wishful volition is always the root of Tapas. It is the very root of Tapas,

That alone is the greatest wisdom, by which Kāma is vanquished. The same in Cāturmāsya they call as the greatest Tapas. It yields
excellent benefit.

Thus vows like those of Cāturmāsya, and other important fasts like Ekadashi, Sivaratri, Navarātris, et al, done as per dharmika injunctions are conducive in regulating the enemy of Kama.

View 2:
In this regard we get a beautiful passage from Mahabharata itself, which is known as Kama-Gita found in the Section 13 of the Ashwamedha parva.
Sri Krishna himself recites this to Yuddhishthira, declaring the unconquerable nature of kama (desires)

Kâma-Gitã, Mahabharata
Sri Krishna Said -
By way of illustration of this truth, the sages versed in ancient
lore, recite these Gathas called by the name of Kamagita, do thou O
Yudhishthira, listen to the recital of them in detail. (Kama says) No
creature is able to destroy me without resorting to the proper methods
(viz., subjugating of all desires and practice of Yoga etc.) If a man
knowing my power, strive to destroy me by muttering prayers etc., I
prevail over him by deluding him with the belief that I am the
subjective ego within him. If he wish to destroy me by means of
sacrifices with many presents, I deceive him by appearing in his mind
as a most virtuous creature amongst the mobile creation, and if he
wish to annihilate me by mastering the Vedas and Vedangas, I over
reach him by seeming to his mind to be the soul of virtue amongst the
immobile creation. And if the man whose strength lies in truth, desire
to overcome me by patience, I appear to him as his mind, and thus he
does not perceive my existence, and if the man of austere religious
practices, desire to destroy me by means of asceticism, I appear in
the guise of asceticism in his mind, and thus he is prevented from
knowing me, and the man of learning, who with the object of attaining
salvation desires to destroy me, I frolic and laugh in the face of
such a man intent on salvation. I am the everlasting one without a
compeer, whom no creature can kill or destroy. For this reason thou
too, O prince, divert thy desires (Kama) to Virtue, so that, by this
means, thou mayst attain what is well for thee. Do thou therefore make
preparations for the due performance of the horse sacrifice with
presents, and various other sacrifices of great splendour, and
accompanied with presents. Let not therefore grief overpower thee
again, on beholding thy friends lying slain on the battlefield. Thou
canst not see the men slain in this battle alive again. Therefore
shouldst thou perform magnificent sacrifices with presents, so that
thou mayst attain fame in this world, and reach the perfect way
(hereafter)."
English Translation by K.M. Ganguli

The above idea is beautifully summarized by Swami Sivananda in his lecture on Purity.
So basically, in the words of Swami Sivananda

The desire says, "People try to conquer me, but they do not know that
even the desire to conquer me is a desire, they don't understand that,
so I am behind all their attempts."
Desire for God sublimates all other mortal desires. The higher absorbs
the lower, the lower should be transmuted to the higher by meditation.

So the answer is, to conquer kama, one must leave all the fruits of their karma to the God (BG 18.66), become Stithaprajña, and perform karma, in conjunction with penance (like sacrifice, fasts, etc.) as per their Dharma.
Comment: Also another [relevant answer is here](https://hinduism.stackexchange.com/a/51439/17833)
Comment: Excellently composed and a very well written Answer Sir!
Upvoted!!!

How to eliminate Kaama?


Any books or web resources for robotics mechanical design?

Question: I plan to build a mechanism with multiple axis, which is similar to a robot. To start, I need to define some specifications such as repeatable precision, speed, acceleration, and payload. Then the motor and structure is selected and designed based on these parameters. After that, I need to choose methods to manufacture these components. I would like to consult experienced experts in this forum that is there any suggested books, textbooks, or website resources I can learn these knowledge?
Comment: Have you considered standards also?
Comment: Welcome to *Robotics*, Superuser. As it stands, I think your question is too broad. You ask for references on setting specifications and manufacture. Determining aspects of mechanisms such as limiting speeds, accelerations, weights, etc. is typically the subject of quite a few collegiate courses - physics, statics, dynamics, mechanical system dynamics, and, debatably, kinematics and structural analysis. If you could provide one aspect of a specific scenario then maybe someone here could help, but with the scope you seek, your best resource would be your local university.
Comment: Stack exchange is not a discussion forum, it is a place to ask *[practical, answerable questions based on actual problems that you face](http://robotics.stackexchange.com/help/dont-ask)*. If you wish to discuss robotics you can use [chat]. Please take a look at [ask] and [about] for more information on how stack exchange works.
Answer: You could look at three books.

A Mathematical Introduction to Robotic Manipulation - S.Sastry, X.Li and R.Murray provides a theoretical foundation to the kinematics, dynamics and control aspects of robotic manipulators. The only downside to this book is that it lacks in algorithmic content like that available in Probabilistic Robotics - Sebastian Thrun
Robotic Engineering An Integrated Approach deals with the A to Z of designing a robotic manipulator. It gives you a theoretical overview of the fundamental concepts. In terms of design it takes you from requirements through implementation and practical considerations while choosing actuators, computing systems etc. The downside for this book is the same as the previous book.
Mechanical Design of Robots covers mechanical engineering topics such as stresses, strains, structures, linkages etc. It is a book to help you design a robotic system from a functionality standpoint. The author maintains that design of robots should not necessarily compromise on aesthetic values by always going by the worst case scenario.
Comment: Thank you very much for your sharing. It is helpful. I will start to study them.


How to performance tune AJAX heavy application

Question: I'm developing kind of image/profile search application, that is based almost exclusively on AJAX. Main page basically displays profile images and allows user to filter/search and paginate through them.
Pagination works when user scrolls, so the interface has to be very very fast. There will be only 6 (maybe 9, but definitely not more) images displayed on the main page, so users will scroll a lot. I'm currently using very simple JS cache to store results of all the requests in case user decides to go back ... in that case, I simply pull everything out of the cache instead of querying the server.
Client cache
One option that I thought of is to pre-load say 10 pages in front and store them in the cache.
But my biggest issue is filtering/searching, since that completely changes the type of query that goes to the server. My filters aren't very complex, only around 6-7 string/number/enum attributes.
Now if I wanted to do all the filtering in the cache, I would have to duplicate all the search logic and fetch all the data from the server (not just the data I'm displaying), so I could filter the results on client side.
Here raises a question, should I make the cache somehow persistent? Store it into a cookie maybe?
Server cache?
One suggestion might be to use memcached on the server and just store everything there. I'm definiely going to cache away all the results I can, but that doesn't save the server from handling loads and loads of AJAX requests.
I'm developing this application on Rails 3, and even though I love it, I wouldn't say it's the fastest thing in the world. Another option that this gives me is to create separate Rack/Sinatra application to handle only the AJAX requests. By this I mean requests from the main query, not all AJAX.
S3 for images?
Big part of this application are images, even though they're mostly small thumbnails (unless user wants to display it bigger).
At the moment, I don't have problems with bandwidth. My VPS host provides me with 200GB, which should be more than enough (I hope). The problem is loading speed. Would it help if I uploaded all the images to S3 and load them from there, or is this worth doing only for larger files? I'm going to load a lot of 100x150px images, which are generally under 50kB.
Answer: Have you looked at SlickGrid. It has an interesting idea of only building the list as users scroll down but then removing the list as the users scroll out of that range.


Store/Google Analytics transactions discrepancy

Question: Is there any reason why Store might not be logging transactions with Google Analytics apart from JS being disabled/unavailable? We have some orders not showing up in GA and the client is keen on identifying the underlying cause.
Comment: What version of EE and Store are you using?
Comment: EE is 2.5.1 and Store is 1.6.3
Comment: Which payment gateway are you using? Are all the orders not in GA using the same payment gateway?
Answer: Store relies on the customer landing on the payment complete/invoice page for the Google Analytics e-commerce tracking to work.
Depending on which gateway you are using (especially if it is an off-site gateway), some customers might simply close their browser after they see the gateway's "payment complete" page, and not click through to your final invoice URL. If that is the case, there is no way for the orders to be reported to GA.
Comment: Many thanks Adrian - that makes a lot of sense as we're using WorldPay to handle transactions off-site


PythonWin not running

Question: Can anyone help? Since moving from Arcmap 10.7 to 10.8
(running Python2.7.18 (v2 )
Window Pop Up message reads:
Answer: The error means that the required module is missing. It's a dependency on pywin32 package.
You have to install this package. What's win32con module in python? Where can I find it? you will find the solutions to resolve this issue.

PythonWin not running


Will an electric megaphone amplify ultrasound and still send it in a narrow cone?

Question: Will an electric megaphone amplify "ultrasound" and still send it in a narrow cone ? If So, how will such a device distort sound at frequencies higher than the human ear can detect ?
Comment: Very much depends on the device. Most are for audible purposes, and will focus on that job.
Answer: Ditto for @JMLCarter comment.
To elaborate on this, Wikipedia refers for some data below, while other sourced from technical literature.
The average reflex or reentrant horn speaker has a typical frequency range of 450Hz - 6KHz.
Also called a folded horn, the reflex type has several horns facing each other to force the sound-path into a Z pattern.
This simply shortens the overall body length to make megaphone more portable, while the horn remains long.
The mouth (front flare) matches the impedance of vocal chords/throat to the air.
Both the amplifier circuit and horn driver (a small but powerful speaker) would be optimized (wide audio band-pass filtration) for vocal range frequency.
Ultrasound is above human hearing, way above human voice frequency (U/S starts at around 15KHz-16KHz).
The horn itself is way too large to be resonant at such high frequency, so there will be attenuation.
Plus, some ultrasound generating circuits produce a square wave signal. A 16-40 KHz square wave alone would introduce harmonics.
Taking all above negatives into account, the answer is no, not feasible.
I don't know what U/S circuitry you have, and for what purpose you want to broadcast/amplify.
However, you could build or buy an amp to operate at HF audio, then use a shorter smaller resonant horn to "channel" the sound.
It is unclear whether a horn profile follows resonance formulas for audio. Speed of sound (symbol v) at sea-level 25~C is 341.376 meters per second.
Standard Loudspeaker enclosures usually use Half-Wave or Quarter-Wave dimensions to reinforce a frequency range, depending on ports.
To convert to mm, v*1000, so v=341376 mm/s.  f=Hz. WL in mm. (WL symbol lowercase Greek lambda). As Lambda is unicode font I'll use WL for wavelength.
FWL=full wave length (WL x 1); HWL=half wave length (WL/2); QWL=quarterwave length (WL/4).
f=v/WL. WL=v/f
Here are some calculated figures
FWL (Lf horn)=341376/450=758.6133 mm. HWL (Lf horn)=379.3067mm. QWL=(Lf horn)=189.65335 mm.
FWL (Hf horn)=341376/6000=56.896 mm. HWL (Hf horn)=28.448 mm. QWL=(Hf horn)=14.224 mm.
FWL (Lf horn)=341376/16000=21.336 mm. HWL (Lf horn)=10.668 mm. QWL=(Lf horn)= 5.334 mm.


Umlet is not working in jsf

Question: I am using xhtml and jsf combination.
If I enter umlet character in text box it chage to other code.
Suppose i give ö it change to ö.
Can please any body help me?
Is need to include any tag for umlet in jsf?
Answer: Facelets uses UTF-8 by default to write the characters to the response, so this issue should not be caused by Facelets. Apparently the file itself is saved with the wrong encoding by your file editor. To be precise, in CP-1252 instead of UTF-8. Explore the editor settings to change it to UTF-8. In Eclipse for example, you can find it in Window > Preferences > General > Workspace > Text File Encoding.

Umlet is not working in jsf


Is allowing kids to leave their bike out on their lawn an example of attractive nuisance?

Question: I know plenty of friends who have allowed their kids to leave their bikes in the front yard.  I'm wondering what would happen if a random child were to steal a bike left out and get hurt playing with it.  Would the parents be liable due to the attractive nuisance doctrine?
Comment: @Trish I am pretty sure that "kids" + "leave their bikes" + "front yard" = bicycle, not motorcycle. It takes a special kind of parent to allow kids to live motorcycles in the front yard.
Comment: @Justaguy motorized bicycles are a thing - Mopeds and Mofas. Over here you can drive the smaller ones at 15, the larger ones at 16 - which is still *kids* territory
Comment: The attractive nuisance doctrine relates to harm coming to children while trespassing. Trip on the bike is one thing, borrow it an fall off it a block away is another.
Comment: @GeorgeWhite what if they play with it on my lawn and hurt themselves there?
Comment: are we talking Bicycle (as assumed) or are we talking Motorcycle? Both are colloquially called "bike". also, we are talking about a kid that *takes property unlawfully* while *trespassing*. Do by parents you mean the (offending) kids legal guardian or the owner of the land the bikes are on?
Answer: According to Cornell's LII page on "Attractive Nuisance Doctrine" the doctrine or concept is:

A doctrine in tort law under which a landowner may be liable for injuries to children who trespass on land if the injury results from a hazardous object or condition on the land that is likely to attract children who are unable to appreciate the risk posed by the object or condition.

The injury or danger must be reasonably foreseeable to the property owner, but not apparent to a child likely to be attracted to the dangerous object or condition. The object or condition must be such as to attract children likely to be put in danger.  An uncovered swimming pool or a disused refrigerator are classic examples of an attractive nuisance
A bicycle would not usually constitute an object of danger to a trespassing child that the child was unable to understand or foresee. A child able to climb on and operate the bicycle is probably aware enough to foresee the ordinary dangers of riding a bicycle. But much would depend on the exact facts of the case. If there was some circumstance that made use of a bicycle more risky than usual, that might alter the decision.
History
According to the Wikipedia article

The attractive nuisance doctrine emerged from case law in England, starting with Lynch v. Nurdin in 1841. In that case, an opinion by Lord Chief Justice Thomas Denman held that the owner of a cart left unattended on the street could be held liable for injuries to a child who climbed onto the cart and fell. The doctrine was first applied in the United States in Sioux City & Pacific Railroad Co. v. Stout  84 U.S. (17 Wall.) 657 (1873), an 1873 case from Nebraska in which a railroad company was held liable for injuries to a child who climbed onto an unsecured railway turntable. The term "attractive nuisance" was first used in 1875 in Keffe v. Milwaukee & St. Paul Railway Co., a Minnesota case. The doctrine has since been adopted in some other common law jurisdictions, such as Canada, but not universally.

Conditions
According to the Wikipedia article listed above, quoting the Restatement of Torts (second) §339, an attractive nuisance is an artificial hazard which meets all of the following conditions. Natural hazards, such as lakes, do not fit the rule:

The place where the condition exists is one on which the possessor knows or has reason to know that children are likely to trespass, and
The condition is one of which the possessor knows or has reason to know and which he realizes or should realize will involve an unreasonable risk of death or serious bodily harm to such children,
The children, because of their youth, do not discover the condition or realize the risk involved in inter-meddling with it or in coming within the area made dangerous by it,
The utility to the possessor of maintaining the condition and the burden of eliminating the danger are slight as compared with the risk to children involved, and
The possessor fails to exercise reasonable care to eliminate the danger or otherwise to protect the children.

Some US jurisdictions, such as Maryland, do not follow this rule.


Is MEF a dependency injection framework?

Question: The recently announced managed extensibility framework (MEF) of .NET 4.0 - is it a dependency injection framework? Will Microsoft Unity from Patterns and Practices be obsolete in 4.0 ? How does MEF compare to a framework like Unity?
Comment: [This question](http://stackoverflow.com/questions/42251/whither-managed-extensibility-framework-for-net) might be of interest to you.
Answer: Specifically addressed in the PDC 2008 2nd Keynote by Scott Guthrie, MEF has a lot more to do with things like extending Visual Studio 2008 and other applications, without having to use all the COM and older technologies...  A very good demonstration of extending the text edition in VS2008 was shown among other things.  Start about an hour and 15 minutes into the 2nd day keynote (http://www.microsoftpdc.com) and you'll get direct information, but basically if you are going to "build an application with built in extensiblity points that can easily be discovered, and which supports discovery of extensions," then MEF is what you want. UNITY is what you want for a high-quality IoC container that does DI as well as the other solutions out there but has great and easy integration with the Enterprise Library.
Regarding Unity in the EL4.0 (now 4.1 --  http://msdn.microsoft.com/en-us/library/dd203099.aspx) its actually a IoC that sits on top of the version 2 ObjectBuilder and the EL4.1 has extensibility points for unifying the configuration of various EL application blocks with Unity.
MEF vs. Unity is like comparing apples to oranges.  Some great and specific podcast/webcast(s) that describe UNITY in full are here, which I highly recommend:
DotNetRocks Show #393  http://www.dotnetrocks.com/default.aspx?showNum=393
DNR.tv Show #126  http://www.dnrtv.com/default.aspx?showNum=126
Comment: But why would I want to use Unity when I have MEF?
Answer: I saw one write up that made it sound like one but more information (Scott Guthrie at PDC2008[Video/wmv]) made me think it's more than a dependency injection framework.
From the sounds of things it can be used for dependency injection but also does more.
Answer: Here's a conversation about MEF/MAF/Unity/Prism I found enlightening.
Comment: Codeplex's archive doesn't make it easy to find old discussions. Here is another version: https://web.archive.org/web/20150131190610/http://mef.codeplex.com:80/discussions/35083
Answer: I would like to add one mopre line which I have just read that MEF is not a part of Inversion of Control(as dependecny is said to be synonym of IOC) but it implements it.
When we implement IOC via dependency injections we generally use Unity, which helps in discovering static dependencies but MEF allows us to increase the extensibility of our application without configuring the components statically, even they can be discovered at run time.
There are other links as well which can help you more:
Difference between Unity and MEF
Comment: I'm not sure this answer is altogether coherent


Scene description language

Question: Does Blender have a scene description language (SDL) that I can view and edit in real-time? Something like JSON or XML? Often, I can work faster with text than a GUI.
Answer: The bpy module and the API provided by Blender is pretty close to a scene description language.
Switch to Console Editor.
Now you can interactively make modifications to the scene.
The bpy module is already imported into the console.
<code>>>> list(bpy.context.scene.objects)

[bpy.data.objects['Point.002'], bpy.data.objects['Point.001'], bpy.data.objects['Point'], bpy.data.objects['Cylinder.006'], bpy.data.objects['Cylinder.005'], bpy.data.objects['Cylinder.004'], bpy.data.objects['Cylinder.003'], bpy.data.objects['Cylinder.002'], bpy.data.objects['Cylinder.001'], bpy.data.objects['Cylinder'], bpy.data.objects['Suzanne'], bpy.data.objects['Plane']]

>>> bpy.context.scene.objects['Suzanne'].location.x = 1
>>> bpy.context.scene.objects['Suzanne'].location.x = 0
</code>
C is an alias for bpy.context, so you can also do
<code>>>> C.object.location.x = 0
</code>
You can keyframe object properties (In the example below we are adding a keyframe on x location attribute)
The data related to the scene can be accessed from the context directly.
<code>>>> C.scene.frame_current = 1

>>> C.object.keyframe_insert('location', index=0)

>>> C.scene.frame_current = 25
>>> C.object.location.x = 5
>>> C.object.keyframe_insert('location', index=0)
</code>
Links to some important blender python API modules

https://docs.blender.org/api/current/info_quickstart.html
https://docs.blender.org/api/current/bpy.context.html
Answer: Blender has an extensive Python API that allows to access and modification of much of it's data, not sure if it fulfills your purpose.
It also has a DNA/RNA based data structure that describes the scene and all of the .blend file structure.
Also see https://stackoverflow.com/questions/11961557/what-is-an-rna-or-dna-property
Comment: Are DNA and RNA abbrevations? I really miss the documantation about these concepts.

Scene description language


If you have designed (and implemented) a programming language, what to do to make it gain attention/popularity?

Question: Let's say you have created a programming language, maybe because there was a problem which was unfeasible to try to solve using existing languages, what would you do to market it (and so on) in order to make it gain attention in the software engineering (or academic etc. depending on the purpose of the language) industry?
Comment: Yet another programming language? Oh FML!
Comment: @Job, the more languages - the better. Evolution needs a mass to go on.
Comment: Luck has much to do with it. It is a winner-take-all. http://steve-yegge.blogspot.com/2007/02/next-big-language.html
Comment: @Job I used to think like that, but, since programming and technology changes too fast, is it possible, that a programming language doesn't suits a need. For example, C# is a language with Java features with new ones...
Comment: @umlcat: What I find frustrating is that lots of details change very fast but a few basic concepts are reused all the time. Most of the concepts that are used in modern programming languages have been around for quite some time already. Often, only the mix of features and many subtle (but less important) details change.
Answer: Use it.
Use it as your primary development tool. When you run into its failings, address them, because you can afford to change basically whatever you want about it before it becomes popular. The language will improve and solidify over time. As you produce more and more great applications written in your language, people will take notice of it and begin to take it seriously as a tool, and they might start using it. That's step one.
Step two is to keep using it, and make it as easy as possible for the people who might want to use it. That means top-notch documentation and examples, actively promoting the language to everyone you can, and getting your users to actively promote it by making it good enough to use as a primary tool.
But it all starts with using it yourself for real tasks. If you never get to that point, neither will anyone else.
Comment: Use it for an important project, then write a series of articles about your project for prominent CS and technology magazines and peer-reviewed journals where you highlight the benefits of your language.
Answer: Unfortunately there's not a whole lot you can do to MAKE something popular.  Take for example the popular game for the apple platform Angry Birds.  The company that made that game had created many many games prior that were only marginally used in comparison.  Then there was just something about Angry Birds that just struck with people... then they told their friends who told their friends to the point that it seems like almost everyone owns/has played/knows about it.  The same thing is true of programming languages.  You make it... then its either a success in time or its not.  The only real things you can do is try to promote it with friends, colleagues, etc.  Certain things will influence its success such as speed, ease of use, functionality, versatility, etc.  Its these areas that are most worth your time and effort.
EDIT:  Well I actually just thought of something... volume might be with in your control.  If you're extremely creative you could just start pumping out hundreds of different programming languages... eventually the odds would get very good that one of them would become popular...
Comment: Well, Microsoft _made_ C# popular (not that it was a bad language).
Comment: mzabsky: I guess if Anto had MS's cash, he wouldn't have to ask us how to make anything popular.
Comment: Yes but MS J# failed massively.
Comment: @Kenneth Huge promotion and community support of whole .NET, enormous standard library, runtime integrated into the most popular OS, luxurious IDE. Minor player cannot do any of this. Microsoft can.
Comment: Yup yup yup yup yup. Hary Potter, Microsoft, Facebook ... "Folled by Randomness" is a good read.
Comment: @mzabsky  What do you mean they __made__ C# popular?
Answer: Flip this around and ask yourself why someone would want to use your new language?

What does it provide that existing languages don't provide?  Are the advantages big enough to warrant someone taking the plunge ...
Is the language specified?  Is the specification complete?  Is it stable?
Are the runtime libraries available?
Is there a decent tool chain?  Compilers, debuggers, IDE support.
Are there real people using it to do real projects?
Are there examples?  Case studies?  Tutorials?

If the answer to many of these questions is "err ... no", then it is too soon to market your language.
Answer: make it fun to use. Besides that have really great documentation! That is always the first thing I look at when trying to evaluate something new.
Actually the thing a new language needs to get picked up by a lot of people is going to be a Book, By O'Reilly or the Prags
Answer: The same as any other thing you've invented, create lots of examples of useful stuff you've built using it.
Answer: Why would you create another programming language? Unless you want to learn some fundamental CS concepts to improve your day to day programming writing a programming language in order to make it popular seems like a waste of time. Then again if you're really set on creating a popular programming language then targeting the JVM or the CLR or LLVM is probably the way to go.
Comment:  Every programming language has its drawbacks. Different languages are better suited for different goals.  Sometimes a project has multiple goals, with some being easy to do in one language and next to impossible in another language.  You could build the project from many different parts that use many different languages, or, by creating a new language that addresses the needs of the project, you ***may*** be able to save yourself a lot of time and headaches in the future.  ...or you could create the mother of all headaches.
Comment: @oosterwal: There are much better ways of doing that with DSLs. A full blown language is overkill if that's your goal.
Answer: Marketing.
That and assuming the this problem that people have affect enough people. I know Ruby got really popular cause of the MVC framework rails. They also had a huge marketing team. Microsoft C# is very popular because they would try to push it on everything. XNA framework uses C# and to do games on their platform (PC, ZUNE, 360, what have you), you got this neat XNA framework that uses C#.
So yeah, it seems like you have to be proactive and push for it or have something so significant that you don't have to do marketing (scala for example). Google Go language for example isn't taking off. I think only time will tell.


Accurately Calibrated Plates

Question: Various manufacturers of Olympic and weightlifting plates use different standards for accuracy.  Is there a good resource for comparing price versus accuracy?  Can anyone suggest some manufacturers and supply some reasonably trustworthy data as to their plates' accuracy?
Comment: @boiky, I found some in the UK: http://www.wolverson-fitness.co.uk/Olympic-Competition-Bison-Bumper-Plates_A1CRH1.aspx  Unfortunately all I know is that they post their tolerances.  I have no information on their reputation or independent reviews.
Comment: Any data for the UK?
Stuck with the same problem - Eleiko\Ivanko is too expensive, the rest is totally unacceptable. Except for 2 brands mentioned nobody even declare their tolerance.
Comment: @boiky Welcome to the Fitness & Nutrition Stack Exchange! If you have a question about weights, you are free to [ask a new question](http://fitness.stackexchange.com/questions/ask) as long as it doesn't duplicate another one. Please have a look at our [faq] and see how this site works.
Answer: Unless a manufacturer specifies the accuracy that they test their plates with, the weight can be off by a few percentage points from the nominal weight.  Of course, if the plates are IWF certified, they go through an independent review process to make sure they are within specification.
MuscleDriverUSA has a good reputation for shipping plates at the same weight they are advertised.  They have "econ" plates that ship at +/- 10g which is a variance within the range of "don't care".  They also have reduced price failed color plates that are +/- 25g which again is insignificant.
Rogue Fitness has a mix of plates, and if they don't specify accuracy, the plates will have a significant variance.  They do advertise some colored plates that are +/- 10g.  They also have some higher bounce plates (hi-temp) that can be off by a few pounds.
I only know this because I read an independent review which I can't find the link to right now, where the guy went through and weighed all the plates he had.  The hi-temps were useful for outdoor lifting, but had a significant variance, and on the heavier plates were as much as a couple pounds.  This was in contrast to both the higher priced competition rogue plates and the Pendlay plates from muscle driver which he also had in his possession.
Some brands are legendary such as Eleiko, but you do get what you pay for.  High price, great construction, and within very tight tolerances.
You don't have to get them IWF certified (which adds cost due to independent testing), but do look for the tolerance spec when reviewing the advertised plates.

Accurately Calibrated Plates


Failed Inspection - rust on rotors from not being driven much

Question: Just attempted to have my car inspected in Vermont and the mechanic immediately said it would fail because of the rotors. He asked if the car has been sitting for a long time, and said that something "isn't even making contact." I was at my dealership (in Massachusetts) just two weeks ago for a tire rotation, and they said nothing, marking the brakes as green for all linings and measurements. I'm trying to find a second mechanic to take a look but I've seen helpful feedback on here before, so what do y'all think?
Comment: Go for an "Italian" service.
Comment: Steel and iron rust when wet on this planet ; find a mechanic from this planet. They do seem to show exceptionally little use.
Comment: Rust around the rim shouldn't matter to anyone. There does appear to be some rust on the area in contact with the brake pads though. As Solar Mike said, an "Italian service" will fix that. (If you don't know what "Italian service" means, drive for a few miles with either the gas or brake pedal always pushed right to the floor.)
Comment: I would recommend the Italian service, but the best method would be to find a highway, at 55 or 60 mph do a hard brake untill you are down to 30 mph. Then cruise for a couple miles to let rotors cool. Repeat several times. If that doesn't clear it sufficiently, do it again on the next day.
Answer: You are right to question this, those look a bit rusty but that will wear off with use. It's normal for brakes to get some surface rust when a car hasn't been driven. Go drive it with plenty of braking, then go to a different inspection center.


What is the difference between a rigid diatomic molecule and non-rigid diatomic molecule?

Question: I started a mock paper for one of my entrance exams with this fairly easy question. I rearranged the equation and got 5/2, knowing that a diatomic molecule has a Cv of 5/2, i concluded that the answer must be either A or C, but I do not know the difference between rigid diatomic and non rigid diatomic, can someone explain the difference?
Answer: At sufficiently high temperature, a diatomic molecule may have a thermodynamic degree of freedom that corresponds to bond length oscillation.   That
would change the '5/2' to '6/2'.
Comment: The vibratory behavior adds *two* quadratic terms to the Hamiltonian, so the change is from 5/2 to 7/2. This is a good reason to be careful how you talk about equipartition: it's very easy to be sloppy about about [the meaning of 'degree of freedom' ](https://physics.stackexchange.com/a/317605/520) and fool yourself.
Comment: Just to confirm , when we increase the energy of the system it is able to get two more degrees of freedom , thereby changing from rigid diatomic (5/2) to non rigid diatomic (7/2) ... That made sense thanks, both of you!
Answer: Rigid diatomic molecule has $C_v = 5/2$ and non rigid has $C_v = 7/2$. From this we can fairly distinguish between both.
Examples of rigid molecules include $\mathrm{Cl_2}, \mathrm{Br_2}, \mathrm{N_2}, \mathrm{O_2}$ and so on.
An example of a non-rigid molecule is $\mathrm{CO}$.
Comment: These might be good examples, but they don't explain *why* some are rigid while others are not.


Accepted "into" journal?

Question: What is the appropriate way to talk about an article that has been published in a journal? Has it been accepted "into" the journal, "to" the journal, "in" the journal, "by" the journal?
Answer: As someone whose wife recently had a paper accepted for publication by a journal, I've been hearing that a lot lately. I imagine once the journal is published, she'll be talking about having her paper published in the journal.
I guess the determining factor is, do we refer to the journal itself, or the company that publishes it?
Answer: "Accepted by the Journal" is correct...here 'Journal' is substituting for the editor or staff of the journal that did the actual accepting.

Accepted "into" journal?


Mass curves spacetime, there is no such thing as gravity?

Question: It is said that there is no such thing as gravity. Mass/energy curves spacetime and a body follows this curvature so gravity is basically the geometry of spacetime. If there is no force of gravity why does a mass move at all along the curvature of spacetime and what determines which way it will move. E.G. If I drop an apple, if there is no gravitation attraction to the earth why does it move towards the earth, why doesn't it move upwards instead?
Comment: Related: http://physics.stackexchange.com/q/219306/50583 and its linked questions. There's a difference between saying "gravity isn't a force" and "there is no gravitational attraction"; I'm not sure why you think the two are equivalent.
Comment: **It is said that there is no such thing as gravity. Mass/energy curves spacetime and a body follows this curvature so gravity is basically the geometry of spacetime.**  Can you see the contradiction  in this statement? Would there be a problem if, instead of saying "matter follows the geometry of spacetime", we just used the word "gravity" to mean the same thing?
Comment: As you move along the apple's worldline in one direction, you get closer to the earth; as you move along the apple's worldline in the opposite direction, you get farther from the earth.  The reason the apple moves toward the earth instead of away from it is that you chose to trace out the apple's worldline in one direction rather than the other, and you then chose to label that direction "forward in time".
Answer: Gravity is a force. It is exerted by curvature of space, which in turn, is caused by mass of earth. So, it is roundabout way of saying that earth exerts a force on the apple. This is per GR which so far, is the most accurate way for quantitative description of the force/phenomena.
It causes acceleration, it requires another force to counter it, it imparts momentum, and kinetic energy, it follows inverse square law, similar to electromagnetic force .. It has all the characteristics of a force.
Curvature of space describes how the action/force at a distance is realized. It does not say that the action/force does not exist.
Comment: Nowadays we don't think of gravity as a force, but as the curvature of spacetime. And yes that causes acceleration. When the curvature is very weak you can approximate it as a force. It only goes as 1/ r squared in that limit. General Relativity does not generally go that way. It is not similar to the electromagnetic force, there are plenty differences. By the way the nuclear force also causes acceleration, requires another force to counter it, imparts momentum and kinetic energy, and is also not similar to the electromagnetic force.
Comment: @BobBee: Yes there are differences. Main one being that gravity is only attractive, electromagnetic is both, attractive and repulsive. Yes, inverse square is an approximation. Still looking at the effects of the curvature of space on mass, I do not think there is anything wrong in considering it a force which is accurately (in quantitative sense) described as curvature of space, especially if someone having difficulty in grasping the effects in absence of a force. Moreover, It can be considered a force as a consequence of the equivalence principle. $a$ =  $g$. Same units, similar effects ...
Comment: 'Nothing wrong'. 'It can be considered a force as a consequence of the equivalence principle'. You're misstating things, and deciding what is wrong or not, on things that have already been decided. Gravity is not a force because of the equivalence principle. That led Einstein to understand that it was an effect of spacetime, not a force. Further, you're confusing the OP, who is trying to understand how it can work with spacetime; your answer is think of it like the electromagnetic force with a few differences. Things would have been a lot easier for physics if what you said had 'nothing wrong'
Comment: @kpv Mass curves spacetime.  For an object with mass to move though time in a straight line, it must follow the curvature of spacetime.  Try making two ribbons lie flat along the surface of a sphere, they will come together even if they started apart.  This is because the straight line on a curve causes things to come together.  So when zero forces are acting on an object with mass, movement through time over the curvature of space causes objects to come together.
Answer: If you drop an apple it does not accelerate. Weird, huh, but fundamental.
To elaborate, if I was in the apple's frame of reference I would feel no acceleration. But normally there  I am standing on the ground by the apple, and I do feel acceleration. But I'm not speeding up. In fact I experience a force resisting the natural motion that free objects will take in a gravity well.
Anyway in the way I described above you can intuitively feel the truth - that gravity is different from other forces.
Answer: All the answers are perfect. I am telling the same in a simpler version. The idea is, consider mass as a deformation, or for convenience, conceptually, a drawing in space-time. Seeing it from a particle physics level, the drawings consist of certain jigzo puzzle like pieces(again conceptually). They cannot be altered or deformed but, together a few such pieces make the drawing. The fundamental particles are these jigzos. When fundamental particles get into a structure, with stability, the nucleus, the atom and everything, they form the matter that we see. Now, to explain gravity, it will be too complex to think in this particle sense. But, since the deformation doesn't really have a definite frame of reference, we can treat gravity like we do to isometric factors. We can see the earth as a big piece of mass, that is a big drawing in space time. But, these drawings or deformations have a tendency to get back to nothing. This cause a force to decrease the deformation. Two such deformations, as they get closer, the sum of their deformations will get lesser. In order to attain such a partial stability by reducing deformations, masses tend to come closer. Call it gravity, if interested. Thank you.


Android Studio - Gradle Sync Connection Timed Out

Question: I just downloaded Android Studio 4.0.1 and tried to build one of the sample projects.
It fails at the very beginning when trying to do a Gradle sync.
It fails to download https://services.gradle.org/distributions/gradle-5.4.1-all.zip
with the error:
Gradle sync failed: Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
Consult IDE log for more details (Help | Show Log) (
What I find really puzzling is that this seems to be an error that has been plaguing people for a very long time, I have found so many questions on this but not a single answer that is helping me.
Just to be clear on what has been tried so far:

I have checked the http proxy settings in File->Settings->http settings. It is set to "No proxy" (as expected, I don't have a proxy).

When I test a connection the one above (https://services.gradle.org) fails. Something simple like www.google.com is ok. More interestingly, I tried another https endpoint and that one failed too. So I don't know if it's something https specific

my gradle.properties file has no proxy settings (as mentioned, I don't use a proxy)

the services.gradle.org endpoint works absolutely fine from my browser and I'm able to download the file. This I find puzzling, they should both be connecting outside via the same wi-fi modem, shouldn't they?

I have tried restarting my machine, no luck

Even more interesting, I created an Ubuntu VM, installed Android Studio there and had none of these issues with the gradle sync failing to connect

Does anybody have any idea what is going on or has managed to crack the code on this after all this time?
EDIT
As I was writing the question above I realised it could be my windows firewall blocking this.
Excited, I rushed off to try it out, completely turned the firewall off, restarted the computer - but still nothing. Gradle syncing is failing in Android Studio while downloading the file works perfectly fine from the browser.
Answer: I also faced a very similar thing, I will suggest you to change the jet pack dependency to https://www.jitpack.io
Comment: Thanks for the suggestion, much appreciated. Unfortunately, I don't have any jetpack dependencies defined.
I'm really just trying to build one of the sample apps available in Android Studio.
Comment: I've tinkered a bit more and still no luck. Might have to move to my Linux VM - the only reason I didn't want to do this is because running the emulator on my VM does not really work.
But Windows has thrown an unexpected blocking issue so it seems I will have to drop it.
Answer: So it is finally working.
What was the fix?
Well, a bit hard to say. In the past weeks I've been having problems with connecting to some sites via wi-fi, a problem I ignored because I would switch to mobile data and get what I needed.
However I started paying attention when the number of non-reachable sites started increasing and when Netflix stopped playing I had to pay attention. :)
I remembered I had tinkered with parental controls on my modem and had left it with some configuration to block certain sites.
So I decided to reset the modem to last working configuration and all of my sites started working again.
When I saw this, I remembered this problem and thought I'd try it again - and it works!!!
What still confuses me is why accessing the gradle site from the browser worked with no problem, but I won't look this gift horse in the mouth. I'll take it!


Can a sump or pool pump be used in shallow water (less than 3 inches)?

Question: I have an issue with rainfall running into the back of my my property and into my house through patio doors.
Would a sump pump start at 2-3 inches of water stopping it from entering my home. When this happens, I usually wind up with 5-8 inches
Comment: Usually not, most inlets on sumps are about an inch or two high, this is why they are usually placed in sump pump pits.  Is there any way of having ground slope down from the house or add better drainage?  Add pictures of house and back yard to question.
Comment: Most sump pumps are bottom-fed, in my experience. Trouble is that the float isn't usually designed for shallow pools. Find one that is and you're golden.
Answer: I bought a utility pump from either Home Depot or Lowes, I don't remember which one, but it starts pumping at about 1-3/8" and turns off at 1/4". It is a Utilitech #0435062 automatic submersible pump that is 1/3 HP and pumps 24GPM. This may work for you. Hope this helps.
Answer: DISCLAIMER: Not explicitly an answer to your question and definitely not what you're going to want to hear. Also, not a landscape expert.
I believe that this is going to take some landscaping instead of or in addition to a pump. Sloping the land away from the house would be ideal. If your house is (unfortunately) on a low spot, you may need to put in a bit of a ditch across the property to catch the water and direct it away from the house. Note that this doesn't need to be an actual trench, just a gentle valley that's lower than the house's elevation - it can still be "flat" enough for the kids to play soccer on and barely notice the ball rolling on its own to the center of the lawn.
This valley would then run the water off your property to another natural low spot where it can continue naturally draining to the city's storm drains, local creek, or whatever. (Note that you'll not want to just dump it in the neighbor's yard unless you really don't like him and don't want to try to repair the relationship and are willing to open yourself to the possibility of lawsuits!) You may need to have a dry well or cistern dug to contain all the runoff. It may be possible to tie this directly into the city storm drains or at the least, run your sump pump from here to dump it to the city.
Depending on the soil type in your area, you may also need to take up the whole surface and put down something more permeable to allow the water to soak into the ground instead of just running across the surface. This would, in effect, make your whole yard the "dry well" and allow it to absorb significantly more of the rain water before it even makes it to the house. You'd need to talk to a local landscaper (or two or three) about your various options and quotes.
Another option, particularly if your property is the low spot in the neighborhood, is be to install "drainage tile" which is (these days) a perforated hose that water will weep into, then gives it a very easy path to follow away from the house or at least to a specified dry well/cistern that will control it and allow you to pump it from there.
I live in the Midwest in farm country. Every year in the late fall, after the harvest, I'll see huge trucks & trailers out in the fields with gigantic rolls of drain tile. A trencher digs a trench and pulls the tile in, then the dirt is pushed back over it. They work from the low spots to the drainage ditches to help eliminate the flooding that kills crops.
Of course, you won't need the massive machinery, but you'll probably end up doing something similar if you really want to solve the problem instead of just band-aid it.
Comment: I'm not a fan of drains, pumps and other solutions that can fail because of a power outage or plugged up pipe. A simple ditch or swale is pretty fool proof. Over time they may fill with soil/sediment but it's something that requires minimal maintenance.


Can a Beast Master ranger's Animal Companion do extra damage from the Hunter's Mark spell?

Question: My Beast Master Ranger player is looking to use his hunter's mark bonus on his animal companion's attack action. Is the hunter's mark damage bonus strictly only for the ranger's attacks, or since the ranger is using their Attack action to command their animal companion to attack in their stead, can the animal companion get that bonus?
Answer: Only for the Ranger's Attacks
Hunter's Mark is cast on an initial target and provides a bonus on the caster's attacks. Emphasis is mine below:

You choose a creature you can see within range and mystically mark it as your quarry. Until the spell ends, you deal an extra 1d6 damage to the target whenever you hit it with a weapon attack, and you have advantage on any Wisdom (Perception) or Wisdom (Survival) check you make to find it.

Just like the extra damage doesn't apply to your allies, it doesn't apply to your beast either (which is effectively another creature and an ally). It is for your attacks and your attacks only.
Comment: Which is a shame; if animal companion could benefit, beast master would be a bit more attractive.
Comment: @BlakeSteel The DM always has the option to houserule anything. But I don't see a huge balance issue in offloading the damage output to the Beast, while keeping the Bonus Action to change targets on the Ranger.
Comment: It is worth noting that it is completely under your purview as the DM to decide that the (correct) ruling of our good NautArch need not affect beast masters in your world, since I also agree with Korvin in that beast masters need love in 5e.
Comment: @DanielZastoupil I think that as long as you choose one at the casting then it's a reasonable addition to boost the Beastmaster a bit.
Comment: I was actually going to add this line to Beastmasters, to compensate: When you cast a spell that states the term "You", it is now amended to reflect "You or your Companion".--- I feel this would dramatically increase the interest in Beastmaster, while still being limited by Ranger spellcasting.
Comment: @NautArch even _both_ would not set the Beastmaster on the Battlemaster's power level
Answer: I'm gonna say No, the animal companion can't claim the bonus damage. Hunter's Mark says...

Until the spell ends, you deal an extra 1d6 damage to the target whenever you hit it with a weapon attack, (...)

Emphasis mine. You, not your allies or friendly creatures or mutual enemies. You, the caster of the spell.


How do i display the number of images on the "post screen"

Question: I need help displaying the number of images in a POST on the post edit screen, For example if 5 images are attached to article A, and they are now reused on article C it should display the total number like the view count we have.
Comment: Hi @iamkingsleyf. Should the processing occur client-side or server-side? Could you please clarify your example that uses **article A** and **article C**? E.g. **post E** has no images. Five images are uploaded to **post F**. Then 3 of **post F**'s images are added to **post E**. I'm assuming **post E**'s image count is three. But, how would this change the image count for **post F**?
Comment: It should count any image on a post attached to that post or not.
Comment: Should the processing occur client-side or server-side? Is the code that renders the image count on the server (PHP) or in the client (JavaScript)?
Comment: Serber side, PHP (wordpress plugin) i do not have the code that is why I am here
Answer: The code below suggests one approach to handling the display of a post image count on the Post Edit List screen (edit.php). The function names provide an outline of what the code is doing. References to WordPress Documentation are below for details about the action and filter hooks used. Add the code to your plugin or child theme.
Images are counted with a simple regular expression matching the opening of an image tag (<img).
An image_count post meta data field is used to store the image count for a post. Using meta data allows for searching, filtering and sorting with WP Query.
The code assumes that images are counted for core WordPress Post types only. Different hooks are needed for custom post types.
<code>/**
 * Register an image_count post meta key if you want
 * it to be available via WordPress REST API.
 */
function register_image_count_post_meta() {
    register_meta(
        'post',
        'image_count',
        array(
            'object_subtype'    => 'post',
            'description'       => 'Count of images in post.',
            'show_in_rest'      => true,
            'single'            => true,
            'type'              => 'integer',
            'default'           => 0,
            'sanitize_callback' => function( $value ) { return $value; }, // Replace with proper sanitization.
            'auth_callback'     => function() { return '__return_true'; } // Replace with proper authorization check.
        )
    );
}
add_action( 'rest_api_init', 'register_image_count_post_meta', 10, 1 );

function add_post_screen_custom_headings( $columns ) {
    $columns['image_count'] = __( 'Images', 'translation_domain' );

    return $columns;
}
add_filter( 'manage_posts_columns', 'add_post_screen_custom_headings', 10, 1 );

/**
 * Render content for the custom column.
 * A switch statement is commonly used when rendering several custom
 * columns.
 */
function add_post_screen_custom_content( $column, $post_id ) {
    switch ( $column ) {
        case 'image_count' :
            $single_value = true; // Single value. Not an array.

            $image_count = get_post_meta( $post_id , 'image_count', $single_value );
            echo $image_count;
            break;
    }
}
add_action( 'manage_posts_custom_column', 'add_post_screen_custom_content', 10, 2 );

/**
 * This filter is needed to make the custom column
 * sortable on the post screen.
 */
function register_post_screen_images_column_as_sortable( $columns ) {
    $columns['image_count'] = 'image_count';

    return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'register_post_screen_images_column_as_sortable' );

/**
 * If the user clicks the custom column header to sort the page
 * this function is called to update the WP Query.
 */
function update_post_screen_images_column_orderby( $query_vars ) {
    if ( isset( $query_vars['orderby'] ) && 'image_count' == $query_vars['orderby'] ) {
        $query_vars = array_merge( $query_vars, array(
            'orderby'   => 'meta_value',
            'meta_key'  => 'image_count',
            'meta_type' => 'NUMERIC'
        ) );
    }

    return $query_vars;
}
add_filter( 'request', 'update_post_screen_images_column_orderby' );

/**
 * This function is optional.
 * It suggests that you might want to initialize the image_count
 * meta data value for all posts that currently do not yet
 * have an image_count post meta key.
 */
function initialize_image_count() {
    $posts = get_posts( array(
        'post_type' => 'post',
        'post_status' => 'publish',
        'numberposts' => -1,
        'meta_query' => array(
            array(
                'key' => 'image_count',
                'compare' => 'NOT EXISTS'
            )
        )
    ) );

    foreach ( $posts as $post ) {
        $count = preg_match_all( "/<img\s+/i", $post->post_content );

        if ( is_bool( $count ) ) {
            $image_count = 0;
        } else {
            $image_count = $count;
        }

        update_post_meta( $post->ID, 'image_count', $image_count );
    }
}
add_action( 'init', 'initialize_image_count', 10, 1 );

/**
 * Whenever a post is updated, this function is called to update
 * the image_count.
 */
function dynamically_update_post_image_count( $post_id, $post, $update ) {

    $count = preg_match_all( "/<img\s+/i", $post->post_content );

    if ( is_bool( $count ) ) {
        $image_count = 0;
    } else {
        $image_count = $count;
    }

    if ( empty( $completion_date ) ) {
        remove_action( 'save_post', 'dynamically_update_post_image_count' );
        update_metadata( 'post', $post_id, 'image_count', $image_count );
        add_action( 'save_post', 'dynamically_update_post_image_count', 10, 3 );
    }
}
add_action( 'save_post', 'dynamically_update_post_image_count', 10, 3 );
</code>
Further Reading / Useful Links
rest_api_init

Fires when preparing to serve a REST API request.

manage_posts_columns

Filters the columns displayed in the Posts list table.

manage_posts_custom_column

Fires in each custom column in the Posts list table.

manage_{$this->screen->id}_sortable_columns

Filters the list table sortable columns for a specific screen.

request

Filters the array of parsed query variables.

init

Fires after WordPress has finished loading but before any headers are sent.

save_post

Fires once a post has been saved.

preg_match_all

Counts regular expression matches in a string.
Comment: @iamkingsleyf Good question. Short answer is "yes". Long answer requires an update to my answer. Are you looking to learn how to do this yourself by making an effort at a solution? I can help. In any case, my answer should be updated to do at least two things: **1.** Move the calculation for `image_count` into its own function; and **2.** Change the regular expression used to calculate `image_count` to match strings like **class="wp-image-230"** instead of **<img**. The new regex can capture the image ID (which is *230* in this example), and be used to verify that an ID actually exists.
Comment: Hi,

Thanks for the code, it's working fine, and the sorting makes it wonderful. I have tested on one site.
Comment: Hi,

I want to add is it possible to also add the featured image as well? so it counts featured images too as part of the images on a post.
Comment: Alright thanks.


LTSpice - varistor component

Question: What is the constitutive relashionship between current and voltage of a varistor in LTSpice? For example, if I set the control voltage V=1V and Rclamp=2, what is the formula to evaluate the resistance of varistor? I tried to do this simulation (I used a 10V voltage source in serie with R1=1 and a varistor), but the result it's strange for me. The current on R1 is 3A, \$V(R1)=R1\cdot I(R1)=1\cdot3=3V\$, but the resistance of varistor is not Rclamp=2 (is 7/3=2.3).
Thank you very much.
Comment: Why don't you plot the current when the applied voltage is a ramp - this seems likely to give you what you want.
Answer: If you read in the LTspice manual, you'll see that it says it's breakdown voltage is set by the voltage applied at its control terminals. The voltage can be of any sign, any polarity (it counts as abs(V(ctl))), and the calculation is like this: if your applied voltage is 10V, the series resistance is 1 Ohm, Rclamp=1 and the control voltage is 1V (I presume), then the varistor will breakdown at 1V (the controlling voltage), meaning from the total of 10V you'll have 10-1=9V which, divided by the total resistance of 3 Ohms results in 3A. If your source voltage is 7V, series resistance is 2 Ohms, Rclamp=1.5 and controlling voltage 3V => (7-3)/(2.5+1.5)=4/4=1A.

LTSpice - varistor component


What algorithm to use to generate random path of given length

Question: I have a map size of 8 x 8 cells with no obstacles. I should generate random path from start cell to the end cell with given length. Path can move up/down/left/right directions but not cross itself. What algorithm I can use to do this?
Comment: I doubt that there is an efficient algorithm for this. @Juho has a suggestion that might work well enough in practice, but the paths generated would not be uniformly distributed. Just counting the number of paths in a grid seems to be an open problem for which no efficient algorithm is known.
Comment: Ingoring the start and end cells, this problem has been studied under the name "self-avoiding walk". The main take-away from the wikipedia entry (https://en.wikipedia.org/wiki/Self-avoiding_walk) is that they are tricky beasts (and in particular, counting them is difficult).
Comment: You could start with randomized DFS. That is, when picking a neighbor, choose one randomly, e.g. uniformly at random. So this would be an instance of rejection sampling. The effectiveness of this strategy will depend on your other constraints. In graph-theoretic terms, I think you want to find a $k$-path from vertex $s$ to vertex $t$ in a grid graph.
Answer: Algo for solving problem when path self-intersections are allowed
Auxiliary problem
First let's solve another problem:

How many paths of length $K$ exists starting at coordinate $(StartRow, StartColumn)$.

Such problem can be solved by dynamic programming: let $dp[K][R][C]$ be answer for question:

How many paths of length $K$ exists that start in $(StartRow, StartColumn)$ and ends in $(R, C)$".

Base case:
$$
dp[0][StartRow][StartColumn] = 1
$$
Step of dynamic:
$$
dp[K][R][C] = dp[K-1][R-1][C] + dp[K-1][R+1][C] + dp[K-1][R][C-1] + dp[K-1][R][C+1]
$$
Here we suppose $dp[K][X][Y]=0$, for any $X$ and $Y$ that outside of grid (e.g. $X < 1$ or $X > N$ or $Y < 1$ or $Y > N$)
Also we can even add more constraints for problem and add obstacles: for doing so - we need to suppose $dp[K][R][C]=0, \forall K$, where cell $(R, C)$ is impassable (e.g. is obstacle).
This will take $O(N*M*K)$ time, where $N$ - number of rows, $M$ - number of columns, and $O(N*M*K)$ memory if we will keep all steps of dynamic or $O(N*M)$ if we will keep only last step of dynamic.
Original problem

Generate random path of length $K$ between cells $S(R_s, C_s)$ and $E(R_e, C_e)$.

First of all we need count how many paths of length $K$ exists between this cells, for that we can use previously described dynamic:
futhermore run it from end cell (e.g. count how many paths of length $K$ exist that start at $(R_e, C_e)$) and save all step of dynamic (we will use it in next steps).
Now add order relation between all paths of length $K$ starting at cell $(R, C)$ and ending at cell $E(R_e, C_e)$:

if $K=0$ we have $0$ or $1$ such paths (such collection is always ordered);
if $K>0$ let's suppose: Paths that go UP $<$ Paths that go RIGHT $<$ Paths that go DOWN $<$ Paths that go LEFT (and for ordering paths in each of 4 groups we can recursevly apply this definition again).

Then we know how many paths of length $K$ exist between cells $S$ and $E$, lets name it $A=dp[k][R_s][C_s]$, now we can uniformly at random peek number $L\in[0, A)$ that will identify choosen path among all $A$ available.
We had ordered all $A$ paths and choose some path to output $L$ ($0-indexed$) and just need to find it. Let $choose(R_c, C_c, L, K)$ - function that return $Lth$ path of length $K$ staring at cell $(R_c, C_c)$ and ending at $E(R_e, C_e)$:

$$
 choose(R_c, C_c, L, K) =\small\left\{
                \begin{array}{ll}
                  \langle empty \rangle, K = 0\\
                  \langle UP, choose(R_c - 1, C_c, L - 0, K - 1)\rangle,
                  \\ \hspace{45pt} L \in [0, Count_u)\\
                  \langle RIGHT, choose(R_c, C_c + 1, L - Count_u, K - 1)\rangle,
                  \\ \hspace{45pt} L \in [Count_u, Count_u + Count_l)\\
                  \langle DOWN, choose(R_c + 1, C_c, L - (Count_u + Count_l), K - 1)\rangle,
                  \\ \hspace{45pt} L \in [Count_u + Count_l, Count_u + Count_l + Count_d)\\
                  \langle LEFT, choose(R_c, C_c - 1, L - (Count_u + Count_l + Count_d), K - 1)\rangle,
                  \\ \hspace{45pt} L \in [Count_u + Count_l + Count_d, A)\\
                \end{array}
              \right.\\
$$
$$
Where \forall K, R_c, C_c\\
Count_u=dp[K - 1][R_c - 1][C_c]\\
Count_l=dp[K - 1][R_c][C_c + 1]\\
Count_d=dp[K - 1][R_c + 1][C_c]\\
Count_r=dp[K - 1][R_c][C_c - 1]\\
$$
And $Count_u$ means how many paths of length $K$ starts at $(R_c, C_c)$ and ends at $(R_e, C_e)$ and first move is $UP$, $Count_l$, $Count_d$, $Count_r$ defines respectively for another directions.
More intuitively, imagine we at $X$ cell choosing for $7th$ path:

...
_   4   _
5   X   0
_   9   _
...

If we go $UP$ we will follow paths $\in [0, 4)$, there is no paths to $RIGHT$, if we go $DOWN$ we will follow paths $\in [4, 4+9)$, so we need to go $DOWN$ and choose $(7 - 4)th$ path among all that starts in that cell.
Note: due to we define ordering on paths $I'th$ path everytime will be the same (so it's possible to store path just as index number among all such paths and restore path when it is needed). Also need to notice that order $UP < RIGHT < DOWN < LEFT$ is not only right choise, you can use any order - just keep it thorugh all algorithm flow the same.
Comment: Nice answer, but unless I'm missing something it does allow a path to cross itself.
Comment: Yes, such algo allows path self-intersection. Almost forget that this is not allowed by original topic while thinking.


What is the difference between material fatigue test with 1 sec cycle and 1 hour cycle?

Question: Assume I have two pieces of metal. I want to test the material fatigue (e.g. how many cycles can the material stand before it will break). Onto one of them I apply a tension force every second. Onto the other one I apply a tension force every hour. Should the results have any difference?
Answer: Yes, depending on the material there might be a difference. I assume you mean a short interval of force applied followed by an hour of rest, not a force applied constantly for an hour.
One hour is a long time and allows the material to return to a relaxed state. A shorter time interval will give the material less time to "repair the damage" done by the force you applied (atoms can not move to fill lattice errors, e.g.).
Basically, the shorter the time interval the faster it will break (maybe except for some special materials). On the extreme you test the material for its ability to withstand vibration.
Comment: Could you please give some examples? Do you have any figures from some experiment? This is a research direction question, so I need some data to support. Thanks
Answer: No, the sample should fail after the same number of load cycles. For a metal piece tested under room conditions, the stress must exceed the elastic limit (somewhere in the specimen) to cause any damage to the sample. The length of time between the time when the stress is greater than this is generally irrelevant.  This is the premise for conducting fatigue experiments to determine the 'lifetime' of a piece on an accelerated schedule.
The differences between one cycle per hour and one cycle per second, at 25 degrees C, is going to be very small for metal. Thermally activated 'recovery' processes just won't proceed fast enough to have any effect at this temperature.
ASTM defines fatigue life, as the number of stress cycles of a specified character that a specimen sustains before failure of a specified nature occurs.
However, if the two experiments give significantly different results this could be an indication that there are time-dependent processes contributing to failure. But this is not the behavior of metals.  Silica glass is an example of a material that has a strength strongly affected by aging.
Comment: " For a metal piece tested under room conditions, the stress must exceed the elastic limit to cause any damage to the sample." I don't think this is right.
Comment: Damage is generally considered irreversible, the elastic limit (reversible limit) on the stress-strain diagram is the critical stress needed to move a dislocation or grow a crack. Unless you mean chemical corrosion of the sample.
Comment: Please read the S-N curve of http://en.wikipedia.org/wiki/Fatigue_(material)   . It only needs 25% or less of the ultimate stress of the aluminium to break that aluminium IF the test is using that stress for running 1E+7 cycles.
Comment: You will never reach 1+E+7 cycles for the 'experiment' you assumed in your question. At 1 cycle per minute that would take 1142 years. Also 25% of the ultimate stress is ~100 MPa - that's a high average stress - clearly the local stress inhomogeneity exceeded the elastic limit as evidenced by the microcracks and plastic deformation visible in the photos in your citation.
Comment: Actually, my math bad, your experiment would complete in 19 years. (10000000 cycles)/[(60 cycles/hour)(24 hours/day)(365 days/year)] = 19 years
Comment: That is NOT my point. I want to tell you that material can be broken under the ideal ultimate stress strength, maybe within elastic range. Have you seen that S-N figure at 1E+3 cycle? The breaking stress from 350MPa to 200MPa.
Comment: You are entirely correct that fatigue failure is a real phenomenon. It is caused by the local stress field near stress-inhomogeneity in the specimen where it locally exceeds the critical value necessary to create or move lattice dislocations and cause (local) plastic deformation (i.e. locally the metal has exceeded its "limit of proportionality" or elastic limit.) Your original question did not specify whether the two experiments would be compared based upon the same time-duration or same number of cycles. That's the reason you got different answers.
Answer: In theory:
Provided that there is no significant increase in temperature between a 1 cycle/s and 1 cycle/hr, the failure mode of the 2 tests will remain the same and hence results should be identical...
In real life:
Fatigue problem is also a statistical problem, you have to test batches of samples at the two speeds in order to tell if there is difference.
Metal Fatigue will occur even below elastic limit [or yield strength]. The 'Fatigue limit' maybe a more appropriate term to consider in engineering design, depends in your desire lifetime.