text:
Q: vb.net Incorrect syntax near the keyword where Incorrect syntax near the keyword WHERE
Dim cmd As New SqlCommand
        cmd.Connection = conn
        cmd.CommandText = "UPDATE main WHERE ID = '" & ID.Text & "'" & vbCrLf & _
        "SET Date = '" & _date.Text & "'," & vbCrLf & _
        "Artist = '" & artist.Text & "'," & vbCrLf & _
        "City = '" & City.Text & "'," & vbCrLf & _
        "Venue = '" & venue.Text & "'"
cmd.ExecuteNonQuery()

I don't understand why I am getting this error. I have tried changing every little thing about it???

A: The correct syntax for UPDATE is
UPDATE tablename SET field1=Value1,..... WHERE keyField=keyValue

So your query should be written as
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandText = "UPDATE main SET Date = @dt, Artist = @art, City = @city," & _
                  "Venue = @ven WHERE ID = @id"

cmd.Parameters.AddWithValue("@dt", date.Text )
cmd.Parameters.AddWithValue("@art", artist.Text )
cmd.Parameters.AddWithValue("@city", City.Text )
cmd.Parameters.AddWithValue("@ven", venue.Text )
cmd.Parameters.AddWithValue("@id", ID.Text )
cmd.ExecuteNonQuery()

Notice how removing the string concatenation and using parameters your query text is more
understandable and easier to verify.
Of course this removes also any possibility of Sql Injection and parsing problems.
Still, this could not be completely correct if any of your fields are not of text type.
As written all the parameter's values are passed as strings and this could cause problems if (for example) your Date field is a smalldatetime instead of a string (or ID is a number).

