stdout thread-safe in C on Linux?

Question: Is writing to stdout using printf thread-safe on Linux? What about using the lower-level write command?
Answer: It's not specified by the C standard -- it depends on your implementation of the C standard library.  In fact, the C standard doesn't even mention threads at all, since certain systems (e.g. embedded systems) don't have multithreading.
In the GNU implementation (glibc), most of the higher-level functions in stdio that deal with FILE* objects are thread-safe.  The ones that aren't usually have unlocked in their names (e.g. getc_unlocked(3)).  However, the thread safety is at a per-function call level: if you make multiple calls to printf(3), for example, each of those calls is guaranteed to output atomically, but other threads might print things out between your calls to printf().  If you want to ensure that a sequence of I/O calls gets output atomically, you can surround them with a pair of flockfile(3)/funlockfile(3) calls to lock the FILE handle.  Note that these functions are reentrant, so you can safely call printf() in between them, and that won't result in deadlock even thought printf() itself makes a call to flockfile().
The low-level I/O calls such as write(2) should be thread-safe, but I'm not 100% sure of that - write() makes a system call into the kernel to perform I/O.  How exactly this happens depends on what kernel you're using.  It might be the sysenter instruction, or the int (interrupt) instruction on older systems.  Once inside the kernel, it's up to the kernel to make sure that the I/O is thread-safe.  In a test I just did with the Darwin Kernel Version 8.11.1, write(2) appears to be thread-safe.
Comment: This answer is ignoring that the question was tagged unix/linux. POSIX requires stdio to be thread-safe, which is quite unfortunate since it kills performance and since there's no practical way to operate on the same FILE from multiple threads (data will come out hopelessly interleaved; atomicity is only at the character level).
Comment: Sometimes it's quite Ok if output is interleaved , e.g. during logging via printf from multiple threads.
Comment: @couling I think he means that the thread-safety is useless because everything gets interleaved anyway -- unless you use an explicit f[un]lockfile anyway.
Comment: i am using amd64 linux with up to date kernel .. when i am using setvbuf to _IONBF for stdout and then calling clone() with CLONE_VM ... causes printf to make a segmantation fault from the children ... even when allocate each there own buffer manually ...  it still happens ... still trying to track down the memory overlapping that is happening ... happens with or without CLONE_IO and or CLONE_IO flags ...
Answer: Whether you'd call it "thread-safe" depends on your definition of thread-safe. POSIX requires stdio functions to use locking, so your program will not crash, corrupt the FILE object states, etc. if you use printf simultaneously from multiple threads. However, all stdio operations are formally specified in terms of repeated calls to fgetc and fputc, so there is no larger-scale atomicity guaranteed. That is to say, if threads 1 and 2 try to print "Hello\n" and "Goodbye\n" at the same time, there's no guarantee that the output will be either "Hello\nGoodbye\n" or "Goodbye\nHello\n". It could just as well be "HGelolodboy\ne\n". In practice, most implementations will acquire a single lock for the entire higher-level write call simply because it's more efficient, but your program should not assume so. There may be corner cases where this is not done; for instance an implementation could probably entirely omit locking on unbuffered streams.
Edit: The above text about atomicity is incorrect. POSIX guarantees all stdio operations are atomic, but the guarantee is hidden in the documentation for flockfile: http://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html

All functions that reference ( FILE *) objects shall behave as if they use flockfile() and funlockfile() internally to obtain ownership of these ( FILE *) objects.

You can use the flockfile, ftrylockfile, and funlockfile functions yourself to achieve larger-than-single-function-call atomic writes.
Answer: They are both thread-safe to the point that your application won't crash if multiple threads call them on the same file descriptor. However, without some application-level locking, whatever is written could be interleaved.
Answer: C got a new standard since this question was asked (and last answered).
C11 now comes with multithreading support and addresses multithreaded behavior of streams:

§7.21.2 Streams
¶7 Each stream has an associated lock that is used to prevent data races when multiple threads of execution access a stream, and to restrict the interleaving of stream operations performed by multiple threads. Only one thread may hold this lock at a time. The lock is reentrant: a single thread may hold the lock multiple times at a given time.
¶8 All functions that read, write, position, or query the position of a stream lock the stream before accessing it. They release the lock associated with the stream when the access is complete.

So, an implementation with C11 threads must guarantee that using printf is thread-safe.
Whether atomicity (as in no interleaving1) is guaranteed, wasn't that clear to me at a first glance, because the standard spoke of restricting interleaving, as opposed to preventing, which it mandated for data races.
I lean towards it being guaranteed. The standard speaks of restricting interleaving, as some interleaving that doesn't change the outcome is still allowed to happen; e.g. fwrite some bytes, fseek back some more and fwrite till the original offset, so that both fwrites are back-to-back. The implementation is free to reorder these 2 fwrites and merge them into a single write.

1: See the strike-through text in R..'s answer for an example.
Answer: It's thread-safe; printf should be reentrant, and you won't cause any strangeness or corruption in your program.
You can't guarantee that your output from one thread won't start half way through the output from another thread.  If you care about that you need to develop your own locked output code to prevent multiple access.
Comment: I don't know what others do, but the GNU C library is thread-safe by default, so no it won't use the same buffer.
Comment: I don't think `printf` is reentrant, see http://stackoverflow.com/questions/3941271/why-are-malloc-and-printf-said-as-non-reentrant
Comment: All calls to printf are likely to use the same buffer to build the string.
Many implementations also share a buffer between scanf and printf - which can cause some weird debugging dependant bugs.

stdout thread-safe in C on Linux?


Vote to close - off-topic descriptions are wrong

Question: Clicking to close a question as 'off topic' gives a list of off-topic reasons but the 'belongs on...' descriptions all say "Q&A for professional and independent game developers" ...
Comment: I cannot reproduce this
Comment: Yes, it's certainly not happening on my work PC (windows 7, Firefox 3.6.13). I will try it again on my laptop (Fedora 14, Firefox 3.6.13) which is in another office. I won't be able to do this until about 1900 UTC so perhaps leave this open until I report back?
Comment: OK - can't now reproduce on Fedora/Firefox so time to close
Answer: I can't see invalid close reasons on Super User - this might have been an artifact of earlier builds for some search improvements.
Comment: Accepted because before this happened the site was down for maintenance so whatever was being done might have had after effects due to caching or..I dunno, but I can't reproduce the problem now.


UISearchBar in UINavigationController with cancel button not selectable

Question: I have added a UISearchBar to the UINavigationController just fine, but as soon as I add the cancel button to the search bar I can no longer select it by touching it.
The code I'm using to create the search bar and add it is:
<code>UISearchBar *theSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0f,0.0f,320.0f,0.0f)];
theSearchBar.delegate = self;
[theSearchBar setPlaceholder:@"Search iPad"];
[theSearchBar setShowsCancelButton:YES animated:YES];
self.navigationItem.titleView = theSearchBar;
self.navigationItem.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[theSearchBar release];
</code>
If I remove the line to add the cancel button I'm able to focus on the search bar and the search works correctly. As soon as I put that line in, it displays properly, but I can no longer focus on it.
I've tried putting it into a simple UIView container, but that didn't solve the problem either.
What about adding the cancel button could be causing this to fail?
UPDATE:
I ended up not using the cancel button because I determined it wasn't necessary the way the search bar was being used.
Answer: I would definitely recommend a UISearchDisplayController: apple docs.
  It has a cancel button built right in, and by placing it in interface builder you can save a lot of code.  Less code = less bugs.


Starter motor or Alternator?

Question: Can anyone offer any advice?  Got in my car on Monday and it was dead.  I turned the key and there was no noise at all, but all the lights etc came on. No clicking or anything.  I got a jump start and took it for a short spin.  Later it started fine,so I drove to the shop but when I went to start it again.. nothing. Totally dead again (apart from lights etc)  Called breakdown who bump started me and said it was a faulty starter motor, so drove it directly to garage.  They said they would check everyting before changing the motor in case it was something else.  They determined it was the problem and charged me to fit a reconditioned starter motor (£190) Two days later, same issue.  Called out rescue who said it may be an earthing problem as the battery was dead. Took back to garage who say I now need a new Alternator.  The car is only 4 years old and has 35,000 miles on the clock.  Can this be right, or being female, is there a chance I am being taken advantage of by the garage? Wanting another £229 to replace alternator...
Comment: Welcome to Motor Vehicle Maintenance & Repair!
Answer: I'm thinking there's a connection issue. If the starter was dead, a jump wouldn't have fixed the issue. If the alternator was dead, which didn't charge the battery (so battery was dead because of this), the car would only have run for a short period of time until the jump which provided a partial charge to the battery, would have run out. Since the lights come on, it's not the battery. Since the battery appears charged, it's not the alternator. I cannot tell you exactly what is the issue, but would suggest it's a connection issue (wiring going from ignition to starter) or might be the starter relay. The alternator is way too easy to check using a multimeter while it's running (should be 13.5-14.1vdc at the battery) or if there's no check engine light while the vehicle is running, it's putting out voltage as well.
Take it to another shop, or tell them to find the real issue. It's not the alternator.

Starter motor or Alternator?


Iphone save picture with a different name

Question: I have one application than record pictures and videos using ALAssetsLibrary . Can i customize the file name of saved image or video ?
Thanks for help !
Answer: Nope you can't change the filename. But you can maybe save the desired name in the metadata of the asset and use that.
Cheers,
Hendrik


Quickest way to change a certain number of characters in INSERT mode?

