Write song to the tune of a copyrighted song

Question: my wife is considering writing (and selling) some childrens' books which will contain songs which are to the tune of various copyrighted songs (like the "Let It Go!" song from Disney's Frozen). She wouldn't have the musical notes in the books. My question is, would it be legally kosher to say that a song is "to the tune of Disney's 'Let It Go!' from Frozen"?
Comment: There's also the question "would Disney sue you", and that would be costly whether the law is on her side or not.
Answer: Such a song would probably be a derivative work, and thus permission would be required. If the rhyme scheme of the original was imitated, or other distinctive elements were used, the case for this being a derivative work would be even stronger. Of course, the copyright owner might not sue, but with Disney ...
It might be that permission could be obtained. There is no knowing until she asks.
She should probably consult a lawyer with knowledge in this area with the specific song(s) she plans to use.
Parody and Fair Use
Strictly speaking, this would not be a parody, because it is neither mocking nor commenting on the original. Rather it is using the form of the original to say something quite unrelated to the original. Many people mistakenly use "parody" for this situation. However, whether or not this is a "parody" it might be fair use if this is under US law. A finding of fiar use is not automatic for any parody under US law.
Note that in Suntrust Bank v. Houghton Mifflin Co 268 F.3d 1257 (The case of The Wind Done Gone (TWDG)) the 11th Circuit Appeals Court did not simply dismiss the infringement claim on the ground that this was a parody. Rather it undertook a detailed study of the factors governing fair use. The court wrote:

There is no bright line that separates the protectable expression from the nonprotectable idea in a work of fiction.

...

While we agree with Houghton Mifflin that the characters, settings, and plot taken from GWTW are vested with a new significance when viewed through the character of Cynara in TWDG, it does not change the fact that they are the very same copyrighted characters, settings, and plot.
Houghton Mifflin argues that TWDG is entitled to fair-use protection as a parody of GWTW. In Campbell, the Supreme Court held that parody, although not specifically listed in [17 USC] § 107, is a form of comment and criticism that may constitute a fair use of the copyrighted work being parodied. Parody, which is directed toward a particular literary or artistic work, is distinguishable from satire, which more broadly addresses the institutions and mores of a slice of society. Thus, " [p]arody needs to mimic an original to make its point, and so has some claim to use the creation of its victim's . . . imagination, whereas satire can stand on its own two feet and so requires justification for the very act of borrowing." (citations, mostly to Campbell v. Acuff-Rose Music, Inc. omitted)

...

The fact that parody by definition must borrow elements from an existing work, however, does not mean that every parody is shielded from a claim of copyright infringement as a fair use. "The [Copyright] Act has no hint of an evidentiary preference for parodists over their victims, and no workable presumption for parody could take account of the fact that parody often shades into satire when society is lampooned through its creative artifacts, or that a work may contain both parodic and nonparodic elements." (quoting Campbell v. Acuff-Rose Music, Inc.)

...

... we will treat a work as a parody if its aim is to comment upon or criticize a prior work by appropriating elements of the original in creating a new artistic, as opposed to scholarly or journalistic, work.

The court found that TWDG was a parody under this definition, and then proceeded with a detailed analysis of the fair use factors in this specific case. After a long analysis of each of the four fair-use factors, soem of them divided into multiple facets, the court concludes:

We reject the district court's conclusion that SunTrust has established its likelihood of success on the merits. To the contrary, based upon our analysis of the fair use factors we find, at this juncture, TWDG is entitled to a fair-use defense.

It should also be noted that this was a preliminary finding on the status of an injunction, and the actual infringement case was settled, rather than tried.
The case of Suntrust Bank v. Houghton Mifflin Co establishes that for US copyright purposes, a parody is a work that is intended "to comment upon or criticize a prior work by appropriating elements of the original in creating a new artistic, as opposed to scholarly or journalistic, work." A work imitating but neither commenting on nor critizing a prior work is not a parody of it. Such would be the case of the songs described in the question.
The Suntrust case also establishes that while a parody will often be a fair use of the original, this is not always nor automatically the3 case. The full four-factor fair-use evaluation must still be made, and not all parodies will pass. Still less will all works that imitate but do not parody the original.
Parody in non-US law
The Suntrust case is all about fair use, a very specifically US legal concept. It does not exist in the law of any other country that I know of.
The UK and several Commonwealth countries have "fair dealing" a somewhat similar but more restrictive concept, which moreover is not exactly the same in the various countries that use it. Some of these specifically mention "parody" as a permitted purpose of fair dealing. Others do not, but mention "criticism" of the original work. A parody may be a form of criticism. None of them grant an automatic and all-embracing exception for parodies.
Other countries have neither fair use nor fair dealing.  Some have limited exceptions for criticism. In some cases parodies might fit these, but it is surely not valid to say that parody is always an assured defense to a claim of copyright infringement.
Comment: @hszmv The above is not correct. There is no absolute immunity for a parody. Many, indeed most, parodies, count as fair use under US law. But for that to apply, the secondary work must either comment on the original (a true parody) or must use the form of the original to comment on something else in a way that is transformative. Whether such a defense would apply depends on the specifics of the alternative words. Also, "fair use" is a very specifically US concept in copyright law, and the question did not state a jurisdiction. The somewhat similar 'fair dealing" exception in UK/EU  ...
Comment: Down voted because permission is not required to make a parody of a work.  In music, Weird Al famously asks permission before releasing a song but this is out of respect for the artist and their work, not out of any legal obligation.  He has, mistakenly mind you, published songs where he did not have such permission that are perfectly legal and resulted in no legal action taken against him.
Comment: @hszmv copyright law is significantly less permissve, and a work what would count as "fair use" in US law might not count as fair dealing in the UK. Parody is a specific exception in some but not all of the commenwealth countries that use fair dealing see https://en.wikipedia.org/wiki/Fair_dealing in the EU and other countries no parody exception exists, as far as i know.
Comment: @hszmv I have significantly expended my answer, dealing specifically with parody and fair use, with citation to the case of *The Wind Done Gone*, probably the most through US case law on parody now available. I urge you to reconsider both your downvote and your answer.
Answer: The copyright holder of a piece of music has the authority to forbid any transcriptions or public performances of that music in association with unapproved lyrics, but at least in the USA has no authority to forbid anyone from imagining how some other lyrics would sound in relation to that music, nor singing the music with other lyrics in contexts that would not be considered public performances for purposes of copyright law(*), nor encouraging others to do such things.
(*) Note that for copyright purposes, not all performances that might be audible to members of the public are considered "public performances"; a discussion of which performances qualify would be beyond the scope of this answer.
If I were to suggest that the lyrics to "Amazing Grace" sound great when set to "The Ballad of Gilligan's Island", such an observation would not violate the copyright of the latter song (the former song--being 200+ years old--is public domain).  Publishing the lyrics to Amazing Grace, or any other set of lyrics which was public domain or to which I held copyright, with a suggestion that they be sung to the aforementioned TV theme, would likewise not involve any kind of copyright infringement.
Anyone wishing to publish a recording of a song using the tune from "The Ballad of Gilligans Island" would need to acquire permission to do so from the composer--permission the composer would be under no obligation to grant--unless some other recording using the lyrics in question had already been published; in the latter scenario, the person wishing to publish the recording would need to acquire a compulsory mechanical license, but at least in the USA the composer would be required to grant such a license in exchange for a royalty fee set by statute.
While it's vaguely conceivable that some songs might have sufficiently complicated rhythms and metrical stress patterns that those features in and of themselves would be worthy of copyright protection, and a work which used the rhythmic structure of another work as a framework but otherwise had nothing in common with it would not be a "derivative work" of the work that shares its structure.
Answer: Parody typically falls into the protection of Fair Use in the United States, which is an Affirmative Defense (i.e. They can still sue you and as part of your Not Guilty Plea or civil law equivalent you would have to assert that it was Fair Use, which shifts the burden of proof onto you.).  Fair Use has strong precedence to Parody (I.E. Writing new lyrics to the Tune Of, ala Weird Al, or Singing popular song lyrics in the style of, Ala Richard Cheese) or Educational Works (i.e. the original Bill Nye the Science Guy had a lot of parodies of popular 90s songs discussing concepts related to the topic of the episode.).
It should be pointed out that while Weird Al does not release music without asking permission from the artist performing the song, this is not required in order to publish a parody song.  Weird Al is just a really nice guy and most artists see it as a sign of making it in the music industry.  Disney's music, characters, and plots, have been subject of vicious parodies over the years (From South Park's use of a foul mouthed Mickey Mouse as the CEO of Disney espousing the more tasteless side of their marketing departments and corporate situations, to even Disney itself in some bizzare levels of Self-Deprecation (Have you ridden the Jungle Cruise ever?)) and Disney has a notorious streak of over-protection of it's intellectual properties.  The good news is, you may not even need to go to court over the matter if they sue you as California has very strong Anti-SLAAP rules (Basically, allows a judge to dismiss the case and possibility of refiling if it's pretty obvious its to shut down critical voice rather than an actual case.).  Additionally, case precedent holds that IP holders suing for Copyright Infringement must take into account the likely hood of a Fair Use defense prior to filing suit.
Comment: Such songs would not be parodies as defined in *Suntrust* interpreting *Campbell* in that they do not comment on the original. Nor are all parodies fair use. And in any case, fair use is a US concept, while the question did not specify any jurisdiction.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/93369/discussion-on-answer-by-hszmv-write-song-to-the-tune-of-a-copyrighted-song).


Mobile + SharePoint 2013 = Possible?