A: You have no space between WHERE ID = '" & ID.Text & "' and "SET Date = '" (The vbcrlfs don't really translate across to Sql when you send it). You may also have something in your textboxes with an apostrophe inside it, which is causing one of the sql strings to terminate early.
For this reason (and so it can't be hacked via Sql Injection) you should use SqlParameters.
Imagine this, for instance. I enter ';Truncate Table main;' into _date.Text. Your query suddenly looks like this:
Update main Set Date = ''; Truncate Table main;'', Artist = '', City = '', venue = '', where id = ''

Most of that will fail, but Truncate Table main is likely to execute and clear your data.
To get around this, use SqlParameter:
    Dim conn As New SqlConnection()
    Dim cmd As New SqlCommand

    cmd.Parameters.Add(New SqlParameter("ID", ID.Text))
    cmd.Parameters.Add(New SqlParameter("Date", _date.Text))
    cmd.Parameters.Add(New SqlParameter("Artist", artist.Text))
    cmd.Parameters.Add(New SqlParameter("City", City.Text))
    cmd.Parameters.Add(New SqlParameter("Venue", venue.Text))

    cmd.Connection = conn
    cmd.CommandText = "UPDATE main " & vbCrLf & _
                        "SET Date = @Date, " & vbCrLf & _
                        "Artist = @Artist, " & vbCrLf & _
                        "City = @City, " & vbCrLf & _
                        "Venue = @Venue " & vbCrLf & _
                        "WHERE ID = @ID"

    cmd.ExecuteNonQuery()


text:
Q: How to delete the URLSafeTimedSerializer token after use in python? I have created a token using python itsdangerous URLSafeTimedSerializer for forgot password functionality. The token is getting expired after the max-age but when the password is reset then i need to expire that token, so that the user is not able to reset password with the token again and again till it is getting expired. So, the question here is how to expire the token after the user resets password?

A: Despite the comment of @Uber , I understand the question. Also I believe this is more a design question, so posting code would not make that much sense. This time I'll provide an answer, but remember to properly write the question for the future times, e.g. providing a scenario, like your database table and better describing the sequence of activities for resetting the password (see https://stackoverflow.com/help/how-to-ask).
So, say you generate a token via the URLSafeTimedSerializer library as follows:
from itsdanger import URLSafeTimedSerializer
ts = URLSafeTimedSerializer("my-secret-key")
token = ts.dumps(email, salt="my-salt")

In order to expire such token, you have different possibilities:

*

*Create a blacklist of already used tokens (not a good idea as it would become too long and you may have clashes when generating tokens).

*Add a 'token_reset' field to your user table, and store the current valid token there. As soon as the user uses it, delete it from the table. If no token exists for an user, it'll mean that he/she has already used it.

*Add a timestamp to your token, so that when you get it back (you can decrypt it with the itsdanger library), you know if it has expired or not (though a user may use it twice in 5 minutes).

There may be other ways to solve such problem, but solution #2 is the one used most frequently (from my experience). If other users have other suggestions, feel free to edit this answer.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Undergraduate Level Math Books What are some good undergraduate level books, particularly good introductions to (Real and Complex) Analysis, Linear Algebra, Algebra or Differential/Integral Equations (but books in any undergraduate level topic would also be much appreciated)?
EDIT: More topics (Affine, Euclidian, Hyperbolic, Descriptive & Diferential Geometry, Probability and Statistics, Numerical Mathematics, Distributions and Partial Equations, Topology, Algebraic Topology, Mathematical Logic etc)
Please post only one book per answer so that people can easily vote the books up/down and we get a nice sorted list. If possible post a link to the book itself (if it is freely available online) or to its amazon or google books page.

A: I am surprised no one has mentioned Halmos' Naive Set Theory or Finite-Dimensional Vector Spaces or Rudin's Principles of Mathematcal Analysis. There's also Sheldon Axler's Linear Algebra Done Right and Royden's Real Analysis.

A: For discrete mathematics, I would recommend Van Lint-Wilson's "A Course in Combinatorics" as a good introductory text.  It consists of 38 (in my edition) chapters that give (often largely self-contained) introductions to various areas of the field.  Although it doesn't go nearly as in depth as, say, Stanley's "Enumerative Combinatorics" or a text focused solely on graph theory, I found it excellent for giving a broad overview and indicating to me where I wanted to explore deeper.
My one caveat would be that some chapters require background in either linear algebra or basic group theory, though those are easily skippable due to the structure of the book.

A: Basic Algebra by Jacobson.

A: General geometry: Coxeter, Introduction to Geometry.
Not so much a textbook as a collection of essays (in particular, it doesn't have exercises), but all of the essays are instructive and enlightening.

A: Ok, this is not a single book, but I have often found books from the Springer Undergraduate Mathematics Series (SUMS) to be excellent. Here is a list of titles.

A: Another one I like is "An introduction to Lie algebras." by Erdmann and Wildon.

A: Galois Theory by Ian Stewart is excellent. The third edition is quite different from the second and includes many more problems.

A: I am surprised this has not been mentioned before (is it too advanced?):
Bott and Tu, Differential forms in algebraic topology.
The best introduction to de Rham cohomology, spectral sequences, characteristic classes from the algebraic point of view, and countless other topics.

A: Algebra: Chapter 0, Paolo Aluffi
Best book on algebra I've had my hands on yet, and I love how it uses category theory. I wouldn't mind having a course taught from this one. Topics from group theory all the way through field theory, linear algebra, and homology. This book deserves more attention!
https://www.amazon.com/Algebra-Chapter-Graduate-Studies-Mathematics/dp/0821847813/ref=sr_1_1?ie=UTF8&s=books&qid=1278799249&sr=8-1

A: Searcóid: Elements of Abstract Analysis. I loved this book as an undergraduate, for many reasons, but mainly because it gave me an idea of the unity of mathematics. It starts from the axioms of set theory and takes you  all the way to C*-algebras and the Gelfand-Naimark theorem. Here's the Google Books page.

A: Jaenich: "Topology"
Introduces the concepts of point set topology ("paracompact" and all this stuff) motivating each via examples which are rigorously defined but also drawn. Other advantage: It is short!

A: Apostol "Calculus"

A: Bartle "The Elements of Integration and Lebesgue Measure"

A: I'm a big fan of John Hubbard's "Vector Calculus, Linear Algebra and Differential Forms" text.  I was a TA for the course twice at Cornell and was amazed at how well it went.  The text has an extremely pleasant "zest" to it. When Hubbard asked me to take a look at it my first response was the text is "overflowing with the spirit of calculus".  I still believe that. I have a hard time containing my praise.
The main problem with the text is that it's so engrossing.  It places more demands on the student than a traditional service course text would ever consider.  But it's also far more rewarding.  At Cornell it was taught as a branch of their traditional calculus sequence -- it was a course that was earmarked for keener students, mostly from other departments.
In short, if you want to have physics, engineering and economics students appreciating the derivative as a linear approximation, thinking Lipschitz bounds for functions are cool, being interested in the computation of norms of linear operators, etc, this is a great resource.

A: Karen Smith et al., An Invitation to Algebraic Geometry

A: Real Mathematical Analysis by Charles Pugh

A: Lectures on Linear Algebra by I. M. Gel'fand

A: Also, I just started this book and absolutely love it
Geometry: Euclid and Beyond, Hartshorne

A: Fraleigh's "A First Course in Abstract Algebra"
https://www.amazon.com/First-Course-Abstract-Algebra-7th/dp/0201763907

A: For a thorough introduction on Partial Differential Equations, read L.C. Evans, "Partial Differential Equations". Features both linear and nonlinear equations.

A: For a long time, Kolmogorov-Fomin's Introductory Real Analysis was my standard for a great mahtematics textbook. I can't imagine a better introduction to serious analysis.
The translation I'm linking to is very good, and includes excercises (the original has many fewer), but it is incomplete (it's missing the chapter on Fourier Series). So if you can read Russian, I recommend you get the original.

A: From the quick look I've had, not much representation theory has been mentioned so here goes for undergrad level rep theory (perhaps suitable for 3rd/4th year in a standard sequence of undergraduate study), roughly in the order of difficulty (from easiest to hardest):

*

*James & Liebeck - "Representations and Characters of Groups" (a very good introduction)

*Sagan - "The symmetric group: representations, combinatorial algorithms, and symmetric functions"; (the first two chapters here at least are representation theory) OR James & Kerber - "Representation Theory of the Symmetric Group" (this one includes some modular representations of $S_n$)

*Alperin - "Local Representation Theory" (basically, modular representation theory)

*Hall - "Lie groups, Lie Algebras and Representation Theory" (a solid introduction to Lie theory); for a more advanced perspective Harris & Fulton - "Representation Theory: A first course" (but it could be slightly terse at points, but not necessarily)
For algebraic geometry, the one book I'd suggest is "Algebraic Geometry: A first course" by Joe Harris, very nice and full of examples. For algebraic number theory, a very good introduction is Janusz - "Algebraic Number Fields" (followed perhaps by Childress - "Class Field Theory", or Silverman - "The Arithmetic of Elliptic Curves" to go in a slightly different direction).

A: Here is an undergraduate level math book recommendation from an early undergrad's position:
I like "Linear Algebra Done Right". I've looked at a bunch of books on linear algebra, and the usual matrix approach is to me a big turn-off when what you're really interested in is the abstract machinery of transformations between vector spaces. I'm not a research mathematician. In fact, I don't even study linear algebra yet, but as a student of mathematics that like algebra, spaces, maps and all that good stuff, I find this to be a very readable account of linear algebra.
There are more abstract books on the subject, and my impression is that LADR prepares you for the next level way before you're usually "allowed to" by other accounts like Lax etc. The trade-off is that LADR is not a book for engineers, but this would be a sad world for a mathematician if that was something he had to worry about (in his spare time). Great for self-study. Reads like a novel. I'd probably prefer it if Axler used sets for span and bases instead of lists, but that's something you'll probably be able to shake off with the next book you read on the subject.

A: Visual Complex Analysis by Tristan Needham is awesome!

A: Linear Algebra / Hoffman & Kunze - A book that truly develops linear algebra in a gradual manner. It starts with a basic discussion of systems of linear equations, matrices, Gaussian elimination, etc. and gradually progresses to the more abstract theory. Eventually it even touches upon subjects such as tensor products, the exterior algebra and the Grassmann ring. In short, it manages to cover a lot of linear algebra in a very leisurely and clear manner. I think that this is the quintessential example of a how an undergraduate level math book should be written. The only thing I don't like about it is the fact that quotient spaces aren't mentioned throughout the book (they're mentioned in the appendix, though).

A: Alexandre Stefanov keeps an extensive list (Wayback Machine, another link) of free math books / lecture notes. The list is divided according to subject and updated frequently. I have found some very nice books there.

A: An Introduction to Manifolds by Loring W. Tu
https://www.amazon.com/Introduction-Manifolds-Universitext-Loring-W/dp/0387480986/ref=sr_1_1?ie=UTF8&s=books&qid=1256082981&sr=1-1

A: Riemannian Geometry: A Beginner's Guide by Frank Morgan
https://www.amazon.com/Riemannian-Geometry-Beginners-Frank-Morgan/dp/1568810733/ref=sr_1_1?ie=UTF8&s=books&qid=1256083041&sr=1-1
I love this book!

A: Subject: FUNCTIONAL ANALYSIS
Erwin Kreyszig
Introductory Functional Analysis with Applications

A: E. Hairer, G. Wanner: Analysis by its history for an introduction to real and numerical analysis from a historical point of view.

A: Kock, Vainsencher: An invitation to Quantum Cohomology.
Written in the most friendly and motivating style I have ever seen in a book. Almost has no prerequisites: You should that there exists something like algebraic varieties - without having to know any technical details - and that P^1 is such a thing. Everything else is provided in easy exercises or the text. It gives an excellent intuition about the subject with lots of outlooks on a field of current research, and at the same time manages to be easily undergraduate readable.

A: Lebesgue Integration on Euclidean Space / Frank Jones - an extremely readable book on Lebesgue theory on $\mathbb{R}^n$ (lots of figures and geometric intuition). He constructs Lebesgue measure in a very down-to-earth manner, much more explicitly than other more abstract constructions (via Caratheodory's extension theorem or Riesz's representation theorem). In my experience, it's best to first study Lebesgue measure on $\mathbb{R}^n$ and only then point out that it's merely one instance of the general theory of measures, which is the way this book is written. It can't compare with the "tougher" books on measure theory (e.g. Big Rudin) since it doesn't discuss the Radon-Nikodym theorem and many other important theorems in measure theory, but then again the book is clearly intended for an undergraduate audience, and as for Lebesgue theory on Euclidean spaces, it provides a pretty complete picture.

A: Algebraic Topology by Hatcher (available online here).

A: Generatingfunctionology by Wilf is fun, free, requires very little in the way of prerequisites, and is as good an introduction to the methods of analytic combinatorics as could be asked for. It's long been one of my favorite textbooks.

A: Spivak, Calculus

A: Concrete Mathematics, Graham, Knuth and Patashnik. Extremely useful, very good exercises, and a sense of humor that appeals to me.

A: A basic undergrad algebra book which I feel is not as well known as it should be is Michael Artin's Algebra. I have it in soft cover so I hope it's actually the one in this Amazon link. Anyway it's beautifully written, provides context and motivation and is just a pleasure to read or browse. How often do you find a basic text written by a world-class expert?
"Always study from the masters".

A: For undergraduate level topology (mostly point set topology) I recommend "Topology" by Munkres. I learned topology from this book as an undergrad and I remember this being one of my favorite books at the time.

A: Milnor, Topology from the differentiable viewpoint.

A: There is a good list here (Wayback Machine), divided by subject, that also contains many links to freely available textbooks and lecture notes.

A: Kelley, General Topology

A: Introduction to Topology: Pure and Applied, by Adams and Franzosa.
The figures in the book are beautiful, the problems are good, and the applications are good (and unusual) to see in an undergraduate text.

A: Linear Algebra and Its Applications by Gilbert Strang. You can also watch his video lectures at MIT OpenCourseWare

A: "Introduction to Mathematical Logic" by Ebbinghaus, Flum and Thomas
Careful introduction, addresses many doubts that one might have about why one does logic in this way and not some other, e.g. whether one is doing something circular when formulating set theory in 1st order logic, or e.g. it proves Lindstroem's Theorem, that says that classical 1st order logic has the highest power of expressability among the logics with completeness and Loewenheim-Skolem.

A: Metric Spaces by Mícheál Ó Searcóid
https://www.amazon.com/Metric-Spaces-Springer-Undergraduate-Mathematics/dp/1846283698/ref=sr_1_1?ie=UTF8&s=books&qid=1256082496&sr=1-1
It's an exhaustive introduction analysis at the level of the metric space that's well worth reading.

A: Introduction to Analysis by William R. Wade
https://www.amazon.com/Introduction-Analysis-4th-William-Wade/dp/0132296381/ref=sr_1_1?ie=UTF8&s=books&qid=1256082707&sr=1-1
This is a good transition from undergraduate calculus to analysis.

A: Godement "Analysis" (I,II,III,IV)
https://www.amazon.com/Analysis-Convergence-Elementary-functions-Universitext/dp/3540059237
"... The content is quite classical ... [...] The treatment is less classical: precise although unpedantic (rather far from the definition-theorem-corollary-style), it contains many interesting commentaries of epistemological, pedagogical, historical and even political nature. [...] The author gives frequent interesting hints on recent developments of mathematics connected to the concepts which are introduced. The Introduction also contains comments that are very unusual in a book on mathematical analysis, going from pedagogy to critique of the French scientific-military-industrial complex, but the sequence of ideas is introduced in such a way that readers are less surprised than they might be.

A: How about an anti-recommendation?  Someone in another answer mentioned Steven Axler's Linear Algebra Done Right.  My comment, not as someone who has used this book in a class, but as someone who has taught the students from this class during the following term:   It doesn't prepare the students to use linear algebra in engineering, in physics, in chemistry, or even in branches of mathematics other than abstract algebra.

A: General Topology, by Stephen Willard
https://books.google.com/books?id=-o8xJQ7Ag2cC&lpg=PP1&dq=stephen%20willard&pg=PP1#v=onepage&q=&f=false

A: A Field Guide to Algebra by Antoine Chambert Loir. Covers a surprising amount of material considering the short length and minimal prerequisites

A: "TOPOLOGY WITHOUT TEARS" by SIDNEY A. MORRIS is a very nice introduction in topological spaces theory, I think.

A: Geroch, Mathematical Physics
Don't be scared by the title: it teaches algebra, topology and measure theory, using category-theoretic language.

A: "Differential Calculus on Normed Linear Banach Spaces" by Kalyan Mukherjee.
The author is a prof at the Indian Statistical Institute (Kolkata)
This is an amazing book which introduces differential calculus in arbitrary finite dimensional spaces (thinking of the derivative as the Jacobian) as the next leap from the Apostol and Rudin level and also build in topological ideas. It then goes into manifold theory and shows how to compute tangents to curves inside lie groups. It has nice sections of things like differentiating the determinant function and the matrix multiplication function and inverse function theorem and idea of equivalence of norms.
I would strongly recommend this book to an undergrad after he/she has done the Apostol/Rudin level of calculus.
"Calculus on Manifolds" by Spivak and "Differential geometry and Lie groups" by Kumaresan are two other good books which can be read alongside it.

A: I liked Elements of Abstract Algebra by Allan Clark, which is mainly a problem book with a moderate amount of exposition, but the problems are so well-chosen that a diligent undergraduate student working through all of them will come out with a solid knowledge of group theory, classical ring theory, and Galois theory.

A: I think that Linear Algebra by Friedberg, Insel, and Spence is a spectacular linear algebra book. It gets straight to the point, it provides a worked out example or two exactly when they're needed, and it has lots of interesting exercises.
There are way too many gigantic linear algebra books with colour pictures and contrived examples which often seem to obfuscate the concepts being introduced. In my mind this book is 'the mathematician's linear algebra book'; clean and concise.

A: For (applied) ODEs: Nonlinear dynamics and chaos by Steven Strogatz.
A very inspiring book! The explanations are crystal clear with lots of pictures. And it's funny too – the "Romeo and Juliet" illustration of 2-dimensional linear systems (Section 5.3) is a classic.

A: Atiyah and MacDonald, Introduction to Commutative Algebra

A: I would recommend Walter Rudin's classic text entitled Real and Complex Analysis for the mathematically mature undergraduate student. (Of course, this should really only be read after one has familiarity with most of Rudin's earlier textbook: Principles of Mathematical Analysis.)
The beautiful thing about this book is that nearly every example or result stated by Rudin is used in "the big picture". As you progress through the book, you really start to appreciate the magic Rudin has used to weave together analysis in a manner that is rarely done in other textbooks.
While Rudin states in his preface that the textbook is intended as a first year graduate course on the subject of analysis, I believe that it is quite possible for a mathematically mature undergraduate to follow it. There is no assumption in the book that the reader has any familiarity with linear algebra, abstract algebra, general topology etc. beyond that which was covered in the first seven chapters of his earlier book, but realistically one would like to have at least mastered the basics of these areas before attempting to delve deeper into the analysis covered in this book. (There is a chapter on Banach algebras, but all the necessary abstract algebra here is developed from scratch.)
The textbook is indeed challenging with plenty of exercises, but it is not something with which a student with the correct prerequisites should have tremendous difficulty. Furthermore, if a student can successfully read most of the book, he is well-equipped to go deeper into most branches of modern analysis, and should find the other classic texts in the subject, for instance Royden's Real Analysis, Bartle's The Elements of Integration and Lebesgue Measure etc., very easy to follow.
The Amazon page for this book can be found here.

A: Algebraic Theory of Numbers, by Pierre Samuel
Assumes only elementary knowledge of group and ring theory (even less than a complete undergraduate course which covers Galois theory) and develops algebraic number theory, a beautiful subject which puts much elementary number theory into an interesting perspective.

A: I would also recommend the book entitled Analysis on Manifolds by James Munkres. I think that this is a good undergraduate textbook in mathematics for any student wishing to pursue multivariable calculus in greater depth. My only complaint is that Munkres often chooses to include details which can be seen easily after a little bit of thought. Perhaps this can be viewed as an effort to show the student how to "properly do analysis": doing analysis, just like doing any other branch of mathematics, requires you to carefully apply definitions and theorems, and it is important for the student to appreciate this early in his/her mathematical learning.
That said, the book is an excellent text overall for "advanced calculus". The student will need to be familiar with single variable analysis and perhaps some linear algebra. (Even a rudimentary knowledge of linear algebra will do since Munkres develops most of the necessary theory from scratch.)
Roughly speaking, the book splits into two parts. The first part covers most of the results students see when doing multivariable calculus that are stated "without proof" in their texts. For example, "the equality of the mixed partials", "double integrals can be done in any order", "a bounded function is Riemann integral if and only if it is continuous almost everywhere", "the change of variables theorem" etc., are (very) imprecise forms of some of the results Munkres establishes.
In the second part of the book, manifolds and their theory are introduced. Thus, for example, a rudimentary introduction to tensors is given, and this is supplemented by the basic theory of differential forms, the De Rham groups (of the punctured plane), Stokes' theorem etc.
I think that the exposition could be tightened: if you actually pick up the book and really make an effort to read it, it is quite possible to finish the first half of the book in the space of a week (that is, approximately 200 pages in a week) simply because certain topics are explained in more detail (at least in my opinion) than necessary. (One example is Munkres' proof of the linearity, monotonicity, additivity etc. of the Riemann integral. This is proved in three contexts separately: the case of the integral over a rectangle, that over a bounded set, and that of improper integrals, when essentially the proofs can be left as relatively easy exercises in some cases.)
As the above comments suggest, I think that this is an excellent book for undergraduate students, but perhaps less so for graduate students. (Spivak's Calculus on Manifolds is good for both undergraduate and graduate students, in my opinion, but some people may suggest that it is too hard for undergraduates.) And after reading this book, you should have more than enough preparation to read more advanced texts such as William Boothby's An Introduction to Differentiable Manifolds and Riemannian Geometry.

A: Serre, A Course in Arithmetic.

A: The Chicago undergraduate mathematics bibliography is a nice annotated list of books.

A: Ordinary Differential Equations by Vladimir I. Arnold

A: Needham, Visual Complex Analysis. I read this while in high school, and it's simply beautiful. I recommend this book as a supplement to any first course in complex analysis (a different book should probably be used for the main textbook since Needham's is very pretty, very engaging, but not very rigorous).

A: Miles Reid, Undergraduate Algebraic Geometry.
ps - anyone who thinks one can teach an undergraduate class out of Hatcher's Algebraic Topology (which is a great book) at more than 10 universities in the US is sadly deluded.  Ditto for a few more things I've seen here.
pps - somewhere between a third and half of the math majors here could handle abstract algebra out of Artin.  It would be great for those that could, but we're not going to ditch half our students.

A: Not exactly one of the topics in the question, but I particularly liked Silverman and Tate's Rational Points on Elliptic Curves.

A: Differential Geometry of Curves and Surfaces, by Manfredo Do Carmo
is an excellent introductory book.
https://www.amazon.com/Differential-Geometry-Curves-Surfaces-Manfredo/dp/0132125897

A: The Princeton Lectures in Analysis by Stein and Shakarchi are great introductions to Fourier, complex, and real analysis (in that order!).

A: Complex Analysis, by Lars Ahlfors
https://en.wikipedia.org/wiki/Lars_Ahlfors

A: Real and Complex Analysis by W. Rudin is a beautiful and extremely well written book which presents the fundamentals of real and complex analysis highlighting the interactions between different results and ideas.

A: Spivak, A Comprehensive Introduction to Differential Geometry.  There is a nice geometrical philosophy and plenty of motivation.

A: As an undergraduate, I loved Shafarevich's book Basic notions of algebra. This is not a textbook, but gives small beautiful tastes of a broad choice of topics in algebra, emphasizing connections with other fields.
I found it very stimulating, in the sense that every example or overview of some topic in this book made me want to learn more details about it. In fact I became interested in algebraic geometry because of this book.

A: Guillemin and Pollack, "Differential Topology"

A: Dummit and Foote's Abstract Algebra is an excellent book for learning group theory, ring theory, and module theory.  There's also a section on basic algebraic geometry and homological algebra.

A: I didn't see any suggested books from the great Russian school of mathematics, here is a brief list of superb, well written, example oriented books:

*

*Elements of the Theory of Functions and Functional Analysis by A. N. Kolmogorov and S. V. Fomin

*Theory of Functions of a Real Variable by I. P. Natanson (this I think, it's hard to find)

*Theory of Functions of a Complex Variable, Second Edition (3 vol. set) by A. I. Markushevich

*Elements of Functional Analysis  by L.A. Lusternik and V.J. Sobolev

*Problems in Mathematical Analysis by B. Demidovich

*Calcul intégral et differentiel (2 vol. set) by N. Piskounov. In English should be something like Differential and Integral Calculus

*A Course of Mathematical Analysis (2 vol. set ) S. Nikols'skii

*Differentialrechnung und Integralrechnung (3 vol. set), by Gregor M. Fichtenholz. Unfortunately, there is no English translation of this book, only the German translation that it's mentioned. I think this was THE calculus book on Russia. THIS BOOK SHOULD BE TRANSLATED INTO ENGLISH, and I suspect that there is no copyright, it appears around 1959 I think.

*Mathematical Analysis (2 vol. set) by Vladimir A. Zorich. This is a very recent book from a great mathematician which is in Moscow university. The book is based upon is lecture.

I have also found a Spanish translation of a book written by S. Banach about "Differential and integral calculus". It is very good as an undergraduate book. The spanish translation (for those who want to search) is Calculo diferencial e integral
Books that undergraduate should not touch (in my humble opinion) are books written in bourbaki's style.

A: Topics in Algebra by I. N. Herstein. A new edition will be coming out this year.

A: Ireland and Rosen, A Classical Introduction to Modern Number Theory is a great second course in number theory. In spite of being part of "Graduate Texts in Mathematics" series and unlike Rudin's Real and Complex Analysis (see a comment above), this is a book at the undergraduate level. It only presupposes undergraduate algebra as in Herstein Topics in Algebra or M. Artin's Algebra, undergraduate analysis like in Rudin's Principles of Mathematical Analysis and basic number theory. In fact it recalls or proves many of the necessary results in each of those fields. A Classical Introduction to Modern Number Theory bridges the gap between basic number theory (that covers modular arithmetic, Fermat's little theorem and QR) and books like Lang's Algebraic Number Theory or Cassels and Fröhlich.

A: Since Numerical Mathematics has not been covered, I would recommend the following
Introduction to Numerical Analysis by Stoer et. al.  https://www.amazon.com/Introduction-Numerical-Analysis-J-Stoer/dp/038795452X/ref=sr_1_14?ie=UTF8&s=books&qid=1255807973&sr=8-14

A: Linear Algebra: With Applications
Otto Bretscher
Used at Carleton College – nice explanations, and quite a few proofs. Presents information primarily by providing examples, definitions/axioms and then proofs.

A: I had many trials and these are in my opinion the best for an introductory, undergraduate level:
ODEs: Holzner: Differential Equations for Dummies
PDEs: Farlow: Partial Differential Equations for Scientists and Engineers

A: Applied Linear Algebra, by B. Noble and J.W. Daniel, https://www.amazon.co.uk/Applied-Linear-Algebra-Ben-Noble/dp/0130412600/ref=sr_1_14?ie=UTF8&s=books&qid=1256927879&sr=1-14 .

A: G. J. O. Jameson: Topology and Normed Spaces for an introduction to functional analysis from a topological point of view.

A: lindsey childs a concrete introduction to abstract algebra
here maybe.

A: Strichartz, The Way of Analysis
Herstein, Abstract Algebra

A: Milnor's book "Dynamics in One Complex Variable: Introductory Lectures".  An early version is available from his website.  Suitable for advanced undergraduates, graduate students, and mathematicians.
http://www.math.sunysb.edu/cgi-bin/preprint.pl?ims90-5 (Wayback Machine)

A: Most readers here will not be able to appreciate them for a simple reason, but my favorite beginners' Analysis text is that by Bröcker (Wayback Machine).  No-nonsense, concise, with a slight orientation towards topology.

A: Hugo Steinhaus https://en.wikipedia.org/wiki/Hugo_Steinhaus book "Mathematical Kaleidoscope". It is kind of mathematical trivia sometimes very deep;-) It is not for learning math but for learning how to learn math in fun way.

A: Complex Variables: Harmonic and Analytic Functions by Francis J. Flanigan
A nice little Dover paperback which turns the standard course on complex variables on its head. It begins by doing some multivariable calculus in the plane and harmonic functions, then proceeds to talk about complex numbers and to build analytic functions.

A: Siegfried Bosch, Lineare Algebra
It's a very elegant, concise but beautifully written approach to Linear Algebra, and I love it.
Unfortunately for people who don't speak German, it has never been translated.

A: I plan to post a complete reading list for undergraduates and graduate students at my blog this summer with my commentaries,but here's one I think that's available online and doesn't get nearly enough credit despite the fame of it's author: Gilbert Strang's Calculus. I wouldn't use anything else for a regular,non-honors calculus course. Carefully written,beautifully motivated with TONS of creative and SIGNIFICANT applications.
I hope one day Strang finds the time to write a second edition-I have a list of improvements to suggest.

A: Linear Algebra with Differential Equations:
Bentley and Cooke 1973

A: A Concrete Approach to Abstract Algebra by W. W. Sawyer ($6 on Amazon!)
Though it goes a bit slow at times, it is by far the simplest, most intuitive book on Abstract Algebra in existence.  Written for the non-mathematician, it does a great job of teaching the subject in simple, easy-to-understand prose.  I couldn't put it down!
There are also two chapters on linear algebra, leading up to the final chapters, "vectors over fields" and "fields regarded as vector-spaces".

A: Introduction to Analytic Number Theory - Tom M. Apostol.
When I bought this I really didn't want to put it down. It's a great book for exciting one's interest in the subject.

A: Real Analysis, by Frank Morgan.
The chapters are short and very directed. The proofs are written well. The exercises are well-selected. The book is written at a level accessible for most students.

A: Vinogradov's Elements of Number Theory - the problems more so than the text itself.


text:
Q: How to delete every n-th char in file (via batch or vbs)? How can I delete every n-th (4000th) char (space character) in a file (.txt or .sql)  best via batch or vbs?

A: You need some VBScript, you can't do this with a batch file.
So something like this will do it for you
option Explicit

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim fso

Dim inFile
Dim outFile
Dim buffer

set fso = CreateObject("Scripting.FileSystemObject")

Set inFile = fso.OpenTextFile("C:\testIn.txt", ForReading)
Set outFile = fso.OpenTextFile("C:\testOut.txt", ForWriting, True)

Do While Not inFile.AtEndOfStream
    buffer = inFile.Read(3999)
    outFile.Write buffer
    If Not inFile.AtEndOfStream Then
        inFile.Read (1)
    End If
Loop

inFile.Close
outFile.Close

Hope this helps :)


text:
Q: MongoDB record missing after insertion I am using MongoDB 2.4.5 64 bit on Linux using C++ API to insert 1 M record
I did turn on write concern after the connection
   mongo.setWriteConcern(mongo::W_NORMAL);

   for (int i=0; i<RECORDS; i++) {
        mongo::BSONObj record = BSON (
                "_id" << i <<
                "mystring" << "hello world" );
        bulk_data.push_back(record);

        if (i % 10000 == 0) {
            mongo.insert("insert_test.col1", bulk_data);

        }
    }

Surprisingly at the end when I do count (via count(), it only shows 990001  records from collection 'insert_test.col1'.
What did I do wrong? Thanks for your help.

A: You're missing mongo.insert("insert_test.col1", bulk_data); at the end of (immediately after) your loop -- unless RECORDS is one less than a multiple of 10000 (you said it was 1000000, which isn't), then the last 9999 iterations are not inserted because they're still in bulk_data!
In other words, i is only 999999 on the last iteration through the loop, so the if isn't entered, and the last 9999 records that were put in bulk_data are not inserted.
Also, bulk_data needs to be cleared after being inserted:
if (i % 10000 == 0) {
    mongo.insert("insert_test.col1", bulk_data);
    bulk_data.clear();  //  <-----
}


text:
Q: Something in AsyncTask Blocking the UI - causing interface to halt briefly I have a listview that is populated thru SQLite with cache data.  After it finishes loading. in the background I check for new data and get a returned JSON result from a MySQL db.
In my onPostExecute of this background task, when this code is ran (the code below), and  while it is being looped thru (a maximum of 50 loops), the UI thread is blocked and scrolling a ListView is not possible.  Here is code:
if (result.length() != 0) {
                JSONArray jArray = new JSONArray(result);
                JSONObject json_data = null;

                for (int ii = 0; ii < jArray.length(); ii++) {
                    json_data = jArray.getJSONObject(ii);

                    item = json_data.getString("item");
                    cat = json_data.getString("category");
                    user = json_data.getString("username");
                    userId = json_data.getLong("user_id");
                    review = json_data.getString("review");
                    reviewId = json_data.getLong("review_id");
                    itemId = json_data.getLong("item_id");
                    commentCount = json_data.getLong("commentCount");
                    url = json_data.getString("name");
                    url = pathUrl + url; // for profile icon
                    date = json_data.getString("date");
                    rating = json_data.getDouble("rating");
                    upVote = json_data.getLong("good");
                    wiki = json_data.getString("wiki");

                    watchItems.add(item);
                    watchCats.add(cat);
                    watchUsers.add(user);
                    watchReviews.add(review);
                    watchUrl.add(url);
                    watchDateList.add(date);
                    watchWikiList.add(wiki);

                    watchItemIdList.add(String.valueOf(itemId));
                    watchUserIds.add(String.valueOf(userId));
                    watchReviewId.add(String.valueOf(reviewId));
                    watchRating.add(String.valueOf(rating));
                    watchCommentCount.add(String.valueOf(commentCount));
                    watchUpVote.add(String.valueOf(upVote));

                    Rateit.haveFollowing = "1";

                    if (Rateit.isUserLoggedIn == true) {
                        boolean oldReview = datasource
                                .getReviewIds(reviewId);
                        if (!oldReview) {
                            // Cache Network Items
                            datasource.createTrendWatch(itemId, item,
                                    review, reviewId, cat, user,
                                    String.valueOf(userId), url, date,
                                    commentCount, rating, upVote, 0,
                                    wiki);
                        }
                    }

                        FollowingItems wti = new FollowingItems(
                                Long.valueOf(watchItemIdList.get(i)),
                                watchItems.get(i), watchCats.get(i),
                                watchReviews.get(i),
                                Long.valueOf(watchReviewId.get(i)),
                                watchUsers.get(i),
                                Long.valueOf(watchUserIds.get(i)),
                                watchUrl.get(i), watchDateList.get(i),
                                Long.valueOf(watchCommentCount.get(i)),
                                Double.valueOf(watchRating.get(i)),
                                Long.valueOf(watchUpVote.get(i)),
                                watchWikiList.get(i++));
                        watchingListObject.add(wti);

                }
            }

Why is this happening? And how can I prevent my code to prevent this?  Are there any optimizations I can make?
Edit:  Someone below requested full task code.
Below repeats the code above but in context with entire task.

    public static class FollowingTask extends AsyncTask<String, String, Void> {
        protected InputStream is = null;
        protected String result = "";
        protected String userId;
        protected ArrayList<FollowingItems> watchingListObject;
        protected Context mContext;

        public FollowingTask(Context context) {
            mContext = context;
        }

        @Override
        protected void onPreExecute() {
            if (mContext != null && (fromRefresh == false)) {
                ((MainFragmentActivity) mContext)
                        .setSupportProgressBarIndeterminateVisibility(true);
            }

            resetLists();

            if (PrefActivity.getUserLoggedInStatus(mContext) == true) {
                userId = PrefActivity.getLoggedInUserId(mContext);
            } else {
                userId = "-1";
            }

            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(String... params) {
            datasource.purgeItemWatchingTable();
            Log.d("1", "Back");
            String url_select = "http://www.---.info/includes_mc_php/featured_watching.php";

            HttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url_select);
            ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();
            param.add(new BasicNameValuePair("user_id", userId));
            param.add(new BasicNameValuePair("v2", "true"));

            try {
                httpPost.setEntity(new UrlEncodedFormEntity(param));
                HttpResponse httpResponse = httpClient.execute(httpPost);
                HttpEntity httpEntity = httpResponse.getEntity();

                // read content
                is = httpEntity.getContent();

            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                BufferedReader br = new BufferedReader(
                        new InputStreamReader(is));
                StringBuilder sb = new StringBuilder();
                String line = "";
                while ((line = br.readLine()) != null) {
                    sb.append(line + "\n");
                }
                is.close();
                result = sb.toString();

            } catch (Exception e) {
                e.printStackTrace();
            }

            return null;
        }

        protected void onPostExecute(Void v) {

            String pathUrl = Rateit.PROFILE_PIC_URL;
            String item, cat, user, review, url, date, following, wiki;
            long itemId, reviewId, userId, commentCount, upVote;
            double rating;
            int i = 0;
            watchingListObject = new ArrayList<FollowingItems>();

            try {
                String c = String.valueOf(result.charAt(0));

                if (c.equals("{")) {
                    JSONObject jsonObject = new JSONObject(result);
                    following = jsonObject.getString("following");
                    if (following.equals("0")) {
                        Rateit.haveFollowing = "0";
                    }

                } else {

                    if (result.length() != 0) {
                        JSONArray jArray = new JSONArray(result);
                        JSONObject json_data = null;

                        for (int ii = 0; ii < jArray.length(); ii++) {
                            json_data = jArray.getJSONObject(ii);

                            item = json_data.getString("item");
                            cat = json_data.getString("category");
                            user = json_data.getString("username");
                            userId = json_data.getLong("user_id");
                            review = json_data.getString("review");
                            reviewId = json_data.getLong("review_id");
                            itemId = json_data.getLong("item_id");
                            commentCount = json_data.getLong("commentCount");
                            url = json_data.getString("name");
                            url = pathUrl + url; // for profile icon
                            date = json_data.getString("date");
                            rating = json_data.getDouble("rating");
                            upVote = json_data.getLong("good");
                            wiki = json_data.getString("wiki");

                            watchItems.add(item);
                            watchCats.add(cat);
                            watchUsers.add(user);
                            watchReviews.add(review);
                            watchUrl.add(url);
                            watchDateList.add(date);
                            watchWikiList.add(wiki);

                            watchItemIdList.add(String.valueOf(itemId));
                            watchUserIds.add(String.valueOf(userId));
                            watchReviewId.add(String.valueOf(reviewId));
                            watchRating.add(String.valueOf(rating));
                            watchCommentCount.add(String.valueOf(commentCount));
                            watchUpVote.add(String.valueOf(upVote));

                            Rateit.haveFollowing = "1";

                            if (Rateit.isUserLoggedIn == true) {
                                boolean oldReview = datasource
                                        .getReviewIds(reviewId);
                                if (!oldReview) {
                                    // Cache Network Items
                                    datasource.createTrendWatch(itemId, item,
                                            review, reviewId, cat, user,
                                            String.valueOf(userId), url, date,
                                            commentCount, rating, upVote, 0,
                                            wiki);
                                }
                            }

                                FollowingItems wti = new FollowingItems(
                                        Long.valueOf(watchItemIdList.get(i)),
                                        watchItems.get(i), watchCats.get(i),
                                        watchReviews.get(i),
                                        Long.valueOf(watchReviewId.get(i)),
                                        watchUsers.get(i),
                                        Long.valueOf(watchUserIds.get(i)),
                                        watchUrl.get(i), watchDateList.get(i),
                                        Long.valueOf(watchCommentCount.get(i)),
                                        Double.valueOf(watchRating.get(i)),
                                        Long.valueOf(watchUpVote.get(i)),
                                        watchWikiList.get(i++));
                                watchingListObject.add(wti);

                                Log.d("1", "Post 2");
                        }
                    } else {
                        Rateit.haveFollowing = "2";
                    }
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
                Rateit.haveFollowing = "2";
            } catch (ParseException e1) {
                e1.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            Log.d("1", "Post COMPLETE");
            mPullRefreshListView.onRefreshComplete();

            // Reset Trending List on Pull-to-Refresh
            if (mContext != null) {

                if (watchUsers.size() == 0) {
                    l.setVisibility(View.VISIBLE);
                    tv.setTypeface(TypeFace.get(mContext, Rateit.BPREPLAY));
                } else {
                    l.setVisibility(View.GONE);
                }

                if (mContext != null) {

                    listView.setAdapter(null);

                    if (watchItems.size() > 0) {
                        wAdapter = new FollowingAdapter(mContext,
                                watchingListObject, TypeFace.get(mContext,
                                        Rateit.BPREPLAY), TypeFace.get(
                                        mContext, Rateit.ROBOTO_LIGHT),
                                TypeFace.get(mContext, Rateit.ROBOTO_THIN),
                                TypeFace.get(mContext, Rateit.ROBOTO_REGULAR));
                        listView.setAdapter(wAdapter);
                    }

                }
            }

            if (mContext != null && (fromRefresh == false)) {
                ((MainFragmentActivity) mContext)
                        .setSupportProgressBarIndeterminateVisibility(false);
                MainFragmentActivity.dismissDialog(mContext);

            }

            fromRefresh = false;

        }
    }

A: onPostExecute runs on the UI thread. It will block the UI. doInBackground runs in the background. You should perform heavy opertaions in the doInBackground (not in onPostExecute)
Solution: you should move the parsing etc. from the onPostExecute to doInBackground and use the onPostExecute just for binding the processed information to the UI.

A: I would suggest as first thing to profile that code and measure how much time exactly is spent to execute it. This way at least you understand if your problem is really here or somewhere else


text:
Q: Problem 2-6 in Lee's Introduction to Smooth Manifolds The problem says

Let $P:\mathbb{R}^{n+1}\setminus \{0\}\to\mathbb{R}^{k+1}\setminus
 \{0\}$ be a smooth function, and suppose that for some $d\in
 \mathbb{Z}$, $P(\lambda x)=\lambda ^dP(x)$ for all $\lambda \in
 \mathbb{R}\setminus \{0\}$ and $x\in \mathbb{R}^{n+1}\setminus \{0\}$. (Such a function is said to be homogeneous of degree d.) Show that the map $\tilde{P}:\mathbb{R}\mathbb{P}^n\to \mathbb{R}\mathbb{P}^k$ defined by $\tilde{P}([x])=[P(x)]$ is well defined and smooth.

To show that it is smooth is alright for me, I combine Examples 1.5 og 1.33 to conclude it. But I do not know how to show that it is well-defined.

A: Let $x,y\in\mathbb{R}^{n+1}\setminus\{0\}$ such that $[x]=[y]$ in $\mathbb{R}P^n$, then there exists $\lambda\in\mathbb{R}^*$ such that $y=\lambda x$, therefore:
$$P(y)=\lambda^dP(x).$$
Whence, $[P(x)]=[P(y)]$ in $\mathbb{R}P^k$.
In other words, the image of $[x]$ under $\widetilde{P}$ does not depend on $x$ the representant of the class.

A: Let $[x] \in \mathbb{PR}^{n}$. Let $x\in \mathbb{R}^n -{0}$ be a representative for the equivalence class. For every $\lambda \neq0$ we have that $P(\lambda x)=\lambda^d P(x)$. Thus $[P(x)]=[\lambda^d P(x)]$. So the function is well defined.


text:
Q: Codeigniter remove index.php when redirected from non-www to www I have added a force redirect from non-www to www on my codeigniter based web app.
After doing that it is working fine, but its showing an extra index.php in URL which I need to remove.
Here is my URL : http://www.testprofile.com (WORKING FINE)
Here is problem caused :
https://testprofile.com/result/184/1103511096450940jawadamin (non www site, it will automatically add www.)
opening the above URL redirects to www but also adds an additional index.php in URL which should be removed.
HERE IS THE CODE OF MY .HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{HTTP_HOST} ^testprofile.com [NC]
RewriteRule ^(.*)$ https://www.testprofile.com/$1 [L,R=301]
</IfModule>

Please help me remove this annoying index.php
Thanks,

A: You missed to escape dot in right hand side of rewrite condition line. It should be like
RewriteCond %{HTTP_HOST} ^testprofile\.com [NC]

or in your whole example
<IfModule mod_rewrite.c>
RewriteEngine On
#If in root of web server you can use next line or set it appropriate according to location on server
#RewriteBase /

RewriteCond %{HTTP_HOST} ^testprofile\.com [NC]
RewriteRule ^(.*)$ https://www.testprofile.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

If dot is not preserved by back slash character apache read it as wild card character. You can find some useful tips on this page.
Also, you can check useful .htaccess snippets here.


text:
Q: Cannot read from/write to external SRAM using FMC on STM32F429I-Disco board I am currently using a STM32F429I Disco board with full FMC (FSMC on F407) pins to try to connect to IS62WV51216BLL SRAM module from Waveshare without much success.
The main SRAM test/initialization code has been given down below.
Apologies for the length of the post. I have tried checking and comparing with all the available codes in the internet, but somehow, it just does not initialize [test value is not returned]
The code was built and debugged in IAR workbench
SRAM_ADR
#define SRAM_ADR   ((uint32_t)0x60000000)
#define SRAM_END   SRAM_ADR + ((uint32_t)0x7FFFF) // not required for test

SRAM initialization, read, and write Code
//--------------------------------------------------------------
// Includes
//--------------------------------------------------------------
#include "stm32_ub_sram.h"

//--------------------------------------------------------------
// Internal Function
//--------------------------------------------------------------
void P_SRAM_InitIO(void);
void P_SRAM_InitFMC(void);

//--------------------------------------------------------------
// Initialize External SRAM
// Return_value :
//  -> ERROR   , when SRAM does not configured properly
//  -> SUCCESS , when SRAM configured successfully
//--------------------------------------------------------------
ErrorStatus UB_SRAM_Init(void)
{
  ErrorStatus ret_value = ERROR;
  uint16_t oldvalue, isvalue;

  // IO-Lines initialization
  P_SRAM_InitIO();
  // FMC initialization
  P_SRAM_InitFMC();

  //-----------------------------------------
  // Check the SRAM live or dead
  // Depends on testing the Adress 0x00
  //-----------------------------------------
  oldvalue = UB_SRAM_Read(0x00);
  UB_SRAM_Write(0x00, 0x5A3C);
  isvalue = UB_SRAM_Read(0x00);
  UB_SRAM_Write(0x00, oldvalue);

  if(isvalue == 0x5A3C)
    ret_value = SUCCESS; // RAM verification

  return(ret_value);
}

//--------------------------------------------------------------
// Internal Function
// Initialize all IO-Pins for the SRAM
//--------------------------------------------------------------
void P_SRAM_InitIO(void)
{

  GPIO_InitTypeDef GPIO_InitStructure;

  /* Enable GPIOs clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE
                         | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOG, ENABLE);

  /* Common GPIO configuration */
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;     // STM32F429I Only support speeds up to 90Mhz
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

  /*-- SRAM GPIOs Configuration --------------------------------------------------*/
  /*
  +-------------------+------------------+-------------------+
  | PD14 <-> FMC_D0   | PF0  <-> FMC_A0  | PE0  <-> FMC_NBL0 |
  | PD15 <-> FMC_D1   | PF1  <-> FMC_A1  | PE1  <-> FMC_NBL1 |
  | PD0  <-> FMC_D2   | PF2  <-> FMC_A2  | PD4  <-> FMC_NOE  |
  | PD1  <-> FMC_D3   | PF3  <-> FMC_A3  | PD5  <-> FMC_NWE  |
  | PE7  <-> FMC_D4   | PF4  <-> FMC_A4  | PD7  <-> FMC_NE1  |
  | PE8  <-> FMC_D5   | PF5  <-> FMC_A5  |-------------------+
  | PE9  <-> FMC_D6   | PF12 <-> FMC_A6  |
  | PE10 <-> FMC_D7   | PF13 <-> FMC_A7  |
  | PE11 <-> FMC_D8   | PF14 <-> FMC_A8  |
  | PE12 <-> FMC_D9   | PF15 <-> FMC_A9  |
  | PE13 <-> FMC_D10  | PG0  <-> FMC_A10 |
  | PE14 <-> FMC_D11  | PG1  <-> FMC_A11 |
  | PE15 <-> FMC_D12  | PG2  <-> FMC_A12 |
  | PD8  <-> FMC_D13  | PG3  <-> FMC_A13 |
  | PD9  <-> FMC_D14  | PG4  <-> FMC_A14 |
  | PD10 <-> FMC_D15  | PG5  <-> FMC_A15 |
  +-------------------| PD11 <-> FMC_A16 |
                      | PD12 <-> FMC_A17 |
                      | PD13 <-> FMC_A18 |
                      | PE3  <-> FMC_A19 |
                      +------------------+
  */

  //-----------------------------------------
  // All pins for Port-D initialization
  //-----------------------------------------
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource0,  GPIO_AF_FMC);       // PD0 = FMC_D2
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource1,  GPIO_AF_FMC);       // PD1 = FMC_D3
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource4,  GPIO_AF_FMC);       // PD4 = FMC_NOE
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource5,  GPIO_AF_FMC);       // PD5 = FMC_NWE
  // GPIO_PinAFConfig(GPIOD, GPIO_PinSource7,  GPIO_AF_FMC);       // PD7 = FMC_NE1
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource8,  GPIO_AF_FMC);       // PD8 = FMC_D13
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource9,  GPIO_AF_FMC);       // PD9 = FMC_D14
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource10,  GPIO_AF_FMC);      // PD10 = FMC_D15
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource11,  GPIO_AF_FMC);      // PD11 = FMC_A16
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource12,  GPIO_AF_FMC);      // PD12 = FMC_A17
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource13,  GPIO_AF_FMC);      // PD13 = FMC_A18
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource14,  GPIO_AF_FMC);      // PD14 = FMC_D0
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource15,  GPIO_AF_FMC);      // PD15 = FMC_D1

  // Structure for Port-D
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0  | GPIO_Pin_1  | GPIO_Pin_4  | GPIO_Pin_5
                                // | GPIO_Pin_7
                                | GPIO_Pin_8  | GPIO_Pin_9  | GPIO_Pin_10
                                | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14
                                | GPIO_Pin_15;

  // Configure Port-D
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  //-----------------------------------------
  // All pins for Port-E initialization
  //-----------------------------------------
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource0,  GPIO_AF_FMC);       // PE0 = FMC_NBL0
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource1,  GPIO_AF_FMC);       // PE1 = FMC_NBL1
  // GPIO_PinAFConfig(GPIOE, GPIO_PinSource3,  GPIO_AF_FMC);       // PE3 = FMC_A19
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource7,  GPIO_AF_FMC);       // PE7 = FMC_D4
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource8,  GPIO_AF_FMC);       // PE8 = FMC_D5
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource9,  GPIO_AF_FMC);       // PE9 = FMC_D6
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource10, GPIO_AF_FMC);       // PE10 = FMC_D7
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource11, GPIO_AF_FMC);       // PE11 = FMC_D8
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource12, GPIO_AF_FMC);       // PE12 = FMC_D9
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource13, GPIO_AF_FMC);       // PE13 = FMC_D10
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource14, GPIO_AF_FMC);       // PE14 = FMC_D11
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource15, GPIO_AF_FMC);       // PE15 = FMC_D12

  // Structure for Port-E
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 // | GPIO_Pin_3
                                | GPIO_Pin_7
                                | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11
                                | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  // Configure Port-E
  GPIO_Init(GPIOE, &GPIO_InitStructure);

  //-----------------------------------------
  // All pins for Port-F initialization
  //-----------------------------------------
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource0,  GPIO_AF_FMC);       // PF0 = FMC_A0
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource1,  GPIO_AF_FMC);       // PF1 = FMC_A1
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource2,  GPIO_AF_FMC);       // PF2 = FMC_A2
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource3,  GPIO_AF_FMC);       // PF3 = FMC_A3
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource4,  GPIO_AF_FMC);       // PF4 = FMC_A4
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource5,  GPIO_AF_FMC);       // PF5 = FMC_A5
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource12, GPIO_AF_FMC);       // PF12 = FMC_A6
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource13, GPIO_AF_FMC);       // PF13 = FMC_A7
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource14, GPIO_AF_FMC);       // PF14 = FMC_A8
  GPIO_PinAFConfig(GPIOF, GPIO_PinSource15, GPIO_AF_FMC);       // PF15 = FMC_A9

  // Structure for Port-F
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3
                                | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13
                                | GPIO_Pin_14 | GPIO_Pin_15;

  // Configure Port-F
  GPIO_Init(GPIOF, &GPIO_InitStructure);

  //-----------------------------------------
  // All pins for Port-G initialization
  //-----------------------------------------
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource0,  GPIO_AF_FMC);       // PG0 = FMC_A10
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource1,  GPIO_AF_FMC);       // PG1 = FMC_A11
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource2,  GPIO_AF_FMC);       // PG2 = FMC_A12
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource3,  GPIO_AF_FMC);       // PG3 = FMC_A13
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource4,  GPIO_AF_FMC);       // PG4 = FMC_A14
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource5,  GPIO_AF_FMC);       // PG5 = FMC_A15
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource10,  GPIO_AF_FMC);      // PG10 = FMC_NE3
  GPIO_PinAFConfig(GPIOG, GPIO_PinSource12,  GPIO_AF_FMC);      // PG12 = FMC_NE4

  // Structure for Port-G
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3
                                | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_10 | GPIO_Pin_12;

  // Configure Port-G
  GPIO_Init(GPIOG, &GPIO_InitStructure);
}