Question: What's the quickest way to change a specific number of characters? I want to edit the next N number of characters without using replace mode.
Comment: Can you clarify your question further more, please? By specifying some sample input and expected outcome?
Comment: @kenorb It was just a Q&A thing that I wanted to post, I just thought to myself that really there are several ways to accomplish something very simple and wanted to share them here (since Vi is now off-topic on SuperUser and SO). I'll edit the question a bit better to reflect that. And I wanted to narrow it down a bit further to avoid the replace-mode way.
Comment: It's ok to post, but the thing is that you don't give enough details/explanation within the question, so people won't understand what's the answer about if they don't understand what was the problem in the first place, in other words you're not allowing other users to post alternative solutions, because the problem isn't clarified enough. E.g. 'a specific number of characters' and 'through the INSERT mode' is ambiguous. Just giving some sample text example (in and out) would be great.
Comment: @kenorb I understand, not sure how to edit it better, I just wanted to post a Q&A about ways to change characters that don't include replace mode (as I believe that's already covered).
Answer: Several straightforward ways, where the number of characters is, say, 5:

5s
c5Space
5xi

Space can be substituted with l or →.
All of those will remove the desired number of characters first (in this case 5) and then put you in INSERT mode.
To avoid entering INSERT mode, refer to this question.
Comment: The question asks: 'through the INSERT mode', but when you type `5s` then you type it literally. If you don't mean in INSERT mode, then you've to press Escape first to exit this mode, unless you was thinking about COMMAND mode. That's why isn't clear for me.


Non-Theoretical Applications of Partitions of Unity

Question: I am studying partitions of unity in Munkres' $\textit{Analysis on Manifolds}$ book. Are partitions of unity just theoretical tools, i.e. used to prove theorems, or do people actually apply them concretely to compute integrals in practice?
Comment: In my experience, you rarely have an explicit partition of unity. So, in my experience, that is mostly theoretical tool.
Answer: Partitions of unity arise naturally in many applications related to affine spaces and affine transformations. In fact, barycentric coordinates are partitions of unity. So, there are lots of applications in geometry.
In other fields, also, there is often the idea of a "weighted average" where the weights necessarily sum to 1. This is common in finance/economics, for example.
The spline techniques mention by @William Krinsman are another example. Many curves in CAGD are so-called "blended curves" of the form
$$
\mathbf{P}(t) = \sum_{i=0}^n \phi_i(t) \mathbf{P}_i
$$
The blending functions must sum to 1, or else this definition is not well defined (it doesn't make sense to form an arbitrary sum of points).
The Bernstein polynomials are one very common example of such blending functions -- they are used to construct Bézier curves and surfaces. But they have many other uses in approximation theory and probability, too.
Lagrange polynomials also form a partition of unity, and these have many uses.
So the short answer is that partitions of unity occur in many places in applied mathematics, computing, and engineering -- they are not just a theoretical concept.
Answer: I'm not an expert on numerical analysis, but based on the textbooks I have read on the subject, partitions of unity are used when defining basises of splines (see below). I think B-splines or Bezier splines; they are used in computer graphics.
http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/bspline-property.html
http://arxiv.org/pdf/1410.5413.pdf
https://www.cs.unc.edu/~dm/UNC/COMP258/Papers/bsplbasic.pdf


What would be the correct word for considering or believing something said by people without knowing the truth behind it?

Question: For example, some people have heard that we should not eat late, and they believe it, without knowing the reason behind it.
Comment: https://www.vocabulary.com/dictionary/credulous    Credulous, gullible, naive, and unquestioning are all words that can describe those who believe what they hear without question or checking the facts. To respond more directly to the question, a term that might describe the behavior they're exhibiting is "blind faith".
Comment: Or for a phrase: "taking on-faith" the truth of something.
Comment: *Unquestioning* (as per @IsabelArcher) + *accepting* suggests *unquestioning acceptance* as an apt description of the behavior in question.
Answer: You may be able to use the expression "to take it on faith that...". This expression introduces an idea which is accepted without further verification. Merriam-Webster defines it as:
to accept (something) as true without proof or evidence that it is true ~ Merriam-Webster
Consider: "He just took it on faith that I was being a responsible and didn't ask any more quesitons."
Answer: One term describing an unverified claim in your context may be:
Old wive's tale

an often traditional belief that is not based on fact ~ Merriam-Webster
a traditional belief, story, or idea that is often of a superstitious nature. ~ Dictionary.com

You may also want to consider superstition and urban legend, but these terms invoke particular connotations and may be out-of-context in your case. Superstition tends to be associated with ominous or supernatural forces. Urban legend tends to be associated with horror or humor.


Is it possible to migrate a Windows installation to another machine or Parallels?

Question: I've got a Windows 7 machine that's about to die and I want to transfer my data to another machine, or possibly to a disk image that I would then run inside of Parallels on my Mac.  I could of course install Windows 7 from scratch, but then I'd have to reinstall dozens of programs and transfer many gigabytes of data, all of which takes a huge amount of time.  So I'm wondering if it's possible to make an image of my Windows installation and just ghost it onto another machine, or into a new virtual machine in Parallels.  Can this be done?
Comment: You may need to reactivate it because it will see Parallels as different hardware, and Windows keys are tied to the motherboard. If you have Windows 7 retail, that will be no problem, but you cannot re-license OEM versions without paying full price for another key. http://tinyurl.com/ca97z47
Comment: Be aware that some software is device-specific and will not work if it is simply copied from one machine to another. Watch out for applications that require specific drivers or come packaged with hardware.
Comment: Both of these comments convinced me that my idea isn't worth doing, since it would still cost a chunk of cash to get new software, and it sounds like a huge hassle too.  If someone reposts as an answer, I would accept it as answering my question.
Answer:
You can use Acronis True Image 2013 (30 days free trial) to create a full backup of your PC.
With the same software you restore that backup on other machines.
Of course you have to re-install drivers when your hardware has changed.
This article states that Parallels can import Acronis Backups.
(Since I don't own a Mac I can't tell you how well both software act together)
Answer: The answers and comments made me decide that this approach is far too messy and I just opted to reinstall everything from scratch.  Thanks to all contributors for their input.


Is less than comparison more natural than greater than comparison?

Question: I was teach on mathematics that on real line small numbers are on left and big numbers are on right. Therefore, I think the comparison 0<1 is more natural than 1>0, and in general, x less than y is easier to read than y greater than x. Is there any statistics if there are less bugs on programs that uses only less than comparisons than programs uses greater than comparisons or both?
Comment: This isn't exactly a question about how to teach or about best educational practice.  With a bit of modification, though, it could easily fit in this forum. (Plus I have an answer I would love to give if it could be made to fit)
Comment: @BenI A little modification. **If** we can show that it has high probability of being true, then it should inform teaching.
Answer: I think the typical order has more to do with grammatical conventions actually.

Joe is heavier than Bob

Joe is the subject, the one we're talking about; Bob is just an object we compare against.

Joe weighs more than 90kg

vs.

90kg is less than Joe weighs

The second one is a very odd sentence.

[subject] [verb] [object]

[variable] [operator] [constant]

This would be a pretty normal construction, such as:
x < 0

or
x > 0

but odd would be:
0 < x

Because the value of 0 isn't changing. Zero is not the "subject" of what we're doing. x is the subject, the variable, the interesting thing.
So what if we're comparing two variables?
x < y

It's possible both of these are new values to us, but intuitively, this code feels like it's more about x than about y. Consider:
if x < y: do something
if x > z: do something

Now, clearly, x is our main subject, running against various other variables to see if something needs to be done.

So, my impression is that any preference for < over > or otherwise pales in comparison for the preference to put the "subject" of the comparison on the left.
Comment: While your statement is true for many written and spoken languages, I think that programming has different needs. Also, some languages reverse word order, so 90kg < Joe would be normal. When I am scanning code, I like to locate the constants. I can guess that the other part is a variable. Constants dictate what will happen, variables are just along for the ride.
Answer: First, I doubt that there are any such statistics because the effect would seem to be so small as to be overwhelmed by other, more common, things. You could, perhaps, create an instrument (as in a compiler) to look for such things and look for effects in, say, unit tests of the code. But that implies that a lot of things come together.
But, I would also suggest that your basic understanding of human psychology may be naive. It could well be that there are people who actually think more effectively in "greater than" mode. As a mathematician, I've often been confused by left-right and by east-west, especially when they all show up in the same context. But it is, I'm pretty sure, because, I look at things with a "frameless" view. What is left and what is right depends on where I think of myself as viewing from.
Also, some times it is just more "natural" to express things with greater than, as in "error > 0.05".
So, I think a teaching "rubric" that punished students for using one form over the other would be misplaced. It would, in some situations, lead the user to perform an extra step in their thinking, and that, alone, could lead to an error.
Comment: There has been research on whether using > vs >= leads to more or fewer errors. (I think the upshot is that people make fewer errors when they use one method consistently instead of trying to be clever.) We often must use "open intervals" where the starting point is an absolute number, like >= 0, and the upper bound is a < comparison, like: 4.9999 is OK but 5.0000 is right out. I used to teach that routinely, from the section of the textbook on Range Comparisons. Not sure anyone really got it, but to me it made sense. Of course, you could say: IF 5.0 NOT <= x THEN... DeMorgan and all that.
Answer: Similar to Buffy, I suspect that which use is more natural depends on the framing of the problem.
while (countdown > 0)

makes perfect sense.  By contrast,
while (0 < countdown)

feels less intuitive, if only because there is a bias towards leaving the variable on the left side of an expression.
I think that the key (and this is what I would communicate to my students) is to make whatever choices you make carefully reflect the mental model of the problem.  This should create the clearest code, and produce the fewest errors.
Comment: I guess I tend to use "Yoda Comparisons" because I was trying to avoid the C error of using = when I meant ==. If I try to assign x to zero, the compiler will not let me. Also, constants tend to be shorter than variables, especially in an OO context. So several comparison lines in succession would all be something like "0 < abcdef.ghe.jkmnop.qrstu(wxyz)"  and it would be easy to read the thing compared against instead of having to hunt for it at the far right of the lines. So, to me "while (0 < whatever)" is good. I know the big long string is the variable part, I want to know the constant.


Generating Sass and Haml in Rails

Question: Does the current head of Rails not come with haml generators? (I know in Rails 2 you had to add a generator plugin.) Setting config.generators.template_engine = :haml doesn't work. Also, how do I switch from generating .scss to generating .sass? Setting config.generators.template_engine = :sass didn't work. I get error haml/sass [not found]. I have both installed and in my Gemfile.
Answer: In 3.0, there is no haml nor sass/scss support, you need to place them in your gemfile, and call bundler. But you will get no generators even with these gems, you should use something with theese if you realy want that.
And with rails 3.1, sass/scss is part of the framework.
Answer: I'm not sure about Sass (although I'd recommend using scss over sass files) - but with Haml, all you need to do is have the haml gem listed in your Gemfile, and have haml instead of erb in your view file names. For example: index.html.haml - and that should just work.

