Brightness dependent texture on mesh Andrew Price showed in one of his tutorials how to use a white material node in the Blender internal render to get the brightness of a point and assign the texture accordingly. 

In this case: Point is bright: assign daylight texture; Point is dark: assign night light texture

Is there anyway to reproduce that in cycles?
No, it's not possible to do this in Cycles, it will first evaluate the material nodes entirely, and then compute the lighting.

Supporting this would be incompatible with progressive rendering and bidirectional lighting algorithms, and so physically based render engines usually can't do this.

For the earth example, a workaround would be to use a Normal node Dot output, with the Geometry node Normal output plugged into the Normal input. If you then set the direction to match the sun light it will give you a factor than can be used for blending.