//--------------------------------------------------------------
// Internal Function
// Initialize FSMC for the SRAM
//--------------------------------------------------------------
void P_SRAM_InitFMC(void)
{
  FMC_NORSRAMInitTypeDef        FMC_NORSRAMInitStructure;
  FMC_NORSRAMTimingInitTypeDef  FMC_NORSRAMTimingInitStructure;

#if 0
  // De-initialize for re-initialize
  FMC_NORSRAMDeInit(FMC_Bank1_NORSRAM3);                        // From FMC_Bank1_NORSRAM1 -> 3
#endif

  /* Enable FMC clock */
  RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC, ENABLE);

  //-----------------------------------------
  // Structure for Timing
  //-----------------------------------------
  FMC_NORSRAMTimingInitStructure.FMC_AddressSetupTime = SRAM_FMC_AST;        // 3
  FMC_NORSRAMTimingInitStructure.FMC_AddressHoldTime = SRAM_FMC_AHT;         // 0
  FMC_NORSRAMTimingInitStructure.FMC_DataSetupTime = SRAM_FMC_DST;           // 3
  FMC_NORSRAMTimingInitStructure.FMC_BusTurnAroundDuration = 0;
  FMC_NORSRAMTimingInitStructure.FMC_CLKDivision = 0;
  FMC_NORSRAMTimingInitStructure.FMC_DataLatency = 0;
  FMC_NORSRAMTimingInitStructure.FMC_AccessMode = FMC_AccessMode_A;

  //-----------------------------------------
  // Structure for Bank-1 / PSRAM-1
  //-----------------------------------------
  FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM3;       // From FMC_Bank1_NORSRAM1 -> 3
  FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable;
  FMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;              // Workaround for 'Free GPIO Pin' <- NOR
  FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_NORSRAM_MemoryDataWidth_16b;
  FMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;
  FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
  FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
  FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
  FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
  FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable;
  FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
  FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Disable;
  FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
  FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &FMC_NORSRAMTimingInitStructure;
  FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &FMC_NORSRAMTimingInitStructure;

  // Configure FSMC
  FMC_NORSRAMInit(&FMC_NORSRAMInitStructure);

  // Enable Bank-1 / PSRAM-1
  FMC_NORSRAMCmd(FMC_Bank1_NORSRAM3, ENABLE);                   // From FMC_Bank1_NORSRAM1 -> 3

}

