How to show that this function is measurable. For a given $N$, I have this function:
$0$ when $0 \le x \le \frac{1}{N+1}$
$\sin\left(\frac{1}{x}\right)$ when $\frac{1}{N+1}<x\le\frac{1}{N}$
$0$ when $\frac{1}{N}<x\le 1$
Here is my attempt.
In the interval $(0,1]$ the function $sin(1/x)$ is measurable since it is continuous. In the same interval the step function which is 0 when $0 \le x \le \frac{1}{N+1}$, 1 when $\frac{1}{N+1}<x\le\frac{1}{N}$ and 0 when $\frac{1}{N}<x\le 1$ is also measurable because the Lebesgue $\sigma$-algebra contains all intervals. Also since the product of two functions are measurable, I have gotten that the original function is measurable if it was defined for $(0,1]$. 
But how do I also get that the function that is 0 when x=0 is measurable?

First note that $\{ 0\}$ is Lebesgue measurable since we have  $\displaystyle \{ 0 \} = \bigcap_{n \in \mathbb N} ( -\frac{1}{n} , 0 \ ]$ is a countable intersection of half-open intervals. Then $[0,1] = \{0\} \cup (0,1]$ is measurable too.
You are right that the function $\displaystyle \sin\left(\frac{1}{x}\right) {\bf 1}_A (x)$ for $A =  [\frac{1}{N+1},\frac{1}{N}]$ is measurable as a product of measurable functions. The indicator function is measurable because of a more general result: This is that ${\bf 1}_A$ is a measurable function iff $A$ is a measurable set. 
To say that a function $f$ is measurable is to say that the set $f^{-1}(B)$ is measurable for all measurable sets $B$. This is the same as the definition you gave since the Lebesgue measurable sets are generated by the intervals $[-\infty, r)$.
The next step is to check what ${\bf 1}_A ^{-1} (B)$ is measurable. To do this consider separately the four cases $0,1 \notin B \ ; \ 0 \in B, 1 \notin B \ ; \ 0 \notin B, 1 \in B \ ; \ 0,1 \in B$. For each case the preimage will be very simple and will turn out to be measurable.