Question: In SharePoint 2013, is there a framework between SharePoint + Windows Mobil 8 and android in order to faciliate the integration?
Answer: For Windows Phone 8 (and 7) the SDK has been released which essentially provides via Visual Studio 2012 a lot project templates enabling fast development and authentication samples for developers. Find a starting point here http://blogs.msdn.com/b/dpe_nigeria/archive/2013/03/05/download-sharepoint-sdk-for-windows-phone-8-free-developer-resources.aspx
However, as you might know SharePoint 2013 comes with OAuth v2 authentication support, as it relies on Claims Authentication. Beyond this, in terms of data access, more than 90% of the SharePoint 2013 API is exposed now via CSOM, with JSOM or REST API. Basically, as soon as you handled properly the authentication, you could very easily consume all type of data from Mobile clients, Tablet or Web sites.
I found that developing with REST is the best and fastest as you could easily format the response as JSON (see here http://msdn.microsoft.com/en-us/library/fp142385.aspx)
Answer: In addition to using REST and other windows phone mobile templates as described by Marius, I would also suggest the following:

Utilize the Sharepoint 2013 Mobile Device Channels
               - Allows for automatic mappings between pools of devices and master pages, page layouts, CSS which will be useful in
  delineating windows phone and android styles
               - http://msdn.microsoft.com/en-us/library/jj862343.aspx
Use Knockout JS in combination with the REST API
        -  knockout is a very powerful JSON data driven UI rendering template framework that is independent of jquery.  Using this
  framework along with JSON based REST API calls will make for rapid
  development
        - http://knockoutjs.com/

Mobile + SharePoint 2013 = Possible?


A Wilson line property

Question: Consider a path, say $P$, and three points on it like $x,y,z$. If there were infinitesmally closed, then the following relation would be true.
$$W_{P}(x,y) W_{P}(y,z)=W_{P}(x,z)$$
If the Lie algebra of the theory was Abelian, it was also held for any three points on the path no matter how far they are. Is it also true in non-Abelian cases? The Wilson line of the path $P$ contains path-ordering so I am not sure whether this is the case in non-Abelian Lie algebras.
Answer: Yes, non-Abelian Wilson lines $W_P[\gamma]$ form a groupoid via concatenation of oriented curves and has OP's mentioned property by definition of path-ordering of ordered exponentials.

A Wilson line property


Access 2013 report/forms not using modified query

Question: I am modifying a very old access app that had been upgraded numerous times.  It may have started out as 2003.  I am running with 2013.  I modified a query to filter on a column that I just added to a table. Neither my form nor my reports is using the modified query.  I know this because I added a column to a table and then modified the query to filter on this column.  the query runs fine.  The reports and form are definitely using the old query.  The app also uses VB6 code which actually adds more SQL based on the report selected.  If I create a totally new report it will execute the new query.  I don't want to create all new reports.  And please I know VB6 is old also, but this company is going out of business and it's just a keep it going type of organization.
Answer: The trick is going to be figuring out where the report gets its data from at run-time.  Because you say that there's VB6 code that alters the SQL, this could be complicated.
There are a number of ways this can change, and with the information in the question at the moment, it's not possible for me to narrow it down, but there are some places that you can look to check.
A report's data can be specified in a number of ways.

You can choose a table or query as the datasource in the properties of the report.  If this was what's happening then your report should have changed as soon as you modified the query.  So it might not be.
A report can have its own query defined using that property. This can be a select statement that uses tables and other queries, chooses specific fields and applies filters.
You say there's a bunch of VB6 that alters the query too.  (Are you sure it's VB6 and not VBA? probably doesn't matter much).  This will change where you need to look.

So what I'd do is:

Look at the properties for the report and find out what the data source is.  See if it's just a query name or an SQL statement.  If it's an SQL statement, fire it up in the builder and see if you can find the query that you modified, or reapply the modifications and see if that works.

If that doesn't work, then you're going to need to look at the VB code.  Find the code that modifies the SQL for this report. Most likely, there'll be a button that user clicks that runs a bunch of code, that updates the SQL and launches the report.  Stick a breakpoint in there and step through until you see some SQL being constructed, then work out how to alter the SQL from there.
Most likely you'll have two strategies:

The VB code constructs SQL raw, which looks vaguely like the SQL in the query,  but with different criteria.  So you could use the modified SQL from your modified query to model the changes you need to make in the VB constructed SQL
The VB code does something like SELECT * FROM [TheQuery] WHERE and just adds criteria.  This would probably make your life easier, but it's probably not what's going on because modifying the query didn't change anything.
Comment: Well interesting enough I removed the record source from the report property sheet and low and behold, it still executed properly...  I am assuming this is telling me the record source query is not even being used, would you agree with this assessment?
Comment: @lesslag yes, I agree. It's probably being populated in code just before launching the report.
Comment: Thank you for your help!   @GregHNZ


Is there any alternate to TextView?

Question: I m new to android application development. I made a project on getting feeds of sites. I displayed the title and description of feeds in textview which is not looking very presentable. Is there any alternate to it? I just need my application to look a bit presentable.
Answer: You'd probably want to use a ListView for displaying a list of items.
Using a ListView would also let you set an onClick listener to let your users click the title/description and open the item.
Answer: Seems to me you want to style it with themes etc.
This is how to do this http://developer.android.com/guide/topics/ui/themes.html
And I guess you already checked all the things you can do with a textview. http://developer.android.com/reference/android/widget/TextView.html

Is there any alternate to TextView?


Hw does a digital piano work?

Question: I know someohow it combines different harmonics to synthsis note, but I don't exactly know how this happens. Does digital piano use pwm to synthesis a note?
Comment: Duplicate of your question on EE: https://electronics.stackexchange.com/questions/514943/how-do-digital-pianos-work
Answer: Piano sound generation is complicated by the sound being so familiar to most of us, and the slowly decaying non-stationary non-harmonic nature of overtones meaning that simple attack + looped samples is hard to get right. It is simplified by the low dimensionality of user interaction (88 keys with velocity, 3 pedals) compared to, say, a guitar where there are many dimensions to how the string is picked and how your left hand interacts with the string.
It used to be that digital pianos used synthesis in order to produce tones. My old Roland piano used «SA synthesis»:
http://www.novelmusic.com/roland/Technical/default.htm
As digital memory has become cheaper, my impression is that nowadays, digital piano generation is mostly PCM samples recorded in multiple key (-zones) and multiple strike velocities, with a minimum of resynthesis to smooth things out. I might be wrong.
https://en.m.wikipedia.org/wiki/Inharmonicity

Hw does a digital piano work?


When should I use typedef in C++?

Question: In my years of C++ (MFC) programming in I never felt the need to use typedef, so I don't really know what is it used for. Where should I use it? Are there any real situations where the use of typedef is preferred? Or is this really more a C-specific keyword?
Comment: @Milan https://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library
Comment: Out of curiosity, what is MFC?
Answer: Template Metaprogramming
typedef is necessary for many template metaprogramming tasks -- whenever a class is treated as a "compile-time type function", a typedef is used as a "compile-time type value" to obtain the resulting type.  E.g. consider a simple metafunction for converting a pointer type to its base type:
template<typename T>
struct strip_pointer_from;

template<typename T>
struct strip_pointer_from<T*> {   // Partial specialisation for pointer types
    typedef T type;
};

Example: the type expression strip_pointer_from<double*>::type evaluates to double.  Note that template metaprogramming is not commonly used outside of library development.
Simplifying Function Pointer Types
typedef is helpful for giving a short, sharp alias to complicated function pointer types:
typedef int (*my_callback_function_type)(int, double, std::string);

void RegisterCallback(my_callback_function_type fn) {
    ...
}

Comment: For C++11, the addition of the "using a = b" syntax pleasantly leaves the "typedef" keyword mostly to memories, as typedef was always confusingly backwards and inconsistent with #define (now I never accidentally reverse the two because it's the same as variable assignment ordering).
Comment: Necessary? Care to give an example? I can't think of any cases where it'd be necessary.
Answer: In Bjarne's book he states that you can use typedef to deal with portability problems between systems that have different integer sizes.  (this is a paraphrase)
On a machine where sizeof(int) is 4 you can
typedef int int32;

Then use int32 everywhere in your code.  When you move to an implementation of C++ where sizeof(int) is 2, then you can just change the typdef
typedef long int32;

and your program will still work on the new implementation.
Comment: Naturally you would use the uint32_t from  though right? :)
Comment: @KeithB: I think the rarity depends on what type of development you do.  Embedded systems developers and those dealing frequently with file formats are two cases I can think of when you will often need to know exact sizes.
Comment: And only for those cases, usually rare, where you need exactly 32 bits.
Answer: use with function pointer
Hide Function Pointer Declarations With a typedef
void (*p[10]) (void (*)() );

Only few programmers can tell that p is an "array of 10 pointers to a function returning void and taking a pointer to another function that returns void and takes no arguments." The cumbersome syntax is nearly indecipherable. However, you can simplify it considerably by using typedef declarations. First, declare a typedef for "pointer to a function returning void and taking no arguments" as follows:
  typedef void (*pfv)();

Next, declare another typedef for "pointer to a function returning void and taking a pfv" based on the typedef we previously declared:
 typedef void (*pf_taking_pfv) (pfv);

Now that we have created the pf_taking_pfv typedef as a synonym for the unwieldy "pointer to a function returning void and taking a pfv", declaring an array of 10 such pointers is a breeze:
  pf_taking_pfv p[10];

from
Answer: Just to provide some examples for the things said: STL containers.
 typedef std::map<int,Froboz> tFrobozMap;
 tFrobozMap frobozzes;
 ...
 for(tFrobozMap::iterator it=frobozzes.begin(); it!=map.end(); ++it)
 {
     ...
 }

It is not unusual to even use typedefs like
typedef tFrobozMap::iterator tFrobozMapIter;
typedef tFrobozMap::const_iterator tFrobozMapCIter;

Another example: using shared pointers:
class Froboz;
typedef boost::shared_ptr<Froboz> FrobozPtr;

