Differences Between Rijndael and AES

Question: I'm investigating encryption algorithms - can someone give me a quick rundown of the differences between Rijndael and AES?
Answer: AES is a United States federal standard, FIPS 197, which is a subset of Rijndael:

AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with block and key sizes in any multiple of 32 bits, with a minimum of 128 bits and a maximum of 256 bits.

From Advanced Encryption Standard on Wikipedia.
Answer: Strictly speaking, the Advanced Encryption Standard (AES) is not an algorithm. AES is a specification defined by the National Institute of Standards & Technology of the United States (NIST). AES is the successor of the Data Encryption Standard (DES).
AES has been announced in FIPS PUB 197 on November 26, 2001. Federal Information Processing Standards Publications (FIPS PUB) are issued by NIST after approval by the US Secretary of Commerce.
Rijndael is a symmetric key encryption algorithm created by Joan Daemen and Vincent Rijmen. It is a block cipher, with variable block size, variable key length & variable round number. Block length and key length can be independently specified to any multiple of 32 bits from 128 bits to 256 bits.
The Rijndael cipher as been selected as the Advanced Encryption Standard (AES).
In the Rijndael AES variant the block size is restricted to 128 bits and key length to 128, 192 or 256 bits only.

NIST document on naming for
AES/Rijndael
NIST FIPS PUB
197
Answer: Actually in the crisis of 3DES(Triple Data Encryption Standard) NIST decided to establish a new standard. AES is the standard actually taken by the algorithm based on Rijndael algo which is nothing but the combination of two research scientists name Dr. Rijmen and Dr. Daemen according to the algo they fixed the size of the block length to 128bits and the key size also 128 or 256 bit. Later at standardization it is mentioned in Advanced Encryption Technique (AES) that the symmetric block cipher with 128 bits can support 128,192 and 256 bits or 16,24 and 32 byte
Answer: AES is a reduced version of Rijndael where it is only defined for block sizes of 128 bit whereas Rijndael is defined for block sizes of 128, 192 and 256 bit. If a different block size between encryption and decryption is used, then it is not possible to recover the original plaintext.
Rijndael-256 and Rijndael-192 must be seen as completely different algorithms from AES (Rijndael-128). They are inherently incompatible.

Differences Between Rijndael and AES


how to install android untivirus and instert an external SD card for storage purposes

Question: My android has been hit by a virus and I can't recover my space even if I delete some files it still says I have 0 B and when I insert an 8 GB memory card its not reading what should I do
Answer: Ok first, antivirus in the classical sense is almost useless on android. Due to the strong security sandboxing, antivirus apps can only detect malicious apps based on signatures but cannot stop or remove them. So you need to take care yourself to get rid of the malware.
Second, viruses in the classical sense also rarely exist on android, so please provide more infos on what exactly your malware is doing. If I got you right, you have some problem with blocked/filled up storage.
Third, just to exclude something completely independent of malware activity, did you ever use the newly inserted sd card in an android phone?  You may need to format the card before it can be used, see storage settings.
Summary: please check if your sd card is properly formatted and also provide more details on your problem and the malware you assume you have on your phone.


Text suggestion for linear algebra and geometry

Question: I want to study more linear algebra over the summer, specifically relating it to geometry. I was originally going to read Shafarevich's Linear Algebra & Geometry, after a recommendation, but it has no exercises. Can anyone suggest a similar text? As for my related background, I learned linear algebra from Hubbard's Vector Calculus text, I've worked through most of Axler's LADR, and through chapter 5 or 6 of Artin.
Comment: Kostrikin/Manin, "Linear Algebra and Geometry", http://books.google.de/books/about/Linear_algebra_and_geometry.html?id=r28nV_sIoxwC&redir_esc=y , sounds like a natural suggestion.
Comment: That text looks nice. Does anyone have a similar suggestion that is less expensive (or free)?
Comment: I found some answers to my question in answers to this post:

