Skip to content

Instantly share code, notes, and snippets.

Matt S m4tt1mus

  • Austin, TX
Block or report user

Report or block m4tt1mus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@m4tt1mus
m4tt1mus / FixieEfExceptions.cs
Created Sep 2, 2015
Catch EF Exceptions and report them in fixie
View FixieEfExceptions.cs
//catch EF Exceptions and report them in fixie
namespace Test.Tests
{
using System;
using System.Data.Entity.Validation;
using Fixie;
public class CustomConvention : Convention
{
@m4tt1mus
m4tt1mus / index.html
Last active Aug 29, 2015
Serialize form to JSON.
View index.html
<html>
<head>
<title>json serialize form</title>
<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
<script type="javascript/text">
$.fn.serializeForm = function () {
var serializedObject = {};
var inputsArray = this.serializeArray();
for (var i = inputsArray.length - 1; i >= 0; i--) {
var input = inputsArray[i];
View ToggleConstraints.sql
-- turn off constraints on db
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
-- turn on constraints on db
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
View TableKiller.sql
-- 1. Fill out the DbName.
-- 2. Run Script
-- 3. Select column with scripts
-- 4. Copy to another the column
-- 5. Paste scripts into new scripts screen and execute
DECLARE @Db varchar(100) = 'TechShare-Prosecutor_midland-smoke-test'
SELECT 1, 'USE [' + @Db + ']'
-- Drops unique and foreign key constraints
UNION SELECT 2, 'ALTER TABLE [' + @Db + '].[' + CONSTRAINT_SCHEMA + '].['+ TABLE_NAME
View sp_drop_constraints.sql
-- Adapted from Jon Galloway: http://weblogs.asp.net/jgalloway/archive/2006/04/12/442616.aspx
-- This couldn't handle multiple schemas in the same table. Fixed.
-- Removed concat to widen support to earlier versions of MSSQL.
CREATE PROCEDURE [dbo].[sp_drop_constraints]
@database [sysname] = NULL,
@table [sysname],
@verbose [bit] = 0
AS
View Stack Usings
using (SqlConnection conn = new SqlConnection(strConn))
using (SqlCommand cmd = new SqlCommand(strQuery, conn))
using (SqlCommand cmdReset = new SqlCommand("DBCC CHECKIDENT('Doctor', RESEED, 0)", conn))
using (SqlCommand cmdUnCheck = new SqlCommand("alter table [dbo].[Doctor] nocheck constraint all",conn))
using (SqlCommand cmdCheck = new SqlCommand("alter table [dbo].[Doctor] with check check constraint all",conn))
{
// do stuff
}
You can’t perform that action at this time.