Generating Sass and Haml in Rails


Which one is correct? affect or effect

Question: what should I write
The complicated political situation will affect/effect our timeline?
Please help me.
Comment: @KateBunting Not always. ("The patient had many affects" and "she effected a plan.") Although in the case of the sentence in the question, the normal distinction applies.
Comment: Have you used a dictionary? The first is a verb, the second a noun.
Answer: affect is a verb and effect is a noun in the sentence affect is the right word
for example, if you watch TV too much, it will affect your health
The rule comes in to effect next year
affect means to have an effect or influence on some thing
effect means force in the given example
However effect can also be used as a verb too
example, the architect has effected a number of changes in the plan.
here effect means bring about or cause
Answer: In the sentence affect is the right answer ,because .affect is a verb and effect is a noun .
Effect is a change that somebody or something causes in a result,while affect is to make somebody sick or I'll.
If you want to know the different  the sentence does not sound the same for example the condition affects one in five weman.
The effect of heat on metal.
Comment: You might want to check the answers in the question that this is marked as a duplicate of.

Which one is correct? affect or effect


If i change the backend of my website from php/wordpress to say, ruby, how will this affect my site? And also the seo of my site?

Question: I'm planning to start a website on php/WordPress. It might get complicated fast due to the amount of categories and sub categories etc? Later on I would like to expand the site, but due to the rigid nature of wordpress I change the backend to ruby. How will this affect my site? How will this affect SEO?
Comment: Sorry but its unclear what your asking. It would depend on the backend effecting the frontend. Google or Bing does not care what CMS or software you use.
Answer: If all the url pages are the same, or are properly redirected, and no 404 errors crop up, then there should be no SEO devaluation.
The only other issue might be with page speed.. if the new pages are loading faster or slower.


The source free RLC series/parallel circuit

Question: If the energy is dissipated more quickly in overdamped circuit then why it does have longest settling time?
Comment: Possible duplicate of [over and critically damped systems settling time](https://electronics.stackexchange.com/questions/296567/over-and-critically-damped-systems-settling-time)
Comment: Please search this site for "damped settling time"
Answer: This answer uses the example of a series capacitor, inductor and resistor and assumes the capacitor is previously charged to some voltage level.
If the over-damping is massive i.e. a massive series resistor then it dominates the inductance and the circuit becomes a resistor discharging a capacitor hence, the discharge time can be very long if R is very large.
As R reduces, the discharge time reduces. But as you approach critical damping (Q = 0.5) from the over-damped case, the decay changes from being a simple exponential situation to a decaying ripple where the frequency of the ripple is a decaying sinewave having a frequency of \$\omega_n\sqrt{1-\zeta^2}\$, where \$\zeta = \frac{1}{2Q}\$ and \$\omega_n\$ is the natural resonant frequency.
At Q = 0.6 (slightly less than critical damping), the decaying sinewave is very limited in its extent. The overshoot of the first cycle is about 0.9% and, to most folk would hardly count. As the sinewave decays, the first undershoot is about 0.008% so it's pretty much over as soon as it began.
The ratio of the magnitude of the 1st positive peak to the first negative peak is approximately 0.9/0.008 = ~112.
However, as Q rises more and more, the overshoot and undershoot become more dominant. For instance at Q = 1, the first overshoot peak is about 16% and the first undershoot peak is about 2.7%. You can see that these are closer in magnitude than was the case when Q was only 0.6. Ratio is about 6.
As Q rises even more you eventually reach the situation where the overshoot and undershoot continue for a very long time. This means that energy is kept in the reactive components for a very long time.
Conclusion: The energy is dissipated more quickly in a series RLC circuit at around critical damping. Either side of critical damping it takes longer and, at extremes (R = infinity, R = 0), it takes an infinite length of time.
Comment: What about in parallel circuit how does smaller value of resistance dominates over capacitance.  If the capacitor is initially charged then energy will be dissipated faster for small R  (p=v²/R)
Comment: @Aaqib and, after I give details about this you might ask about series-parallel arrangements and there are two of them so, I'm declining to pursue this further. I will say this though: you should get hold of a free simulation tool and perform the experiment by yourself. I use micro-cap student version and find it to be very good and accurate. If you've never used a sim tool before then there is a steep learning curve however, if you are planning a career in EE then you'll have to learn sims sooner rather than later.
Comment: I will also add this: If the initial energy was stored in the inductor in a parallel circuit (i.e. current was flowing in the inductor) and you reduced the parallel resistor to zero ohms near instantly then the inductor will continue to circulate the current indefinitely i.e.a very low Q factor will still produce a very long decay. So, this brings in the concept of initial conditions and, those initial conditions can lead to different conclusions.


Is there a systematic way to find irreducible polynomials?

Question: I am preparing for an exam and I'm looking for a systematic way to find all irreducible polynomials. I am given the following problem > Find all irreducible polynomials of degree 3 with coefficients over Z2.
I know that a polynomial is reducible if it can be represented as a product of two or more polynomials, but I can't find an efficient algorithm which can help me to list all the irreducible polynomials.
Any suggestions?
Comment: There are only eight polynomials of degree 3 over the field of two elements, and if a polynomial of degree 3 is reducible then it has a root, and the only possible roots are zero and one. So brute force is a pretty efficient algorithm in this case. And no one is going to ask you to find all irreducible polynomials of degree 100 with coefficients in the field of 65,537 elements, so don't worry about it.
Comment: I have another question (maybe a stupid one) : How do you calculate that there are 8 polynomials? Is it because of the fact that  we can represent the polynomial of degree 3 as : a*x^3 + b*x^2 +c*x + d   and we have that
a can be 1 , b can be {1,2},c {1,2} and d {1,2}  so we would have 1*2*2*2 = 8 possible combinations.
What confuses me is the "-" sign. Do we skip the polynomials with "-" coefficients because in the Z 2 field we calculate with mod 2 ? I mean for example -1 would be actually 1 (because -1 mod 2 = 1) . Did I grasp the idea?
Comment: Yes to all of your questions.
Comment: You can search for irreducible polynomials $f(x) \in \mathbb{F}_q$ by checking all the finite possible factors, then $f(x)$ will be also irreducible over $\mathbb{Q}$. Also, there is an easy combinatorial proof that for every $k$, there exists $\sum_{d | k} \frac{q^d}{d}$ irreducible polynomials of degree $k$ over $\mathbb{F}_q$
Answer: If $f(x)\in \mathbb Z_2[x]$ and has degree $3$,then  $f(x)=x^3+ax^2+bx+c$ and we have the possible states:
$a=0,b=0,c=0 \Rightarrow f(x)=x^3$
$a=1,b=0,c=0 \Rightarrow f(x)=x^3+x^2$
$a=1,b=1,c=0 \Rightarrow f(x)=x^3+x^2+x$
$a=1,b=1,c=1 \Rightarrow f(x)=x^3+x^2+x+1$
$a=1,b=0,c=1 \Rightarrow f(x)=x^3+x^2+1$
$a=0,b=1,c=0 \Rightarrow f(x)=x^3+x$
$a=0,b=1,c=1 \Rightarrow f(x)=x^3+x+1$
$a=0,b=0,c=1 \Rightarrow f(x)=x^3+1$
$f(x)$ is irreducible polynomial in $\mathbb Z_2[x]$ if $0$ or $1$ isnot roots, then $f(x)=x^3+x^2+1$ and $f(x)=x^3+x+1$ are irreducible polynomials in $\mathbb Z_2[x]$.


Hide Icon and label in Activity (splash screen)

Question: Here's the part of the Manifest that I believe is important:
<code><application android:icon="@drawable/icon"
             android:label="TestApplication"
             android:theme="@android:style/Theme.Holo.Light">

    <activity android:icon="@drawable/splashicon"
              android:label=""
              android:name=".Splash">
</code>
The splashicon is a 1x1 transparent png. When I try this way, the Application icon renders then fades to the transparent one.
I've tried various combinations of modifying the icon/label section for both activity and application and getting bad results. Removing the icon/label from the activity gives the most preferred result sans icon and label displaying during splash.
How do I get rid of those two items without messing up the icon/label in the app drawer and possibly other locations (haven't tested Market).
Edit:
I'm not after removing the icon/label from the app drawer (in fact, that is one thing I'm trying to retain).
The issue is that if I run the application in 3.0+, I get the icon and the label in the upper lefthand corner of the splash screen which is not what I'm wanting to see.
An example of an application that performs this behavior properly would be Pulse, Angry Birds Rio, and the like.
One application that I've noticed that falls victim to the same issue I'm having is Wyse PocketCloud Pro. If you run it in Honeycomb, look in the upper left hand corner as it is initially loading. Momentarily you can see the icon/label and it fades.
Answer: You need to be more specific about what you are looking for.  I'll try to answer what you may possibly be asking for.
An activity that is being displayed in the launcher must have a label and icon.  That's kind-of...  well, it wouldn't make sense to not need these.  So please don't play games here and try to not have them.  You start to look like a malicious app by doing so.
If you don't want your activity to show up at all in the launcher, then don't declare the intent filter for the MAIN action and LAUNCHER category.
If you want the preview window when launching the app to look more like your real window (let's say you hide the title bar), then in the  tag in your manifest use android:theme="..." to declare the theme you use so this can be used for the preview.  For example, if you are using Theme.NoTitleBar to not have a title bar, do android:theme="@android:style/Theme.NoTitleBar".
If you want to show a splash screen for your app and have the preview window match it, and one of the standard themes does not match enough, then make your own theme and in the manifest specify it for android:theme.  This will let you set a custom background color, or even set the background to an image that is your splash screen.
Keep in mind that launching applications should be fast, so having to show a splash screen every time it launches is very not desirable.  On a mobile device, there is a good chance this will greatly reduce the amount your app is used because people won't wait for a long time for it.
If you are looking for something else, please update your question to more clearly state what it is.
Comment: since I'm using Theme.Holo.Light, I used @android:style/Theme.Light.NoTitleBar and it achieved the desired effect.


Free tool that can split PDFs and can be used over an API in .NET (not command line)

Question: What are some free tools that will allow someone to split PDF files using the software's API in .NET? (not by using the software over a command line interface). Not looking for shareware which may have watermarks etc.
Answer: Essential PDF can be used to split PDFs : C# sample. The sample linked to here is ASP.NET based, but the library can be used from Windows Forms, WPF, ASP.NET Webforms, ASP.NET MVC, Silverlight, WinRT, Windows Phone, Windows store Universal and Xamarin applications
The whole suite of controls is available for free (commercial applications also) through the community license program if you qualify. The community license is the full product with no limitations or watermarks.
Note: I work for Syncfusion.


How to set the default dialer?

Question: Where are the configurations to set the default dialer? I installed a new one and want to know where I set the default.
Answer: Go to your Settings -> Applications -> Manage Applications.
Select the 'All' tab and scroll to the current dialer app.
Scroll down and press the 'Clear defaults' button. Now when you select dial, you should be prompted to select a particular app and also have the opportunity to set a new default.
Comment: It should have automatically done the prompt for you to choose once you downloaded it but this solution guarantees that it will ask you to choose the default.
Comment: @Vian - Unless the way Renato is launching the dialer is actually via a shortcut to a specific dialer. Some launcher apps allow you to place shortcuts on the dock (I vaguely remember Zeam working like this when I tried it).

How to set the default dialer?


Help to figure out xinput transform matrix for a tablet?

Question: I have a small wacom pad and a large monitor. And i wanted to reduce the area of the screen where the tablet surface is mapped. Sadly graphical utility does not allow this.
Currently the configuration is the following:
<code>    Coordinate Transformation Matrix (216): 0.571429, 0.000000, 0.428571, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
</code>
This maps to the HDMI connected 2nd monitor in landscape mode. I want to rotate mapping 90 degrees and use half of the screen in portrait mode. Infotunnely just multiplying given figures to rotation matrix gives total mess. As i unerstand due to not square shape of the area. But no idea how to do it right. So basically i need do the following.
Answer: Figured out. Basic transform matrix can be
<code>0.25  0.000000  0.75 0.000000  1.000000  0.000000 0.000000  0.000000  1.000000
</code>
Pretty good starting point.


Can gems be gifted across platforms?

Question: A friend of mine recently got an Android phone, and a few updates back DragonVale was released on Android.  I'm a long time player on the iOS platform, but I'm wondering if there is a way for us to gift gems to one another given DragonVale's cross platform support.  Can gems be gifted to friends across Android, iOS, and Facebook - or can you only gift gems to friends on your platform of choice?
Answer: Yes, gems can be gifted cross platform. However, because the Android version is not connected to iOS's GameCenter at all, your friend on Android must be friends with you on Facebook in order to be able to gift you gems and vice versa. Facebook is the only bridge between the two platforms. I use the Android version and I have 2 friends on iOS and one friend on Android and I have no issues gifting to them.
As a side note, the Android friending is a little buggy still. It took some time before my friends showed up after adding them through Facebook, and Dragonvale will still, on occasion, say that my Friends list is completely empty and/or have specific friends not show up on it randomly. Restarting the app will sometimes fix it, but it occasionally takes more time to fix itself. If this happens, don't worry about messing with Facebook or anything, your friends have not been lost, it's just the app being buggy.
Comment: Thanks for the answer @FAE.  At least local to GameCenter that buggy behavior has been explained by your friends and/or you loading an update.  If you are not on the same version, sometimes your friends will not appear (at least temporarily).  I have observed this to be the case empirically.
Comment: @EBongo Good to know! I'm not sure that's the case though given the frequency that it occurs on the Android version. Usually at least once a day (I check this app uh, a lot...), I'll load up the game and have an empty friends list. At this point, I'm just resigned to it happening and try to remember to gift gems later on.
Comment: I was added on Facebook by an iOS friend, and he gifted me a gem, but I couldn't see him until I'd restarted the app, for what it's worth.  Most of the game's tech support appears to boil down to "well, quit the app, and if that doesn't work, reinstall"

Can gems be gifted across platforms?


How do teams work on VB ASP.NET MVC sites?

Question: In PHP, you can just log in to the FTP and see all of the files.  I notice in VB ASP.NET MVC when I publish a site it doesn't include the controllers or models.  Rather, it seems to compile them into DLLs.  How can the files be modified with out access to the originals?  Would a developer have to publish the files in a separate directory and then the other developer pull them down and open the project in visual studio?
Comment: It's considered bad practice to make edits directly to deployed files, even if it's a dev environment.
Answer: Keep your SourceCode in a Version Control System  like SVN /GIT /TFS etc.. Whenever you want to make an update , Get the specific version you want to update and make update to that.
Having a Version control gives you so many advantages
1) Collaborative working. Many members of a team can work on same code base without overwriting conflict
2)  Restore to a Previous Version : Something wrong with the current production move ?. Just get the Previous version (Label) which is working fine (and was running in prod) and rollback to that till you fix the issue.
Keeping the Previous versions of code will save a lot of time in a Programmers / Team's life.
This SO question has good points about why we should use version control.
Version control is not only for Teams. Individual developers can keep their code in Version controls and sleep nicely
Btw, Your MVC project's Model classes and Controllers classes are compiled into the DLL files.
Answer: I've seen a lot of companies that work with Visual Studio implement Visual Source Safe.
information can be found here http://msdn.microsoft.com/en-us/library/3h0544kx%28v=vs.80%29.aspx
otherwise it's pretty much what Shyju said.
Answer: In a professional environment, there is a very clear distinction between editing source code, and deploying to production. You seem to make no distinction.
Usually developers make changes under careful control using a source control system like SVN.
Build & deployment is then done separately by a dedicated team member. Developers do not touch the production servers willy-nilly.

