Skip to content

Instantly share code, notes, and snippets.

@weedkiller
weedkiller / CollectionHelpers.cs
Created February 19, 2017 18:17 — forked from siimv/CollectionHelpers.cs
ASP.NET MVC 3 helper for collection rendering
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace TSolution.DataManagement.Infrastructure.Presentation.Mvc.Helpers
{
@weedkiller
weedkiller / sites.cleanup
Created February 22, 2017 06:40 — forked from yurifedoseev/sites.cleanup
Delete all sites from IIS express configuration
appcmd.exe list site /xml | appcmd delete site /in
@weedkiller
weedkiller / most100executed.sql
Created February 22, 2017 06:42 — forked from yurifedoseev/most100executed.sql
100 most executed queriest
--Get Top 100 executed SP's ordered by execution count
SELECT TOP 100 qt.text AS 'SP Name', qs.execution_count AS 'Execution Count',
qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()) AS 'Calls/Second',
qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
qs.total_worker_time AS 'TotalWorkerTime',
qs.total_elapsed_time/qs.execution_count AS 'AvgElapsedTime',
qs.max_logical_reads, qs.max_logical_writes, qs.total_physical_reads,
DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache'
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
@weedkiller
weedkiller / sql worst queries.sql
Created February 22, 2017 06:42 — forked from yurifedoseev/sql worst queries.sql
Long long executed script
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan'),
core AS (
SELECT
eqp.query_plan AS [QueryPlan],
ecp.plan_handle [PlanHandle],
q.[Text] AS [Statement],
n.value('(@StatementOptmLevel)[1]', 'VARCHAR(25)') AS OptimizationLevel ,
ISNULL(CAST(n.value('(@StatementSubTreeCost)[1]', 'VARCHAR(128)') as float),0) AS SubTreeCost ,
@weedkiller
weedkiller / sql space usage.sql
Created February 22, 2017 06:42 — forked from yurifedoseev/sql space usage.sql
sql space usage
select *
from sys.dm_db_session_space_usage spu
join sys.dm_exec_sessions s on s.session_id = spu.session_id
join sys.dm_exec_requests r on s.session_id = r.session_id
cross apply sys.dm_exec_sql_text(sql_handle) t
order by internal_objects_alloc_page_count desc
@weedkiller
weedkiller / ReadonlyDbContext.cs
Created February 22, 2017 08:23 — forked from cmatskas/ReadonlyDbContext.cs
ReadonlyDbContext
public class ReadonlyDbContext : MyDbContext
{
static ReadonlyDbContext()
{
Database.SetInitializer<ReadonlyDbContext>(null);
}
public ReadonlyDbContext()
{
SetConfigurationOptions();
// DON'T add the key if auto-generated
ctx.BulkInsert(customers, operation => operation.ColumnInputExpression =
customer => new {customer.Name, customer.Email});
// ALWAYS add the key
ctx.BulkUpdate(customers, operation => operation.ColumnInputExpression =
customer => new { customer.ID, customer.Name, customer.Email });
// ALWAYS add the key
ctx.BulkMerge(customers, operation => operation.ColumnInputExpression =
// Single Key
ctx.BulkUpdate(customers, operation => operation.ColumnPrimaryKeyExpression =
customer => customer.Code);
// Surrogate Key (with anonymous type)
ctx.BulkUpdate(customers, operation => operation.ColumnPrimaryKeyExpression =
customer => new { customer.Code1, customer.Code2, customer.Code3 });

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@weedkiller
weedkiller / Cross Table Drag Drop.html
Created July 28, 2017 03:34 — forked from davemo/Cross Table Drag Drop.html
This works for dragging, dropping table rows between two separate tables across most browsers :)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="David Mosher">
<!-- Date: 2010-11-18 -->