[update] As per comment - where to put them?
The last example - using shared_ptr - is easy: are true header material - or at least a forward header. You do need the forward declaration for shared_ptr anyway, and one of its declared advantages is that it's safe to use with a forward decl.
Put it another way: If there is a shared_ptr you probably should use the type only through a shared_ptr, so separating the declarations doesn't make much sense.
(Yes, xyzfwd.h is a pain. I'd use them only in hotspots - knowing that hotspots are hard to identify. Blame the C++ compile+link model...)
Container typedefs I usually use where the container variable is declared - e.g. locally for a local var, as class members when the actual container instance is a class member. This works well if the actual container type is an implementation detail - causing no additional dependency.
If they become part of a particular interface, they are declared together with the interface they are used with, e.g.
// FrobozMangler.h
#include "Froboz.h"
typedef std::map<int, Froboz> tFrobozMap;
void Mangle(tFrobozMap const & frobozzes);

That gets problematic when the type is a binding element between different interfaces - i.e. the same type is needed by multiple headers. Some solutions:

declare it together with the contained type
(suitable for containers that are frequently used for this type)
move them to a separate header
move to a separate header, and make it a data class where the actual container is an implementation detail again

I agree that the two latter aren't that great, I'd use them only when I get into trouble (not proactively).
Comment: Thanks. I've put a longer version of this question here: http://stackoverflow.com/questions/2356548/header-file-best-practices-for-typedefs. I fear I've come to the same conclusions so far, which is that there isn't really a good answer you can use consistently, which means it's hard to have a rule that everyone on the team can follow and rely on. "For this header you need to use the fwd version, but *this* header you just include the base header, and *this* related stuff is defined over here in common.h..." How does anyone ever write maintainable and reusable C++? (ObjC has spoiled me... :D)
Comment: Can you discuss best practices on this for header files? The options seem to be putting the typedef in Froboz.h, which creates header dependency and long build times; putting the typedefs in Frobozfwd.h (per Effective C++), which seems a pain for maintainability (two headers for everything); or putting the typedefs in FroCommon.h, which kills reusability. Is there some better way?
Answer: typedef is useful in a lot of situations.
Basically it allows you to create an alias for a type. When/if you have to change the type, the rest of the code could be unchanged (this depends on the code, of course).
For example let's say you want to iter on a c++ vector
vector<int> v;

...

for(vector<int>::const_iterator i = v->begin(); i != v.end(); i++) {

// Stuff here

}

In the future you may think to change the vector with a list, because the type of operations you have to do on it. Without typedef you have to change ALL occurrences of vector within your code.
But if you write something like this:
typedef vector<int> my_vect;

my_vect v;

...

for(my_vect::const_iterator i = v->begin(); i != v.end(); i++) {

// Stuff here

}

Now you just have to change one row of code (i.e from "typedef vector<int> my_vect" to "typedef list<int> my_vect") and everything works.
typedef also saves you time when you have complex data structures which are very long to write (and difficult to read)
Comment: @xtofl: typedefs and interface types are both valid ways to solve this particular problem.  Interface types are more general, but they are also more heavyweight.  Also, correct use of interface types implies that all calls will be virtual -- a heavy price for iterator advancement/dereference.
Comment: That's not a really good rationale of using typedefs: you should use an interface type for that (Abstract Data Type, if you prefer).  That's why you needed to add the 'depends on the code'.  It should be the code that depends on the type :)
Comment: And C++0x is coming!  AWW-TO!  AWW-TO!  AWW-TO!
Answer: One good reason to use typedef is if the type of something may change.  For example, let's say that for now, 16-bit ints are fine for indexing some dataset because for the foreseeable future, you'll have less than 65535 items, and that space constraints are significant or you need good cache performance.  However, on the off chance that you need to use your program on a dataset with more than 65535 items, you want to be able to easily switch to a wider integer.  Use a typedef, and you only have to change this in one place.
Comment: what if I want to change from int to say unsigned long?  I would have to check all my source code for overflows etc... -> not a good reason to use a typedef!  Use a wrapper interface instead.
Comment: Or give the typedef a sensible name which indicates what properties (such as size and signedness) can be relied on, and then don't change it in a way that breaks those properties. stdint has some good models for how to do this, such as int_fast* and int_least*. No need for a big interface there.
Comment: @xtofl: If you are worried about overflows, you would already be performing checks using numeric_limits, and those checks will continue to Do The Right Thing when you change what my_int is typedef'd to.
Comment: If you just use int for indexing, the sizeof(int) usually corresponds to the bit'edness of the processor and is the limit on how much memory is indexable. So if you can use an int, you'll never be in this situation.
Answer: typedef allows to not only have an alias for complex types, but gives you a natural place to document a type. I sometimes use it for documentation purposes.
There are also times when I use an array of bytes. Now, an array of bytes could mean a lot of things. typedef makes it handy to define my byte array as "hash32", or "fileContent" to make my code more readable.
Answer: Real-world uses of typedef:

providing friendly aliases for long-winded templated types
providing friendly aliases for function pointer types
providing local labels for types, e.g.:
template<class _T> class A
{
    typedef _T T;
};

template<class _T> class B
{
    void doStuff( _T::T _value );
};

Comment: I don't think that will compile.  Do you maybe mean "void doStuff( typename A<_T>::T _value );"?  (You need the typename keyword in there because the compiler will interpret A<_T>::T as a member variable name otherwise.)
Answer: There is one another use case to use typedef is when we want to enable a kind of  Container Independent code (but not exactly!)
Let us say you have class:
Class CustomerList{

public:
    //some function
private:
    typedef list<Customer> CustomerContainer;
    typedef CustomerContainer::iterator Cciterator;
};

The above code encapsulates the internal container implementation using typedef and even if in future the list container needs to changed to vector or deque still the user of the CustomerList class doesn't need to worry about exact container implementation.
Hence, the typedef encapsulates and somewhat help us to write Container Independent code
Answer: Whenever it makes the source clearer or better to read.
I use kind of typedef  in C# for generics/templates. A "NodeMapping" is just better to read/use and understand then a lot of "Dictionary<string, XmlNode>". IMHO. So I'd recommend it for templates.
Answer: Typedef allows flexibility in your class. When you want to change the data type in the program, you do not need to change multiple locations but just need to change one occurrence.
typedef <datatype example  int or double> value_type

you can give nay name instead of value_type, but value_type is normally the standard name.
So u can use typedef like
value_type i=0;     //same as a int or double i=0;

Answer: 1 practical example of typedef is size_t. It is guaranteed to be big enough to contain the size of the biggest object the host system can handle. The maximum permissible size is dependent on the compiler; if the compiler is 32 bits then it is simply a typedef for unsigned int but if the compiler is 64 bits then it would be a typedef for unsigned long long. The size_t data type is never negative.
Answer: ... and you Don't Need a Typedef for an enum or a struct.
Or do you?
typedef enum { c1, c2 } tMyEnum;
typedef struct { int i; double d; } tMyStruct;

can be better written as
enum tMyEnum { c1, c2 }
struct  tMyStruct { int i; double d; };

Is that correct?  What about C?
Comment: Why do you have questions in your answer?
Comment: In C, you'd need to say "struct tMyStruct foo;" to declare in the last situation, so typedefs are often used in C struct definitions.

When should I use typedef in C++?


Gear Stick sticking but only when I'm driving in the city and doing a lot of gear changes

Question: I noticed when I'm doing city driving that my gear stick is getting stuck moving from 1st to 2nd gear. I brought the car to a mechanic and they replaced the clutch. Now a month later, I'm having the same issue.
I have a Ford ka plus any it's 2017 model. It's in great condition. On a day to day basis I've no issues on short trips (driving 20-30) mins but it's when I have to travel into the city that it starts getting stuck.
I only bought the car in June.
Comment: Welcome to Motor Vehicle Maintenance & Repair! Could you please describe a little better as to what you mean by "my gear stick is getting stuck"? Is it not shifting at all, or does it shift out of 1st gear and not want to go into 2nd? It doesn't stick on any other gear changes (ie: 2nd to 3rd, etc)?
Comment: It doesn't want to shift from 1st to 2nd gear. I have to really yank it down from one gear to the other. Same when I was moving from 2nd to 3rd gear.  Doesn't happen going into 4th or 5th gear.
Driving through the city there is a lot of stopping and starting and that's when it happens. Ordinarily I'm nit driving in the city and so I don't have to stop and start because of traffic, traffic lights etc.
I hope that makes it a bit clearer. I don't quite know why it's happening as a new clutch went in very recently.
Comment: It sounds as though the clutch isn't properly disengaging. Are you pressing the pedal all the way to the floor? Do you have trouble engaging first gear from standstill? How far do you have to lift it for the clutch to 'bite' when pulling away from standstill? Have you asked the clutch fitter? What did they say?
Comment: Yes, pressing it all the way to the floor. Not such an issue getting it into 1st gear from take off, but it is when I need to move up the gears.
I will phone the garage tomorrow and talk to the mechanic who fitted the new clutch.
Answer: Thank you for trusting us with your transmission issue.
From the data provided, it sounds like your transmission's synchronizers are beginning to fail. Basically, the synchroniers synch up the main shaft and the desired gear so that the teethe of the gears mesh up. I'm going to go on a limb and say that it growls at you when you attempt to engage each gear.
The reason why 2nd gear started going first is that, in city driving, you shift most often back and forth between 1st, 2nd, and 3rd and back again. So your 4th gear sits mainly unused. The reason why I reject your clutch as an issue is that it would happen in all gears, including reverse and 1st, which it isn't. The good news is that manual transmissions are much easier to work on, thus making them cheaper to work on.
Please let me know if this answers your question!
Comment: Thank you, that makes sense. I can't say that they growl at all. But it's definitely related as you say to the frequency of gear change in the city.
The car is still under warranty so I'll get it back to the garage in the new year.
You think it's damaging to continue driving when it gets like that?
Comment: If it's not grinding, then probably not. But I still wouldn't delay too long,  because I wouldn't be the farm on "probably"

Gear Stick sticking but only when I’m driving in the city and doing a lot of gear changes


Is it legal to compare a patented technology algorithm with a non-patented algorithm

Question: I am curious is it legal to compare performance of a patented algorithm with a non-patented algorithm? I guess it would be because it is purely non-commercial and educational even if that kind of research would be conducted by a commercial company. Is there any law case that would support this thesis?
Comment: Does the comparison involve executing the steps of a patented process? Why would a commercial company spend its resources on an academic curiosity?
Answer: U.S. Patent law does not say infringement requires a financial gain. It says you infringe if you make or use a patented invention. It also says you can't sell, offer for sale or import which are commercial activities, but use and make do not require any explicit commercial exploitation or any diminution in the patent owner's commercial prospects.
It is not the comparison that is the problem, it is the performance of a patented set of steps, presumably needed to have something to compare to. If you can do a comparison on paper without executing the patented method then no infringement has occurred.
In the U.S. a research exemption is very narrow other than spelled out in the Hatch–Waxman Act which only applies to certain drug development situations.
An article published by the National Library of Medicine says -

