Austin Samuels gave Inverness the play-off advantage at Firhill with a late winner, with the 2nd leg to be played on Friday.