How can the files be modified with out access to the originals?

I don't understand. If you want developers to have full access to the production environment, why not give them full access to the source code as well? In your PHP example this is a given.
Comment: In PHP, there is only one version: the source code.  There is no compiled version.  Working alone, I typically never used version control (never had a need for it).  Shyju offered good insights promoting it's usage.  I see that may be the only option for providing the source code to the rest of a team.
Comment: Compiled vs. uncompiled doesn't matter. It's a question of access to production environment and the deployment process. Also there are lots of versions: every change a developer makes is a revision, and it's important to keep track of revisions using a source control system. @Pluc: It doesn't matter whether it's "scripting" or "programming". It's software development and the concept applies equally.


First place to build the first mini space colony/factory

Question: I thought it was a good question - somebody else ask it if you like.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/85364/discussion-on-question-by-userltk-first-place-to-build-the-first-mini-space-colo).
Answer: There is plenty of solar energy in the asteroid belt, and that would be my answer for the abundance and variety of asteroids to be found there.
As an answer to Could you liquefy an asteroid to collect its resources?, I provide most of an asteroid mining operation, including power. With a 100 meter diameter parabolic mirror made of paper-thin polished aluminum, near the center of the asteroid belt (400M km) you can capture about 1.5 Mw of solar energy (190 watts per square meter; vs 1370 watts per square meter anywhere near Earth). That size mirror is manageable in space, and you can have hundreds or thousands of them working together. They can power Stirling heat engines, or even closed cycle steam engines, to turn the heat into electricity. Or they can be used to focus light to any degree on photovoltaics which generate electricity more directly. Or to provide enough heat to melt the asteroid material so it can be centrifuged at very high centrifugal gravities to separate it into rings of constituent masses.
Any mining or manufacturing operation in space is going to have accidents and problems, the further from Earth the better. Every "planetary" surface like a moon is going to have a gravity well to deal with, which complicates everything. The place to mine is in microgravity, where things are easier to move and you can command and position in all three dimensions without difficulty, and generate all the gravity you DO need by centrifugal force, with the precise amount of gravity you want.
That includes within a miner's habitat, which can include a hospital, game rooms, exercise fields, spacious quarters, whatever is desired.
One primary extraction from asteroids is going to be iron for construction steel. The miner's habitat can be large, because in space the steel is cheap. I imagine it would the first thing they start building. Steel produced on Earth (or in any gravity well) is extremely expensive to lift out, that's why our ISS can't be the size of a town with foot-thick steel walls. If it is produced in space it can be "shipped" hundreds of millions of kilometers with very little fuel, just a shove in the right direction, and deceleration.
On the economic side, the raw materials and energy to produce the steel and power the robots that do most of the work are free, mining would be a profitable operation, and considering the price of alternative steel, the profit margins do not have to be modest. Plus, of course, the miner's will find trace levels of other valuable metals.
From This Link:

An asteroid's composition is mainly determined by how close it is to the Sun. The asteroids that are nearest the Sun are mostly made of carbon, with smaller amounts of nitrogen, hydrogen and oxygen, while the ones further away are made up of silicate rock. Silicates are very common on Earth and in the Solar System. They are made up of oxygen and silicon, the number one and number two most abundant elements in the Earth's crust. The metallic asteroids are composed of up to 80% iron and 20% a mixture of nickel, iridium, palladium, platinum, gold, magnesium and other precious metals such as osmium, ruthenium and rhodium. There are a few that are made up of half silicate and half metallic.

