Skip to content

Instantly share code, notes, and snippets.

@mikekwright
mikekwright / input.cs
Created November 5, 2013 05:58
Sample of int parsing
public static int GetResponse()
{
int result;
do
{
Console.Write("Enter an int: ");
} while (!int.TryParse(Console.ReadLine(), out result));
return result;
}
@mikekwright
mikekwright / reqs.rb
Created June 5, 2013 20:15
Requirements used for install
sudo apt-get install --assume-yes build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
@mikekwright
mikekwright / getTodos.js
Created February 13, 2013 21:46
Dynamic list creation from json results (using only domcore js) for ASP.NET MVC Tutorial 4.
function getTodos(callback) {
var request = new XMLHttpRequest();
request.open("Get", "/api/Todo", true);
request.onload = function() {
console.log("Returned");
if (request.error) {
console.log(request.error);
} else {
var response = JSON.parse(request.responseText);
console.log(response);
@mikekwright
mikekwright / getTodos.js
Created February 13, 2013 21:30
Javascript XMLHttpRequest that is used to return the Todo objects for ASP.NET MVC 4 Tutorial.
function getTodos() {
var request = new XMLHttpRequest();
request.open("Get", "/api/Todo", true);
request.onload = function() {
console.log("Returned");
if (request.error) {
console.log(request.error);
} else {
var response = JSON.parse(request.responseText);
console.log(response);
@mikekwright
mikekwright / Todo.cs
Created February 13, 2013 21:16
Todo Model that is Used with ASP.NET MVC 4 Tutorial.
using System;
using System.Data.Linq.Mapping;
using System.Linq;
[Table(Name="Todos")]
public class Todo
{
[Column(IsPrimaryKey = true, IsDbGenerated = true)]
public int Id { get; set; }
[Column]
@mikekwright
mikekwright / ConnectionManager.cs
Created February 13, 2013 20:54
ConnectionManager class for ASP.NET MVC 4 tutorial.
using System.Data.Linq;
using MvcTutorialTwo.Models;
public class ConnectionManager
{
public const string ConnectionString =
"Data Source=localhost;Database=TodoCS2450;Integrated Security=True;";
public static Table<Todo> GetTodoContext()
{
@mikekwright
mikekwright / DbUpdater.cs
Created February 13, 2013 20:49
Adding the automatic database update call that uses DbUp for the ASP.NET MVC 4 Tutorial.
public class DbUpdater
{
public void RunUpdate()
{
const string connectionString = ConnectionManager.ConnectionString;
var updater = DbUp.DeployChanges.To
.SqlDatabase(connectionString)
.WithScriptsEmbeddedInAssembly(GetType().Assembly)
.LogToConsole()
@mikekwright
mikekwright / Script0001.sql
Created February 13, 2013 20:47
Simple Table that holds the Todo Tutorial Data.
CREATE TABLE Todos
(
Id INT PRIMARY KEY IDENTITY(1, 1),
Title VARCHAR(255) NOT NULL,
Completed BIT NOT NULL DEFAULT(0),
DateAdded DATETIME NOT NULL DEFAULT(GETDATE())
)
GO
@mikekwright
mikekwright / gist:4947840
Created February 13, 2013 20:17
Sample CSS file for ASP.NET MVC 4 tutorial.
/* Access using - <link rel="stylesheet" type="text/css" href="/Content/home.css"/> */
body {
}
ul {
list-style: none
}
.completed {
text-decoration: line-through
@mikekwright
mikekwright / Index.cshtml
Created February 13, 2013 19:50
Added more context to the Todo page for ASP.NET MVC 4 tutorial
@model dynamic
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>