explanation on a scheme which is not affine scheme Hartshorne at the end of page 76 of his Algebraic Geometry book gives an example of a scheme which is not an affine scheme. The scheme is constructed by gluing two affine lines together along their maximal ideals obtained by removing a point P. There's also a figure accompanying the example: 
___________:_________
Can someone please explain how to show that this is not an affine scheme?
 A: Compute the ring $R$ of globally defined regular functions. If the scheme were affine, then there would be a bijective correspondence between closed points of the scheme and maximal ideals of $R$, given by taking a closed point to the ideal of functions that vanish at that point. But the two points represented by the colon in your diagram give the same ideal of $R$, so this "correspondence" is not injective.  Therefore, the scheme is not affine.
A: Call $X $ your scheme over the field $k$, $P_1$ and $P_2$ the two special closed points, $A_1$and $A_2$ their respective  open complements and $A_{12}=A_1\cap A_2$, so that $A_i\simeq \mathbb A^1_k$ and $A_{12}\simeq\mathbb G_m$, all affine schemes.
Here are some (not independent) proofs that $X$ is not affine.   
Proof 1
The point $(P_1,P_2)\in X \times X $ is in the closure of the diagonal $\Delta_X\subset X \times X $, but  $(P_1,P_2)\notin \Delta_X$ . So $\Delta_X$ is not closed, hence $X$ is not separated and a fortiori not affine     
Proof 2
The images  of the restriction map $\Gamma(A_i,\mathcal O_X)=k[T] \to \Gamma(A_{12},\mathcal O_X)=k[T,T^{-1}]$ are both
$k[T]$, and together  do not generate  $ k[T,T^{-1}]$. However, in an affine scheme (or more generally in a separated scheme) the ring of regular sections on the intersection of two open affines is  generated by the images of the regular sections on the two opens.    
Proof 3
The two open immersions $\iota_j:\mathbb A^1_k \to X$ with respective image  $A_j\subset X$ coincide on the  open subscheme $\mathbb G_m\subset \mathbb A^1_k$ but are nevertheless  distinct. This couldn't happen if $X$ were affine (or just separated).    
Proof 4
The cohomology vector space  $H^1(X,\mathcal O_X)$ is infinite dimensional, whereas the cohomology of a coherent sheaf on an affine scheme vanishes in positive degree.
In detail, consider the covering $\mathcal U=\lbrace A_1,A_2\rbrace$ of $X$. It is a Leray covering because $A_1,A_2,A_{12}$ are affine hence acyclic, for the coherent sheaf $\mathcal O_X$ (cf. Proof 2) . Thus Čech cohomology computes genuine cohomology.
The Čech complex is the linear map $$C^0=\Gamma(A_1,\mathcal O_X)\times \Gamma(A_2,\mathcal O_X)=k[T]\times  k[T]\stackrel {d^0}{\to} C^1=\Gamma(A_{12},\mathcal O^*_X)=k[T,T^{-1}]\to 0$$ 
given by $$d^0(P(T),Q(T)) =Q(T)-P(T)          $$.
Hence we get $H^1(X,\mathcal O_X)=k[T,T^{-1}]/k[T]$  
Proof 5
The Čech complex above proves that  $\Gamma(X,\mathcal O_X)=k[T]$ so that the restriction to the   strictly smaller open affine subscheme $A_1\subsetneq X$  is bijective: $res: \Gamma(X,\mathcal O_X)\stackrel {\simeq}{\to} \Gamma(A_1,\mathcal O_X)$.
This cannot happen for an affine scheme $X$.
[In categorical language: $\Gamma$ is an anti-equivalence from the category of affine schemes to that of rings] 
Proof 6
Every global function $P(T)\in \Gamma(X,\mathcal O_X)=k[T]$ (see Proof 5) takes the exact same value at $P_1$ and $P_2$, namely  $P(0)\in \kappa(P_1)=\kappa (P_2)=k$.
In contrast given two closed points in an  affine scheme , there exists  a global regular function vanishing at the first one but not at the second. 