As I detail in my other answer, even the gases (hydrogen and oxygen being of particular interest) can be captured from the asteroids by the miners.
Answer: Earth Orbit
The first step in conquering space is simply to escape the tyranny of the Earth's gravity well. The delta-v from Earth's surface to LEO (as in the ISS) is around 9.4 km/s. Meanwhile, the delta-v from the Moon's surface to LEO is more like 2.7 km/s. Once you get off of Earth, it is a lot cheaper to get resources from anywhere. Here are a list of benefits for having a large colony / spaceport in LEO.

Cheapest trade with Earth: If the spacers eventually want to trade with Earth, LEO is the place to do it. The cheapest possible launch with a chemical rocket is to blast into LEO. Once there, you can transfer cargo to more efficient ion drive spacecraft to take it anywhere else. Alternately, sub-orbital launches and a skyhook might be the cheapest long term way to get thing off the planet. As far as putting things onto the planet, it is a relatively easy matter to de-orbit things from LEO using atmospheric drag.
Accessible materials: First, materials from the moon are very accessible from LEO. Moon to LLO (low lunar orbit) is about 1.9 km/s; but Moon to LEO is only 2.7 km/s, so its not much harder to get things to LEO than LLO. There are plentiful near-Earth objects that could be mined for materials. There is at least one confirmed trojan in Earth's L4 point, only 0.8 km/s away. There are several more objects in horseshoe libration, quasi-co-orbital solar satellites, and temporary satellites. For example, 2006 RH$_{120}$ is a near Earth asteroid that orbited the Earth from 2006-2007, before it went back to orbiting the sun. Every 20 years or so, it could be 'captured' but a little (nuclear explosive?) nudging and put into Earth's orbit.
Plentiful sunlight: Or, at least, as much sunlight as they have here on Earth. Earth orbit also has the advantage of little time with no light; lunar eclipses are rare and even an equatorial orbit gives you >12 hours of sunlight every day. That is certainly enough from plant life evolved on Earth.


How do I pixelize this light screen?

Question: I am trying to recreate Wheatly from Portal, and I have tried to make his pixelated eyes by have a pixel grid with rectangular holes over the light source. However, as you can see by the picture, the curves within some of the pixels destroys the pixelated attempt. Is there a clear way for pixelating circuluar patterns like this? If, so, which method would you recommend? Thanks!
Comment: Have a look at the 'pixellate' node group from @Rich Sedman 's answer to [this question](https://blender.stackexchange.com/questions/112304/how-to-achieve-a-realistic-material-for-an-operative-phone-screen/118394#118394)
Comment: No, How does he do it?
Answer: While I am not familiar with the subject in question, one way would be to use a custom image and use it as an emissive shader.
image used: http://orig14.deviantart.net/3961/f/2012/050/a/f/wheatley__s_eye_by_mycroftporthos-d4qarjf.png
Obviously you can find a better image (more pixelated) or make your own and use some filter in photo editors app like Photoshop, Affinity, Gimp or whichever you prefer.
Photoshop has a bunch of filter under the category Pixelate.
Affinity also has a filter under the Distort category called Pixelate and I'm sure Gimp also has one.
Answer: This isn't more of an answer than this one by @Rich Sedman, but I've taken the 'pixellate' section from it and made an adjustable node-group from it.
This is the node group:

How it works is explained in the original answer.
This is an example of its usage:

Inputs: Number of tiles in X,  Number of tiles in Y, The thickness of the borders between pixels as a fraction of 1 (the full UV dimension)
Outputs: The vector to plug into your image texture, and an 'In Border' value of 0 or 1, so you can decide what to do with the parts of the output between the tiles.
Example material:

I can't promise it's bombproof .. or necessarily the simplest group to do this.

How do I pixelize this light screen?


How to use high and low bytes?

Question: I am trying to represent 32768 using 2 bytes. For the high byte, do I use the same values as the low byte and it will interpret them differently or do I put the actual values? So would I put something like
32678 0   or    256 0? Or neither of those? Any help is appreciated.
Comment: I am trying to send a iRobot Create a command to drive straight. It says a value of "32768 or 32767" will make it drive straight. It takes in a high byte and low byte. The best I have gotten (in terms of driving straight) is 255 128, but that still turned some.
Comment: Homework, eh? :) Look here: http://en.wikipedia.org/wiki/Binary_numeral_system Bytes are nothing but groups of eight bits.
Comment: What are you trying to do? An unsigned short is 16-bits in c++, and would store numbers up to 32767.
Comment: @Mike Bantegui A signed short stores numbers up to 32767, an unsigned short goes up to 65535.
Answer: In hexadecimal, your number is 0x8000 which is 0x80 and 0x00.
To get the low byte from the input, use low=input & 0xff and to get the high byte, use high=(input>>8) & 0xff.
Get the input back from the low and high byes like so: input=low | (high<<8).
Make sure the integer types you use are big enough to store these numbers. On 16-bit systems, unsigned int/short or signed/unsigned long should be be large enough.
Comment: Or `unsigned short`. Generally better to use `unsigned` types with the `>>` operator.
Comment: `short` is large enough that 32768 may overflow to -32768, and `int` may be the same size as `short`. Thus the value of `32768 >> 8` is implementation-defined.
Comment: Actually, this conversation is irrelevant. I just noticed that the question is tagged 16-bit. Updating my answer accordingly...
Comment: Only because two bytes are involved is it wise to assume that the 16-bit boundary will not be broken. Generally though, bit shift operators work just find with `signed` integers and the choice to go unsigned should have more to do with whether or not negative values are required.
Answer: Bytes can only contain values from 0 to 255, inclusive. 32768 is 0x8000, so the high byte is 128 and the low byte is 0.
Comment: Fair enough. But I think I could count the number of modern systems that have a byte defined as something other than 8 bits on one hand.
Comment: Always with the zebra. Horses people, horses.
Comment: You have a lot of reputation, but it's still not true that a byte always is exactly 8 bit wide. That, btw, is also the reason why in protocol specifications often the name "octet" is used as opposed to "byte". There are still systems around where a byte can have a size bigger than 8 bit. Also see Wikipedia: http://en.wikipedia.org/wiki/Byte
Comment: true true. I reckon in practice this often won't matter, but I think one should know the distinction. And since the question of the OP is a very basic one, I think it would be worth to mention that in an answer.
Answer: Try this function.
Pass your Hi_Byte and Lo_Byte to the function, it returns the value as Word.
WORD MAKE_WORD( const BYTE Byte_hi, const BYTE Byte_lo)
{
     return   (( Byte_hi << 8  ) | Byte_lo & 0x00FF );
}

Answer: Pointers can do this easily, are MUCH FASTER than shifts and requires no processor math.
Check this answer
BUT:
If I understood your problem, you need up to 32768 stored in 2 bytes, so you need 2 unsigned int's, or 1 unsigned long.
Just change int for long and char for int, and you're good to go.
Answer: 32768 is 0x8000, so you would put 0x80 (128) in your high byte and 0 in your low byte.
That's assuming unsigned values, of course.  32768 isn't actually a legal value for a signed 16-bit value.
Answer: 32768 in hex is 0080 on a little-endian platform. The "high" (second in our case) byte contains 128, and the "low" one 0.
Comment: This is unhelpful and confusing. It introduces a second property of the bytes, relative order in memory, and fails to explain it as well as the high-order/low-order property mentioned by OP.

How to use high and low bytes?


Is GPL linking to AGPL possible?

Question: Suppose I have a program that uses a library released under the AGPL license. Can the program be released as GPL, or does it have to be released as AGPL too ?
Answer: Yes, you may perform this combination, and the works technically retain their respective GPL/AGPL licenses. However, your concern that the combination may "have to be released as AGPL too" has some truth to it: the AGPL requirement to share source over a network does indeed apply to the combination.
This is explicitly handled in section 13 of the GPLv3 (and correspondingly in section 13 of the AGPLv3), which articulates the interaction between GPLv3- and AGPLv3-licensed code when combined:

13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.

The last sentence here means that the most significant requirement of the AGPL -- disclosing source to users over a network -- applies to a combination of GPL and AGPL work.
It is technically true, though, that the AGPLv3 copyleft requirements do not extend into the GPLv3-licensed material (nor vice versa), so the two licenses are compatible. The GPL and AGPL components may be freely intermixed and each retains its original AGPL/GPL licensing status.
Answer: The GPL3 has provisions that let you link to the AGPL, though there are caveats that other answers have covered adequately so need no repeating here.
The GPL2 however you can not as the AGPL violates the following condition of the GPL2

Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

The GP2L does not require you make your sourcecode available if its user interface is merely accessibly over the web, it only requires it if you distribute the program. Since the AGPL DOES have this requirement , that requirement counts as a "further restriction", and thus prohibits AGPL code linked to GPL2 code from further distribution.
Again, the GPL3 has specific language that permits this, although it behooves you to understand specifically how the resulting derivative work is actually licensed. The GPL2 does not.
Answer: In https://www.gnu.org/licenses/agpl-3.0.txt, section 5:
The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
So, no GPL linking to an AGPL library.

Is GPL linking to AGPL possible?


Are there any tools to integrate MS SQL Server Reporting with Ruby?

