Let's just work on $[0,1]$. The general case is only slightly different.
Given $x$ irrational and $\epsilon>0$, we want to show that there is a $\delta>0$ so that $|f(x)-f(y)|=|f(y)|<\delta$ for all $y\in[0,1]$ satisfying $|x-y|<\delta$.
In the following, by "rational", I mean a rational number in $[0,1]$ in lowest terms.
Take any open interval containing $x$. There are at most two rationals in the interval with denominator $2$. There are at most three in the interval with denominator $3$ ... You can find an open interval containing $x$ that does not contain rationals with denominators $2$ or $3$.
In fact, given any positive integer $N$, if you choose $\delta>0$ small enough, you can insure that the interval $I=(x-\delta,x+\delta)\cap[0,1]$ contains no rational with denominator less than $N$.
So, pick $N$ with $1/N <\epsilon$ and choose $\delta$ as just described. Then for $x\in I=(x-\delta,x+\delta)\cap[0,1]$, you'll have what's needed: If $y$ irrational is in $I$, then $f(y)=0$. If $y\in I$ is rational, we must have, by the choice of $\delta$, $f(y)=1/M$ for some $M> N$. But then $|f(y)|<\epsilon$, as desired.