Monday, December 31, 2012

CookieContainer for HttpWebRequest

Happy New Year!

Are you making a series of HttpWebRequests where you need to persist cookies? For example, perhaps you are experiencing an infinite series of authentication hops. Don't worry, this is very easy to resolve by using the System.Net.CookieContainer class.

xUnit Example

[InlineData("", 0)]
[InlineData("", 2)]
[InlineData("", 8)]
public void CookieJarCount(string requestUriString, int expectedCookieCount)
    var request = (HttpWebRequest) HttpWebRequest.Create(requestUriString);
    // Create a CookieContainer and assign it to the request.
    var cookieJar = new CookieContainer(); 
    request.CookieContainer = cookieJar;
    // Make the request like normal.
    var response = (HttpWebResponse) request.GetResponse();
    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
    // Let's see how many cookies are in the cookie jar!
    Assert.Equal(expectedCookieCount, cookieJar.Count);
Shout it


Friday, December 28, 2012

Best Emulators for Android

Happy Holidays!

If you were lucky and got an Android tablet or phone this holiday season, congratulations! If you got a bunch of gift cards and you don't know what to do with them, I strongly suggest that you take a look at the Nexus 7! (Although I personally have an ASUS Transformer Prime.)

Best of all, if you like old school video games, you can emulate just about anything made in the 90s on modern Android devices! (Don't know what emulators are? Here is a helpful article about video game emulation for newbies.)

Please remember that emulation is legal, so long as you own the console and game that you are trying to emulate. As always, please play nice and play fair!

The Best Emulators

Platform Emulator Extras Price
SNES Snes9x EX Free
NES Nesoid Free
Game Boy Advance GameBoid Free
Game Boy Color GBCoid Free
Sega Genesis GENPlusDroid Free with Ads
PlayStation FPse for Android Requires a BIOS file $3.63
DOS DosBox Turbo DosBox Manager $3.49

How To Install

You must manually install applications that are not purchased from the Google Play Store. Fortunately this is very easy to do:

  1. Copy the .APK file to your Android device.
  2. Allow installations from "Unknown sources".
    (Settings > Security > Device Administration > Unknown sources)
  3. Navigate to the APK file using a file manager.
    (I prefer ASTRO File Manager.)
  4. Launch the APK file, and accept the installation of application.
  5. For safety, I recommend you then undo your "Unknown sources" setting.

All you have to do know is copy your ROMs to your device, and then select them from the App.


Real Time Web Analytics