//--------------------------------------------------------------
// Sends 16-bit value to the external SRAM
//--------------------------------------------------------------
void UB_SRAM_Write(uint32_t adr, uint16_t wert)
{
  // Transfer 16-bits data to the memory
  *(uint16_t *) (SRAM_ADR + adr) = wert;
}

//--------------------------------------------------------------
// Reads 16-bit value from the external SRAM
//--------------------------------------------------------------
uint16_t UB_SRAM_Read(uint32_t adr)
{
  uint16_t ret_wert = 0;

  // Read 16-bits data from the memory
  ret_wert = *(__IO uint16_t*) (SRAM_ADR + adr);

  return(ret_wert);
}

Is there any missing points that I should check before doing this?

A: From a software perspective you've got a mismatch between your bank selection and your base address. The FMC banks are arranged as 4x64Mb (banks 1,2,3,4) with the following base addresses:
bank 1: 0x60000000
bank 2: 0x64000000
bank 3: 0x68000000
bank 4: 0x6C000000

It's confusing that ST refer to the 64Mb ranges as banks themselves when they are really sub-banks of the larger bank #1 that's allocated to NOR/PSRAM.
You've defined this:
#define SRAM_ADR   ((uint32_t)0x60000000)

// [...]

FMC_NORSRAMCmd(FMC_Bank1_NORSRAM3, ENABLE);