http://math.stackexchange.com/questions/60918/what-is-the-connection-between-linear-algebra-and-geometry?rq=1 ... more suggestions are welcome.
Comment: You might find my answer to books about [Linear algebra and geometric insight](http://math.stackexchange.com/questions/1032723) useful.
Answer: In my opinion, having a basic knowlegde of algebra (Axler is very good, for sure), I would bet on learning different small topics from different books, because it is rather difficult to find everything in one book. If you want to have deeper insight in linear algebra with applications to geometry, I would suggest you to study the following (advanced) topics:

Tensor, symmetric and antisymmetric vector spaces (that is, given vector spaces $V$ and $W$, to construct the objects $V\otimes W$, $Sym^r(V)$, $\bigwedge^n V$) together with a  review of basic algebra from a higher point of view. For this item, I have found an extremely good source, Multilinear Algebra and Applications. It will help you have a solid ground on linear algebra, being a quite nice book.
Basic Lie Theory: I strongly reccomend you Naive Lie Theory. It is a must for someone wishing to relate linear algebra and geometry. Exceptional good book.
(Optional) Clifford Algebras: this is a bit more difficult but nevertheless useful if you have time enough, at least to have a rough idea. Please read the article here and then try to read the first 20 pages of Spin Geometry.

I think this is a good planning to study in summer. The references are nice and easily readable, but also having a higher level.
Comment: +1 for Iozzi's notes-I was completely unaware of them and they are quite good indeed!
Answer: I spent nearly 3 years looking for an understanding as to how linear algebra related to geometry and how this approach was supposed to unify the subject, I have looked at every single one of the books mentioned here and none of them answered my question.
The best versions of what all these books are trying to do (in terms of relating all of linear algebra to geometry) are two rare books, one by Fekete "Real Linear Algebra", whose introduction absolutely must be read to get a sense on how to view linear algebra as a whole, and another by Dieudonné "Linear Algebra and Geometry", which is extremely geometric in spirit, uses very rigorous notation and whose introduction stresses the distinction between affine and metric properties of Euclidean geometry,
Comments such as Artin's famous comments on linear transformations, or the notion that a determinant should be interpreted as a homothety of volumes (best done in Dieudonné!) etc... make it seem like some deep unified view of linear algebra in terms of geometry exists, e.g. that something that explains all the theorems with pictures may exist. Similarly chapters such as "Unitary Geometry" in Weyl's 'Group Theory and Quantum Mechanics' would only lead one to push harder in finding some unified interpretation of linear algebra, so who wouldn't want to check every good reference?
I've since found there is only a partial answer to this question, and the answer is Gelfand, once you have general relativity and quantum mechanics to actually guide you into seeing this. You can basically view the first chapter (on vector spaces and inner product spaces) as developing a geometric formalism, modelled on putting a vector space into a curved space (manifold), applicable to general relativity (and Euclidean geometry by extension), and the second chapter (on operators and linear transformations) as developing an algebraic formalism, modelled on complex numbers and polynomials (which Axler also mentions, as I'm sure you've read) mainly applicable to quantum mechanics (remember QM is not going to demand pretty geometric interpretations! Hence the importance of discarding the necessity for geometric interpretations here, and it unifies the subject when one does this!).
In rough overview, in Ch. 1 you first begin discussing the affine geometry of parallelism through the concepts of linear independence, bases, changing bases & isomorphisms (refer to Dieudonne for a lovely reason to see why you can think of this as affine geometry, more generally it follows Klein's view of affine/Euclidean/projective geometry as a geometry invariant under parallel/orthogonal/central projections, but there is a more technical sense in which the word Affine is used in linear algebra (see below) so be careful), then we add perpendicularity via an inner product to get Euclidean geometry (or Hermitian geometry if you want complex numbers) and discuss the general principles, then we strictly focus on orthogonal geometry (i.e. w.r.t. an orthogonal basis) via Gram-Schmidt & least squares and stuff. After this linear, bilinear and quadratic forms enter the picture, which is just another (general) way to talk about non-orthogonal (curvilinear) geometry, it just allows you to do Euclidean, Hermitian,  Minkowskian & Symplectic geometry in one fell swoop using the same ideas, and then the final sections discuss Lagrange's & Jacobi's methods for reducing a quadratic form to a sum of squares, which is just another way of saying Einstein's equivalence principle, i.e. that locally at any point of spacetime we can work as if we are working in an orthogonal geometry, but globally this will not be true, i.e. we can diagonalize our metric (a quadratic form) locally using these methods, but globally it will not hold! (The very last section is on Hermitian geometry, i.e. doing all this stuff over the complex numbers). Thus the picture is all motivated by imagining putting a vector (tangent) space to a curved manifold and invoking the equivalence principle locally. You can ignore all this and pretend we're studying the algebra for it's own sake as the other books do, but you don't get a unified motivation/explanation for what you're doing that way...
There is a similar way to naturally motivate all the Jordan normal forms, eigenvalues, adjoint, self-adjoint, normal, unitary etc... concepts of linear algebra & I'll write a big explanation up if you like this description so far.
Based on all this, I can now mention a more advanced version of Gelfand & Shafarevich, namely Kostrikin, who has an exercises book does the affine stuff the way it's usually done & really does link operators with geometry (!), but I recommend this view as a secondary outgrowth/application of the algebraic interpretation to actually carrying out the Euclidean, Hermitian, Minkowskian & Symplectic geometry I mentioned above, because it doesn't unify the subject the way thinking about complex numbers/polynomials does. Basically you can view sections from chapter 2 of Kostrikin as like a chapter 3 of Gelfand mixing your ideas together, or perhaps just extended versions of his section on bilinear forms.
Thus, I recommend a mix of Dieudonné, Fekete, Gelfand & Kostrikin + exercise book. Hope this helps!
Answer: For more on the geometry, take a look at Berger's wonderful two-volume text Geometry. It's a very sophisticated treatment of classical geometries (not differential geometry), full of linear algebra. You might also look at Pedoe's beautiful book, Geometry, A Comprehensive Course, which uses multilinear algebra as well as linear algebra. There's also the beginnings of Lie groups, so you could look at Curtis's Matrix Groups.
Perhaps if you added a bit more focus to your question, we might be able to help you a bit more.
Comment: +1 for a very good list of uncommon sources-especially Berger,which sadly is ridiculously expensive for the average student and is a must have for those interested in a modern take on classical geometry via linear algebra.
Answer: As darij grinberg comments above, there's Linear Algebra and Geometry by Suetin, Kostrikin, and Manin; it's fairly difficult, but it should be accessible, given the time between now and when you originally asked this question. I didn't read all of it, but quite liked what I did. It has plenty of good exercises.
On a different level entirely (and not helpful for you, given that you've read Hubbard and Axler - I'm mostly putting this here in case someone else runs into this question) is Ted Shifrin's Linear Algebra: A Geometric Approach is a nice geometric approach to linear algebra. It's less abstract than the sources you give (and covers far less ground than Shafarevich's book does), but offers a lot of geometric intuition. He also prides himself on his exercises, in contrast to your experience with Shaferevich.
Answer: See also Advanced Linear Algebra, Steven Roman, chapters 9 and 14, just as a supplement.
Answer: The best general advanced linear algebra book I know is Module Theory An Approach to Linear Algebra by T.S.Blyth. It's beautifully written, very careful and modern.It has probably the most detailed treatment of multilinear algebra you'll find outside of a graduate algebra text. It may be a bit too difficult for your level, though. Check it out and judge for yourself.
I'm happy to report there are several excellent advanced books on the subject now available from Dover. A very good introduction to the geometry of linear algebra is Linear Algebra and Geometry: A Second Course by Irving Kaplansky. This is a strongly rigorous and abstract treatment by one of the masters of algebra of the last century. it focuses largely on the geometry of inner product and projective spaces,which are very naturally expressed in terms of linear transformations. I think you'll find this book very helpful indeed. Also from Dover and written by one of the true masters, is Linear Algebra and Projective Geometry by Rienhold Baer. It's considerably more difficult and specialized then Kaplansky, but I doubt you'll find a deeper treatment of the connection between these 2 important subjects. Lastly, one of the most comprehensive treatments of the relationship between classical geometry and abstract algebra can be found in Groups and Symmetry by Paul Yale. This is a surprisingly sophisticated treatment of not only groups of transformations,but the relations between rings and algebras and the classical transformations as well. A wonderful treatment you simply have to have and there's no good reason not to.
Comment: -1 for no reason at all. 'Tis the season for my trolls to give me agita...........
Answer: A bit different look, to build different intuitions:
Paul R. Halmos, A Hilbert Space Problem Book.
It cannot be the main textbook for you, but seems to be a good source of exercises on the border of linear algebra and geometry, from near elementary to very advanced ones.
Comment: Uh-I think that's not only too sophisticated for the reader's level, but more then that,it's only tangentially related to the subject matter requested.
Answer: N.Jacobson. Lectures in Abstract Algebra, vol 2. Linear Algebra.
M.M. Postnikov. Lectures in Geometry: Semester II. Linear Algebra and Differential Geometry.
Linear Algebra and Geometry
Shafarevich, Igor R., Remizov, Alexey
Translated by Kramer, D.P., Nekludova, L.
2013, http://www.springer.com/mathematics/algebra/book/978-3-642-30993-9
Comment: The third is what I was seeking an alternative to. Why do you recommend the first two?
Comment: @5space People in MSE are not reading the body of the question anymore. They read only what you put in the title. I've noticed this a lot in my questions.
Answer: I remember when I was in your situation trying to find the right source for good studying and intuitive thinking.
I recommend this MIT course with full video lectures, notes, problem sets, practice tests, and challenge problems (the best!). I personally like this course as a whole because it develops you intuition over you reasoning, which is what a mathematician needs. In addition, I have also learned from this course about a six months or so ago and with full knowledge and understanding of the subject of mathematics. I have done all the practice problems and even the challenging problems and that is what guided me through the course fast and efficiently. The course took me about a month or so to complete if you work really hard every day and constantly do problems so that the theorems and definitions just "stick."
Another recommendation is the edX course by The University of Texas at Austin (UTAustinX). It is actually a live online course that lets you interact with the community of other students in the program and the professors directing the course (which to me is quite amazing). the course features a real virtual classroom setting with homework and tests and even a certificate of completion in the end (if you make it to the end which I know you will :) ) I would recommend that you begin this course after you have gone through half of the MIT course. You have time; course starts on January $28, 2015.$
Another great source is the MIT OpenCourseWare. There are over $20$ different versions of teaching linear algebra by MIT professors. However, no matter which one you choose, you will have a great experience with the concepts.
In reference to learning geometry, I believe these course hold a firm foundation of high geometry. If you take a look at them and experience the course yourself, you will understand. However, if you would like a supplementary source specific to geometry, I think that your current answers have pretty good suggestions for that.
My final remarks: The internet is full of many great sources that you can choose from. If you ever have trouble or find my resources not helpful (I hope not!), then click here for what I did to search linear algebra resources. Again, no matter what you choose from my "arsenal," I bet that you will have a great intuitive experience with these sources. Also, it is always good to have more than one source when you are studying because you can compare and contrast the ideas presented by each other resource.
I understand that you are higher level. So I would recommend clicking here. You will be able to learn analytic geometry along with linear algebra in the first result. In addition, I will say that there are over a million results. You will have many graduate and undergraduate courses and lecture notes to work with to further you studies.
If you have anymore questions, just feel free to email me. Good luck with your studies!
P.s., I am sorry that I did not put it in a numbered list for you. I thought that it would be better in a paragraph format for both of our benefit, as I wanted to write a lot to make sure that you understand where each source can from and their format.
Comment: The material you suggest is on the elementary level. OP asks for more advanced texts and with connection to geometry.
Comment: Please let me know why I got down voted.
Answer: For linear algebra I recommend Linear Algebra and its Applications by Peter Lax.
Answer: A free online book A First Course in Linear Algebra by Robert A. Beezer


writing a chef cookbook for an application with lots of dependencies

Question: If i have a a software system that has a lot of dependencies on other libraries, like libssl, or libxml etc,  should I be creating separate cookbooks for each of these libraries (with a recipe that really only has like 2 lines)  or do people do several 'package' blocks in a cookbook to ensure the dependencies are there (and not split out these package blocks to their external cookbooks)?
Comment: Libraries can be a part of the software cookbook itself. ( Eg: libxml, libssl ). There are 100s of libraries and creating a cookbook for each of them doesn't make sense and is not practical.
Answer: If you only need to install package dependecies, you can do something simple like this:
%w{ package1 package2 package3 }.each do |pkg|
  package pkg
end

Or you can even create an attribute and iterate through those.
attributes/default.rb:
default['app']['deps'] = [ "package1", "package2" ]

recipes/deps.rb:
node['app']['deps'].each do |pkg|
  package pkg
end

The second way will allow you to update the package list via overrides.
You can even add this to a seperate recipe in your cookbook that you can add to the bootstrap run_list, or the application role.
Answer: As CS3 said it really isn't practical to have hundreds of cookbooks just to end up installing one application. Chef actually uses your system's package manager and can automatically resolve the dependencies for you.
The only reason you would want to split off a dependency is if you have some specific configuration items that may change across systems, or may vary based on the package that depends on it.
Answer: I would start by suggesting to just embed your dependencies like installing libssl-dev, libxml2-dev, libxslt-dev, etc directly in the cookbook that installs your application for simplicity.
Where this approach gets into trouble is if you ever deploy two different application cookbooks on the same image which both contain resources like package "libssl-dev" which is where you'll see a warning about CHEF-3694 resource cloning.  Since both cookbooks have a resource named the same thing you wind up with that problem, at some point we do want that to go away and we really want to move to a world where package "libssl-dev" is only defined once in the chef run.
You can then either start to collect those dependencies in a common cookbook that your application cookbooks will all include (if they're mostly the same deps for every application that you deploy).  Or else you can start breaking them out into different application subtypes or being very explicit about single-purpose cookbooks like the opscode xml and zlib cookbooks.
I would suggest creating a 'platform' cookbook that collects all kinds of misc base stuff that you tend to want on all your platforms (install lsof, tcpdump, strace, zsh, htop along with all the -dev/-devel RPMs and debs that you commonly need).  Until that list of things to install becomes too unwieldy then you would need to break it up.
All of this is debatable, though, and the advantage of more fine-grained cookbooks is that you understand your dependencies much better and your chef runs should have fewer resources and be smaller.  Its a bit of a tradeoff between manageability and precision.  As a best practice you probably 'should' break them all up.  But if too many 'shoulds' start getting in the way of doing real work, then I'd consolidate.
Berkshelf and test-kitchen and proper integration testing of cookbooks make it a lot easier to have smaller single-purpose cookbooks, but there's a learning curve there and its probably better not to get hung up on busting apart installing libssl-dev into its own cookbook until you're further down the road.


How to get height of iframe cross domain

Question: I have iframe (cross domain) with src from Facebook, Twitter or etc.
I need to get height of iframe but I got error:

Permission denied to access property 'document'
Answer: Couple issues. First, the height of the iframe is likely not what you want. I mean that's set explicitly in the HTML code of the page you control and is readily accessible and modifiable through any Javascript means. What it appears you are after is the height of the page inside the iframe. If that's the case, the simple answer is you can't, at least not with external services like Facebook/Twitter.
Due to security reasons, one can easily pass messages from child to parent, but not from parent to child, unless a communication pathway has been built into your javascript in both documents. There is a postMessage protocol for handling this in modern browsers. https://developer.mozilla.org/en/DOM/window.postMessage . But, it's wholly useless in this case unless the document you are communicating with is setup to handle an incoming postMessage, which to my knowledge Twitter/Facebook frequently are not.
If a parent document could freely communicate with children from different domains, then any javascript could effectively execute any series of commands on any site you're logged in as. The security implications of that are frightening and thankfully not possible.
Answer: There is no options in javascript to find the height of a cross domain iframe height but you can done something like this with the help of some server side programming. I used PHP for this example
<?php
$output = file_get_contents('http://yourdomain.com');
?>

    <?php echo $output; ?>

Comment: the problem about this is, that the css file of the iframe webpage is changing your actual css as it gets all linked files in the header
Comment: maybe putting the div touside the html document


spring boot 1.3.3 create multiple resttemplate per env

Question: I am on spring boot 1.3.3 version, I have a requirement where my spring boot application need to call endpoint(s) based on env passed,
which means if env passed as Dev i would need to call devendpoint,
if env passed as Dev1 then need to call dev1endpoint and so on.
So how can I do this ?
Do I need to create multiple restTemplate instances ?
Should I construct the resttemplate dynamically based on env passed ?
As part of constructing resttemplate i would also need to add appllicable interceptor based on env selected.
Plesae suggest.
Answer: You can have two beans of the same class. One can be labeled as the primary, and the use on the @Autowired can specify which one to use with the @Qualifier.
Example:
<code>@Configuration
public class MyConfig {
  @Bean
  @Primary
  public RestTemplate typicalConfig() {
    // various configs on your rest template
    return new RestTemplate();
  }

  @Bean
  public RestTemplate lessTypical() {
    // various alternate configurations
    return new RestTemplate();
  }
}
</code>
Now in your service class:
<code>@Service
public class MyService {

  @Autowired
  RestTemplate typicalRestTemplate;

  @Autowired
  @Qualifier("lessTypical")
  private RestTemplate alternateRestTemplate;

  ...
}
</code>
Answer: correct me if I didn't understand your question. I understand that you are going to have different environments but you are going to change this endpoints in runtime depends on some information or whatever, but I don't understand the part when you said you have to create multiple instances of restTemplate for that environments, from my experience on spring boot applications you don't have to do things like that, You just have to create your restTemplate configuration bean.
<code>@Bean
public RestTemplate restTemplate() {
    return new RestTemplate();
}
</code>
And then injected that object on your services class and do whatever you want with them. I recommend you to read the follow article about restTempalte may this could help you http://www.baeldung.com/rest-template
Comment: In my requirement, based on env passed I would need to set the relevant interceptor (Dev) to resttemplate.This interceptor contains the hmac details for that end point(Dev env ).So next time when different env (Dev1)passed I would need to remove Dev env interceptor from resttemplate and then add Dev1 env interceptor to restemplate.So this way i can resuse the same resttemplate instance.Is that possible to do this ?
Comment: I have a similar requirement due to differing authentication requirements. It's a pity this didn't answer the question asked.


Problem with keyboard on Del xps 12 9q33

Question: I recently purchased a used Dell XPS 12 9q33. This is a Dell 2-in-1 laptop from about 2013. I've installed Ubuntu 20.04 dual booting with Windows 10 on this machine. Everything works great and Ubuntu 20.04 runs much faster than does Windows 10 except that there is an annoyance with the keyboard.If I type a word where there are two identical letters one after the other, such as 'too' then the second letter will not appear, e.g. I get 'to' unless I slow down my typing and make a small pause before repeating the letter. (If you look at my message you will so that I had to handle this issue quite a bit while creating this note!!) Any advice on how to correct this issue? Its specifically a Linux problem as the keyboard works fine under Windows.
Answer: weird - the answer is to delete the .config/dconf/user file in my home directory. See about 3/4 down on the following web page.
http://www.linuxquestions.org/questions/linux-mint-84/keyboard-repeat-problem-on-dell-xps-12-running-mint-linux-17-2-a-4175559054/


Not able to send emails through Microsoft Outlook on iPhone

Question: I use Microsoft Outlook as my email client but I also have separate Gmail account on my iPhone 4S which has no problems sending or receiving emails. On my Outlook account at home I can always receive and send emails but only receive from my iPhone. When sending a message from my iPhone it says that the recipient has been rejected by the server.
It keeps trying to send but keeps rejecting.
Comment: When you say that you use Microsoft Outlook as your email client, do you mean the desktop client or the web client (outlook.com)?  If it's the latter, then the answer from HelpingHand is the one you need.  If it's the former, then you'll need to tell us who provides your email service (your employer, Comcast, or something else).  If you tell us what version of Outlook you're using, and on which operating system, we might be able to tell you how to get the necessary information out of Outlook.
Answer: There are two methods for adding an Outlook account to your iPhone:
In the Mail, Contacts, Calendars --> Add account section of the Settings app:

When adding the account you select "Hotmail" (Outlook) and type in your email and password.
You select "Other" and type all information required.

Unless its too hard and it may delete something that you need, delete the mail account, and create another one using the opposite method of how you originally created it.
This may help. (If it does, upvote or confirm)
Answer: When you add an account to your email accounts, have you entered the correct information?
I have my work email address connected through MS Exchange fine, and is on my iPad.
<code>Email: email@example.com
Server: mail.outlook.com
Domain: outlook.com
Username: email@example.com
Password: *****
Description: Outlook Emails
Use SSL: On
</code>
Obviously, you replace the details with your own.


Adjusting brightness and contrast on an ASUS monitor?

Question: I feel really silly having to ask this but I can't figure out how to use the brightness and contrast buttons on my ASUS VS247H monitor. The buttons are clearly labeled but they don't seem to do anything. I've tried a quick press, long press, and in different "mode" contexts. The on screen setup menu shows the values for brightness and contrast, but they're always grayed out.
Answer: I just had this problem and discovered it was because I had "eco" mode turned on (under system setup).
Comment: I had the same issue on my ASUS PB278 and turning ECO Mode OFF in System Setup solved the problem for me as well and I was then able to adjust brightness and contrast settings for all Splendid profiles.
Comment: 2021 and I swore I wouldn't have to google it. I did. Who designs their UIs? Jesus.
Answer: Since this came up as a first page result for my search for "asus tuf gaming vg289 brightness",
I found in my case it was because Mac OS had defaulted "High Dynamic Range" to enabled. If you disable that, then you can configure all the brightness settings with monitor's buttons.
Comment: thank you! This is exactly what I was looking for.
Answer: It's been 3.5 years, and I have a different Asus monitor, but to fix this I disabled Game mode and Eco mode in the system setup, and changed the splendid mode to standard. After that I was able to adjust brightness and contrast separately.
Comment: A bit unrelated question to the post (sorry for this): When you control the brightness setting on your Asus monitor, does it actually make the amount of light more/less intense (dimming the backlight)? Or does it just make the image kind of more/less gray like on regular TVs? (Again sorry for the offtopic, but I am wanting to buy one and have no way to verify this!)
Answer: I fixed this problem by doing this in the screen menu:
System setup > All Reset > Yes
I just got this screen, but it appears it locks all the modes in the 'splendid' tab...
Answer: For a Asus ProArt Monitor the solution is as follows in 2021:

ProArt monitors can select different Preset modes in the OSD menu
according to needs,
sRGB mode is made according to the standard provided by the sRGB
definition, so it cannot adjust the color settings, including the
brightness.
If you want to set the monitor to sRGB color gamut, but you want to
adjust the brightness or other color settings according to your
preferences,
You can select Rec.709 mode and modify it. The color display of this
mode is the same as that of sRGB mode, but it can be adjusted various
color settings.

https://www.asus.com/support/FAQ/1043885


Minimum torque required to turn a large gear

Question: I want to preface this by saying that this isn't homework, it's just a question I've made up myself (so it could just be impossible to solve), and I am a beginner so apologies if I miss something obvious.
I'm asking this question to confirm whether my reasoning is correct, and if it isn't where I went wrong / what I missed.
Let's say I have a very large gear (specifically a pinion) on a rack (which cannot move at all, only the gear may move up and down the rack, and it is free to do so for any distance (for all intents and purposes the rack is infinately long)) with $n$ teeth, a radius $r$ (which extends from the centre of the gear to the tip of the teeth), a static friction constant $\mu_s$ with the rack it is touching, a depth/length $\ell$, a mass $m$ and $\tau_{\text{applied}}$ is the torque I apply to the centre of the gear to turn it. It is some positive number. In what range must that torque be to turn the gear? I.e.: $\tau_{\text{min}} < \tau_{\text{applied}} < \tau_{\text{max}}$. Below $\tau_{\text{min}}$ the wheel would just not be able to tilt over the rack and start moving, and above $\tau_{\text{max}}$ the gear will start slipping and be considered to not work at optimal efficiency.
To calculate $\tau_{\text{max}}$ I get the force exerted on the tip of the wheel by doing $\frac{\tau_{\text{applied}}}{r}=F$. There will be friction $F_{f\text{, max}}$ opposing this and it is equal to $F_{f\text{, max}} = \mu_s N$, and since the downwards force on the gear is $-mg$, the normal must be $N=mg$ as $\sum{F_y}=0$, so $F_{f\text{, max}} = -\mu_s mg$ (negative as it is acting in the opposite direction to $F$. This means that in order for $\sum{F_x}=0$, $F$ must be at maximum $\mu_s mg$ at all times, hence $\tau_{\text{max}}=\mu_s mg \cdot r$.
To calculate $\tau_{\text{min}}$, I reason that to be able to turn and go past the turning point enough such that the centre of mass surpasses it and it begins to topple, the force acting upwards on that point must be greater than $mg$, so the torque at the turning point must be $\tau_{\text{min}}=mg \cdot d$, where $d$ is the distance from the turning point to the centre of the gear tooth. Since each gear tooth is equidistant, the width $w$ of each tooth must be $w=\frac{2 \pi r}{n}$. This means that $d=\frac{w}{2}$, or $d=\frac{\pi r}{n}$. So the minimum torque required to start to turn the gear would be $\tau_{\text{min}}=\frac{mgr}{n} \pi$.
Therefore the torque $\frac{\pi}{n} \cdot mgr < \tau_{\text{applied}} < \mu_s \cdot mgr$
This would also mean that when $\frac{\pi}{n} \ge \mu_s$ there would be no possible $\tau_{\text{applied}}$ to have turning without slipping.
Is this correct? If not, where have I gone wrong / what have I missed?
Comment: You should really clarify this with less description and more of a drawn out diagram showing where all things are defined, it will make it more clear to people viewing the post.
Answer: The purpose of a "rack and pinion" is to convert the circular motion of the gear into linear motion of the rack$^1$.
To roll the gear, torque would work against inertia and friction in the same way a smooth wheel (like a rail road locomotive) would.
However, some systems that you propose do exist for climbing steep grades.  If the gears are properly made, resistance to turning or slippage will be minimal.  It will essentially ride along with its teeth applying force to the matching component of the rack.
You would want the teeth long and strong enough not to slip or break.
$^1$ as in rack and pinion steering


Capsules and caffeine: How many Nespresso capsules are too many for a days? Is caffeine content different in different types of capsule?

Question: And the last question here: is there a big difference between squeezing a capsule once and twice concerning caffeine content?
Comment: Welcome to Coffee! It is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions.
Answer: How many are too many for a day depends on which you're using. As you suspect, different pods might have different levels of caffeine. Darker roasts tend to have less caffeine, while lighter roasts and flavored coffees likely have more caffeine. From what I can tell, it looks like Nespresso pods ought to vary between 50 and 150 milligrams per pod with the majority of varieties in the 70-80mg range.
Regarding caffeine consumption, please understand that we are not doctors and cannot provide medical advice. Everyone is affected differently by caffeine. If you're looking for your own limit, start at 2 Nespresso brews per day (140-200mg) and work from there. Also, coffee itself isn't generally harmful to people, though sweeteners, including milk (lower fat milks tend to be higher in sugar), can be.
Lastly, regarding caffeine extraction, the answer depends on some variables. Coffee grind size, water temperature, brew time, brew method, and amount of caffeine in the coffee all affect this. For the Nespresso, which uses pressure to draw a relatively short extraction somewhat like an espresso machine, the first brew probably extracts about 60% of the caffeine, while a second brew of a once-used pod might get you 80%. This is just a guesstimate based on what I know about espresso brewing.


Which features of a data set can be used for market campaigning using propensity scores?

Question: A dataset contains so many fields in which there is both relevant and irrelevant field. If we want to do a market campaigning using propensity scoring, which fields of the data set are relevant? How can we find which data field should be selected and which drive to the desired propensity score?
Answer: If you take a machine learning approach, the machine learning model would automatically find which features to weigh to predict an outcome.
For example, a decision tree would tell which combination of features are associated with higher propensity scores.


The right way to pack BGRA and ARGB color to int

Question: In SharpDx BGRA shift for red is 16:
(color >> 16) & 255
see here.
But in .NET, ARGB shift for red is also 16:
private const int ARGBRedShift    = 16;
see here and here and here.
I'm confused, what's right?
this (like .NET):
public int PackeColorToArgb()
{
    int value = B;
    value |= G << 8;
    value |= R << 16;
    value |= A << 24;

    return (int)value;
}

or this (like SharpDx):
public int PackeColorToArgb()
{
    int value = A;
    value |= B << 8;
    value |= G << 16;
    value |= R << 24;

    return (int)value;
}

For .Net 0xFFFF0000 is Argb Red, but for SharpDx this is Bgra Red. what's right?
Comment: What do you mean "what's right" ? Can you clearly state the issue you're facing?
Answer:
The right way to pack BGRA and ARGB color to int

That depends on where you're going to use the int. But for the two examples you've provided, you'll pack the byte values into the integer value in exactly the same way. They are both "right". It's only the name that's different, and you can have many different names for the same thing.
Importantly, your second code example — supposedly "correct" for SharpDx — is not correct for the color format you're asking about. You can see right in the source code you reference, while you are packing the bytes in the order A, B, G, and R, LSB to MSB, the correct order of component is in fact BGRA (again, LSB to MSB).
Your second code example should look just like the first.
Long version…
As you can see from the two source code references you've noted, the actual formats are identical. That is, the format from each API, stores the byte values for each color component in the same order, within a single 32-bit integer: blue in the lowest 8 bits, then green, then red, then alpha in the highest 8 bits.
The problem is, there's no uniform standard for naming such formats. In the context of .NET, they list the color components in big-endian order (which could be thought of as a little ironic, since so much of the Windows ecosystem is based on little-endian hardware…but, see below). I.e. the most-significant byte is listed first: "ARGB". I call this name "big-endian order" simply because that name is consistent with a scenario in which one stores the 32-bit integer in a sequence of 4 bytes in memory on a computer running in big-endian mode. The order of component initials in the name is the same order they'd appear in that context.
On the other hand, in the context of SharpDx, the name is consistent with the order of bytes you'd see on little-endian hardware. The blue byte would come first in memory, then green, red, and finally alpha.
Fact is, both of these are somewhat arbitrary. While most mainstream PCs are running in little-endian mode now, which would argue in favor of the SharpDx naming scheme (which is inherited from the DirectX environment), these APIs both also can be found on big-endian hardware as well, especially as .NET Core is gaining traction. And in a lot of cases, the programmer using the API doesn't even really care what order the bytes are in. For code that has to deal with the individual bytes, it's still important, but a lot of the time it's more about just knowing what format the tools you're using is writing bitmaps in, and then making sure you've specified the correct format to the API.
All that said, I suspect that the main reason for the discrepancy has less to do with big-endian vs little-endian and more to do with underlying philosophical differences between the people responsible for the API. The fact is, even on big-endian hardware, the SharpDx format for a pixel where the components show up in memory in BGRA order will be "BGRA". Because, bitmap formats don't change just because the byte-order mode of the hardware is different. A pixel is not an integer. It's just a sequence of bytes. What will be different is that the shift values will have to be different, i.e. reversed, so that for code that does treat the pixel as a single 32-bit integer, it can access the individual components correctly.
Instead, it seems to me that the .NET designers recognized that the users of their API will most of the time be dealing with colors at a high level (e.g. setting the color of a pen or brush), not at the pixel level of bitmaps, and so naming the pixel format according to conventional order makes more sense. On the other hand, in SharpDx people are much more often dealing with the low-level pixel data, and having a name that reflects the actual byte-wise sequence of components for a pixel makes more sense in that context.
Indeed, the .NET code you've referenced doesn't involve bitmap data. The Color struct is only ever dealing with single int values at a time, with respect to the "ARGB" nomenclature. Since conceptually, we imagine numbers in big-endian format (even for decimal, i.e. with the most-significant digits first), ARGB is more human-readable. On the other hand, in the areas of .NET that do involve byte order in pixel formats, you'll find that the naming goes back to being representative of the actual byte order, e.g. the list of PixelFormats introduced with WPF.
Clear as mud, right? :)


moveToThread(qApp->thread()) and signal-slot

Question: If I understand correctly, slots will always occur in the main thread.
So what is the difference between using the signal-slot system and moveToThread(qApp->thread())?
Answer: Your understanding is incorrect.
Each thread has its own event queue, so when a signal is emitted, if the connection is queued (not direct), it will be added to the event queue matching the thread affinity of the object.
For example: -
Let's assume that we have 2 objects; object1 running on the main thread and object2, which has been moved to a new thread.
connect(object1, &SomeObject::signal1, object2, &SomeOtherObject::signal2);

When object1 emits signal1, an event is posted to the new thread; the thread to which object2 was moved.
When the new thread processes its event loop and the event for signal1 it will execute object2's slot, signal2. This is not on the main thread.
Comment: thank you so much. I have acouple of questions:
1. what is "thread affinity of the object"? the thread that the object was created in?
2. so if I'm in a worker thread and I want to change the gui, I need to do it from the main thread. I can only use moveToThread() function? what about invokeMethod?
Comment: Thread affinity is the thread on which an object is running. If object2 starts on the main thread, it has thread affinity with that thread. Move it to thread2, then its thread affinity is thread2. *I want to change the gui* - what do you mean by this? The GUI must (with rare exceptions) be on the main thread. invokeMethod is another way of calling a slot of an object, usually on a different thread, but doesn't require connecting an object with a signal.
Comment: when I create a new widget I get the error: widgets must be created in the gui thread. I tried to use moveToThread(qApp->thread()) before I create the new widget but I still get the error.
Comment: Then I suggest starting a new question with examples of your code. You can read about how to create a good example [here](http://stackoverflow.com/help/mcve)
Answer: Each QObject tree can be assigned to a specified thread. moveToThread means move tree of objects (for given root object) to that thread.
That doesn't mean that that all code of the QObject is assigned to that thread. It means that any slot invoked by queued connection  (not direct connection) will be invoked in given thread. Read carefully documentation of QObject::connect and Qt::ConnectionType.
Except for Qt::DirectConnection, all connections use the owning thread of the receiving object to deliver the signal. All arguments are packed and sent to the receiver's event queue. When the receiving thread's event loop gains control it will unpack the arguments and invoke the slot.
Note that I wrote above about a tree of objects. You can't move an object to a different thread if it has a parent.  And you can't reparent an object to one that belongs in a different thread.
By default objects are assigned to thread which created them (if they do not have a parent). So it doesn't have to be main thread.
Answer: Thread a,b,c;
a created b,  b created c;
connect(a, &QThread::finished, a, &QObject::deleteLater);
connect(b, &QThread::finished, b, &QObject::deleteLater);
connect(c, &QThread::finished, c, &QObject::deleteLater);

I do some experiment, found that if b had finished faster than c, c would not be deleted; But can do that:
    b->moveObject(a);   //then b would be deleted again.


Why does mother cat attack me if I clean kitten's pee?

Question: My cat attacks whoever cleans her kittens pee or pooh. Except if it was me cleaning it. Why? What does she think of this? If I cleaned it, she'd just check the clothe and it's over. It seems shes satisfied. If anyone else comes near the pee of her kittens it's war. She allows her kittens to be handled and played with though.
Answer: female cats are very protective of their kittens and the waste the kittens make do have the smell of them so this might trigger the mothers protective instinct.
the mother trust you more than the other people around for now,but this is not positive for the kittens they need human interaction to be good house cats.
you do not say if the mother cat allows the kittens to be lifted and played with by other people,it is important for the kittens to have human interaction from the time their eyes open for them to be used to people.
Comment: This is the reason I am asking this, because she lets anyone carry the kittens and play with them, but she gets aggressive when someone cleans their wastes as if they really want to.
Comment: i am not sure why she does this,cats do strange things i do not think i will ever fully understand them.it is the mothers job to clean the kittens so mabe she dissaproves of the method used i simply do not know.
Answer: Predators are likely to check out urine and faeces to get the smell of their prey before they start hunting. Your cat trusts you, but not anyone else, since they might be predators.


What are the primary differences between Haskell and F#?

Question: I've searched on the Internet for comparisons between F# and Haskell but haven't found anything really definitive. What are the primary differences and why would I want to choose one over the other?
Comment: The nice thing about F# is that due to its mixed paradigm it provides a better starting point for the OO programmer.  He can gradually come up to speed with functional thinking and still fall back on using familiar OO libraries as he would have in C#.  Haskell forces the whole functional enchilada on you all at once.
Comment: It's important to note that F# is not a functional programming language. It adopted quite a bit from FP however, so it's possible to find perhaps many similarities, but nevertheless primarily I'd say they're entirely different languages.
Answer: Haskell is a "pure" functional language, where as F# has aspects of both imperative/OO and functional languages. Haskell also has lazy evaluation, which is fairly rare amongst functional languages.
What do these things mean? A pure functional language, means there are no side effects (or changes in shared state, when a function is called) which means that you are guaranteed that if you call f(x), nothing else happens besides returning a value from the function, such as console output, database output, changes to global or static variables.. and although Haskell can have non pure functions (through monads), it must be 'explicitly' implied through declaration.
Pure functional languages and 'No side effect' programming has gained popularity recently as it lends itself well to multi core concurrency, as it is much harder to get wrong with no shared state, rather than myriad locks & semaphores.
Lazy evaluation is where a function is NOT evaluated until it is absolutely necessary required. meaning that many operation can be avoided when not necessary. Think of this in a basic C# if clause such as this:
if(IsSomethingTrue() && AnotherThingTrue())
{
    do something;
}

If IsSomethingTrue() is false then AnotherThingTrue() method is never evaluated.
While Haskell is an amazing language, the major benefit of F# (for the time being), is that it sits on top of the CLR. This lends it self to polyglot programming. One day, you may write your web UI in ASP.net MVC, your business logic in C#, your core algorithms in F# and your unit tests in Ironruby....  All amongst the the .Net framework.
Listen to the Software Engineering radio with Simon Peyton Jones for more info on Haskell: Episode 108: Simon Peyton Jones on Functional Programming and Haskell
Comment: @JonHarrop: That's a statement about algorithms, which is unrelated to the applicability of compiler optimizations. Enforced purity languages generally allow you to write explicitly impure code if you really need to (if nothing else, using an FFI to call C). The compiler can apply code transformations more freely when it isn't bound to preserve the order of (unknown) side effects. In "encouraged purity" languages you write mostly similar code so the same optimizations would be applicable, only they might invalidate side effects (which aren't there, but the compiler can't assume that).
Comment: Another feature worth pointing out is that a language that enforces pure programming, the compiler has a LOT more freedom for many optimizations. Languages like F# that encourage purity but still allow unchecked impure operations to be dropped inside any block of code lose out on some potential optimizations, as the compiler is forced to assume every call contains necessary side effects.
Comment: Another potential major benefit of F# (depending on the situation) is that it's not lazy, which means that the learning curve for reasoning about space-time behaviour will be much simpler for virtually everyone.
Comment: Direct link to se-radio Episode 108 (Simon Peyton Jones):
http://www.se-radio.net/podcast/2008-08/episode-108-simon-peyton-jones-functional-programming-and-haskell
Comment: @JonHarrop When did I claim they were all algorithms? In any case, we're comparing Haskell and F#, not Haskell and C. F# is an "encouraged purity" language, so you often write pure code. All I'm claiming is that the *exact same code* can often be better optimised by the compiler in an "enforced purity" setting, because the F# compiler has to assume that calls have side effects. You're talking about rewriting the code to use a different algorithm (one which depends on side effects); I'm taking about the "optimisability" of pure code in F# vs Haskell.
Comment: @Ben "the compiler has a LOT more freedom for many optimizations". Only in theory. There are no known competitively-performant purely functional solutions to many common problems in practice, e.g. sorting, dictionaries, graph algorithms, union-find.
Comment: excellent description of polyglot programming (+1)
Comment: one point is that lazyness is not a differnece to F# see: http://weblogs.asp.net/podwysocki/archive/2008/03/21/adventures-in-f-f-101-part-6-lazy-evaluation.aspx
Comment: From looking at that blog, F# has manually declared laziness and manual forcing. That's a pretty huge difference from Haskell's implicit-laziness-everywhere approach.
Comment: @Ben "The compiler can apply code transformations more freely..." And what is the sole purpose of those optimizations? To improve performance. And is the resulting performance competitive in practice? No, it isn't. For example, on all of the problems I already referred you to. Note that they are not all algorithms as you claim.
Comment: @JonHarrop This is a question about differences between Haskell and F#, not about whether the performance of pure functional programs can be "competetive in practice" with that of imperative programs.
Comment: @Ben "When did I claim they were all algorithms". When you wrote "That's a statement about algorithms" about my statement that was not solely about algorithms.
Comment: @Ben "the exact same code can often be better optimised by the compiler". Sure, I'm pointing out that the performance of the resulting code is such that these optimizations are of little practical value or interest. What is of value is the ability to drop down to efficient imperative code when you need the performance and that requires a VM optimized for imperative programming, i.e. not GHC.
Answer: Big differences:

Platform
Object orientation
Laziness

The similarities are more important than the differences. Basically, you should use F# if you are on .NET already, Haskell otherwise. Also, OO and laziness mean that F# is closer to what you (probably) already know, so it is probably easier to learn.
Platform : Haskell has its own runtime, F# uses .NET. I don't know what the performance difference is, although I suspect the average code is about the same before optimisation. F# has the advantage if you need the .NET libraries.
Object orientation : F# has OO, and is very careful to make sure that .NET classes are easy to use even if your code isn't OO. Haskell has type classes which let you do something like OO, in a weird sort of way. They are like Ruby mixins crossed with Common Lisp generic functions. They're a little like Java/C# interfaces.
Laziness : Haskell is lazy, F# is not. Laziness enables some nice tricks and makes some things that look slow actually execute fast. But I find it a lot harder to guess how fast my code will run. Both languages let you use the other model, you just have to be explicit about it in your code.
Minor differences:

Syntax : Haskell has slightly nicer syntax in my opinion. It's a little more terse and regular, and I like declaring  types on a separate line. YMMV.
Tools : F# has excellent Visual Studio integration, if you like that sort of thing. Haskell also has an older Visual Studio plugin, but I don't think it ever got out of beta. Haskell has a simple emacs mode, and you can probably use OCaml's tuareg-mode to edit F#.
Side effects : Both languages make it pretty obvious when you are mutating variables. But Haskell's compiler also forces you to mark side effects whenever you use them. The practical difference is that you have to be a lot more aware of when you use libraries with side effects as well.
Comment: see for [performance](http://www.slideshare.net/pt114/haskell-vs-f-vs-scala). Not sure how legit it is
Answer: F# is part of the ML family of languages and is very close to OCaml. You may want to read this discussion on the differences between Haskell and OCaml.
Answer: A major difference, which is probably a result ofthe purity but I less see mentioned, is the pervasive use of monads. As is frequently pointed out, monads can be built in most any language, but life changes greatly when they are used pervasively throughout the libraries, and you use them yourself.
Monads provide something seen in a much more limited way in other languages: abstraction of flow control. They're incredibly useful and elegant ways of doing all sorts of things, and a year of Haskell has entirely changed the way I program, in the same way that moving from imperative to OO programming many years ago changed it, or, much later, using higher-order functions did.
Unfortunately, there's no way in a space like this to provide enough understanding to let you see what the difference is. In fact, no amount of writing will do it; you simply have to spend enough time learning and writing code to gain a real understanding.
As well, F# sometimes may become slightly less functional or more awkward (from the functional programming point of view) when you interface with the .NET platform/libraries, as the libraries were obviously designed from an OO point of view.
So you might consider your decision this way: are you looking to try out one of these languages in order to get a quick, relatively small increment of improvement, or are you willing to put in more time and get less immediate benefit for something bigger in the long term. (Or, at least, if you don't get something bigger, the easy ability to switch to the other quickly?) If the former, F# is your choice, if the latter, Haskell.
A couple of other unrelated points:
Haskell has slightly nicer syntax, which is no suprise, since the designers of Haskell knew ML quite well. However, F#'s 'light' syntax goes a long way toward improving ML syntax, so there's not a huge gap there.
In terms of platforms, F# is of course .NET; how well that will work on Mono I don't know. GHC compiles to machine code with its own runtime, working well under both Windows and Unix, which compares to .NET in the same way, that, say, C++ does. This can be an advantage in some circumstances, especially in terms of speed and lower-level machine access. (I had no problem writing a DDE server in Haskell/GHC, for example; I don't think you could do that in any .NET language, and regardless, MS certainly doesn't want you doing that.)
Answer: Well, for one I'd say a main advantage is that F# compiles against the .NET platform which makes it easy to deploy on windows. I've seen examples which explained using F# combined with ASP.NET to build web applications ;-)
On the other hand, Haskell has been around for waaaaay longer, so I think the group of people who are real experts on that language is a lot bigger.
For F# I've only seen one real implementation so far, which is the Singularity proof of concept OS. I've seen more real world implementations of Haskell.
Comment: F# has already had several major success stories (Halo 3, AdCenter, F# for Visualization) that dwarf the nearest thing Haskell has to a success story (Darcs).
Comment: Worth pointing out that there are downside for this, of course. (CLR limitations)


Insider News Price Move

Question: If there is a big price move before an important event such as earnings report etc., should I take this into consideration because it might be leaked news?
Answer: I wouldn't use it to base any decisions on, it could be a result of many factors, none being a leak. Consider for a minute what size a leak you would need to actually move price in whatever instrument your looking at, that may help you put it into context.
If it moves down a few days leading into an ER, it could just be uncertainty or a bit of panic, which a positive ER can quickly erase.
Answer: I knew someone who had the inside track on the spin off date that had been speculated about for many years.  It was anticipated to be a good news event.  Option and stock volume increased steadily for a few days.  He loaded up on expensive calls (option premium expands when there is increased buying).  When the news hit, there was no reaction at all.  Option premium contracted immediately and the loss was baked in.  OTOH, had the stock gapped up, he would have had a tidy pay out.
The short answer is that you should take everything into consideration.  The real question is whether the price move before the news presages further move or the news is out and the move is over?  There's no way to know that.
Comment: To Bob's point, if you are concerned about that sort of information, you can also look at the insiders' buying and selling activity leading up to the earnings date. Usually when insiders are dumping their positions en masse, this is not a good sign. But as Bob said, you need to take everything into consideration.

Insider News Price Move


how to calculate max spendable from all wallet

Question: Using latest bitoind, any way to calculate max spendable from wallet with some amount of outputs? For example i need to send all wallet amount to 2 outputs and set mining fee enough to get confirmation in first block. How can i calculate max spendable amount?
Answer: In Bitcoin Core, there is the option to subtract the fee from the amount. When you create a transaction, you set the amount to be the maximum amounts, and then you enable the subtract fee from amount options which will then reduce the specified outputs by the fee. This way, you can choose to send your entire balance without change and have the fee be subtracted from the output.
In the GUI (bitcoin-qt), there is a checkbox labeled "Subtract fee from amount" which you can set for each recipient. You can use the "Use available balance" button to auto-fill the full wallet balance. It will also automatically check that option for you.
If you are using bitcoind over the RPC interface, sendtoaddress has a parameter subtractfeefromamount which you can set to true in order to deduct the fee from the amount you are sending. sendmany has a similar option but it is instead an array of addresses so you specify the addresses that will receive less due to the fee being subtracted from their amounts.
Comment: ye i know about subtractfeefromamount but i need to calculate amount before(!) send, so with your example we'll understand how much we sent only after processing transaction
Comment: You can use fundrawtransaction with the subtractFeeFrom option to construct a transaction (but not sign or broadcast it). Then you can look at the amount in the output to see how much will actually be sent.


WhatsApp with asterisk but not bold

Question: In WhatsApp how to send *something* with asterisk before and after the word without getting bold?
Answer: From WhatsApp help:

There is no option to disable this feature.

However you can type a space between asterisk and the first letter after it and MAYBE the text will not be bold on the receiver side (this "hack" depends on the smartphone model and does not work on iPhones).
Answer: I found this out by accident trying formatting out for the first time:
If the first asterisk immediately follows an emoji with no space between them, then the asterisks appear verbatim instead of making the word bold.
e.g.
(punching fist emoji)*BOOM* appears as (punching fist emoji)*BOOM*
but
(punching fist emoji) *BOOM* appears as (punching fist emoji) BOOM
I am using WhatsApp Messenger Version 2.17.24 on a BQ Aquaris E5 4G with Android 6.0.1

WhatsApp with asterisk but not bold


Can someone explain if this wiring is correct

Question:
Yesterday when I was replacing the old ceiling light fixture with a new led disc light in the laundry room, I notice the old light was being wired like the above diagram (probably by previous owners).
Basically there are 2 pairs of wire coming from 2 end of the electrical box. The neutrals (yellow in the diagram) were twisted together. The black wire (red in the diagram) of the light fixture was wired to the black wire (hot) from the power source and the neutral (white wire) of the light fixture was wired to the black wire on the other end of the box, which I believe is connected to the switch?
Can someone please explain to me what kind of wiring is this? and is this legal at all? Thanks.
P/S: the diagram was drawn on phone so please excuse me if it's not looking good.
Comment: Yeah, NEC 404.2(B) has prohibited what you're describing for somewhere close to a *century* now...
Answer: The details of this answer assume you are in North America. If you are elsewhere, you should add that information to your question.
Assuming you are correct in the wiring, then no, it is neither legal nor safe currently, though if the wiring is old enough, it may have been "normal" at the time.
The problem is that the switch is interrupting the neutral wire to the light while the hot wire goes directly to the light. The problem is that if you turn off the switch and go to work on the light without flipping the breaker (a bad idea but some people just depend on the switch), you can get shocked as the red wire to the light is still hot.
It should be very little effort to change the wiring so that the switch interrupts the hot instead. Also, on the white wire coming back from the switch, you should add a wrap of black tape or paint at each end to mark it as (switched) hot.


Can Entity Framework access In Memory OLTP Tables?

Question: Are there any restrictions with having Entity Framework access In Memory OLTP Tables? Or is this not possible?
Answer: I created a small test application to see if there were any issues accessing IMOLTP tables from Entity Framework.  My test application uses the latest stable version of Entity Framework (EF6).
With the default settings, I got this error initially trying to insert a row into a memory-optimized table:

SqlException: Accessing memory optimized tables using the READ COMMITTED isolation level is supported only for autocommit transactions. It is not supported for explicit or implicit transactions. Provide a supported isolation level for the memory optimized table using a table hint, such as WITH (SNAPSHOT).

This is because Entity Framework creates an explicit transaction automatically when using the "SaveChanges()" method (the most common approach for inserting rows):

In all versions of Entity Framework, whenever you execute SaveChanges() to insert, update or delete on the database the framework will wrap that operation in a transaction.

The simplest way to work around this in the case of EF is to turn on the database-level option MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT, which essentially adds the needed WITH (SNAPSHOT) hint automatically:
ALTER DATABASE [YourDatabaseName] SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT ON;

Other than that, there seems to be no issues with accessing the in-memory tables.  This isn't all that surprising, since under the covers Entity Framework is using the .NET Framework Data Provider for SQL Server (SqlClient), which has no documented limitations when it comes to in-memory tables.
Comment: Create an explicit transaction with the isolation level you want. EF will use that. This is best practice anyway because otherwise you can get a random isolation level inherited from the pooled connection for EF select queries.
Comment: @Josh Darnell Hi, Did your test program call a stored procedure to access (write?) the in-memory OLTP table?   Anybody tried this using EF5 & ObjectContext (rather than EF6 & DBContext)? From link above, looks like it might have same problem (transaction wrapper around operation) but solving it would not be straightforward/possible: for EF6 it says "ObjectContext.ExecuteFunction() does the same (except that the default behavior cannot at the moment be overridden".
Comment: @Zeek I didn't try calling a stored procedure.  However, since the fix I described is on the database side, I would expect it to still work with EF5 and ObjectContext (automatically elevating the default isolation level to snapshot).  Are you seeing different behavior, or you haven't tried it yet?


Webservice protection against big messages

Question: I am developing a WebService in Java upon the jax-ws stack and glassfish.
Now I am a bit concerned about a couple of things.
I need to pass in a unknown amount of binary data that will be processed with a MDB, it is written this way to be asynchronous (so the user does not have to wait for the calculation to take place, kind of fault tolerant aswell as being very scalable.
The input message can however be split into chunks and sent to the MDB or split in the client and sent to the WS itself in chunks.
What I am looking for is a way to be able to specify the max size of the input so I wont blow the heap even if someone delibratly tries to send a to big message. I have noticed that things tend to be a bit unstable once you hit the ceiling and I must be able to keep running.
Is it possible to be safe against big messages or should I try to use another method instead of WS. Which options do I have?
Well I am rather new to Java EE..
Answer: If you're passing binary data take a look at enabling MTOM for endpoint. It utilizes streaming and has 'threshold' parameter.


How to set up passwordless SSH access for root user

Question: I need to configure a machine so software installation can be automated remotely via SSH. Following the wiki, I was able to setup SSH keys so my user can access the machine without a password, but I still need to manually enter my password when I use sudo, which obviously an automated process shouldn't have to do.
Although my /etc/ssh/sshd_config has PermitRootLogin yes, I can't seem to be able to log in as root, presumably because it's not a "real" account with a separate password.
How do I configure SSH keys, so a process can remotely log in as root on Ubuntu?
Comment: If you automate installation from a central machine, you can limit the scope of the key so it will only be accepted from the given host. Simply prefix the line in authorized_keys with from="host.ip.goes.here" ssh-rsa [...]
Comment: At the end of the day, this question has a poor title. The user can already log in via ssh with a key without a password but now wants to run sudo without a password. I revised the answer to address both issues as this question is linked as how to generate a paswordless ssh key (due to poor title).
Comment: Not sure if someone else has answered this already but I had a similar issue when trying to git pull from root user on the same box. My solution was to set up a ssh key for root user and add its public key to the authorised_keys file for my git user. Wish I had done this earlier.
Answer: Part 1 : SSH key without a password
To set up a passwordless SSH connection for the root user you need to have root access on the server. Easiest method is to temporarily allow root to log in over ssh via password. One way or another you need root access on the server to do this. If you do not have root access on the server, contact the server administrator for help.
On the client (where you ssh FROM)
First make a ssh key with no password. I highly suggest you give it a name rather then using the default
ssh-keygen -f foo

The -f option specifies a file name, foo is an example, use whatever name you wish.
When you are prompted for a password, just hit the enter key and you will generate a key with no password.
Next you need to transfer the key to the server. Easiest method is to use ssh-copy-id . To do this you must temporarily allow root to ssh into the server.
On the server (where you ssh TO)
edit /etc/ssh/sshd_config
sudo nano /etc/ssh/sshd_config

Make sure you allow root to log in with the following syntax
PasswordAuthentication yes
PermitRootLogin yes

Restart the server
sudo service ssh restart

Set a root password, use a strong one
sudo passwd

On the client :
From the client, Transfer the key to the server
ssh-copy-id -i ~/.ssh/foo root@server

change "foo" the the name of your key and enter your server root password when asked.
Test the key
ssh -i ~/.ssh/foo root@server

Assuming it works, unset a root password and disable password login.
On the server :
sudo passwd -l root

Edit /etc/ssh/sshd_config
sudo nano `/etc/ssh/sshd_config`

Change the following :
PasswordAuthentication no
PermitRootLogin without-password

Restart the server
sudo service ssh restart

On the client (Test):
You should now be able to ssh in with your key without a password and you should not be able to ssh in as any user without a key.
ssh -i ~/.ssh/foo root@server

Part 2 : Running commands via sudo without entering a password
You configure sudo to allow you to run commands without a password.
This is answered here in two places:

How do I run specific sudo commands without a password?
How to run sudo command with no password?

Of the two, I suggest allowing as few commands as possible (first answer) rather then all commands (second answer).
Comment: @Ashimema for sudo -i see https://ubuntuforums.org/showthread.php?t=1817402 and https://askubuntu.com/questions/376199/sudo-su-vs-sudo-i-vs-sudo-bin-bash-when-does-it-matter-which-is-used and https://help.ubuntu.com/community/RootSudo#Special_notes_on_sudo_and_shells
Comment: @Ashimema - so you make a key ? Where did you make the key ? On the server ? so how does the client machine get the key ? On the client? so how does the key get to the server ? The "proper" ie easiest method is to make the key on the client machine (does not require root) and use `ssh-copy-id` to transfer the key to the server.
Comment: That escalated fast. Personally, I'm not impressed by the complete rewrite from a number of angles but as I'm not a regular contributor here anymore I'm really not in the frame of mind for further trolling. Thank you for linking to `sudo -i` information, it was an interesting read.
Comment: Way to remove lots of helpful comments
Comment: 'Make a key'.. original questions clearly stated they had already made a key and linked to documentation on how.
Comment: ssh-copy-id by default does add the users public key to /root/.ssh/authorized_keys.. so you've clearly not answered my question of how you accomplish passwordless ssh to root without the key being present in /root/ssh/authorize_keys
Comment: I was asked to re-write the answer. If you do not like it, revert the changes I made, that is fine with me. `ssh-copy-id` will add the public key to authorized_keys when you sign (log) in via password authentication, this is what ssh-copy-id does. Not to be rude, but your answer was poor quality as you do not need to use sudo to make the key, you did not explain how to transfer the key between server and client, and you do not seem to understand what ssh-copy-id does. I flagged your answer as poor quality and was asked to re-write it.
Comment: ssh-copyid is the easiset method to transfer keys between client and server and does not require physical transfer (flash drive), or manually editing authorized_keys. See https://www.ssh.com/ssh/copy-id "Once an SSH key has been created, the ssh-copy-id command can be used to install it as an authorized key on the server." and "This logs into the server host, and copies keys to the server, and configures them to grant access by adding them to the authorized_keys file. The copying may ask for a password or other authentication for the server."
Comment: Trying to move discussion to meta - https://meta.askubuntu.com/questions/17246/updated-an-question-answer
Comment: for me, `ssh-keygen -f foo` created the key file at `~/foo`, not `~/.ssh/foo` (so `ssh -i ~/.ssh/foo root@server` won't find it). I executed `ssh-keygen -f ~/.ssh/foo` instead.
Answer: You are confusing two different things:
passwordless log is used to make sure that people can't log into your system remotely by guessing your password.  If you can ssh username@machine and connect without a password, this is set up correctly, and has nothing else to do with this.
sudo is used to permit a normal user account to do something with super user permissions.  This does require the user to type their password.  This happens whether you are connected remotely (via passwordless or password-protected SSH) or are local on the machine.  You are trying to set sudo to not ask for your password, which is not recommended, but you can learn how to do that via an answer like https://askubuntu.com/a/74083/6161
Note to future readers of this answer:
My above answer does not answer the original poster's actual question, it describes what you should do instead.  If you really want to allow remote connections directly to the root account, you need to enable the root account (see my comment below).  Again, let me say DO NOT allow remote remote log-ins to your root account.
Comment: You're misunderstanding me. I know the difference between SSH and sudo. The problem is that I'm unable to ssh using root@machine. Using my "normal" account and adding it to my sudoers file would accomplish the same thing, but I was trying to do it solely through SSH. This is possible in Redhat based distros. I take your answer to mean this is not possible in Debian based distros.
Comment: sudo provides more fine-grained control. For instance, you could allow the non-root user to run apt as root without giving a password, but not arbitrary commands. Since your goal is automated software installation, you should use the least privileged solution to your goal.
Comment: @Cerin Ah - you want to enable root log-in http://askubuntu.com/q/44418/6161  Again, this is almost always a ***bad*** idea, ***especially*** when you're allowing external connections.  But, the link in the comment describes how to do it.
Comment: Thanks. Since my goal is automated software installation, does it matter whether I add a non-root user to sudoers, or allow root log-in? There both potential security concerns, but one of them is necessary.
Comment: @Cerin Yes, it does matter.  Beyond what Egil pointed out, http://askubuntu.com/q/16178/6161 is a whole discussion of why logging in a root is a bad idea.
Answer: Q. Login to remote host as root user using passwordless SSH (for example ssh root@remotehost_ip)
A. In order to login to remote host as root user using passwordless SSH follow below steps.
1st Step:
First you have to share local user's public key with remote host root user's authorized_keys file. There are many ways to do so, here is one example.
https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2
Or you can simply copy paste your public key content to remote host root user's authorized_keys file.
2nd step:
Configure ssh to permit passwordless login in remote host. Login to remote host and edit /etc/ssh/sshd_config file then restart ssh service. Do not forget to comment out "PermitRootLogin yes".
#vim /etc/ssh/sshd_config
PermitRootLogin without-password
StrictModes no

#service ssh restart

Comment out #PermitRootLogin yes
3rd step:
Test you connection from your local machine using user whose public key is shared earlier.
$ssh root@remotehost_ip

Comment: Turns out StrictModes no is important on some systems
Answer: PermitRootLogin controls whether the user named "root" (to be precise: any user with UID 0) is allowed to login. If you're logging as root, you do not need sudo to perform privileged tasks.
On the other hand, if you to login on a user account and use sudo without a password, you must configure the sudoers file without having to fiddle with /etc/ssh/sshd_config. See How to make Ubuntu remember forever the password after the first time


How to make iTunes video window float on top?

Question: In iTunes you can play videos in a seperate window. Is it possible to make that window stay on top? Preferably without any 3rd party apps?
Answer: Yes, there is an option under Preferences -> Advanced Preferences, under the separator saying 'Keep movie window on top of all other windows'.
The window may look slightly different than this (I found this example online), but the wording is still the same.
Answer: Yes it's a built-in feature and it's in iTunes preferences. Look Under the advanced tab as pictured below:
Make sure "Keep movie window on top of all other windows" is checked.
Comment: Where abouts? I had looked through preferences but couldn't find such an option?
Comment: I tried that as well. Where is the option in prefernces?
Answer: Along the same lines, you may want to "Float" other applications, such as a browser watching a playlist on youtube or even your facetime window like I do.  I use a program called Afloat that works well.
http://www.macupdate.com/app/mac/22237/afloat


What is the correct name for the ">" command

Question: I was trying to find how to pass some text to a file without overwriting what's there already using the > command and I realised I don't know what it's called. Searching for right arrow or right chevron or more than command didn't show up anything. I've always just called it pass to.
Answer: > is not a command but a file descriptor redirection. This means that the shell parses this assignment, removes it from the command line and changes the environment for the new process in which it is started. The new process does not notice this part of the command line. That's the reason why you can put it everywhere: At the beginning, at the end or in between.
Look for the REDIRECTION block in man bash.
In order to append to an existing file you need to use >>.
Comment: If the option `noclobber` is set, then `>|` will override and allow clobbering the file.
Answer: > is a redirection operator. Note that using > to redirect to a regular file will overwrite what is already there, unless noclobber is set. >> will append to the end of the file.
Comment: @HaukeLaging `noclobber` isn't just a bashism. It's [part of POSIX](http://pubs.opengroup.org/onlinepubs/009695299/utilities/set.html)
Comment: And it doesn't overwrite if `noclobber` has been set (bash).
Comment: Updated my answer, thanks for the clarifications.
Answer: As other people have answered, > is not a command, but rather a redirect operator. However, the term 'redirection operator' doesn't specifically refer to the >, but a number of different possible redirection operators. The dash man page lists the following as redirection operators:
 < > >| << >> <& >& <<- <>

I'm not sure there is a valid individual name for each one. Maybe if you dig through some old shell manuals you will find something interesting. This source, correct or incorrect, certainly has a go at naming some of them:
>  - 'output redirection operator'
<  - 'input redirection operator'
>> - 'output append operator'

But also:
2> - 'standard error redirection operator'

However I don't think this is really correct since the 2 is technically an argument rather than part of the operator.
A quick reference (in case you don't recognise any of the ones above):
>   - redirect output stream to a file, eg >somefile (for stdout) or 2>somefile
>|  - as above but overwrite the file even if the noclobber shell option is set
>>  - append output stream to file
<   - redirect input stream from file, n defaults to 0 for stdin
<>  - open file for reading and writing on stdin
>&  - redirect output stream to another stream (eg >&1) or close with - (eg 2>&-)
<<  - here document - see http://en.wikipedia.org/wiki/Here_document
<<- - here document with leading tabs removed.

In bash you also have:
<<< - here string, a one line here file. Eg <<<"foo bar"

Comment: Very nice quick reference list, but doesn't `<<-` remove leading tabs *and* spaces?
Comment: @iconoclast, nope, definitely just tabs.
Answer: >  redirects output to a file (or device) overwriting anything already existing there
>> redirects output to a file (or device) appending to anything already existing there
<  directs data from a file (or device) to a program or device
<< a here document
Comment: `<<` is a [here document](http://en.wikipedia.org/wiki/Here_document)
Comment: @ Graeme I edited my answer. Thank you for the help


My car want go into D but will go into 1st &2nd grear it's also been leaking transmission fluid what could be the problem 07 Buick lacrosse

Question: 2007 Buick GMC lacrosse CXL V6 Transmission fluid been leaking now it doesn't want to go into drive(D) but will go/work in 1st and 2nd
Comment: Welcome to Motor Vehicle Maintenance & Repair! When you say "it won't go into drive", do you mean it doesn't engage (start the car moving)? Have you been replacing fluid as it leaks out (as in, keeping it topped off every evening or whenever)? How much has been leaking out? How long has the leak been going on?
Answer:
fluid can be contaminated or you are running very dry

Pressure-range sensor is busted

Check engine codes for the speed sensor circuit - can be another notable cause

This is just aside mechanical damage to the gears.


Prove the following language is regular using closures

Question: How can I prove this language is regular using just closures and homomorphism?
$$
L = \{a_1b_1a_2b_2\dotsm a_nb_n \mid a_i \in L_1 , b_i \in L_2\}
$$
and we know $L_1$ and $L_2$ are regular.
Comment: What did you try? Where did you get stuck? We're happy to help you understand the concepts but just solving exercises for you is unlikely to achieve that. You might find [this page](http://meta.cs.stackexchange.com/q/1284/755) helpful in improving your question.  Also, I suspect what adrianN is asking is: Is $n$ fixed in advance (and the same for every word in $L$), or is it free to vary?
Comment: How is  $n$ defined?
Comment: n is a finite number
Comment: I'm trying to understand what are the steps i am supposed to do in order to solve this kind of questions. I don't know how to begin and would love to get some help.
Comment: Try to express $L$ in terms of $L_1$ and $L_2$ using some known algebraic operator. E.g. If we knew that (random example) $L = (L_1(L_1 + L_2)) \setminus L_2L_1$ we could conclude $L$ regular by the closure properties.
Answer: To get you started, consider a restricted version of your languge:
$$
L'=\{ab\mid a\in L_1, b\in L_2\}
$$
Notice that $L$ is the concatenation $L'=L_1\circ L_2$. Can you carry on from there?


how to give input to the block 'model' in simulink

Question: I am working in matlab simulink.There are two parts of my work.one is about control systems and the other is about image processing.I want to link them such that the control system part only receives a scalar input from image processing part.So i want to use the 'model' block attached to the image processing part such that there is a scalar input to the model block.How can I use this 'model' block such that it has an input port as I donot see any input port to this block.Please guide me.
Answer: The Model Block is used whenever you want to make use of a model inside of another model.  This is something that is useful, for example, when multiple people are working on a large system that is comprised of multiple self-contained systems each of which could be its own model, but that could also act together in some useful way.
If you are just using Model Blocks for the sake of organizing subsystems together, then you should consider using Subsystems, instead.  Subsystems allow you to group blocks together and do not require you to create separate models for each of your components (i.e. your Controller subsystem and your Image Processing subsystem).  You can easily make a Subsystem either by dragging in the Subsystem block from the Simulink Library Browser, or by selecting components in your model, right-clicking, and selecting Create Subsystem from Selection.
However, if you actually do want to use Model Blocks, that can be done as follows.  So, I'm assuming that you have already created two models -- one for your control system, the other for your image processing algorithm.
First, in each model, make sure you have specified the proper inputs/outputs.  You will do this by adding Inport and Outport blocks to the top-level of each model.
Next, create a new model in which you will integrate the Control model and Image Processing model.  Add a Model Block for each model (as you had already described doing).  For each Model Block, open the Parameters dialog box.  You will see a parameter where you can specify the model name.  Enter the name of the model that you will be referencing (i.e. either the controller or image processing model).  Additionally, you can browse for these models.  Once you do that, the inputs and outputs that you had previously specified should now be visible on the Model Blocks.


Velocity in different time frames

Question: A satellite orbiting the earth experiences time faster than a person on earth as its in a weaker gravitational field (which has a greater effect than the slowing down of time caused by its motion) does this mean that if someone was on the satellite they would disagree with someone on earth about the satellite's velocity around the earth saying it was slower because it would seem to move less distance per second?
Comment: If you read about this experiment http://hyperphysics.phy-astr.gsu.edu/hbase/relativ/airtim.html  which was performed using a flight around the world in 1971 and atomic clocks, it's pretty much the same idea as you ask. But don't mix up gravitional time effects (GR) with velocity  induced effects (SR).  If you read about GPS satellites you will see how they need to compensate for both effects.
Answer: Consider a satellite in a geostationary orbit which means that it's relative velocity with the earth is equal to 0, there is an astronaut Nick on satellite and Bob on earth observing Nick. Bob will observe that time for Nick is going faster due to gravitational time dilation so they will disagree about time but they will not disagree about speed of the satellite relative to earth. This is due to a phenomenon of length contraction, Bob observes that time goes faster for Nick but also he observes that Nicks length is "contracted" so that velocity of Nick remains constant in both frames of reference.

A clock which is on top of a mountain(farther from center of the earth) will run faster relative to clock which is closer to the earths center, in the same way two clocks moving at relative velocity v from each other will also disagree about time. the difference between time is represented by following equation:
$$\Delta t'= \frac{\Delta t}{\sqrt {1-\frac{v^2}{c^2}}}$$
And gravitational time dilation is represented by following equation:
$$\Delta t'= \frac{\Delta t}{\sqrt {1-\frac{2GM}{rc^2}}}$$

(Source: http://www.leapsecond.com/great2016a/)
To explain why is this the case consider a light clock consisting of two mirrors A and B at a distance of L from each other and a particle of light bounces from A mirror to B mirror continuously. Now let's consider what time it takes for a light particle to complete one pulse, this is represented by following formula:
(1) $$\Delta t= \frac{2L}{c}$$

(Source: Wikipedia)
Now let's look at this system from different frame of reference which has velocity v relative to our light clock. Consider the following - Bob standing on earth and Nick flying in a rocket with a light clock with a velocity v relative to Bob, Nick will observe the light clock same way it is illustrated above but Bob will observe light particle covering longer distance - D than Nick - L.

the first picture is light clock as observed from Nick's (who's in a rocket) frame of reference and second picture is light clock observed from Bob's frame of reference. Now let's consider what time it takes for a light particle to complete one pulse but now from Bob's(on earth) frame of reference, this is represented by the following formula:
(2) $$\Delta t'= \frac{2D}{c}\Rightarrow D = \frac{\Delta t' c}{2}$$
Now we can apply Pythagorean theorem to solve for path covered by particle of light - D (from Bob's frame of reference), one of the Cathetus is equal to L and the other one we can derive that it is equal to:
$$\frac{\Delta t'}{2}v$$
(Half the time because light has covered by our definition half the pulse)
Now we can solve for the Hypotenuse - D using Pythagorean theorem and we get:
$$D = \sqrt{(\frac{1}{2}\Delta t'v)^2+L^2}$$
Now we can substitute D using (2) equation
$$\frac{\Delta t' c}{2} = \sqrt{(\frac{1}{2}\Delta t'v)^2+L^2}\Rightarrow \Delta t'=\frac{\sqrt{(\Delta t'v)^2+(2L)^2}}{c}$$
simplify:
$$(\Delta t')^2 = \frac{v^2}{c^2}(\Delta t')^2+\left (\frac{2L}{c}  \right )^2\Rightarrow(1-\frac{v^2}{c^2})(\Delta t')^2 = \left (\frac{2L}{c}  \right )^2$$
More simplification:
$$\Delta t'^2 = \frac{\left (\frac{2L}{c}  \right )^2 }{(1-\frac{v^2}{c^2})} \Rightarrow \Delta t' = \frac{\left (\frac{2L}{c}  \right ) }{\sqrt{1-\frac{v^2}{c^2}}}$$
Now we can substitute (1) equation and we have derived equation of time dilation:
$$\Delta t' = \frac{\Delta t }{\sqrt{1-\frac{v^2}{c^2}}}$$
from this observation we can conclude that In order for speed of light to remain constant Bob must observe the frame of reference of Nick slower so that:
$$\frac{2L}{\Delta t}=\frac{2D}{\Delta t'}$$
L and D are constants therefore times must be different so that this equality holds.
Now to calculate gravitational time dilation we have to substitute escape velocity equation, escape velocity is defined as the speed an object must reach to escape the gravitational pull of another object. to have an intuitive understanding of why we have to substitute escape velocity equation, Think of it as a speed the earth pulls you to its center and it is different at different distances from earth and because of this we can observe that time for a satellite goes faster relative to a person standing on earth. escape velocity is represented as following formula:
$$v_{escape}=\sqrt{\frac{2GM}{r}}$$
Where r is distance from an object(earth) and M is the mass of an object
When we substitute this escape velocity into time dilation equation we calculated before we get this formula:
$$\Delta t'= \frac{\Delta t}{\sqrt {1-\frac{2GM}{rc^2}}}$$
Comment: Does this mean that after the clock is slowed down on the satellite so that the GPS works correctly someone on the satellite would now disagree with someone on earth about the satellites velocity?
Comment: When you say that nicks length is contracted do you mean that nick and the satellite are shortened or that nicks journey around the earth is shortened by space being shortened as well?  It seems to me that if nick is shortened it would have no effect on his velocity and that if space is shortened we should now disagree on nicks distance from earth.
Comment: It seems strange to me that a satellite can have a relative velocity with some point on earth that is equal to 0 and yet we know its real velocity is faster than the point on earth as it has to travel further to maintain its relative velocity position. Could this mean that true velocity is never known and that velocity is a dodgy component when its used in a maths equation?
Comment: @StewartCheckley  There is a specific orbit at which satellites have velocity equal to zero relative to earth, This orbit is called Geostationary orbit, which is at a specific distance away from earth (different for other planets) and at that specific orbit angular velocity of a satellite is equal to the angular velocity of Earth's rotation, As a result a satellite at this specific orbit has velocity equal to 0 relative to earth.

Velocity in different time frames