Blog
Jan 9, 2014
Monty Hall Brainteaser Simulation
The Monty Hall problem is a brain teaser, in the form of a probability puzzle (Gruber, Krauss and others), loosely based on the American television game show Let’s Make a Deal and named after its original host, Monty Hall. The problem was originally posed in a letter by Steve Selvin to the American Statistician in 1975 (Selvin 1975a), (Selvin 1975b). It became famous as a question from a reader’s letter...
Jul 22, 2013
Basic chat client & server using .NET Framework's TcpClient and TcpListener
I considered getting rid of this bit of code while trying to determine whether it provided any real value to anyone. I’ve opted to keep it for future reference for myself and anyone else who may need an example of how the TcpClient and TcpListener classes can be utilized in .NET. The VS 2012 solution files can be cloned from it’s GitHub repo here. The files should be compatible with...
Mar 7, 2013
Connection strings with Entity Framework 5 (Code First)
First, we add our connection string that Entity Framework will use to our web.config. Be sure to replace the connection name, server, and database from the example with your own values. web.config Add the connection string to web.config <!--web.config of the project that is utilizing Entity Framework--> <connectionStrings> <add name="YourConnectionName" providerName="System.Data.SqlClient" connectionString="Server=YourServerNameOrIP; Database=YourDatabaseName; Integrated Security=SSPI" /> </connectionStrings> This connection string will target the server’s (YourServerNameOrIP) default instance of SQL server...
Mar 6, 2013
Entity Framework Custom Database Initializer From web.config
Create a class that inherits from DropCreateDatabaseIfModelChanges<MyContext> where MyContext is the class that is extends DbContext. The DropCreateDatabaseIfModelChanges class has a virtual method named Seed that can be overridden to enter sample data into the database. As the name infers, this database initializer class will be invoked when one of the model (POCO) classes in MyContext is changed. If a model is changed, the database is dropped then recreated with...