As you can see you've got a mismatch between bank selection (#3) and base address selection (#1). You need to get them aligned.
If you continue to have issues after fixing this then look at your timing calculations and definitely the electrical connections.


text:
Q: Java find Minimum rotation calculate in 2 Array In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)
We may rotate the ith domino, so that tops[i] and bottoms[i] swap values.
Return the minimum number of rotations so that all the values in tops are the same, or all the values in bottoms are the same.
I was able to solve it without the minimum requirement, how can I solve it with the minimum requirement, also is there a non-recursive solution?
@Test
public void runDomino(){
    int[] tops = new int[]{2,1,2,4,2,2};
    int[] bottoms = new int[]{5,2,6,2,3,2};
    System.out.println(getCounter(tops, bottoms, 0,0));
}

private int getCounter(int[] tops, int[] bottoms, int counter, int i) {
    if(i==tops.length-1){
        return counter;
    } else {
        if(tops[i]== tops[i+1] || bottoms[i]== bottoms[i+1]){
            i++;
            return getCounter(tops, bottoms, counter, i);
        }
        else if(tops[i]== bottoms[i+1] || bottoms[i+1]== tops[i]){
            counter++;
            i++;
            int temp = tops[i];
            tops[i] = bottoms[i];
            bottoms[i] = temp;
            return getCounter(tops, bottoms, counter, i);
        } else {
            System.out.println("not matches anyway");
            return Integer.MAX_VALUE;
        }
    }
}