Question: I need to pull some reports that live in a SQL Server Reporting Server from a Ruby web application.
How can this be done?
Comment: I am not particularly familiar with Ruby but I know RS exposes some web services that can be used to execute a report and return the result in a given format, such as PDF.  Might be one direction to explore.
Comment: @Rozwel Thanks! I think I might have to go that route, but I just wanted to ask the community if there are any tools similar to the .Net ReportViewer class. Where the end user can navigate, print, or export the report without having to re-invent the wheel.
Answer: There is nothing out there pre-built that I'm aware of, but you have some options for integration.
The simplest, if users have direct access to the RS server, is to just redirect or link them to the report using their URL-based strategy, possibly opening a new window.  If users do not have direct access, you can still use the URL-based strategy, but perform a request on the back end from your Rails app to the MS Reporting Services server, and stream all the report bytes through to the browser:
<code>open("http://ReportServer/reports?querystringxxxx") { |f|
    @response = f.read
}
</code>
This is drastically simplified, of course.  You'll need to pay particular attention to your content types to ensure things get interpreted correctly by the browser.
The next option is to use their web services API, but unless you need particularly advanced functionality, I'd say the URL/REST based approach is far, far simpler.
If you get it working, take the opportunity to try creating your first gem, put it up on github, and then maybe somebody else will use it one day... :)
Answer: The rest-based approach would only work for a report with no parameters.
If the report has parameters, you will need to use the Web Services API, a SOAP-based interface that requires you to parse the request (with the parameters) into XML and send that with the request to MSSRS.
According to my co-worker, who has done it, it's pretty cumbersome for what you actually get.


Is matching combined with Diff-in-Diff a bad idea?

Question: I remember seeing such a comment on Twitter long time ago but I see so many prominent papers doing it that I doubt it can really bad. Does somebody know more (e.g. papers) on this?
Comment: just because something is done in many papers does not mean its a good idea, it wasn't that long ago when even top papers ignored the requirement for first stage to have sufficient F-statistics leading to, thankfully now bygone, era of publications with wrong instruments
Answer:
Is matching combined with Diff-in-Diff a bad idea?

No.
But, as with anything, it depends on the context. One point to consider is that you should match on pre-treatment characteristics, because treatment can affect the variables used for matching.
All usual caveats of both approaches still apply, but I'm not aware of any literature diving deep into this combination per se.


Can employment contracts force all litigation into arbitration?

Question: Is it legal for an employment contract to stipulate that all litigation from the employee towards the employer must be in the form of arbitration or do you have the right to litigate in the court system?
Source.
Answer: The only significant exception to employment arbitration scope in the U.S. is for sexual assault cases under a law that took effect about a year ago (whose effective date language is actively being litigated over what triggers a before or after effective date determination).  H.R. 4445, the Ending Forced Arbitration of Sexual Assault and Sexual Harassment Act (the Act), into law on March 3, 2022.
Also, arbitration clauses can't bind non-party government labor law enforcement agencies that aren't parties to the arbitration agreement. Likewise, criminal violations can't be subjected to arbitration (e.g. a criminal prosecutor prosecuted wage theft claim, or involuntary servitude claim).
Limitations on the scope of the substantive remedy in arbitration are not always allowed, but if the necessary substantive remedy is available in arbitration, any employment matter can be subject to arbitration if the parties agree either pre-dispute or post-dispute in the U.S. An arbitration clause isn't supposed to change substantive law in practice, even if it is possible to do so unreviewably in practice on a case by case basis.
At some point, children or other people who lack capacity may be incapable of agreeing to an arbitration clause but the threshold is low and can be met by a fiduciary for the person who personally lacks capacity to contract.
Answer: See Epic Systems Corp. v. Lewis, 584 U. S. ____ (2018).
Courts must enforce agreements to arbitrate, even in the employment context. Where an agreement requires arbitration, the only way to avoid this is through "generally applicable contract defenses, such as fraud, duress, or unconscionability."


When do you stop Minocycline/Spirnolactone prior to start of Accutane?

Question: I will be meeting with my Dermatologist to start on Accutane Sept. 16. She is on vacation now so I cannot contact her, but she mentioned that before I start Acutane that I need to stop taking my Minocycline and Spirnolactone, but I can't recall how far in advance that is. Is it a month or two weeks? (Also, yes, I know that I need to take a blood test at the start of the month and be on birth control and sign the "I pledge" and all that jazz). Thanks!
Answer: This is a very interesting, yet tricky, question. The reason you must stop taking the minocycline is because of the interaction between tetracyclines (minocycline) and vitamin A (Retinoic acid) derivatives (isotretinoin/Accutane) causes a pseudotumor cerebri also known as increased intracranial pressure, which can be deadly.
Now when taking spironolactone and isotretinoin, I don't see a problem per se, as far as interactions go. However, maybe your doctor doesn't want you to endure any of spironolactone's side effects as it will be minimally effective in treating the acne by comparison to the isotretinoin.
Comment: Do you know how much prior to start date of Acutane though?


php mysql fetch array in global

Question: i got this code
<code>     while ($aResult = mysql_fetch_array($result))
  {
   $sResult[$aResult[userID]] = $aResult;
  }
</code>
but i want to know is there a faster way to put everything from $aresult in the sresult global?
Comment: what's wrong with this current code?
Answer: It depends on the definition of "faster". If you want minimum CPU usage, you propably should use the function above, or as Col. said, try to avoid fetching all and use pointers.
If you want less coding time, consider using a a wrapper such as PEAR DB. With it you can just write $res = $db->getAll( $SQL );
http://pear.php.net/manual/en/package.database.db.db-common.getall.php

php mysql fetch array in global


Retrieve and Display Data inside of a Webpart

Question: If I need to display data from a customized database to a webpart for a SP solution 2013, what approach or tool is the recommended or best practice to do it? What is the common approach to use it to faciliate the work? I'm talking about Nhibernate, bindlinglist, Entity Framework etc.
Answer: What we did was deploy our Business-Logic and Data-Access Layers to the GAC as a dll, and in our SharePoint WebParts, we referenced these dlls. Whenever I need to call upon a service in my BLL, create an instance of a model, query the custom DB (we only use Stored Procedures) etc., we just had to include the proper reference in the class. Moreover, if I ever had to update the layers to add a new service/model/entity it would be a single update.
Comment: Please define GAC?
Comment: Global Assembly Cache. "The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer". You can use 'gacutil.exe' to install your dll into the GAC, and then reference it in your sharepoint webpart project


What is the garbage collector in Java?