The judicially created exemption is a narrow exemption, reliance upon which is not likely to be fruitful."

and in a drug related case (Roche v. Bolar, ) that did not fall under the safe harbor of Hatch-Waxman -

The court ruled that whenever experiments were performed for business purposes, those experiments were not exempt. "[T]ests, demonstrations, and experiments which are in keeping with the legitimate business of the alleged infringer are infringements for which experimental use is not a defense."

What about a not-for-profit university? see the case Madey (307 F.3d 1351) about the fact that a university's reputation enhancement leads to financial gain.

Although a university may fund or allow research projects with arguably no commercial application, these activities further the legitimate business objectives of the university. Research projects may increase the stature of universities and help attract grants, students, and faculty. "[S]o long as the act is in furtherance of the alleged infringer's legitimate business and is not solely for amusement, to satisfy idle curiosity, or for strictly philosophical inquiry, the act does not qualify for the very narrow and strictly limited experimental use defense."

I think the bottom line in the U.S. is that executing the steps of an algorithm that is patented unless it is for purely "philosophical  inquiry" will be infringement without permission of the patent owner.
Do it in the EU
Also published by National Library of Medicine this article covers the laws in a variety of EU countries, many of which have explicit laws allowing experimental use.
Germany

effects of a patent shall not extend to "acts done for experimental purposes relating to the subject matter of the patented invention."

U.K.

An act that would constitute an infringement of a patent for an
invention shall not do so if it is done for experimental purposes
relating to the subject matter of the invention (§60(5)(b) UKPA).

Do it in Canada

New section 55.3 of the Patent Act, which came into force on December 13, 2018, provides:

55.3 (1) An act committed for the purpose of experimentation relating to the subject-matter of a patent is not an infringement of the patent.

Or better yet, do it in a country where the algorithm is not patented.
Patents are territorial. No commercial entity finds it cost effective to file for patents everywhere.
Answer: Let me preface this by pointing out that I am not a lawyer. So this isn't legal advice. There is a Research Exemption, but I've been advised that this mainly covers generic drug development. That said, I do have a number of patents on algorithms related to real time PCR analysis and have published papers comparing their performance against other algorithms even after retiring from my company who owns the patents. My old company seems to have no problem with this, but I can't guarantee this is true for other patent owners.
In my old companies case, the algorithm is part of an entire instrument system and isn't sold as a software product. A company selling their algorithm as commercial software might not be so understanding so I do believe there is some risk of infringement. After all, educational institutions do purchase products so reproducing the algorithm might represent a lost sale. You could, perhaps, reach out to the patent holder and obtain permission to utilize the algorithm for your non-commercial purposes.


Scheduling WP cron jobs

Question: I am new with cron jobs and I have to schedule cron jobs. There are a lot of cron jobs in my website which are running randomly but I want all these to run at specific time. Actually I do not want these cron jobs to run at day time and instead I want these to run at night because these are significantly slowing down the server.
Mostly these are firing via plugins so I do not have control over these functions directly.
Is there a way to control schedule for these cron jobs. Your help will be much appreciated.
Answer: you could use something like this, WP Crontrol to see what those events might be and when they are scheduled to run ( interval ), but the time of the day ( when they run ) is controlled by visitors viewing your site ( which is why they run during the day, because that when your site has most traffic).  The only way around this is to run it server side or a service that provides such actions.
Answer: WP Crontrol is a good solution, or you could disable WP-Cron completely and run the cron jobs from the server (or a service like EasyCron) on whatever schedule you want.
To disable WP-Cron, in 'wp-cron.php' add:
define('DISABLE_WP_CRON', true);

Answer: Alternatively you can also use Advanced Cron Manager plugin as you can pause any cron events that are running in your site system, and to remove it if you need.
Answer: First disable schedule executions as a side effect of normal http requests to your website define('DISABLE_WP_CRON', true); in wp-config.php.
Second use wp-cli to execute schedules via crontab -e.
0 2 * * * wp cron event run --path=/path/to/wp/docroot --due-now
This executes all your schedules at two o'clock. But beware that all schedules will only be executed at this time so you planned post will not be published until two o'clock the next day for example.

Scheduling WP cron jobs


The perfect book?

Question: Theoretically if I made a neural network which made combinations of every character possible within a 500,000 character limit. Will there be one instance where we have the perfect combination giving us the perfect book which in my context is a book which contains all future predictions?
Comment: A neural network would not be a useful approach to have combinatorial completeness, a simple algorithm would suffice for this question.
Comment: You seem to assume that the perfect book can exist within 500,000 characters. But yes, if so, every possible character combination would lead to the perfect book (within that limitation), although it would not necessarily be obvious to anyone which permutation was the 'perfect' book. For one person, the 'perfect' book might be a single apostrophe's difference from another's. ( In hindsight, this is probably just a rewording of Haxor's answer).
Comment: Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
Comment: I'm voting to close this question because it's highly speculative and doesn't fit the Q&A format that PhilSE aspires to.
Comment: A better forum for these sorts of questions is https://thephilosophyforum.com/
Comment: You could have it but you won't recognize it when it's under your nose, since you'll have no way to know which prediction is accurate.
Answer: If we restrict attention to all the relevant facts of the rest of your life. Probably, they fit in about 500 pages. The answer is yes, it is theoretically possible to obtain the perfect book in this way. An way to see it is to review the Infinite Monkey Theorem, a rigurous theorem in probability:

It states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type any given text, such as the complete works of William Shakespeare.

but there are many practical difficulties:

However, the probability that monkeys filling the entire observable universe would type a single complete work, such as Shakespeare's Hamlet, is so tiny that the chance of it occurring during a period of time hundreds of thousands of orders of magnitude longer than the age of the universe is extremely low (but technically not zero).

In addition, this theorem can be generalized to state that any sequence of events which has a non-zero probability of happening will almost certainly eventually occur (i.e. writting the perfect book), given enough time. In the case you propose, we eliminate the random factor, since the perfect book will necessarily be one of the 27^(500000) texts generated. But that number is vastly greater than the number of particles 10^80 in our observable universe. Therefore, although such a procedure, given sufficient space and time would generate, the perfect book is surely one of the least practical means of even predicting tomorrow.
Comment: As I noted in my answer - if you get the perfect book, how do you recognize that this is it? There will be many books that have past events correct, but the future is wrong. Even if you had ALL the books, you couldn't tell which is the right one.
Comment: A primate named Shakespeare wrote the complete works of Shakespeare within a lifespan of only 52 years. What are the odds!
Comment: @user4894 although by using a feather pen, rather than a typewriter, his chances seem to have increased!
Comment: @kutschkem you are right, although the question here is not how to recognize the "perfect book" but whether you would actually get it. It is clear that the perfect book would be obtained, it is NOT clear how such a book would be recognized.
Answer: Absolutely not. The finite character limit limits the book to finite predictions. Even restricting the case to 'predicting the relevant facts of your life' or in some other way, that's going to be a very ambiguous and limited set of predictions.
You should read the short story The Library of Babel by Borges, which grapples with issues of scale and consequences of a collection of books of exactly the kind you imagine.
It's interesting to consider the ontology of the Many Worlds interpretation of quantum mechanics. If it's right, every combination of probabalistic outcomes does happen in some subset of branches in the state-space. So if you could make it into a problem for a quantum computer algorithm, with some criteria to make the correct answer stand out, you could imagine directing the decoherence of all the books, into one specifically, by using destructive interference to remove all the other answers.
In practice, only relatively short strings by comparison can be tested so far, for minimal useful sifting processes, just prime factors for cryptography. I'd say all you could do even with a most-powerful-imaginable quantum computer in the future, is limit the set of books to the set of real possible futures for a defined subsystem, probably only in relative isolation, or the inputs would get too complex.
The consequences of finite time and energy, and the finite states or bit-representations of subsystems of the universe (eg measurements not wavefunctions), seem to place fundamental constraints on how much information can be represented in the macroscopic universe. You need constraints, like knowing initial conditions to limit the state-space, or even far smaller calculations than the one you propose become 'unphysical', not relisable even in principle in the universe as we understand it (but only in the multiverse of Many Worlds). I suggest the appropriate accuracy of the initial conditions of your life, to get any useful answer, would be such an unrealisable variable.
If Many Worlds is right, preserving determinism but only across the multiverse, then the book you speak of is the states of all your particles, and all those that could interact with you as limited the speed of light. But that wouldn't give you a precise prediction of your future, because all the futures would happen to every possible subjective you, with no way to distinguish between them (without a way to get destructive interference, which finite inputs constrain).
Answer: That's only about 1000 pages, depending on what you mean by "all future predictions" that's not really much. So if you make that too short, the world formula might not be able to be written down in it's full comprehendable glory leaving you with something like "42". Which for all intents and purposes could be correct, but also makes you ask what exactly the question was. While if it's too long you might not really be able to read it in a live time or before those predictions came to be.
The other problem is that you'd probably also get every other prediction of future events. Meaning not only do you have the problem that you can't read them in time, you'd also only after the fact, know which of the predictions was actually correct. Meaning you might as well have the book that contains all the predictions but you wouldn't know which one it is.
Answer:
Will there be one instance where we have the perfect combination giving us the perfect book which in my context is a book which contains all future predictions?

Perhaps. However, assuming a 28-character alphabet (26 letters, space, full stop), there would be 28500 000 - 1 other books. That's over 1.0367×10723 579 books; the number's too big for the Stack Exchange post limit, and my rounding error is more books than could be read if the whole population of Earth worked on it for a thousand trillion millennia.
Even if you read all of the books, you'd have no way of knowing which was accurate.
Generating the books is the easy part. Working out which book is right is the hard part; to do that, you have to collect lots of information about the world and compare them to your candidates. Many of the books will say:

the sky will be filled with densely packed teleporting frogs on the second of august of the year two thousand and twenty two.

so you can rule these books out. Once you've discarded the obviously-wrong books, you'll have to look harder at the world, and find deeper contradictions and impossibilities, ruling more and more of the books out.
And once you've ruled out all but a single, self-consistent group of the books… you're not done. Because you're only checking books up to 500 000 characters long; it might be that none of them hold only true predictions! Your job is never done. We call this endless task science.
Answer:
Theoretically if I made a neural network which made combinations of every character possible within a 500,000 character limit.

You don't need a neural network for that, it's just a plain set of business rules and a lot of memory and processing resources.

Will there be one instance where we have the perfect combination giving us the perfect book

"Perfect" is subjective. So, any book will do for some specific subject. You don't need many books, you just need one book and many people.

which in my context is a book which contains all future predictions?

Any prediction can be broken, there's no way to have a set of predictions that can't be broken, so, the book is impossible.
Notice that "future predictions" is a pleonasm. All predictions are about the future.
Answer: Yes, in fact you don't need a neural network at all. Just list all the 500.000 character books and the "perfect book" will be among them.
The problem is that you can't tell which one it is. Determining which one it is is as difficult as actually writing it.
Comment: Actually it's easy: just wait until all predictions come to pass. But by then the book is useless... (T_T)

The perfect book?


Has any member of Congress served concurrently in State Office?

Question: The Constitution's ineligibility clause prohibits Senators and Representatives from also serving in the Executive or Judicial Branch. Has there ever been a situation where a Senator or Representative served in state government concurrently with service federally?
Comment: An interesting related question would be whether any court has ruled, or other opinion been offered, on the question of whether a state office could be considered to be "under the Authority of the United States."
Comment: @phoog good point. My thoughts were that at the time the constitution was written that language would only refer to the federal government, but I may be wrong.
Comment: I think you're right, but if a court has ruled on it the answer would be rather clearer.
Comment: Since it's considered a full-time Washington DC position, there might be at least some states where they can't do both, by state law. I'm interested to see the responses to this, so +1.
Answer: I don't know what case law says, but here's the United States constitution, Article I, Section 6, paragraph 2:

No Senator or Representative shall, during the Time for which he was elected, be appointed to any civil Office under the Authority of the United States, which shall have been created, or the Emoluments whereof shall have been encreased during such time; and no Person holding any Office under the United States, shall be a Member of either House during his Continuance in Office.

So this would depend on whether a state office is an office under the United States or not.  There may be case law (precedent) on this point.
Each state may also have rules.  The National Conference of State Legislatures lists a summary of the rules for each of the fifty states.  I'm not going to try to include all of them, but here's Alabama:

Federal office holders may not hold a state office, and state officials may not hold two offices at once. Exception for justices of the peace, constables, notaries public, and the commissioner of deeds. Ala. Const. Art. XVII, § 280 & Ala. Code § 36-2-1.

Federal office holders are specifically excluded from state offices.  So even if the federal constitution or law does not prevent it, the Alabama state laws do for Alabama office holders.
North Dakota:

While serving in the legislative assembly, no member may hold any full-time appointive state office established by this constitution or designated by law. During the term for which elected, no member of the legislative assembly may be appointed to any full-time office that has been created by the legislative assembly. During the term for which elected, no member of the legislative assembly may be appointed to any full-time office for which the legislative assembly has increased the compensation in an amount greater than the general rate of increase provided to full-time state employees. N.D. Const. art. IV, § 6.

North Dakota's summary does not say anything about federal offices.  Whether that's a failure of the summary or an accurate depiction of North Dakota law, I don't know.
These examples are not meant to be representative.  Alabama is the first one I checked.  North Dakota was the first that I found that did not start something like "No person" nor include federal office holders at least implicitly.  I didn't attempt a careful reading though, so I could have missed more examples like North Dakota.  I found several other examples like Alabama while I was looking for North Dakota.


Change reference from GAC to BIN on .net website?

Question: I added a reference to the third party .net tool Farpoint Spread in my asp.net website. This was an actual install on my machine so the DLL's got installed into my GAC. When I add references to the DLL's they also point to the GAC (even though I copied them to a seperate folder).
What I would like to do is reference the DLL's from a third party DLL folder in my solution and they then get dropped in the BIN (and I would then just check in the .refresh files to TFS). Is there anyway to change the below from GAC to BIN? I am picking the third party folder DLLs however it is referring to the GAC (I am guessing this is visual studio's first place to look before falling back on the BIN).
My goal is not have to have every developer install this Farpoint tool so when they get everything from TFS it is properly references in my third party folder.
Any ideas how to fix this?
Screen shot:
Answer: I think you have to manually add these assemblies to your bin folder.
See http://msdn.microsoft.com/en-us/library/ez524kew%28v=vs.80%29.aspx


