Skip to content

Instantly share code, notes, and snippets.

View tompazourek's full-sized avatar
👨‍💻
Busy

Tom Pažourek tompazourek

👨‍💻
Busy
View GitHub Profile
@tompazourek
tompazourek / commit-config.sh
Last active April 15, 2020 13:59 — forked from tqheel/commit-config.sh
Prevent ASP.Net Web.Config From Being Committed By Git
#Run this to reverse ignoring of changes to web.config so it gets committed.
git update-index --no-assume-unchanged path_to_file/web.config
-- Disable all table constraints
ALTER TABLE MyTable NOCHECK CONSTRAINT ALL
-- Enable all table constraints
ALTER TABLE MyTable CHECK CONSTRAINT ALL
-- Disable single constraint
BEGIN TRY
BEGIN TRANSACTION
-- statements here
COMMIT TRAN
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRAN
@tompazourek
tompazourek / RebuildAllIndexes.sql
Created July 9, 2015 09:58
Rebuild all indexes
DECLARE @TableName varchar(255)
DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'
<modules runAllManagedModulesForAllRequests="false">
<!-- disable authorization section -->
<remove name="UrlAuthorization" />
<!-- disable unused authentication schemes -->
<remove name="WindowsAuthentication" />
<remove name="PassportAuthentication" />
<!-- disable ACL file and directory check -->
<!-- <remove name="FileAuthorization" /> -->
<!-- We don't use ASP.NET Profiles -->
<remove name="Profile" />
@tompazourek
tompazourek / Global_Application_Error.asax
Last active August 29, 2015 14:21
ASP.NET MVC Errors
// NOTE: ELMAH logs the errors anyway
protected void Application_Error(object sender, EventArgs e)
{
var exception = Server.GetLastError();
var httpException = exception as HttpException;
if (httpException != null)
{
switch (httpException.GetHttpCode())
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
@tompazourek
tompazourek / TruncateAllTables.sql
Created March 4, 2015 11:09
Truncate all tables in the database. Source: http://stackoverflow.com/a/12719464/108374
exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
exec sp_MSforeachtable 'DELETE FROM ?'
exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'
exec sp_MSforeachtable 'IF NOT EXISTS (SELECT *
FROM SYS.IDENTITY_COLUMNS
JOIN SYS.TABLES ON SYS.IDENTITY_COLUMNS.Object_ID = SYS.TABLES.Object_ID
WHERE SYS.TABLES.Object_ID = OBJECT_ID(''?'') AND SYS.IDENTITY_COLUMNS.Last_Value IS NULL)
AND OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Domain.ValueObjects
{
/// <summary>
@tompazourek
tompazourek / bower.json
Last active August 29, 2015 14:15
main-bower-files overrides
{
"name": "Example",
"private": true,
"dependencies": {
"bootstrap": "~3.3.2",
"font-awesome": "~4.2.0",
"jquery-validation": "~1.13.1",
"jquery-validation-unobtrusive": "~3.2.2",
"eonasdan-bootstrap-datetimepicker": "~3.1.3",
"smartmenus": "~0.9.7",