Question: I am new to Java and confused about the garbage collector in Java. What does it actually do and when does it comes into action. Please describe some of the properties of the garbage collector in Java.
Comment: Sometimes it is better to read chapter in a good book expect to understand a complex subject from the answer to one question.
Comment: @Ian It's a similar question, but not a duplicate. And that question *reeks* of homework.
Comment: possible duplicate of [Garbage Collection](http://stackoverflow.com/questions/774357/garbage-collection)
Answer: The garbage collector is a program which runs on the Java Virtual Machine which gets rid of objects which are not being used by a Java application anymore. It is a form of automatic memory management.
When a typical Java application is running, it is creating new objects, such as Strings and Files, but after a certain time, those objects are not used anymore. For example, take a look at the following code:
for (File f : files) {
    String s = f.getName();
}

In the above code, the String s is being created on each iteration of the for loop. This means that in every iteration, a little bit of memory is being allocated to make a String object.
Going back to the code, we can see that once a single iteration is executed, in the next iteration, the String object that was created in the previous iteration is not being used anymore -- that object is now considered "garbage".
Eventually, we'll start getting a lot of garbage, and memory will be used for objects which aren't being used anymore. If this keeps going on, eventually the Java Virtual Machine will run out of space to make new objects.
That's where the garbage collector steps in.
The garbage collector will look for objects which aren't being used anymore, and gets rid of them, freeing up the memory so other new objects can use that piece of memory.
In Java, memory management is taken care of by the garbage collector, but in other languages such as C, one needs to perform memory management on their own using functions such as malloc and free. Memory management is one of those things which are easy to make mistakes, which can lead to what are called memory leaks -- places where memory is not reclaimed when they are not in use anymore.
Automatic memory management schemes like garbage collection makes it so the programmer does not have to worry so much about memory management issues, so he or she can focus more on developing the applications they need to develop.
Comment: Would it be true to say a java application running on a computer then have two garbage collection functionalities. One with the Java virtual machine. And then one on the actual machine that runs windows? (Or any other OS)
Comment: No, usually Java applications run only if JRE is present. So, only JVM's garbage collection functionality is required! @Lealo
Answer: It frees memory allocated to objects that are not being used by the program any more - hence the name "garbage". For example:
public static Object otherMethod(Object obj) {
    return new Object();
}

public static void main(String[] args) {
    Object myObj = new Object();
    myObj = otherMethod(myObj);
    // ... more code ...
}

I know this is extremely contrived, but here after you call otherMethod() the original Object created is made unreachable - and that's "garbage" that gets garbage collected.
In Java the GC runs automatically, but you can also call it explicitly with System.gc() and try to force a major garbage collection. As Pascal Thivent points out, you really shouldn't have to do this and it might do more harm than good (see this question).
For more, see the wikipedia entry on Garbage collection and Tuning Garbage Collection (from Oracle)
Comment: I believe one should not call `System.gc()`, the whole point of having a GC is to not have to do that.
Comment: AFAIK `System.gc()` does not force GC to run.
Comment: +1 for the good code example. Note that it's perfectly valid for the GC to destroy `myObj` before the call to `otherMethod` takes place, because `myObj` is no longer accessible at that point.
Comment: @Italy I believe that's implementation specific.
Comment: with escape analysis (http://en.wikipedia.org/wiki/Escape_analysis) , it's possible that the JVM might not even allocate the object in the first place in this example. The entire object creation can (in theory) be optimised away. Implementation dependent of course.
Answer: An object becomes eligible for Garbage collection or GC if it's not reachable from any live threads or by any static references.
In other words, you can say that an object becomes eligible for garbage collection if its all references are null. Cyclic dependencies are not counted as the reference so if object A has a reference to object B and object B has a reference to Object A and they don't have any other live reference then both Objects A and B will be eligible for Garbage collection.

Heap Generations for Garbage Collection -
Java objects are created in Heap and Heap is divided into three parts or generations for the sake of garbage collection in Java, these are called as Young(New) generation, Tenured(Old) Generation and Perm Area of the heap.

New Generation is further divided into three parts known as Eden space, Survivor 1 and Survivor 2 space. When an object first created in heap its gets created in new generation inside Eden space and after subsequent minor garbage collection if an object survives its gets moved to survivor 1 and then survivor 2 before major garbage collection moved that object to old or tenured generation.
Perm space of Java Heap is where JVM stores Metadata about classes and methods, String pool and Class level details.

Refer here for more  : Garbage Collection

You can't force JVM to run Garbage Collection though you can make a request using System.gc() or Runtime.gc() method.
In  java.lang.System
public static void gc() {
    Runtime.getRuntime().gc();
}

In java.lang.Runtime
public native void gc();  // note native  method

Mark and Sweep Algorithm -
This is one of the most popular algorithms used by Garbage collection. Any garbage collection algorithm must perform 2 basic operations. One, it should be able to detect all the unreachable objects and secondly, it must reclaim the heap space used by the garbage objects and make the space available again to the program.
The above operations are performed by Mark and Sweep Algorithm in two phases:

Mark phase
Sweep phase

read here for more details - Mark and Sweep Algorithm
Answer: garbage collector implies that objects that are no longer needed by the program are "garbage" and can be thrown away.
Answer: Garbage Collector is part of JRE that makes sure that object that are not referenced will be freed from memory.
It usually runs when you app runs out of memory.
AFAIK it holds a graph that represents the links between the objects and isolated objects can be freed.
To save performance the current objects grouped into generations, each time GC scans an object and finds that it is still referenced its generation count incremented by 1 (to some max maximum value, 3 or 4 i think) , and the new generation are scanned first (the shortest the object in memory the more probably it is no longer needed) so not all objects being scanned every time GC run.
read this for more information.
Comment: @quantumSoup - that depends on the JRE's GC implementation.  In many cases, the GC *does not* run constantly.  Instead, it runs when your app is unable to allocate an object because the heap is full.  Recent HotSpot JVMs do include a parallel GC, but it is not enabled by default.
Comment: @erikb: By that logic there would never be any downvotes. And downvotes are necessary to weed out relatively poor answers. The OP is obviously a beginner, and the specific inner workings of the GC simply aren't important to the question asked. Since this answer doesn't answer the question asked (it answers a different one), downvotes are perfectly justified.
Comment: @quantumSoup are you possitive on this? I believe some kind of garbage collection (a more expensive one) only happens when the heap fills.
Comment: This answer concentrates too much on the mechanism. The question was "What is the garbage collector", not "How does the garbage collector operate"
Comment: @quantum: neutralised your -1,because: Learning, that is, what this page is for, right? To learn you need to make mistakes. Punishing mistakes makes people not learn. Hope, you can agree in that point. And maybe you did a mistake here.
Comment: @Billy: I agree on using downvotes to weed out poor answers. I just don't think that a mistake nessesarily and always makes a poor answer. Here, in this case are obvious reasons for a GC to not run all the time, while a situation dependend execution itself probably also has disadvantages. It is valuable to discuss that point, especially since yosanu wanted to know more about GC's attributes. This is one. Also, Itay does not seem to be the 12 year old "My guess is better then your knowledge" type. I did not actually value his unedited post an upvote, but also thought it far above a downvote.
Answer: The garbage collector allows your computer to simulate a computer with infinite memory. The rest is just mechanism.
It does this by detecting when chunks of memory are no longer accessible from your code, and returning those chunks to the free store.
EDIT: Yes, the link is for C#, but C# and Java are identical in this regard.
Comment: There's actually a question on SO about the difference between java and C#'s GC: http://stackoverflow.com/questions/492703/c-vs-java-garbage-collector
Answer: Many people think garbage collection collects and discards dead objects.
In reality, Java garbage collection is doing the opposite! Live objects are tracked and everything else designated garbage.
When an object is no longer used, the garbage collector reclaims the underlying memory and reuses it for future object allocation. This means there is no explicit deletion and no memory is given back to the operating system.
To determine which objects are no longer in use, the JVM intermittently runs what is very aptly called a mark-and-sweep algorithm.
Check this for more detail information:
http://javabook.compuware.com/content/memory/how-garbage-collection-works.aspx
Answer: To put it in the most simple terms that even a non-programmer can understand, when a program processes data it creates intermediate data and storage space (variables, arrays, certain object metadata etc.) for that data.
When these objects are accessed across functions or over a certain size, they are allocated from a central heap.   Then when they are no long needed, they need to be cleaned up.
There are some very good articles online about how this works, so I'll just cover the very basic definition.
The GC is basically the function that does this cleanup.  To do this is clears table entries that aren't referenced by any active objects, effectively deleting the objects, than copies and compacts the memory. It's a little more complicated than this, but you get the idea.
The big problem is some parts this process often requires the entire Java VM to require to be stopped temporarily to take place, as well as this entire process being very processor and memory bandwidth intensive.   The various options as of GCs and tuning options for each one are designed to balance these various issues with the whole GC process.
Answer: Garbage Collection in Java (and other languages/platforms as well) is a way for the java run-time environment (JRE) to reuse memory from java objects that are no longer needed.  Simplistically, when the JRE initially starts up it asks the Operating System (O/S) for a certain amount of memory. As the JRE runs your application(s) it uses that memory. When your application is done using that memory, the JRE's "Garbage Collector" comes along and reclaims that memory for use by different parts of your existing application(s).  The JRE's "Garbage Collector" is a background task that is always running and tries to pick times when the system is idle to go on its garbage runs.
A real world analogy would be the garbage men that come to your house and pick up your recyclable garbage... eventually, its reused in other ways by yourself and/or other people.
Answer: Garbage collector can be viewed as a reference count manager.
if an object is created and its reference is stored in a variable, its reference count is increased by one. during the course of execution if that variable is assigned with NULL. reference count for that object is decremented. so the current reference count for the object is 0. Now when Garbage collector is executed, It checks for the objects with reference count 0. and frees the resources allocated to it.
Garbage collector invocation is controlled by garbage collection policies.
You can get some data here.
http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html
Comment: Reference counting is one lousy way to implement GC. I don't think any major JVM implementation uses this.
Answer: Garbage collector is a component of jvm.
It is used to collect garbage when ever cpu gets free.
Here garbage means unused objects it runs in Background of main program
to monitor the status of the main program.
Answer: Automatic garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects. An in use object, or a referenced object, means that some part of your program still maintains a pointer to that object. An unused object, or unreferenced object, is no longer referenced by any part of your program. So the memory used by an unreferenced object can be reclaimed.
In a programming language like C, allocating and deallocating memory is a manual process. In Java, process of deallocating memory is handled automatically by the garbage collector. Please check the link for a better understanding.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
Answer: Garbage collection refers to the process of automatically freeing memory on the heap by deleting objects that are no longer reachable in your program.
The heap is a memory which is referred to as the free store, represents a large pool of unused memory allocated to your Java application.
Comment: Don't use quote formatting for text that isn't quoted, and if it is quoted you need to cite the source.
Answer: The basic principles of garbage collection are to find data objects in a program that cannot be accessed in the future, and to reclaim the resources used by those objects. https://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29
Advantages
1) Saves from bugs, which occur when a piece of memory is freed while there are still pointers to it, and one of those pointers is dereferenced. https://en.wikipedia.org/wiki/Dangling_pointer
2) Double free bugs, which occur when the program tries to free a region of memory that has already been freed, and perhaps already been allocated again.
3) Prevents  from certain kinds of memory leaks, in which a program fails to free memory occupied by objects that have become unreachable, which can lead to memory exhaustion.
Disadvantages
1) Consuming additional resources, performance impacts, possible stalls in program execution, and incompatibility with manual resource management.
Garbage collection consumes computing resources in deciding which memory to free, even though the programmer may have already known this information.
2) The moment when the garbage is actually collected can be unpredictable, resulting in stalls (pauses to shift/free memory) scattered throughout a session. Unpredictable stalls can be unacceptable in real-time environments, in transaction processing, or in interactive programs.

Oracle tutorial
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

Garbage collection is the process identifying which objects are in use and which are not, and deleting the unused objects.

In a programming languages like C, C++, allocating and freeing memory is a manual process.
int * array = new int[size];
processArray(array); //do some work.
delete array; //Free memory

The first step in the process is called marking. This is where the garbage collector identifies which pieces of memory are in use and which are not.
Step 2a. Normal deletion removes unreferenced objects leaving referenced objects and pointers to free space.

To improve performance, we want to delete unreferenced objects and also compact the remaining referenced objects. We want to keep referenced objects together, so it will be faster to  allocate new memory.

As stated earlier, having to mark and compact all the objects in a JVM is inefficient. As more and more objects are allocated, the list of objects grows and grows leading to longer and longer garbage collection time.

Continue reading this tutorial, and you will know how GC takes this challenge.
In short, there are three regions of the heap, YoungGeneration for short life objects, OldGeneration for long period objects, and PermanentGeneration for objects that live during the application life, for example, classes, libraries.
Answer: As objects are dynamically allocated by the new operator, you can ask how these objects are destroyed and how busy memory is freed. In other languages such as C++, you need to free manually allocated objects dynamically by the delete operator. Java has a different approach; it automatically handles deallocation. The technique is known as Garbage Collection.
It works like this: when there are no references to an object, it is assumed that this object is no longer needed and you can retrieve the memory occupied by the object. It is not necessary to explicitly destroy objects as in C++. Garbage collection occurs sporadically during program execution; It does not simply happen because there are one or more objects that are no longer used. In addition, several Java runtime implementations have different approaches to garbage collection, but most programmers do not have to worry about this when writing programs.
Answer: Automatic garbage collection is a process where the JVM gets rid of or keeps certain data points in memory to ultimately free up space for the running program. Memory is first sent to heap memory, that is where the garbage collector (GC) does its work, then is decided to be terminated or kept. Java assumes that the programmer cannot always be trusted, so it terminates items it thinks it doesn't need.

