PHP if statement not returning the right page number Ive got this script to narrow down which page number a release ID is it seems to work for the most part but when i enter 0013 as the number it should say its pageNum=311 but it always comes back with 261.  Have i done something wrong?  Here is the script:  $releaseNumber = sprintf('%04d', 0013);  if($releaseNumber &lt; 6300 &amp;&amp; $releaseNumber &gt; 6000) {     $pageNum = 1; }elseif($releaseNumber &lt; 6001 &amp;&amp; $releaseNumber &gt; 5800) {     $pageNum = 16; }elseif($releaseNumber &lt; 5801 &amp;&amp; $releaseNumber &gt; 5600) {     $pageNum = 26; }elseif($releaseNumber &lt; 5601 &amp;&amp; $releaseNumber &gt; 5200) {     $pageNum = 36; }elseif($releaseNumber &lt; 5201 &amp;&amp; $releaseNumber &gt; 5000) {     $pageNum = 56; }elseif($releaseNumber &lt; 5001 &amp;&amp; $releaseNumber &gt; 4700) {     $pageNum = 66; }elseif($releaseNumber &lt; 4701 &amp;&amp; $releaseNumber &gt; 4300) {     $pageNum = 81; }elseif($releaseNumber &lt; 4301 &amp;&amp; $releaseNumber &gt; 3900) {     $pageNum = 101; }elseif($releaseNumber &lt; 3901 &amp;&amp; $releaseNumber &gt; 3500) {     $pageNum = 121; }elseif($releaseNumber &lt; 3501 &amp;&amp; $releaseNumber &gt; 3100) {     $pageNum = 141; }elseif($releaseNumber &lt; 3101 &amp;&amp; $releaseNumber &gt; 2700) {     $pageNum = 161; }elseif($releaseNumber &lt; 2701 &amp;&amp; $releaseNumber &gt; 2300) {     $pageNum = 181; }elseif($releaseNumber &lt; 2301 &amp;&amp; $releaseNumber &gt; 1900) {     $pageNum = 201; }elseif($releaseNumber &lt; 1901 &amp;&amp; $releaseNumber &gt; 1500) {     $pageNum = 221; }elseif($releaseNumber &lt; 1501 &amp;&amp; $releaseNumber &gt; 1100) {     $pageNum = 241; }elseif($releaseNumber &lt; 1101 &amp;&amp; $releaseNumber &gt; 0900) {     $pageNum = 261; }elseif($releaseNumber &lt; 0901 &amp;&amp; $releaseNumber &gt; 0700) {     $pageNum = 271; }elseif($releaseNumber &lt; 0701 &amp;&amp; $releaseNumber &gt; 0500) {     $pageNum = 281; }elseif($releaseNumber &lt; 0501 &amp;&amp; $releaseNumber &gt; 0301) {     $pageNum = 291; }elseif($releaseNumber &lt; 0301 &amp;&amp; $releaseNumber &gt; 0100) {     $pageNum = 301; }elseif($releaseNumber &lt; 0101 &amp;&amp; $releaseNumber &gt; 0000) {     $pageNum = 311; }
How do you debug PHP scripts? How do you debug PHP scripts?  I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in PHPEclipse is also quite useful.  What is the best (in terms of fast and easy) way to debug in phpStorm or any other IDE?
Repeat each line multiple times Would like to have each line in a file repeated a fixed number of times.  e.g. have each line repeated four times:  a b c   becomes:  a a a a b b b b c c c c   I've done some searching, and there are a lot of questions and answers along the lines of doing the reverse, e.g. merging duplicate lines into single lines, and maybe a few about doubling lines by printing them again.  It would be easy to do this in C, but I wish I knew more about the native commands so I wouldn't have to resort to these kinds of one-off throw-aways all the time. How do you document your databases? I find that most of my clients are not documenting their databases at all and I find that pretty scary. To introduce some better practice, I would like to know what tools/process people are using.   How do you document your database? (SQL-Server)  What tool do you use?  Documentation Storage Format for database schema/meta-data?   Word documents Excel spreadsheet Plain Text  Documentation process or policies?   I am not talking about reverse engineering / document a existing database, but mainly on the documentation best practices while you develop your system/database. Spartan 6 DCM unstable clock output Is there any way to automatically get notified of property changes in a class without having to write OnPropertyChanged in every setter?  (I have hundreds of properties that I want to know if they have changed).    Anton suggests .  I've actually used the "Castle" library for something similar in the past, and while it does reduce the amount of code I've had to write, it added around 30 seconds to my program startup time (ymmv) - because it's a runtime solution.  I'm wondering if there is a compile time solution, maybe using compile-time attributes...    Slashene and TcKs give suggestions which generates repetitive code - unfortunately, not all my properties are a simple case of m_Value = value - lots of them have custom code in the setters, so cookie-cutter code from snippets and xml aren't really feasible for my project either. How do we perform transverse measurements in a two level system? In quantum mechanics any two level system can be mapped onto effective spin variables. If the system is defined by two energy levels, $|E_1\rangle$ and $|E_2\rangle$, the Hamiltonian is  $$ H = \left(\begin{array}{cc} E_1 &amp; 0 \\ 0 &amp; E_2 \end{array}\right) \, .$$  This can be recast as  $$ H = \frac{E_1+E_2}{2} 1\!\!1 + \frac{E_1-E_2}{2} \sigma_3\, .$$  $1\!\!1$ is the identity operator and $\sigma_3$ is the third pauli matrix. This is very nice because we can now apply our knowledge and intuition of spin dynamics to any two level system.  My question is the following: for a real spin I can measure expectation values of $\sigma_{1,2}$ by physically rotating my system and align its $x$ or $y$ axis with my measuring apparatus. How do I do this (in the lab!) with a pseudo-spin system? Imagine I am looking at a cold atom and I want to know if the system is in an symmetric or anti-symmetric superposition of $|E_1\rangle$ and $|E_2\rangle$, how do I do it? I want to find all files which contain a specific string of text. The grep command works, but I don't know how to use it for every directory (I can only do it for my current directory). I tried reading man grep, but it didn't yield any help. Coloring arrows in \xymatrix PSTricks error "Undefined control sequence  \c@lor@to@ps" When I launch certain programs from the command line like eclipse and document viewer in 11.10 it spews a load of information that seems inconsequential.   Also when they are run in the background they sometimes continue to produce output to the terminal which I am currently working on, which is irritating.  I would like them just launch and keep the background stuff in the background. My reasoning is that if you launch these programs through the GUI (eg double clicking on an icon) these messages are never shown to me, so I don't need them in the command line. We have various ways of invoking apex. Triggers, Inbound Webservices, @InvocableMethod,@RemoteAction and what not. Often we call some or other utility methods from these execution contexts. I have some generic utility method,that should behave differently from the context it is called?  I know about Trigger.isExecuting but it only tells if its running in trigger context or not.  I have a utility method that creates lead from Webservices, VF button click and via Lightning . Whenever we create a lead I want some special operations to be done via the source it was originated.(Its not just updating a simple field leadSource, I have some methods that creates some childs and update other records of other type) . I can achieve this by passing an extra parameter to utility method to tell about source, but i have then to edit hundred of other class that uses this utility method. If i could dynamically find out via which context this piece of code is running,then i would have to change only one class to satisfy my requirement.    Is there something in APEX that tells in what context the apex method was called? I need to show that for any countable ordinal $\alpha$ there is a set A $\subseteq \mathbb{Q}$ such that (A, &lt;) is isomorphic to ($\alpha, \in$).  To do it I am supposed to show the following stronger statement by induction on ordinals $\alpha$ &lt; $\omega_{1}$:  Let P($\alpha$) be the statement "For every interval (a, b) with rational endpoints, there is an A $\subseteq$ (a,b) such that (A, &lt;) is isomorphic to ($\alpha, \in$)."  I think that the purpose of breaking $\mathbb{Q}$ into intervals (a,b) is to make $\mathbb{Q}$ a countable set, but I don't see the significance of doing this or how it would make the proof easier.  I feel like I need to define a well-ordered set in (a,b) but I don't know how to do this since if a and b are both negative then there is no least element, so no well-ordering.  I believe that I am supposed to be using transfinite induction? But I don't know how P($\alpha$) implies P(S($\alpha$)) for S($\alpha$) successor of $\alpha$.  Any help would be greatly appreciated... thanks in advance. The Unix environment has some excellent tools for parsing text in various forms. However, of late, the data is not in the traditional (historical) formats (CSV, TSV, record-based or some other delimiter-based) it used to be before. Data these days is exchanged in structured formats like XML/JSON.  I know there are some good tools like sed, awk and Perl which can chew down nearly any form of data out there. However, to work with this sort of structured data, often one has to write a complete program, and, given the little time available to extract information, one has to sit down and figure out the whole logic of what one wants to query and put it down programmatically. Sometimes this is not OK – basically because the information extracted from those files acts as inputs for further work; also because of the time it takes to search for the appropriate solution and code it up. A command line tool is needed with sufficient switches to find, query and dump data.  I'm looking for tools that take a XML/JSON or other forms of structured data and dump it into other formats like csv, etc., so that from there one could use other commands to get any information out of it.  Are there any command line utilities you know of which do this kind of a job? Are there already awk/Perl scripts available to this? I need to draw a tree, and constantly using dotty and including the PNGs is starting to be a pain. Is there a way to get LaTeX to draw it's own trees that doesn't involve learning an entirely new language like TikZ? Show that there exists a unique $v_0 \in H^1(0,1)$ such that $u(0)=\int_0^1(u'v_0'+uv_0), \forall u \in H^1(0,1)$ Find files that a user can write, efficiently with minimal process creation I am root. I would like to know whether a non-root user has write access to some files - thousands of them. How to do it efficiently while avoiding process creation? How to convert a string of bytes into an int? How can I convert a string of bytes into an int in python?   Say like this: 'y\xcc\xa6\xbb'  I came up with a clever/stupid way of doing it:  sum(ord(c) &lt;&lt; (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1]))   I know there has to be something builtin or in the standard library that does this more simply...  This is different from  for which you can use int(xxx, 16), but instead I want to convert a string of actual byte values.  UPDATE:  I kind of like James' answer a little better because it doesn't require importing another module, but Greg's method is faster:  &gt;&gt;&gt; from timeit import Timer &gt;&gt;&gt; Timer('struct.unpack("&lt;L", "y\xcc\xa6\xbb")[0]', 'import struct').timeit() 0.36242198944091797 &gt;&gt;&gt; Timer("int('y\xcc\xa6\xbb'.encode('hex'), 16)").timeit() 1.1432669162750244   My hacky method:  &gt;&gt;&gt; Timer("sum(ord(c) &lt;&lt; (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1]))").timeit() 2.8819329738616943   FURTHER UPDATE:  Someone asked in comments what's the problem with importing another module. Well, importing a module isn't necessarily cheap, take a look:  &gt;&gt;&gt; Timer("""import struct\nstruct.unpack("&gt;L", "y\xcc\xa6\xbb")[0]""").timeit() 0.98822188377380371   Including the cost of importing the module negates almost all of the advantage that this method has. I believe that this will only include the expense of importing it once for the entire benchmark run; look what happens when I force it to reload every time:  &gt;&gt;&gt; Timer("""reload(struct)\nstruct.unpack("&gt;L", "y\xcc\xa6\xbb")[0]""", 'import struct').timeit() 68.474128007888794   Needless to say, if you're doing a lot of executions of this method per one import than this becomes proportionally less of an issue. It's also probably i/o cost rather than cpu so it may depend on the capacity and load characteristics of the particular machine. I have a bash script that makes a cURL request and writes the output to a file called resp.txt.  I need to create an exclusive lock so that I can write to that file and not worry about multiple users running the script and editing the text file at the same time. Here is the code that I expect to lock the file, perform the request, and write to the text file: ( flock -e 200 curl 'someurl' -H 'someHeader' &gt; resp.txt ) 200&gt;/home/user/ITS/resp.txt  Is this the correct way to go about this?  My actual script is a bit longer than this, but it seems to break when I add the flock syntax to the bash script. If someone could explain how these file descriptors work and let me know if I am locking the file correctly that would be awesome! Can the most important information of reputation audit appear first? I regularly find myself having to scroll to the bottom of the reputation audit to find all the good stuff that appears last. On my computer this is a single key press, but on my mobile it takes 30 seconds of scrolling. Lord alone knows how long it would be for Jon Skeet!  Since the principles of good user experience suggest putting the most important information first, why not do the same here? I never look at my first 5 days of rep gathering. But I often look at the current day, the true rep, days with 200 rep (hunting legendary badge!), trigger recalc etc. Pretty please, can we have it up top? LaTeX package "titling", titles with hard line breaks, and \MakeUpperCase I have a document with a title that is spread over several lines using hard line breaks. To configure the title formatting, I use the titling package with code adapted from its documentation:  \documentclass{article}  \usepackage{titling} \pretitle{\begin{center}\LARGE\sffamily\bfseries} \posttitle{\par\end{center}\vskip 0.5em}  \title{Higgelty Pigglety Pop! \\ or \\ There Must Be More to Life}  \begin{document} \maketitle \end{document}   …and it works perfectly.  I now want the title additionally to be in all caps and therefore change the \pretitle command:  \pretitle{\begin{center}\LARGE\sffamily\bfseries\MakeUppercase}   …and I get the following error message:  ! Use of \@icentercr doesn't match its definition. &lt;argument&gt; \def  l.12 \maketitle   This only happens with a title that includes hard line breaks.  What does this error message mean? How can I fix it? For the Fibonacci numbers, show for all $n$: $F_1^2+F_2^2+\dots+F_n^2=F_nF_{n+1}$