Tic-tac-toe and Connect 4

How many winning lines are there on a tic-tac-toe board? How many winning lines are there on a 3×3×3 grid of cubes? Explanations of the solution, to the latter question, can be found here, and here.

How many ways can you connect 4, on a standard connect 4 game board? Explanations of the solution can be found here, here, here, and here. The standard connect 4 game board has 6 rows and 7 columns. How many ways are there to connect k, on a w×h board? How many ways are there to connect k on a w×h×d grid of cubes?

For both the tic-tac-toe and connect 4 problems, what if you played on a surface that wasn't a square. For example, what if you played on a cylinder? a torus? a Mobius strip? a Klein bottle? See this article to get started.

Here are some explanations of the solution.