By combining (i) the economic theory of rational expectation bubbles, (ii) behavioral finance on imitation and herding of investors and traders and (iii) the mathematical and statistical physics of bifurcations and phase transitions, the log-periodic power law (LPPL) model has been developed as a flexible tool to detect bubbles. The LPPL model considers the faster-than-exponential (power law with finite-time singularity) increase in asset prices decorated by accelerating oscillations as the main diagnostic of bubbles. It embodies a positive feedback loop of higher return anticipations competing with negative feedback spirals of crash expectations. The power of the LPPL model is illustrated by two recent real-life predictions performed recently by our group: the peak of the Oil price bubble in early July 2008 and the burst of a bubble on the Shanghai stock market in early August 2009. We then present the concept of "negative bubbles", which are the mirror images of positive bubbles. We argue that similar positive feedbacks are at work to fuel these accelerated downward price spirals. We adapt the LPPL model to these negative bubbles and implement a pattern recognition method to predict the end times of the negative bubbles, which are characterized by rebounds (the mirror images of crashes associated with the standard positive bubbles). The out-of-sample tests quantified by error diagrams demonstrate the high significance of the prediction performance.