photocells and shift registers

Why'd you write your own shift out function?

What do 2 !!s do here?
digitalWrite(dataPin, !!(val & (1 << i)));

and why the 500ms delays?
That's going to be a sloooow shift out.