how can I upload a file to sharepoint using vba?

Question: Update, I've learned that the SharedWorkSpace object has been deprecated.  Anyone have another solution that doesn't use this object?
I need to write a quick Excel VBA tool to send to our overseas partners so they can upload some big files to our SharePoint site.  I used to be able to do this in older versions of SharePoint using the Office.SharedWorkSpace object, but I no longer have the code and my new attempts have failed to find the right process.  I would share code, but I haven't written any yet that can even compile.  I am able to create the SharedWorkSpace Object, but I can't find any members of that Object that relate to uploading.  Can someone help me get started with some sample code or pointers.  I'm pretty good at figuring things out once I get pointed in the right direction.
Sub UploadFileToSharePoint(stFile as string)
<code> Dim sws as Office.SharedWorkSpace

 sws.  ' this shows me the list of members but I can't find any that apply
</code>
End Sub
I've also searched a lot using the Object Browser.  Maybe this functionality has been deprecated?  Frustrated.
Answer: The SharedWorkSpace Object has been deprecated starting with Office 2010.


Locally compact metric space having atleast one non-compact closed ball

Question: Can we have a non-trivial example of a locally compact metric space in which atleast one non-trivial closed ball is not compact.
I am considering that infinite set with discrete metric is a trivial example. More than one examples are appreciated.
Answer: The real numbers, usual topology, but metric $d(x,y) = \min\{1,|x-y|\}$.  It is still locally compact, but $\overline{B}(0,1)$ is the whole space and is not compact.
Answer: Take $(-1,1)$, endowed with the usual distance. It is locally compact and, if $r>1$ and $x\in(-1,1)$, the closed ball centered at $x$ and with radious $r$ is non-compact. Note that, it some cases, it is not the whole space either (such as when $x=\frac45$ and $r=\frac32$).
Comment: @AbdulGaffarKhan If you aren't satisfied with José's example for whatever reason, I suggest posting a new question, explicitly mentioning any extra criteria.
Comment: I forget to mention that closed ball required is distinct from the whole space. As these balls are obtained because of finite diameter of the space like in infinite discrete metric the ball behaving  B(x, 1] of infinte discrete metric. .
Comment: @AbdulGaffarKhan I've edited my answer. What do you think now?
Answer: Let $(X,d)$ be any non-compact metric space.
Form the standard bounded metric $\bar{d}=\min\{d,1\}$ (note that $d$ and $\bar{d}$ generate the same topology).
If $r\geq 1$, the closed ball $\bar{B}(x,r)=X$ and is therefore not compact.

Note: The original question was edited to impose the condition that the closed ball also be non-trivial, so this answer now does not furnish an example.
Answer: Here is another example.  Take $X=(0,1)\times S$ where $\# S\geq 2$, with the distance function
$$
d((t_1,s_1),(t_2,s_2))=
\begin{cases}
|t_1-t_2| & s_1=s_2\\
2 & s_1\neq s_2
\end{cases}
$$
i.e., you are taking $\#S$ disjoint copies of the interval and declaring the distance between two points to be the same as that on $(0,1)$ if they are on the same copy and $2$ otherwise (there is nothing special about $2$, any $M>1$ works).
Then $\overline{B}_1((t,s))=(0,1)\times\{s\}$ is non-compact and not the whole space $X$.
Note that you could replace $(0,1)$ by any noncompact, locally compact metric space with diameter $\leq 1$.


After emailing a professor and getting no response from him, how long should I wait before sending a second email?

Question: From time to time, I come across this problem: I send an email to a professor asking him about something (e.g., making an appointment to ask his opinion on something) and I do not hear back from the professor. In this case, how long is the reasonable amount of time for me to resend a similar email?
Answer: It all depends on the professor, but in general I believe you might get the same result with the second or third email attempt.
I would suggest you try another method to reach the professor. Maybe see if he has allocated to receive students, for questions and guidance. If not, you can try approaching him after a class (be that class yours or not).
The main point is that you try a physical interaction, after all your professor must have hundreds of students and most with issues and concerns. The email is a fast communication lane, but it is still dependent on a persons availability.
Don't discard going directly to his office and asking if he has the time to see you for a quick question. A professor is there to help you and, I like to believe, they take gratification in doing so.
Comment: Thanks so much. Usually I just hesitate to just knocking the door. I shall try this approach.


Can I install a USB-charger receptacle on a GFCI-protected circuit?

