How to define a bijection between $(0,1)$ and $(0,1]$? 
How to define a bijection between $(0,1)$ and $(0,1]$?
  Or any other open and closed intervals?

If the intervals are both open like $(-1,2)\text{ and }(-5,4)$ I do a cheap trick (don't know if that's how you're supposed to do it):
I make a function $f : (-1, 2)\rightarrow (-5, 4)$ of the form $f(x)=mx+b$ by
\begin{align*}
-5 = f(-1) &= m(-1)+b \\
4 = f(2) &= m(2) + b
\end{align*}
Solving for $m$ and $b$ I find $m=3\text{ and }b=-2$ so then $f(x)=3x-2.$
Then I show that $f$ is a bijection by showing that it is injective and surjective.

Let $A=\{\frac{1}{2},\frac{1}{3},...\}$,$B=\{1,\frac{1}{2},\frac{1}{3},...\}$.
Define $f:A\rightarrow B$ such that $f(\frac{1}{n})=\frac{1}{n-1}$.It is easy to show that $f$ is a bijection.
Then define a function $g:(0,1) \rightarrow (0,1]$ such that 
$g(x)=x$ if $x$ is not in $A$ , otherwise $g(x)=f(x)$.
Then $g$ is a required bijection from $(0,1)$ to $(0,1]$.
Remark:
We can always solve this kind of question by picking a countable proper subset from (say)    $(0,1)$ and then define a bijection $f$ so that the image of $f$ is a little bit bigger than its domain and then define a function which is equal to $f$ on the picked countable set and identity function outside that set.