A: I'm going to assume reasonable inputs and that there are no duplicate dominoes in the set.
The first thing to do is identify the common value. I'll wave my hands at how you determine what the common value because it shouldn't be hard given the assumptions.  So I'll leave that as a method to be implemented...
int value = findCommonValue(tops, bottoms);

Count the number of times that value occurs in each of the arrays. Since we can get all of the common values in either tops or bottoms, the minimum number of swaps is the shared length of the arrays minus the larger value.
int numValuesTops = (int) Arrays.stream(tops).filter(e -> e == value).count();
int numValuesBottoms = (int) Arrays.stream(bottoms).filter(e -> e == value).count();
int minSwaps = Math.min(numValuesTop, numValuesBottoms);

So, given the tops/bottoms that follow:
int[] tops =    new int[] {2, 1, 2, 4, 2, 2};
int[] bottoms = new int[] {5, 2, 6, 2, 3, 2};

*

*In this case, the common value is 2.

*The number of 2s in tops is 4

*The number of 2s in bottoms is 3

*Length of arrays (6) minus larger count (4) is 2


text:
Q: CSS - MULTIPLE DIV How would I link css to sp-copyright

A: To style classes you use a "." before the class name.
To style id's you'd use a "#" before the id name.
Note that "margin-top" won't work on inline elements (like span is).
You can use a div instead, which is a "block" element, and then add margin to that.
Or, instead, make the span a block element.


text:
Q: Multiple project for a Prism application I would like to create a new Prism/Xamarin.Forms application but I want to create more than 1 portable project.
What I would like to achieve is the following :

*

*MyProject.Models : a portable project that contains the business objects (the models).

*MyProject.ViewModels : a portable project that contains the viewmodels (references MyProject.Models).

*MyProject.Views : a portable project that contains the views (references MyProject.ViewModels).

*MyProject.Droid, MyProject.UWP : the executable projects.

Is this organisation possible in a Prism solution ? Will the templates work in this setup ?
In fact, I try to convert a MvvmLight project to Prism and it's how my solution is currently done.
Many thanks in advance for your answers,
Julien

A: Yes, it will work just fine.  It doesn't matter how you have your projects structured.  When you register your pages for navigation, just make sure you use the explicit RegitserTypeForNavigation<View, ViewMOdel> method.


text:
Q: Android 2.2: Turning of screen under certain times of the day by code I would like to know if there is any way to turn off the screen on an android device on for example 19.00-22.00 every day. I have some tablets running in kiosk mode, and i want the screens to turn off when no one is using them and the store is closed.
Thanks

A: Screens will turn off automatically, if you have that set up properly in the device settings.
You can use AlarmManager and a WakeLock to arrange to keep the device screen awake during business hours. Have the AlarmManager start up a service that acquires the WakeLock and waits until closing time. You will need to use startForeground() in the service to prevent Android from killing off your service.
In the real world, this implementation would suck, as it forces you to keep a service running all the time -- if you let the service shut down, you lose the WakeLock and can never release() it, so the screen will never shut off. So, outside of this sort of kiosk thing, I do not recommend this technique.


text:
Q: what type of projects exist to php none framework for xss filltering and security What type of projects exist to php  none framework for xss filltering and security?
I know there is OWASP ESAPI for PHP
but its hardly update and not seem good as well i looking for something that can give good solution for security part for input filter and not just this.
i looking something that is best practice hehe,
as well if someone have good tips around security  so if have nothing so i know what to do here.

A: You can try http://htmlpurifier.org/


text:
Q: Remove focus from dynamically created button I have added a button to the DevExpress extra bar like below.
    Dim bbiBtn As New DevExpress.XtraBars.BarButtonItem
    bbiBtn.Caption = "Delete"
    bbiBtn.Name = "bbiDelete
    bbiBtn.Tag = "Delete"
    bbiBtn.ButtonStyle = BarButtonStyle.Check
    barMain.AddItem(bbiBtn) 'barMain is  DevExpress extra bar

