How is the distance to a $\gamma \mathrm{-ray}$ burst (GRB) measured in just a few days? Recently the Fermi Gamma-ray Space Telescope recorded the most energetic Gamma Ray burst (GRB 130427A) yet observed with a peak $\gamma \mathrm{-ray}$ energy of $94\, \mathrm{GeV}$.  Various sources have reported that the burst was determined to be $3.6 \times 10^9\, \mathrm{lightyears}$ away.
How can a distance measurement like this be made so quickly?  It has only been a few days since the GRB.  No articles mention any supernova remnant being seen yet or anything else besides just the GRB.  I don't see how the photons in a GRB could have absorption or emission spectra that would help and there isn't any mention of the GRB being localized to a particular galaxy.
NASA says:

The burst subsequently was detected in optical, infrared and radio wavelengths by ground-based observatories, based on the rapid accurate position from Swift. Astronomers quickly learned that the GRB was located about 3.6 billion light-years away, which for these events is relatively close.

How are distance measurement like this made so quickly and what sort of accuracy do they have?
 A: Here is the actual announcement of the redshift from Andrew Levan. For those unfamiliar with astronomy practices, circulars are generally where simple things like discoveries, first spectra, redshifts, etc. are announced just as soon as the data is gathered and a preliminary reduction is performed, usually issued the morning after the observation.
In this case, the Gemini Multi Object Spectrograph (GMOS), attached to the $8\ \mathrm{m}$-class Gemini-North telescope, was used to get a visible/near-UV spectrum of the afterglow the same day the burst was detected. Absorption lines for calcium1 and magnesium2 were used to get a redshift of $0.34$.
So yes, it is optical astronomy pinning down the redshift. As to how this was done so fast, GRB's (and other interesting transients) are followed by many observatories, which have measures in place to slew to "targets of opportunity" the moment they are reported to get data before they vanish. For GRB's in particular, they are often detected in gamma rays first, but gamma ray "telescopes" are basically blocks of scintillating material sitting in space, and so they have terrible angular resolution. Here, as is often the case, the Swift satellite was triggered to search the general area with its X-ray instrument, getting a somewhat more precise sky position. Then other facilities operating in other EM bands were able to look for the object. This happens largely automatically over the course of minutes to hours.

1 Specifically, the H and K lines were used. These are very common for getting redshifts of galaxies hosting distant transient phenomena.
2 $\mathrm{Mg}~\mathrm{I}$ is atomic; $\mathrm{Mg}~\mathrm{II}$ is singly-ionized. The latter has a nice, recognizable doublet at rest wavelengths of 2796.352 Å and 2803.530 Å, as described in this Astrobites article. By the way, you will often see the doublet referred to with the numbers 2796/2803 rather than 2796/2804, which is not an effect of truncation instead of proper rounding, but rather a leftover tradition from back when spectroscopy was reported in air wavelengths rather than vacuum ones.
A: The red shift (of 0.34) was measured by Andrew Levan's team using the Gemini North Telescope in Hawaii. See this link, or Google for lots more related articles.
A: Gamma Ray Bursts are a special case of Supernovas. Supernovas mostly happen in areas of heavy star formation, which means that they happen inside a galaxy and are enveloped in or obscured by clouds of hydrogen (both neutral and ionized) and various amounts of other elements inside the host galaxy. These clouds leave absorption lines in the light spectrum of the GRB afterglow, which can then be used to determine the redshift and hence the distance of the host galaxy.
Even if we can find emission lines in the GRBs, these lines would be so broad due to the high temperature of the explosion that the host galaxy absorption lines are a much more reliable method for determining the distance.