Question: I want to replace a standard duplex receptacle in my kitchen with one that provides integrated USB ports. The existing receptacle is protected by a GFCI receptacle upstream in the circuit. Is this against the NEC? Will I encounter any problems with this setup?
Answer: There is no fundamental reason why you should not be able use an integrated USB outlet on a GFCI circuit.  There should be no stray current going elsewhere that would trigger the GFCI, and the 5V USB output is isolated from the mains current anyway.
Comment: Essentially identical to plugging a USB charger into a GFCI-protected outlet.
Answer: I can speak from experience. I was installing outlets in my son's garage. The first outlet on the circuit was a GFCI. Every outlet worked fine until I installed a Leviton USB outlet. Every time I pressed the reset button it would immediately trip. I disconnected the USB outlet and it reset okay. So, I figured I had a bad device and promptly replace with another Leviton USB outlet. It tripped just as the previous one did. I replaced it with a standard commercial grade duplex receptacle and had no GFCI tripping.
Answer: Actually there is a possibility of leakage current that may trip. These USB sockets and even standard USB chargers actually leak current. As long as your national electrical code applies to IEC60950 which most do and depending on its Class rating it should be fine.
It is not unknown for people to have used genuine iPhone devices connected to genuine iPhone chargers or any other tablet/phone devices and to have up to 90V between the case of the device and ground. This effect if using the device can feel like static shock or tingling.
Most people would think it a fault and or dangerous however, on the contrary this is not dangerous though and the current should not exceed 250 micro amps. Generally these chargers have one ceramic cap connected from the primary (mains voltage) side to the output. the purpose of this capacitor is to reduce the conducted electromagnetic interference (EMI) so that the power supply can legally be sold and meet the legal requirements that involve the leakage current being low enough not to cause a hazard to a person that touches the output connector of the power supply.The leakage current can legally be high enough to give you a real shock if your hands are wet. but not high enough to stop your heart. The unfortunate thing is that these power supplies that do not have any ground connection on the primary side will leak some current through this EMI capacitor, so if you measure the voltage between the output and earth ground with a high impedance voltmeter you will see a significant ac voltage. That is just normal.
The ultimate point been depending on the sensitivity of your GFCI/RCD circuit it could trip.


How to start Gnome Screen Recorder from command line

Question: I want to use Gnome's inbuilt Screen Recorder. I know that I can Launch it using the keyboard shortcut Ctrl+Shift+Alt+R. I am looking for options to start the gnome screen recorder using some command so I can automate it in script. Please help.
Answer: The screen recorder is accessible via D-Bus at the bus name org.gnome.Shell.Screencast, and provides a control object /org/gnome/Shell/Screencast. Looking at it through d-feet, these are the available methods:

Screencast(Str file_template, Dict{Str,Var} options) → (Bool success, Str filename_used)
StopScreencast() → (Bool success)

The parameter file_template is either a full path or just the base filename of the video file (which needs to have a .webm extension either way). The options dict can remain empty.
Unfortunately, the screencasting sessions are tied to a specific D-Bus client – so you cannot use them through usual shellscript tools (busctl, gdbus, dbus-send) as the recording would stop as soon as the tool starts it and exits. So you'll have to write a wrapper in some other language which has native D-Bus client bindings.
Comment: Thank you for the answer. Unfortunately I am not sure how to achieve my requirement with your suggestion. However, I was able to achieve it using a different method, using xdtool. I created a file with content
xdtool key Alt+Shift+Ctrl+R

and when this file is executed, it will start/stop screen recording.

Note: Later I noticed, it is not working perfectly, may be the script is not able to replicate the effect of four simultaneous key presses.So I changed the Shortcut as "Alt+U" and then changed the file as below.
xdtool key Alt+U

And it is working without any issues so far.
Answer: import time
import dbus
session_bus = dbus.SessionBus()
session_bus.call_blocking(
    'org.gnome.Shell.Screencast',
    '/org/gnome/Shell/Screencast',
    'org.gnome.Shell.Screencast',
    'Screencast',
    signature='sa{sv}',
    args=["Screencast_%d_%t.webm", {'draw-cursor':True, 'framerate': 35}],
)

time.sleep(5)

result2 = session_bus.call_blocking(
    'org.gnome.Shell.Screencast',
    '/org/gnome/Shell/Screencast',
    'org.gnome.Shell.Screencast',
    'StopScreencast',
    signature='',
    args=[],
)

$ gdbus call --session --dest org.gnome.Shell.Screencast --object-path /org/gnome/Shell/Screencast --method org.gnome.Shell.Screencast.Screencast "Screencast_%d_%t.webm" "{'draw-cursor':<'true'>,'framerate': <35>}"
$ # "The screencast is stopped here, the command below is meaningless.'
$ gdbus call --session --dest org.gnome.Shell.Screencast --object-path /org/gnome/Shell/Screencast --method org.gnome.Shell.Screencast.StopScreencast


restrict just one document in a document library not to show in search result in SP2013

Question: What is the best and easy way to restrict a one document in a document library not to show in the SharePoint 2013 results page
Answer: If it is just one document in a document library of many files, I would go into Central Admin and create a Search Exclusion rule for the file and it won't appear in the index. It might be listed as Remove Search Results, I only have 2010 on prem atm and 2013 delivered via Office 365 so I can't verify the exact language in Central Admin of 2013 on prem.
An ootb approach would be to enable content types on your document library and utilize the Link to a document content type. You would store the document you don't want to appear in search results in a separate document library that is excluded from search. You would utilize the link to a document content type to create a link to this file in the document library that has all your other files.
Comment: Is there something I could do in the site search page itself, Iike in the search webpart?
Comment: not that i'm aware of, search exclusions happen at the farm level, edited with another ootb type approach
Answer: The simplest approach is to secure the document to just yourself. Then it will only appear in YOUR results and no one else.


Using 555 as an external Watchdog

Question: I would like to use a 555 circuit as an external watchdog for my Arduino project. The project is a cellular tracker that goes to sleep for an hour, wakes up and does some measurements, uploads them and then goes to sleep again. The 555 should take care that the active period does not take too long because the systems hangs, and in that case trigger a reset. My first thought was to power the 555 circuit with a PIN of the Arduino so that it only goes on when the system is awake and is turned off while sleeping.
But this does not work as the reset line has to stay high even while sleeping and if i turn the 555 off reset would also go low. Could a Mosfet help? Any other ideas?
Comment: Why can't you use the internal watchdog for this?
Comment: Because it is not reliable and way too fast. I am running on reduced clock speed which means maximum watchdog cycle would be 3-4seconds. GSM communication takes time...
Comment: GSM communication shouldn't block the arduino code. You should at least be able to work around any blocking code that is in the library. Something like `while(!Serial.available() && millis()-starttime<10000){wdt_reset()}`.
Comment: Will give it a try - but nevertheless - would feel saver with an external fallback, still. Any ideas on this?
Answer: ok guys - found the answer: this post here at electronics-stackexchange gave the right hint: Watch-Dog Timer. And my gut feeling was right as well - i simply use a NPN-Mosfet that is being triggered by an Arduino-PIN (which easily can be done while sleeping as well as sleeping means waking up every 8seconds anyway) that connects the capacitor to ground and therefore discharges the guy. Awesome.
This solution can be used as a real fallback in case of whatever happens, while operating the system with built in watchdog-functions while everything is ok.

Using 555 as an external Watchdog


Maximal number of conserved quantities (classical integrability)

Question: In these notes on page 4 the author says that if a $2d$-dimensional phase space has $d$ conserved quantities $F_{\mu}$ that Poisson commute, then $H$ can be written as a function of the $F_{\mu}$. Why should this be the case?
Answer:
I) Lemma: On a $2d$-dimensional symplectic manifold $(M,\{\cdot,\cdot\})$, there can at most be $d$ independent quantities that Poisson commute.

Indirect proof: Assume that $$\text{There exist }d+1 \text{ independent quantities } (F^1, \ldots , F^{d+1}) \text{ that Poisson commute.} \tag{1}$$ Consider a fixed point $p\in M$. (It does not matter which.) Define a $d+1$-dimensional subspace
$$W~:=~{\rm span}_{\mathbb{R}} \{ \mathrm{d}F^1_p, \ldots, \mathrm{d}F^{d+1}_p \} ~\subseteq~T^{\ast}_pM.  \tag{2}$$
The perpendicular complement $W^{\perp}$ wrt. the symplectic structure is then $d-1$ dimensional.
From assumption (1) it follows that  $$W ~\subseteq~ W^{\perp} \tag{2} $$ is an isotropic subspace. Contradiction. $\Box$
II) Returning to OP's question: If $H$ is not a function of the $F$'s, then there would be $d+1$ independent quantities that Poisson commute. Contradiction.
See also this related Phys.SE post.
Comment: I had a go at showing this, and I think I'm on the right track, but I couldn't finish it off. I've posted my work as an answer - would you mind taking a quick look at it?
Comment: I updated the answer with a proof.
Answer: Theorem: Let $M$ be a $2d$-dimensional phase space, and $F_{1},\ldots F_{d+1}:M \to \mathbb{R}$ be functionals that Poisson commute at some point $P$. Then the set $$\left\{\frac{dF_{1}}{d\mathbf{x}},\ldots \frac{dF_{d+1}}{d\mathbf{x}}\right\}$$ is linearly dependent at $p$, where $$\frac{df}{d\mathbf{x}}:=\left(\frac{\partial f}{\partial q_{1}}\ldots \frac{\partial f}{\partial p_{n}}\right)$$ and $(q_{1},\ldots q_{n},p_{1},\ldots ,p_{n})$ are coordinates on $M$.
Lemma: The set
$$\left\{\frac{dF_{1}}{d\mathbf{x}},\ldots \frac{dF_{d}}{d\mathbf{x}}\right\}$$ if and only if the set $$\left\{\frac{dF_{1}}{d\mathbf{q}},\ldots \frac{dF_{d}}{d\mathbf{q}}\right\}$$
is linearly independent.
Proof of Lemma: One direction is trivial. For the other, suppose $\left\{\frac{dF_{i}}{d\mathbf{x}}\right\}$ is linearly independent, and
$$\sum_{i=1}^{d}\alpha_{i}\frac{dF_{i}}{d\mathbf{q}} = 0$$
Taking the dot product,
$$\sum_{i=1}^{d} \alpha_{i}\frac{dF_{i}}{d\mathbf{q}}\cdot \frac{dF_{j}}{d\mathbf{p}} = 0$$
$\{F_{i},F_{j}\} = 0$, so $$\frac{dF_{i}}{d\mathbf{p}}\cdot \frac{dF_{j}}{d\mathbf{q}} = \frac{dF_{i}}{d\mathbf{q}}\cdot \frac{dF_{j}}{d\mathbf{p}}$$
So $$\left(\sum_{i=1}^{d} \alpha_{i}\frac{dF_{i}}{d\mathbf{p}}\right)\cdot \frac{dF_{j}}{d\mathbf{q}} = 0$$
I'd like to deduce that the vector in brackets is $0$ (since then we can inherit the linear independence of $\frac{dF_{i}}{d\mathbf{x}}$). Of course, we have that it is orthogonal to $d$ vectors in $\mathbb{R}^{d}$, but if we don't know they're linearly independent I don't think we can deduce anything.