Now when I click the button and task inside the click event is performed but the button is still focused. I want this to be removed.
I tried making other fields like a label to be focused. I also loop through all item inside the bar and reset it and refresh like below.
 For Each btn As DevExpress.XtraBars.BarButtonItem In barMain.Manager.Items
      If btn.Name = "bbiDelete" Then
        btn.Reset()
        btn.Refresh()
      End If
    Next

But none of this worked. Could you please help me on this.

A: Does this one fix your problem?
ButtonName.focus()
If not use this.
ButtonName.Select()
Add this code if after you created your button.
By this code you can set where you want to focus your button. Set focus on any type of button not the one that you dynamically created.


text:
Q: GetRequiredService and AddHttpClient freeze .NET console application (stack overflow) In my .NET Core console application, this line freezes:
services.GetRequiredService<ISomething>();
in the following code:
interface ISomething { }
class Cool : ISomething
{
    public Cool(IHttpClientFactory factory) { }
}

class Program
{
    static async Task Main(string[] args)
    {
        var host = CreateHostBuilder(args).Build();
        await host.StartAsync();

        // Freezes here and maxes out memory
        ISomething internalApiConnector = host.Services.GetRequiredService<ISomething>();

        await host.RunAsync();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureServices((_, services) =>
            {
                services.AddHttpClient<IHttpClientFactory>();
                services.AddSingleton<ISomething, Cool>();
            });
}

and ends up maxing out the memory with eventually crashes the app.
What am I missing?
Note:

*

*Cool constructor does not get run, so doesn't appear to be something halting in there.

Solution (Thanks all):
serviceCollection.AddHttpClient<IHttpClientFactory>(); needed to be changed to
serviceCollection.AddHttpClient();
and
.BuildServiceProvider() was superflous.

A: What you're experiencing is a stack overflow exception, caused by the AddHttpClient<IHttpClientFactory> registration. This causes a cyclic dependency which is not detected by MS.DI, causing the unfortunate stack overflow.
To understand why this happens, you need to look at the code for HttpClientBuilderExtensions:
builder.Services.AddTransient<TClient>(s =>
{
    var httpClientFactory = s.GetRequiredService<IHttpClientFactory>();
    var httpClient = httpClientFactory.CreateClient(builder.Name);

    var typedClientFactory = s.GetRequiredService<ITypedHttpClientFactory<TClient>>();
    return typedClientFactory.CreateClient(httpClient);
});

As the code shows, a call to AddHttpClient<TClient> results in the registration of a delegate. When that delegate is invoked, an IHttpClientFactory is resolved. From that IHttpClientFactory an HttpClient is created. In your case, however, you specified IHttpClientFactory for your TClient, effectively replacing the original IHttpClientFactory registration. This caused the call to s.GetRequiredService<IHttpClientFactory>() to callback into itself, hence the cyclic dependency and the stack overflow.
What you did wrong is supplying IHttpClientFactory as the TClient of AddHttpClient<TClient>. AddHttpClient is meant to register a 'client' class that takes a HttpClient as direct dependency. For instance:
services.AddHttpClient<GitHubApiClient>() // GitHubApiClient depends on HttpClient

You, however, aren't the only party at fault here. Microsoft should have been a better job, because:

*

*MS.DI's cyclic-dependency detection is lacking and too simplistic causing it to miss this type of cyclic dependency.

*The AddHttpClient<TClient> method doesn't validate it's preconditions allowing this to happen. As it makes no sense to supply AddHttpClient with an abstract TClient, at the very least it should have prevented this and throw an exception. Further more, it makes no sense to register a TClient that contains no HttpClient as constructor dependency, so this should have been a case prevented as well.

This means that there is room for improvement in the Microsoft stack ;-)


text:
Q: Get specific element of associative array by position without loop Is there any function which can return, for example, the 3rd element of an associative array without any loop? (and without copying the array)
I know that I can do a for/foreach loop together with a counter, but I'm just curious.

PS: I already found this example, but I was expecting something from php which would do something like getAssociativeDataByIndex($array, $index) for example.
EDIT: content of this post:

function getAtPos($tmpArray,$pos) {
 return array_splice($tmpArray,$pos-1,1);
}

$array = array('Alpha' => 1.1,'Bravo' => 2.2,'Charlie' => 3.3,'Delta' => 4.4,'Echo' =>5.5, 'Golf' => 6.6);
$pos = 3;

$return = getAtPos($array,$pos);
var_dump($return); // 3.3

PS2: I also found this answer, but the ArrayIterator class and the seek method is not (well) documented, so I'm not if this create a copy of the array or not (if it does, I do not think it's interesting)
EDIT: content of this post:

$keys = array_keys($array);
echo $array[$keys[$position]];

OR

The ArrayIterator class can also do this for you:

$iterator = new ArrayIterator($array);
$iterator->seek($position);

example of array:
$a = array('jean' => 3, 'simon' => 2, 'alex' => 5, 'derek' => 4);

Example of use case:
you have an external library which takes an array in parameter, process it and return you an array like index=>boolean (or index=>data)
e.g.: array(1=>false, 2=>false, 3=>true)...

A: array_values() will basically convert your associative array to a numeric array while maintaining the order:
<?php
$a = array('jean' => 3, 'simon' => 2, 'alex' => 5, 'derek' => 4);
$values = array_values($a);
print_r($values);
?>

result:
Array
(
    [0] => 3
    [1] => 2
    [2] => 5
    [3] => 4
)


text: Q: Is it possible to take a screenshot of an open browser window that includes the area hidden by a scroll bar? I am in need of a screenshot of an entire web page that has a height much greater than my physical screen. I am able to take multiple screenshots as I scroll down the page and then manually stitch them together on graphic design software, but ideally I could take a screen shot that does not require this extra step. Does anyone have any solutions, either first-party or through a third-party Mac application?


text:
Q: Different OS - How to read server txt file with client app I am writing a test application. It consists of a small desktop app and servlet. The desktop is a client and is to connect to my servlet, as I suppose, from any OS. It is greate but I have a txt file which is on the server. My desktop app adds lines to the txt file (images files names). The lines may contain cyrillic words like a "картинка1.jpg" and that is the most big problem because I cannot get the original cyrillic image name back to my client. That's make impossible to download image by using its name because server cannot identify such an image name like a "???????1.jpg" to read it back to my client.  I know it is all the encoding problem but I am wondering how to make my client desktop app work correctly togather with my servlet which is on linux? I mean what should me do if my client and server have different localization and "file.encoding"?
OK... accepting your silence I want to decrypt some details... So things I do and things I get are

*

*A) (client) I use JFileChooser to get
image file name (lets call it nameX)

*B) (client) I use httpclient 4 and
StringBody(nameX,"utf8") to send the
nameX to my servlet

*C) (server) Gets nameX from FileItems
and writes (adds) it to N.txt file

*D) (client) I get the images file
names list shown (in cp1251 encoding
because the client supports it) and
choose the "nameX"

*E) (client) Sends the "nameX" with
StringBody(nameX,"utf8") header to
servlet

*F) (server) Gets nameX but for some
reason it is something like
??????1.jpg so it cannot identify the
file name is...

SO my problem is somewhere is back/previous encoding I guess but I am not sure...
I have checked my server encoding it is

*

*os.name = Linux

*sun.jnu.encoding = UTF-8

*file.encoding = UTF-8

*user.language = en

and my client is:

*

*os.name = Windows XP

*sun.jnu.encoding = Cp1251

*file.encoding = Cp1251

*user.language = ru

Please help me to understand what am I doing wrong?
Any useful comment is appreciated :)

A: Do the following:

*

*When writing to a file: new BufferedWriter(new OutputStreamWriter(new FileOutputStream(File), "UTF-8"));

*When retrieving the image file from the web server, do not use anything but ASCII in the URL. Unfortunately, only ASCII will work reliably across all web clients and servers.


text:
Q: configurar zona horaria JDBC driver java presento un error al ejecutar mi codigo de parte de la persistencia el cual es el siguiente
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: The server time zone value 'Hora est. Pac?fico, Sudam?ric' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

¿Donde se configura la zona horaria para solucionar ese problema?
utilizo el siguiente driver de mysql
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.5</version>
        </dependency>

A: En mi caso, estoy utilizando SpringFramework, con configuración mediante xml.
Lo solucioné añadiendo al final del valor de la property url : ?serverTimezone=UTC
Quedando algo como:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/miBBDD?serverTimezone=UTC"/>
        <property name="username" value="root"/>
        <property name="password" value="miPassword"/>
    </bean>

A: Puedes configurarlo en la URL de la conexion:
jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Aqui la respuesta en ingles.
Ademas creo, como muestra el error SQL con ?, que deberias de configurar MySQL con encoding ISO-8859-1 para que permita caracteres como la ñ al tratar de insertar VARCHARS y no se corrompa tu data.

A: Tenia el mismo error y lo solucione agregando a la Url de la db :
?serverTimezone=UTC

ejemplo :
public String url="jdbc:mysql://localhost:3306/nombreDB?serverTimezone=UTC";

espero te sirva!:3

A: También se puede configurar la zona horaria de MySQL ejecutando esta query y asi evitar modificar la URL
SET GLOBAL time_zone = '-3:00';

A: Siempre me ha funcionado agregar en la ruta de la BD, despues del nombre de la base de datos lo siguiente: ?serverTimezone=UTC
A modo de ejemplo dejo una ruta para que sea mas claro:
"jdbc:mysql://localhost:3306/biblioteca?serverTimezone=UTC","root","root"
Espero funcione sin problemas

A: Muchas gracias aquí encontrare la solución al error de conexión de mysqlcon java,se soluciono añadiendo al
url: ?serverTimezone=UTC

