Sheepdog rescued from Gwynedd quarry ledge