How can I take this kitchen faucet apart?

Question: The hot water on my kitchen faucet recently started dripping. I haven't a clue what make or model it is, and I cannot for the life of me figure out how to take it apart to get at the seat and springs. Can anybody help identify it or give my some hints on where I might find a model numbers, so I can find instructions to take it apart? Or, any suggestions on how to get it apart?
Answer: You can try one of those round rubber jar opener and if that doesn't work, go to your Harbor Tool store and purchase a rubber strap wrench.  At Harbor, it is sold as a set of three and relatively inexpensive.  Use the one that fits.  Also, try spraying some WD-40 penetrating oil at the base so it loosens the thread (don't get any on the upper part; only the base). The rubber strap wrench won't damage the finish.  This worked for me.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know the details of contributing here.
Answer: Pfister Hanover 2-Handle, Pull-Down Kitchen Faucet
Instruction sheet
I'd include some actual instructions here, but it's spelled out in the linked sheet. Have a look at that.
Comment: Have you tried to get a hand grip on the hub with a friction rubber gripper, such as one which is used to open jars? Failing that, there are 'strap' wrenches with a Kevlar reinforced rubber strap which should do the job without scratching the finish.
Comment: The instructions suggest that I just need to rotate the hub in a counterclockwise direction. It's way too tight for me to do this by hand, at least not without a wrench or something. But I am afraid a wrench will damage the finish. Any hints?


Using can in the future

Question: Can I use the helping verb can in the future?
"I can travel to London tomorrow."
Or I have to use able to?
"I am able to travel to London tomorrow."
Comment: You can use 'can' for future events. I can visit you tomorrow. You can drive my car next Sunday.
Answer: 'Can' is perfectly fine in this context, though it is often used in a 'reserved' manner, by which I mean that someone might well say "I can travel to London tomorrow, (but really don't want to.)"
'Can' is not a direct replacement for 'Able to' in all circumstances - it works fine in your example, but to borrow Michael H's example, "You can drive my car" does not mean the same thing as "You are able to drive my car"
Comment: I'm not sure about that *a 'reserved' manner.* It seems to me the "reserved, cautious, tentative, provisional" sense is more naturally conveyed with the explicitly "non-Present" form *I **could** travel to London tomorrow (but I'd rather not)*.
Comment: @FumbleFingers  Yeah, 'Reserved' in its normal sense isn't the word I was scrabbling for, but still can't think of the right one!
Comment: In formal English, that second sense of "can", conveying permission rather than ability, is instead handled by "may".
Comment: @MontyHarder: I'd say that usage is more "dated" than "formal". *I asked the boss if I **might** leave work early* isn't something you're likely to hear today (it's always ***...if I could***).
Answer: English doesn't really have a Future Tense anyway, but I would say that in I can go tomorrow, can is effectively Present Tense. You can see this at the syntactic level by noting that the "future" version of I can go is I will be able to go.
But it's also true at the semantic level, in that I can go tomorrow effectively means My current status is that I will be able to go tomorrow. That "present tense reference to future ability" may be more obvious if we also consider negating contexts...