A: Yo lo solucioné añadiendo el nombre del puerto completo (ej:"128.0.0.1:3306/db) y seguidamente adjunté lo siguiente:
?serverTimezone=UTC

A: A veces podrías darse el caso que UTC no te funciona como deseas quizás debas usar alternativas como:
 1. UTC
 2. CST
 3. EST
 4. GMT
depende como se acomode a los registros en tu base sino podrías tener una fecha en la base y otra totalmente distinta e tu aplicación.


text:
Q: Why can I not see my HTTP headers in Chrome? I am performing a fetch:
fetch(url, fetchOptions);

fetchOptions is configured like so:
var fetchOptions = {
  method: options.method,
  headers: getHeaders(),
  mode: 'no-cors',
  cache: 'no-cache',
};

function getHeaders() {
  var headers = new Headers(); // Headers is part of the fetch API.
  headers.append('User-ID', 'foo');
  return headers;
}

Checking fetchOptions at runtime it looks as follows:
fetchOptions.headers.keys().next() // Object {done: false, value: "user-id"}
fetchOptions.headers.values().next() // Object {done: false, value: "foo"}

But user-id is nowhere to be found in the request headers per Chrome dev tools:
GET /whatever?a=long_name&searchTerm=g HTTP/1.1
Host: host:8787
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
accept: application/json
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
Referer: http://localhost:23900/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,fr;q=0.6

Why can I not see my "User-ID" header in Chrome dev tools, and why does the header key appear to have been lowercased?

A: Incase someone else has a similar problem there were two possible culprits for this:

*

*I might not have been starting Chrome with the correct flags.

The following didn't work when run from a Windows shortcut:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -enable-precise-memory-info -disable-web-security

The following did work when run from a Windows command prompt:
C:\whatever\48.0.2564.82\application\chrome.exe  --disable-web-security --user-data-dir=C:\whatever\tmp\chrome

*The addition of no-cors to the mode of the request might have caused an OPTIONS request to precede the GET request and the server did not support OPTIONS.


text:
Q: Can someone help me understand the Iterable interface? I found this code snippet and have been having trouble fully understanding its implementation. I know it has one method:
Iterator<T> iterator()

which creates a new iterator. But what is the point of this one method.
In this example:
import java.util.Iterator;

public class Range implements Iterable<Integer> {
  private int start, end;
  public Range(int start, int end) {
    this.start = start;
    this.end = end;
  }

  public Iterator<Integer> iterator() {
    return new RangeIterator();
  }
}

public static void main(String[] args) {
  Range range = new Range(1, 10);
  for(Integer cur : range) {
    System.out.println(cur);
  }
}

The code works correctly, yet iterator() has never been called. I know you need the Iterable interface to use the for each loop, but what is the point of the one method inside the interface? Any help in clearing this confusion would be appreciated.


text:
Q: Wouldn't decreasing the radius that an object revolves around, increase its velocity to infinity You know the angular momentum equation that makes keplers second law work
L=rmv where L is angular momentum is r radius, m is mass and v is velocity.
Well according to that equation if we decrease the radius  then either the mass or the velocity would have to increase (sort of how keplers second law works) right? Well then if we decreased the radius to Planck length or something extremely small, wouldn't that mean that the object would have to increase its velocity (since it can't increase its mass )so it could keep angular momentum constant?... Pls explain this to me (try to use equations) but any help would be helpful...Thanx in advance

A: You are right, given a point mass and some way to pull the mass toward its center of revolution.  But it would take an infinite amount of energy to reduce that radius of revolution to zero.


text:
Q: Xpath finding in the html code I am trying to get the Xpath of the following. I am trying to get the name of the location. 'London' from this div tag. I use \h4\a as Xpath but i am unable to do so. Any suggestions on how to specify correct Xpath?

London

A: You can use the XML package, applying XPath to grab the text from that node.
library(XML)
res <- xpathSApply(htmlParse(doc), '//h4/a', xmlValue)

Or the shorthand version:
res <- doc['//h4/a/text()'][[1]]


text:
Q: Getting error when adding a middleware to the route in Slim I wrote this code in Slim and it works fine but when I add the middleware I get the following error!!! Can not figure out what is happening, could any one please help me.
PHP Catchable fatal error:  Argument 3 passed to fileFilter() must be callable, array given FILENAME in line 90

This middleware filters unsupported file types
use Slim\Http\Request;
use Slim\Http\Response;
use Api\ErrorList as ErrorList;

function fileFilter(Request $request, Response $response, callable $next){
        $allowedFiles = ['image/jpeg', 'image/png', 'application/pdf'];
        $files = $request->getUploadedFiles();
        $flattened =array_flatten($files);

        foreach ($flattened as $key=> $newFile){
            $newFileType = $newFile->getClientMediaType();

            if(!in_array($newFileType, $allowedFiles)) {
                return ResponseHelper::createfailureResponse($response, HTTPStatusCodes::BAD_REQUEST, ErrorList::UNSUPPORTED_FILE_TYPE);
            }

        }
        return $next($request, $response); // line 90
    }

And here I add the middleware to my route.
 $app->group('/test/api/v1', function () {
        // other routes here
        $this->post('/resume/edit','fileFilter', ResumeController::class. ':edit')->setName('Resume.edit');

    });

A: You should remove 'fileFilter' from
$this->post('/resume/edit', ...

and change it to something like
$this->post(...)->add((Request $request, Response $response, callable $next){
    $allowedFiles = ['image/jpeg', 'image/png', 'application/pdf'];
    $files = $request->getUploadedFiles();
    $flattened =array_flatten($files);

    foreach ($flattened as $key=> $newFile){
        $newFileType = $newFile->getClientMediaType();

        if(!in_array($newFileType, $allowedFiles)) {
            return ResponseHelper::createfailureResponse($response, HTTPStatusCodes::BAD_REQUEST, ErrorList::UNSUPPORTED_FILE_TYPE);
        }

    }
    return $next($request, $response); // line 90
});

or as invokable class
class MyMiddleware
{
    public function __invoke(Request $request, Response $response, callable $next){
        $allowedFiles = ['image/jpeg', 'image/png', 'application/pdf'];
        $files = $request->getUploadedFiles();
        $flattened =array_flatten($files);

        foreach ($flattened as $key=> $newFile){
            $newFileType = $newFile->getClientMediaType();

            if(!in_array($newFileType, $allowedFiles)) {
                return ResponseHelper::createfailureResponse($response, HTTPStatusCodes::BAD_REQUEST, ErrorList::UNSUPPORTED_FILE_TYPE);
           }

        }
        return $next($request, $response); // line 90
    }
}

and in route
$this->post(...)->add(MyMiddleware::class);

Slim Middleware


text:
Q: Detect IsAlive on an IObservable I'm writing a function IsAlive to take an IObservable<T>, and a timespan, and return an  IObservable<bool> The canonical use case is to detect if a streaming server is still sending data.
I've come up with the following solution for it, but feel it's not the most clear as to how it works.
public static IObservable<bool> IsAlive<T>(this IObservable<T> source,
                                           TimeSpan timeout,
                                           IScheduler sched)
{
    return source.Window(timeout, sched)
                 .Select(wind => wind.Any())
                 .SelectMany(a => a)
                 .DistinctUntilChanged();
}

Does anyone have a better approach?
FYI -
Here are the unit tests and existing approaches that I've tried: https://gist.github.com/997003

A: This should work:
public static IObservable<bool> IsAlive<T>(this IObservable<T> source,
                                           TimeSpan timeout,
                                           IScheduler sched)
{
    return source.Buffer(timeout, 1, sched)
                 .Select(l => l.Any())
                 .DistinctUntilChanged();
}

This approach makes semantic sense, too. Every time an item comes in, it fills the buffer and then true is passed along. And every timeout, an empty buffer will be created and false will be passed along.
Edit:
This is why the buffer-1 approach is better than windowing:
var sched = new TestScheduler();
var subj = new Subject<Unit>();

var timeout = TimeSpan.FromTicks(10);

subj
    .Buffer(timeout, 1, sched)
    .Select(Enumerable.Any)
    .Subscribe(x => Console.WriteLine("Buffer(timeout, 1): " + x));

subj
    .Window(timeout, sched)
    .Select(wind => wind.Any())
    .SelectMany(a => a)
    .Subscribe(x => Console.WriteLine("Window(timeout): "+x));

sched.AdvanceTo(5);
subj.OnNext(Unit.Default);
sched.AdvanceTo(16);

yields:
Buffer(timeout, 1): True
Window(timeout): True
Buffer(timeout, 1): False

To be specific, the window is open for the whole timeout and doesn't close and reset as soon as an item comes in. This is where the buffer limit of 1 comes into play. As soon as an item comes in, the buffer and its timer get restarted.
I could re-implement my buffer as a window, as buffer's implementation is a window, but a) I think buffer makes better semantic sense and b) I don't have to SelectMany. Scott's Select and SelectMany could be combined into a single SelectMany(x => x.Any()), but I can avoid the entire lambda and specify the Enumerable.Any method group, which will bind faster (trivial) anyway.

A: How about:
source.Select(_ => true)
    .Timeout(timeout, sched)
    .DistinctUntilChanged()
    .Catch<bool, TimeoutException>)(ex => Observable.Return(false));


text:
Q: Milkdown Editor get latest change Iam trying to make an CollabEditor myself, now i want to get the changes from the editor.
But iam only able to get the full markdown or json.
If the user types "Hello" i want to get:
//string is the add string, start is the index where it got added

*

*change: {string:'H', start:0}

*change: {string:'e', start:1}

*change: {string:'l', start:2}

*change: {string:'l', start:3}

*change: {string:'o', start:4}

It is possible that the user pastes the string then it should output:

*

*change: {string:'Hello', start:0}

On delete it should output:
//from delet from, to index

*

*change: {from:0, to:4}

Maybe someone knows how this could work with the MilkdownEditor


text:
Q: Minimum number of replications for certain confidence interval Par(3) distribution I have some trouble solving the following question:
Given are $M$ replications of $Par(3)$ distributed stochasts $X_1,X_2,...,X_i$. Known is that $Var(x_i)=3/4$. Now I have to determine, using Chebyshev's inequality, the minimum value of $M$ for which the chance on an error less than 0.05 is 0.9. So I need the $M$ in the following equation: $P(\mu-0.05\le X_M \le \mu +0.05)=0.9$. I can't figure out how all these things are related and how to solve this without knowing the expected value itself. Help is appreciated.

A: For reference, Chebychev's inequality states: $P(|X-\mu|\geq \epsilon)\leq\frac{\sigma^2}{\epsilon^2}$
Also, as written your statement does not make sense, as $P(\mu-0.05\le X_M \le \mu +0.05)=0.9$ is a feature of the distribution, not the sample size. However, if you meant $\bar X_M$ then this makes sense. This can be rewritten as $P(|\bar X_M-\mu|\leq 0.05)=0.9$. Now, Chebyshevs inequality does not give you an exact error bound, only an upper bound. Therefore, you cannot use Chebyshev's inequality to answer your question as stated. However, you can answer the related question: $P(|\bar X_M-\mu|\leq 0.05)\geq0.9$
Rearranging the senses of the inequality we get:
$P(|\bar X_M-\mu|\leq 0.05)=1-P(|\bar X_M-\mu|> 0.05)\geq1-\frac{\sigma_{x_i}^2}{0.05^2M}$ since the variance of the sample average decreses as $\frac{1}{M}$. Now select M using your known variance to get the required sample size.


text:
Q: How to Restart cmd every 30 Minutes with Node I have a bot and I want, this bot restart every 30minutes I have a .batch code to start the bot. Now I want this bot starts every 30min.
I have this :
node bot.js
pause

A: old school (and not really good) solution is:
:label1
taskkill /f /fi "windowtitle eq %SYSTEMROOT%\system32\cmd.exe - MyBotName.bat"
start MyBotName.bat
ping -n 1801 127.0.0.1>nul
goto :label1