What is the garbage collector in Java?


Classification of Differential Equations: Order, Homogeneity, Linear

Question: How do you tell whether a differential equation is nonlinear or linear. And how do you determine the order and whether it is homogeneous? I'm trying to understand by reading my textbook, but I'm quite confused.
Thanks!
Answer: The order of a differential equation is the highest derivative in equation. Th highest power of an order in equation is degree for differential equation. A differential equation is linear if we can write that of the form
$$f_n\frac{d^ny}{dx^n}+f_{n-1}\frac{d^{n-1}y}{dx^{n-1}}+\cdots+f_1\frac{dy}{dx}+f_0y=g$$
\begin{eqnarray}
y^{\prime\prime\prime}-6xy^\prime=2-3e^x &\hspace{1cm}& \text{order(3),degree(1),linear} \\
y+9x(y^\prime)^2=e^x-5
&\hspace{1cm}& \text{order(1),degree(2),nonlinear} \\
x^2\frac{d^2y}{dx^2}-2x\frac{dy}{dx}-(\sin x)y=0
&\hspace{1cm}& \text{order(2),degree(1),linear} \\
y^{\prime\prime}y-2x+y^\prime=e^x
&\hspace{1cm}& \text{order(2),degree(1),nonlinear} \\
3t(\frac{dy}{dt})^3+4(\sin t)y^4-2=0
&\hspace{1cm}& \text{order(1),degree(3),nonlinear} \\
t^2\frac{d^3y}{dt^3}-\sin t\frac{dy}{dt}-\cos(ty)=0
&\hspace{1cm}& \text{order(3),degree(-),nonlinear} \\
5x\dot{y}-4(\dot{y})^7y=x
&\hspace{1cm}& \text{order(1),degree(7),nonlinear} \\
\end{eqnarray}
Comment: @projectilemotion thanks
Answer: A linear differential equation is generally given by:
$$\frac{d^n y}{dx^n}+f_{n-1}(x) \frac{d^{n-1} y}{dx^{n-1}}+...+f_{2}(x) \frac{d^2 y}{dx^2}+f_1(x)\frac{dy}{dx}+f_0(x)y=g(x) \tag{1}$$
Obviously, a non-linear differential equation is one which cannot be written in that form.

The order of a differential equation is the highest derivative present in the differential equation.
For example, these are examples of second order differential equations, because the $\frac{d^2y}{dx^2}$ term is the highest derivative. Note that they are also both linear, since the first one can be written in the form of $(1)$ if divided by $a$ on both sides, and the second can be divided by $x^2$:
$$a \frac{d^2 y}{dx^2}+b\frac{dy}{dx}+cy=0$$
$$x^2 \frac{d^2 y}{dx^2}+x\frac{dy}{dx}+y=\cos{x}$$

A homogeneous differential equation is one which can be written in the form:
$$\frac{d^n y}{dx^n}+f_{n-1}(x) \frac{d^{n-1} y}{dx^{n-1}}+...+f_{2}(x) \frac{d^2 y}{dx^2}+f_1(x)\frac{dy}{dx}+f_0(x)y=0 \tag{2}$$
Which is when $g(x)=0$.
Answer: What is the order of the highest derivative? (i.e. first derivative is order 1, second second is order 2..) that's the order of your DE.
Look at the function in your DE (usually $y$, not sure what notation you use). Also look at the derivatives present ($y'$, $y''$, etc). Are any inside of some nonlinear function such as a power, right etc? Then the DE is nonlinear. The DE is linear if the function and all its derivatives are to the first power only.
Look at the coefficients of your function and its derivatives. If all coefficients are constant, the DE is autonomous. If any coefficient is a function of your variable, then the DE is non-autonomous.
Now look for the term which does not have your function or its derivatives in it. If it is zero, your DE is homogeneous. If it is not zero (a constant or a function of your variable) then your DE is non-homogeneous.
When beginning to save a DE, I would recommend making an abbreviated note to yourself of the type of DE. For instance, most courses spend a lot of time on SOLHA DEs: second-order linear, homogeneous, autonomous DEs. FOLHA is about as simple as they get. Those and FOLA can be solved completely, not to be said of all DEs.


Is it legal to cheat in single player games with no in-app purchases?

Question: I had a single player free-to-play (gratis, but not libre) game on my phone a couple years ago. It has no in-app purchases; AFAICT it's completely funded by ads. One feature of it is that you can get free "coins" every hour. One time I decided to run a packet sniffer on my phone's network traffic just out of curiosity, and saw that every time I open that game, it makes an unencrypted HTTP request to the developer's server, and the server sends back the UNIX time. I set up a fake server on my LAN that increments by one hour every time it is requested, regardless of how much time actually passes, and used a custom DNS server to make the app's requests go to my spoofed server. After I did this, the app let me get free coins whenever I wanted. Was this legal? I didn't modify the app code or hack the developer's server; I just reverse engineered the app's communication with the server and set up a spoofed server on my LAN.
Answer: They could take you to court for loss of income - since you were gaining coins for free instead of paying for them (essentially theft)
In the UK it actually falls under Theft as you dishonestly appropriated goods which did not rightfully belong.
Would someone chase you up on this... probably not. I'd say you're safe.
Comment: You can't buy the coins. The only way to get them is by playing the game for free. You get a few in the course of normal gameplay, and every hour it gives you more. All my "hack" did was make the app "think" an hour had passed when it actually had not.
Comment: Apologies - in that case then no, I wouldn't say it's illegal. They aren't loosing out on anything. No loss of business.
Comment: Does it really work this way? Your software is "invited" onto my phone and runs there with my permission under my physical control. I decide that instead of running your software I would rather run a modified copy of your software, OR I would rather run your software on a modified phone. That is perhaps a copyright violation in many circumstances - or hacking under the CFAA - but *theft*?! Even if you had to buy the coins, would it really be *theft* to modify something you own, in order to avoid paying money? Does installing the software constitute a contract to not use it without paying?
Comment: Nice, there is loss of business. You can get the game for free, but can only play say half an hour a day. If you want to play, you need to pay money.


Is there anything the priest does in Whiterun? (Skyrim)

Question: Is there any special thing you can do with the priest blabbing about Talos all day or does he just stand there being obnoxious
Comment: I like to let him watch me enter his house so he'll come running to see why I'm in there, but getting in stealth before he gets in so I can backstab the *censored* out of him and shut him up for good.  But that's probably not the answer you're looking for....
Answer: I assume you are talking about Heimskr?
As with many other NPCs the Radiant system makes him a potential quest giver/quest target. Some of the potential quests in which he can be involved can be seen here.
The Elder Scrolls Wiki speaks of an additional two interactions with this NPC:

After Battle for Whiterun: His house will be destroyed during the battle; in the aftermath he will reside in a small tent next to the shrine of Talos or he can be jailed if the Legion wins the battle. Should the Stomcloaks take over Whiterun, Jarl Vignar Gray-Mane mentions building a temple of Talos in Whiterun, and making Heimskr the high priest.
The Burglar Job: His house may be the target for one of Vex's burglary jobs, in which the Dragonborn must steal a specific item. If his house has been destroyed, it becomes impossible to complete the burglary


Is it possible for the commit and reveal transaction to be on the same block?

Question: I'm new to the inscribing process and I noticed there were two transactions required for inscribing. Is it possible to have these on the same block? or is there a way to control the tx fee on the reveal tx to help increase the possibility of it to be on the same block?
Answer: If you give the second transaction a higher fee rate, the two transactions will be treated as one "package" by any reasonable transaction selection algorithm and will almost certainly be mined in the same block. However, there's no way to actually prevent a miner to only mine the first transaction but not the second.


Is it possible to retrieve the optimal policy from the state value function?

Question: One can easily retrieve the optimal policy from the action value function but how about obtaining it from the state value function?
Comment: This seems to be a duplicate of [this](https://ai.stackexchange.com/q/10584/2444) and [this](https://ai.stackexchange.com/q/22907/2444).
Answer: You can obtain the optimal policy from the optimal state value function if you also have the state transition and reward model for the environment $p(s',r|s,a)$ - the probability of receiving reward $r$ and arriving in state $s'$ when starting in state $s$ and taking action $a$.
This looks like:
$$\pi^*(s) = \text{argmax}_a [\sum_{s',r} p(s',r|s,a)(r + \gamma v^*(s'))]$$
There are variations of this function, depending on how you represent knowledge of the environment. For instance, you don't actually need the full distribution model for reward, an expected reward function and separate distribution model for state transition rules would also work.
Without at least an approximate model of the environment, you cannot derive a policy from state values. If all you have is state values, then to pick an optimal action, you absolutely need the ability to look ahead a time step at what the next state might be for each action choice.
Comment: How would this extend to two player (and more than three or more player) games, say just adversarial zero-sum ones, assuming reward and transition probability is known? Specifically, how does the argmax work, since the next state corresponds to the next player? Is the state input to the value function ordered to be from the perspective of the current player?


java mysql innodb disable transaction

Question: how do I disable transaction temporarily if I'm using innodb from java jdbc?  I'm doing a mass insert and wonder if it will speed up things. or should I just set autocommit to true?
Answer: Actually things will be a bit faster if you perform a mass insert in a single transaction, this is something opposite to setting autocommit to true. Insert will go much faster if you perform it via the "Handler socket" plugin, latest Percona Server already includes it.
Comment: With large tables that's not true.
In my case it takes 5 days to make a INSERT INTO SELECT * FROM.
If I instead insert in 10k chunks it takes 2 hours.

And the 5 day statement has another problem: If I cancel it there will be a slow rollback takeing weeks to finish.
The only way to free that table again is to start mysql in crash recovery mode.

java mysql innodb disable transaction