[My mother's dementia is getting worse...]
   1: ... I hope she will be able to recognise me next Christmas
   2: ... I'm afraid she won't be able to recognise me next Christmas (won't = will not)
   3: ... I hope she can recognise me next Christmas  (QUESTIONABLE - see below)
   4: ** I'm afraid she can't recognise me next Christmas  (INVALID)

Most native speakers would accept the "Present as Future" usage in #3 - particularly if extended to ...can still recognise me (which more overtly references the passage of time between now and next Christmas).
But note that most native speakers would not accept #3 if we change I hope... to The doctor says... That's because my specific example refers to [future] ability. In a structurally / syntactically identical example where the meaning is more about [present / future] permission, there's no real difference between...

5: The doctor says I can go home tomorrow
   6: The doctor says I will be able to go home tomorrow

Because it's both a "defective" verb (with an incomplete conjugation) and a "modal" (auxiliary verb expressing necessity or possibility), can is a difficult word to master in English. There's too much to cover in a single Answer here on ELL, but I'll just point out that in most contexts, the meanings of...

7: The doctor said I can go home tomorrow
   8: The doctor said I could go home tomorrow

...are identical. But sometimes, #8 means ...might be able, not ...will be able or ...will be permitted.
Comment: Thanks all for good information. I understand now it is right to say:
Comment: Thanks so no difference between. I will be able to travel tomorrow And I can travel tomorrow.
Comment: @Sdg: Normally there's also no difference with *I **am** able to travel tomorrow*. Mostly these are just stylistic choices, with no particular syntactic or semantic implications.

Using can in the future


Disadvantages of using Basic4Android?

Question: I am currently researching the pros and cons about Basic4Android. I have a good list of pros (http://www.basic4ppc.com/android/why.html) but what are some disadvantages to using this? What limitations does this tool have?
Thank-you for the help!
Answer: The only real down side I see is (potentially) wasting $49.00 ;)
Frankly, I'd encourage anyone to download the Google SDK and become familiar with Android Studio and the Java API.
But this looks like it might be very easy to get started with, shouldn't incur any runtime performance penalty, and allows you to create unencumbered (fully redistributable) APK's.
So if you prefer Basic over Java, and have a spare $49 - sure, go for it!
IMHO...
Answer: There are many many pros to using Basic4android. Its a neat package and well supported by the author Erel.
Pros
+ Feature-rich in terms of settings
+ Intellisense editor
+ Many libraries
+ GUI designer
+ Plain and easy to pick up language
+ Debugger
Cons
- lack of support for Object orientation
- No unique global variables within Subs
Comment: Note that since v2.00 Basic4android does support classes and polymorphism.
Answer: After trying virtual every platform from Basic4Android, thru Eclips, RadStudio Xe2, and Windev Mobile which I had high hopes for,  I can say I strongly prefer B4A.  The easiest I found by far, and the most useful examples by far.  As far as limitations, I have found only a few and those are easily gotten around since you can take any Java code and wrap it in a library that B4A can use quite easily.  With that capability, I can go to Eclips if needed and generate code and use it in B4A.  I am not a fan of Basic.  But I also do not know Java.  For me that was not the issue.  It was the ease of using the interface without getting lost and most important, a solid example of damn near everything the phone can do.
Answer: The only disadvantage I see is that not everything from the whole Android Java API is supported. There are some things (like the MapView for example) that are (currently) not usable in B4A. The most important things are available but there are still parts which need some improvement (like the homescreen widgets).
If you want to get good results very quickly and don't need to use every exotic Android feature, give it a try.
If you want access to every feature that is available in Android there is only the way to choose the Eclipse IDE and directly use Java. But you have to invest much more time for developing than you have to do with B4A.
Comment: GoogleMaps (API v2) is now supported.
Answer: As an accomplished VB.NET programmer for me there were so many traps to just getting started with Eclipse, instructions weren't clear, things just didn't work for the beginner. Two weeks of installing this and that, and still could get Hello World to run.
I have a huge codebase of functions of have written with VB.NET in the last 10 years, and getting those functions ported across, while not trivial, happens quickly. With Basic4Android I ran the 3 installs in their list, and started coding. In minutes I had accomplished more than with weeks with Eclipse.
If you are exerienced in VB, unless you have a buddy that can get you going, you are way ahead with Basic4Android.
Answer: Personally as a beginner to B4A and programming in general, my main hurdle is there seems to be a steep learning curve in the very beginning (which I'm still trying to ascend).  I'm sure this holds true for any language/IDE. I just wish there were more tutorials geared towards users like me.  The beginner's guide is great but even in there there are things I don't quite understand.  I came from AppInventor in which I made 3 apps within a month.  I wish Erel or some of the other users would make Youtube video tutorials!
Comment: I also hope for more tutorial videos coming soon. That's how I landed on this posting. It was when I googled for Basic4Android tutorials. :-)
Answer: My opinion is if you are familiar with VB, better to go for b4a. It is not wasting of money. May be some limitation compared to Google SDK b4a is improving in every version. Insteading of learning java and do the exercises being a VB programmer I prefer  b4a. As Markus stipp states that If Erel try to incorporate mapview that would be great for supporting many applications.
 I hope Erel will do it shortly :)
Comment: GoogleMaps (API v2) is supported.
Answer: b4a uses a very "keep it simple" and easy to use interface
So does not have the incredibly complex .net wysiwyg interface.
There is a learning curve to the designer itself, but its easy to learn.
The other learning curve is learning the "keep it simple" consepts with android designs.
b4a has an abstract designer for control layouts that can also be viewed on a physical device or an emulator.
b4a now includes a wysiwyg visual designer that can be viewed on a physical device or an emulator.
Currently developers use a virtual box emulator that is very fast in comparison to the SDK and ADV Manager.
Using the virtual box emulator we can create emulators for all sized devices.   Quickly and easily.
There are all kinds of step-be-step beginners guides and beginners tutorials and control tutorials with simple and advanced sample projects.
And a very active beginner, medium and advanced support developers forum.
Where just about everything you could think of has already been asked, discussed and answered.
Where beginners can feel safe in a supporting environment without the rude burntout bullies you get in other forums.
Where other rediculously overpriced products are still stuggling to come to grips with even the basic Android features, b4a already has the solutions.  That are simple and easy to understand.
Have a look around for basic4android coupons to find a rediculously low price on a professional licence.  WITHOUT the yearly overpriced upgrade fees.
All I can suggest is not to bring .net C++ OO mehodologies baggage mindset into the future.
And be prepared to enjoy producing real apps in a very short time.
(yeah ok, I didn't want to mention is but b4a now has classes. jeez!)
Answer: I have used the software and created about three apps for industrial control system monitoring. B4A had it all as far as functionality is concerned. Where it finds its limitations are the graphical editing abilities avalible to the average user. It can be very difficult to have complete control over the graphical properties of a button for example. Once you have created you interface you still dont get to see the final product until you have loaded it into the emulator (or the device), and I think most of us know how slow it can be emulating HC 3.0. I understand that realtime rendering of the form/activity can be very difficult from the software programers point of view, but it will help B4A keep its edge as other programs similiar to B4A begin to pop up.
Despite my critisims above it is well worth the 50$
Comment: Yes, it's a good investment for people like myself who use VB.Net and yes it would be nice to have real time rendering in the graphical editor. I hope they introduce that soon.
Comment: Quick update (2 years later). I wanted to credit b4a on there incredible support. The are continuously updating and increasing the software functionality. However they still need to make some changes to there GUI designer.
Comment: They are still improving the GUI. Maybe soon it will be more like the designer in VB.Net but it's getting closer.
Answer: I am a JAVA coder with OCJP.
I have done a university paper with native JAVA Android and have a game app on the playstore from that experience.
Right now I have to code an app for a client.
I am using B4A not native JAVA and eclipse because it is faster & easier
As many have said above the only disadvantage is that it may not have some features.

Disadvantages of using Basic4Android?


In Prometheus, is it possible that the trilobite which attacked the Engineer was protecting Shaw?

Question: Is there any indication that (perhaps in some script version), as in Alien 4, that the trilobite, being the offspring of Shaw, recognizes her and that motivates it to attack the Engineer which, in this case, saves her life? I realize that it seems pretty mindless, basically a machine for creating the deacon but it would be interesting if indeed the trilobite had some protective motivation.
Comment: I'm guessing the the trilobite would not be much more protective of Shaw than chestbursters are, of their hosts. Although unrefined, it's still a bio-weapon.
Comment: @Raj: I agree, but at the same time, some kind of sentience that would make it choose to protect its "mother" would be consistent with not only Alien 4 but also Alien 3 where an alien chooses not to attack Ripley when it senses that she bears a chest burster.
Comment: I may need to rewatch Alien 4. Although your example from Alien 3 might be a good precedent, I would personally argue that it's a different case as Ripley is still needed by the chest burster that she is carrying. Once Shaw has "delivered" the trilobite, she's probably outlived her usefulness.
Comment: In Alien 4, a "baby" (born almost like a mammal from a giant queen) alien seems to show actual affection for Ripley.
Answer: If you pay close attention to the scene where the Trilobite is released and attacks the engineer, you will also notice during the scuffle at one point that it wraps a tentacle around Shaw only to almost immediately release her and pursue the engineer. This a possible indication that it recognizes shaw.
Comment: Interesting and consistent with Alien 3 and 4 where indeed xenos treat Ripley differently than other humans. I will have to rewatch the scene in Prometheus.
Comment: It occurs to me that this grabbing of Shaw and sudden release could simply be that in the chaos of the struggle in close quarters, the trilobite not necessarily recognizing Shaw as "mother" but instead that she is not the one it is targeted on impregnating and it needed to focus on the Engineer.


Confusion in derivation of Formula of divergence

Question:
This is from the book Mathematical Methods (Arfken),
Can someone explain how did one del(x) and one dx came here,?
Comment: what is del(x)? Anyway, its just standard formula $f(x+\Delta,y,z)-f(x,y,z)\approx \frac{\partial f}{\partial x}\Delta $, or are you confused about something else?
Comment: You mean on the RHS of the highlighted equation?
Answer: What the LHS of the highlighted equation represents is the change in $\rho v_x \,dy \,dz$ between two $x$ values. Let the rate of change of this wrt $x$ be $$\frac{\partial (\rho v_x \,dy\, dz)}{\partial x}=\frac{\partial (\rho v_x )}{\partial x} dy\,dz$$
Now $\Delta (\rho v_x)=\frac{\partial \rho v_x}{\partial x} \Delta x$. $\Delta x= x+dx/2-(x-dx/2)=dx$, So the RHS becomes,
$$\Delta (\rho v_x)=\frac{\partial (\rho v_x )}{\partial x}\,dy \,dz \,dx$$
This is a general technique while building differential equations. We calculate the variation of some quantity as a finite difference over a differential element. Then linking that change to the derivative or higher order terms gives a locally valid, differential equation for that quantity.


Struts 2 validate field if not empty

Question: There are two fields email and phone number (integer) in a form. The form is validated using the struts validation framework (ActionClass-validation.xml). These two fields are optional, so the user can leave them blank. But if they are not blank the fields need to be validated. Please help me find out how to write validators in xml to do this.
Comment: xml is good if you intent to reuse them (to the point it will save time), I've seen a lot of people rack their brains over the right regular expressions/xml syntax when simply adding a validate method and a few line of java would have only taken a few minutes!
Comment: For the email it's clearer to use @EmailValidator on the setter. See (section validation annotations): http://struts.apache.org/2.x/docs/annotations.html
Comment: @Quaternion I also prefer validate method. I feel more powerful using java code for validation
Answer: You can also use annotations. In my opinion it's more clear to understand and easy to write and debug. This is an example:
@EmailValidator(type = ValidatorType.SIMPLE, message = "", key = "validation.email")
public String getEmail() {
  return email;
}

For the number, you can use a regex validator:
@RegexFieldValidator(key = "validation.number", message = "", type = ValidatorType.SIMPLE, expression = NUMBER_PATTERN_STRING)
public String getNumber() {
  return number;
}

In your jsp you can reference the errors using field (or action) error tags:
<s:fielderror fieldName="email" cssClass="myerrorclass"/>
<s:textfield  name="email" cssClass="myclass" cssErrorClass="myothererrorclass"/>

I hope the code is quite self-explanatory.
Happy coding! ;)
Comment: If email and phone are empty strings will have fielderrors from validation. The title is "Struts 2 validate field if not empty"
Answer: Try this
<field name="email">
    <field-validator type="email">
        <message>Invalid Email (empty email accepted)</message>
    </field-validator>
</field>

<field name="contact">
     <field-validator type="regex">
       <param name="expression"><![CDATA[([1234567890]+)]]></param>
       <message>Invalid Contact Number (empty number accepted)</message>
    </field-validator>
</field>

Here is a complete example.

Struts 2 validate field if not empty


Displaying a Pop Up Message before standard Case Save Button

Question: I have seen similar questions but no answers to this particular situation.
I want to show a Pop Up message when someone clicks on standard 'Save' button.
This should be applicable to both situations
1) When user does Inline Edit and click Save.
2) When User clicks on Edit button and make changes and then click Save.
Please note i cannot use a Custom VF page. I want to achieve the above requirements with using Salesforce standard Layouts (both Detail and Edit )
Thanks in advance..
Chellappa
Answer: This cannot be done using the standard buttons and page layouts. You need to write a VF page to do this.
Someone on the developer forums had this same question bit more specifically asked about using a custom button a while ago. There answered question can be found here which seems to suggest it is possible however this solution is prone to issues if Salesforce update their Javascript files or something during a release and alter the way the save system works for standard buttons (although this is highly unlikely).
My personal view would be that you should not need to display a pop-up on save (assumedly it is for confirmation?) as this is not a useful function to have in the system and you could simply turn on field history tracking to audit what changes have been made by people.
Comment: Ok i was expecting this. Can you tell if it is possible to hide the standard 'Save' button and provide Custom button. If Yes, can u also confirm if it works for Inline Edit save also.
Comment: I have added a link to a custom button based solution but as per the answer I would not recommend a pop-up on save and would suggest using field history tracking or something similar.
Comment: You should head pbattisson's advice. Do not use the javascript hack. I have had to rip out those hacks several times at clients during re-implementation projects due to poor work.
Comment: It looks like i have no choice,but to think of other options. While i was waiting for some responses, i had a discussion with Business. They were fine with having a separate button , along with Save. So all the extra logic which i wanted on Save , we can do it with new custom button. My requirement was to trigger some validations before making a webservice call to Oracle. With the new custom button, i can perform those validations. Thanks for the responses again.


Are there alternate OSes for the click-wheel iPods?

Question: The firmware on the click-wheel iPod is very simple and doesn't have a lot of "extra" features. It also doesn't allow you to drop music on it; it has to go through iTunes. Are there alternate OSes for the click-wheel iPods?
Comment: If you downvote, ***please*** comment and tell why you downvoted!! A downvote is useless if you don't give a reason for your downvote.
Answer: An alternate OS is Rockbox. It is a free firmware replacement that works on many music players. Rockbox supports:

iPod 1g through 5.5g, iPod Mini, iPod Nano 1g and iPod Nano 2g

One downside to Rockbox is that you have to make your iPod a Windows formatted partition on a Windows computer.
There are many different themes for Rockbox. Here's an example of just one:
Answer: There's another alternative operating system for click wheel iPods called iPodLinux. Here's the iPodLinux status: http://www.ipodlinux.org/Project_Status/


Metadata in photos - not showing when sent from other people

Question: I'm not having ANY photos showing metadata with geolocation unless it's photos taken from my own phone. I have tested if sent on messenger (where I know FB removes it) But also is sent on iMessage as normal SMS from friends phone to me, it doesn't show geolocation on the photo. Even if geo on photos are turned on - on their phone. How can this be?
Answer: Apple's Messages doesn't strip EXIF data from photos transmitted 'in blue'. I can't test for if it does if they arrive as SMS 'in green', though that might be done by whatever network sends the SMS.
You might need to test if that data is still present, or has been stripped on the way, or even before sending. Photoshop's new 'Export' will strip most exif data, whereas the older 'Save for Web' doesn't.
If you drag one of the photos to the desktop & then Get Info [right click or  Cmd ⌘   I  ] you will be able to see at least some of the EXIF data, if present.
If you need to see more of the data, or if the data from Get Info isn't very comprehensive, you can dig deeper using ExifTool by Phil Harvey which isn't actually quite as scary as it looks.
Once installed it runs from Terminal. You simply type exiftool then a space, then drag the photo into the Terminal window to provide the path. Hit Enter & it will list all EXIF data for that photo.
Comment: Thank you so much on the reply! If Apple don't strip the metadata (that I also thought they didn't) I don't get at all why it's gone when I get the photo on iMessage. To me it makes no sense which is why I'm so confused. (Thanks for tip on the Exif link, but if doesn't work with the 5 tools I have used to see geo, then more details won't give geo. Good to know about though!)