How can I add dark matter to my $N$-body simulation? I've written a simple non-scientific N-body simulation for fun:
http://magwo.github.io/fullofstars/
I expected to create something looking like spinning galaxies (there are two invisible very heavy objects in that simulation).
However, as I learned, for it to resemble galaxies there needs to be something more than just $N$-body simulation. http://en.wikipedia.org/wiki/Galaxy_rotation_curve
So my question is this: For my simulation to look like spinning galaxies, how should the dark matter be positioned, moving, and how should it interact with the visible particles?
Should the dark matter be at all affected by the gravity of the visible particles? Or should it be a one-way interaction? What makes the dark matter stay "in place" to preserve its "compressing" effect on the particle cloud? Is the gravity interaction from the dark matter an attraction force just like normal gravity, or is it a repelling force?
 A: The answer of Acid Jazz is correct in every point, in my opinion. However, I think that the problem in your simulations is not dark matter, but something more subtle. Perhaps I oversimplify here, but dark matter will behave in your model exactly like normal matter, with the exception of being dark, not visible. It is in fact exactly the case of the two invisible objects of your simulation. In fact, you are already considering two dark matter halos in the simulation. 
For what I see, in your simulation the "stars" are accelerated and expelled at huge speeds after that they experience a close encounter with another star (or with one of the invisible objects). I presume that you are solving directly and separately the dynamics of each of these star, taking into account the mutual attraction. However, the newtonian potential has a singularity when two masses approach at short distance $r\approx0$ (the attraction is proportional to $r^{-2}$). This constitutes a computational problem in gravitational simulations, and is probably why you see these anomalies in your simulation, which prevent the emergence of large scale structures, like galaxies.  A method to deal with this problem is known as Regularization (although I think it is not the only method). 
I am not an expert in the field, I just found this link that seems to be a useful introduction to non-experts: 
Basics of regularization theory
A: As I understand your question, and after watching your simulation, it seems that you actually only have dark matter (DM) in your simulation. An N-body code simulates DM, i.e. particles that interact only by gravitation. If you want to take it a step further, you want to include gas, i.e. particles that interact both by gravitation and by hydrodynamics.
This is not trivial, but the basic idea is that when gas particles get close enough, they build up pressure, are slowed down by viscosity forces, experience turbulence, heat up and lose energy through radiation, etc. If a region becomes sufficiently dense, it may form stars, which in turn heat up the gas again.
When a code is particle-based (as opposed to grid-based), this is called smoothed particle hydrodynamics (SPH).
However, I think you can start by doing something more simple. I may be wrong, but from looking at your simulation, it seems to me that you are calculating gravitational forces between particle $i$ and particle $j$ through
$$
F_{ij} = \frac{m_i m_j}{r_{ij}^2}, \qquad\qquad(\mathrm{correct \, in \, real \, life})
$$
which of course in principle is correct. However, in numerical simulations, due to finite step sizes and floating point precision, particles easily come to close, resulting in diverging forces, which tend to sling out particles with unnaturally high velocities. For this reason, people use a so-called gravitational softening length $\varepsilon$, such that the force between the particles become
$$
F_{ij} = \frac{m_i m_j}{r_{ij}^2 + \varepsilon^2} \qquad\qquad(\mathrm{correct \, in \, simulations}).
$$
The optimal value of $\varepsilon$ is a matter of choice. You may want to try different values, but it should be of the order of (or a little smaller than) the mean distance between particles in the regions you want to resolve. Your time steps should also be adapted to this, so that particles on average don't travel more than $\varepsilon/2$ per timestep (e.g. Rodionov & Sotnikova 2005). For instance, try and start by setting $\varepsilon = L/100$, where $L$ is the length of your box.
Including this parameter should make your DM particles clump more. However, if you want beautiful spiral patterns, you have to include gas.
A: My best guess for these questions: (but I am no expert so it's a guess, right?)

Should the dark matter be at all affected by the gravity of the visible particles?

Yes

Or should it be a one-way interaction?

No, gravity should act equally on visible and dark matter.

What makes the dark matter stay "in place" to preserve its "compressing" effect on the particle cloud? 

Normal gravity probably (open to correction though), I am not exactly sure what else you mean, it is distributed  in a halo around galaxies but extends much further out than visible matter. Also, it may be distributed  in filaments and clumps without any visible matter nearby.

Is the gravity interaction from the dark matter an attraction force just like normal gravity, or is it a repelling force?

Attractive only
A: I've written a few small gravity simulations, and I would bet that the problem is that the particles aren't colliding. I know this doesn't answer your original question, but I think that's the answer to fixing your simulation. 
