Skip to content

Instantly share code, notes, and snippets.

@FilipDeVos
FilipDeVos / ListDiff.cs
Created September 6, 2012 07:21 — forked from praeclarum/ListDiff.cs
Computes a diff between two different IEnumerables. It's better than anything you have ever seen. Ever.
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace TheBestAppEver
{
/// <summary>
/// The type of <see cref="ListDiffAction{S,D}"/>.
Performance of scalar functions is usually not very good, to do what you ask I would write it as a table valued function. A table valued function has the benefit that it is inlined properly.
Other forms of the query will not make a huge difference as it is the calls to the function which eat up the time.
CREATE FUNCTION dbo.fn_age(@birthdate datetime, @current_date datetime)
RETURNS TABLE
WITH SCHEMABINDING
AS
return (
SELECT cast((DATEPART(year, @current_date - @birthdate)) - 1900 as varchar(4)) + 'y '
@FilipDeVos
FilipDeVos / SignUnsafeAssembly.sql
Last active October 6, 2015 15:28
Script to sign an unsafe assembly.
SET NOCOUNT ON
DECLARE @cert_name sysname = 'MyLovelyCertificate'
, @assembly_name nvarchar(4000) = 'MyAssembly'
, @assembly_path nvarchar(256) = 'c:\MyAssembly.dll'
, @safe_cert_name sysname
, @cert_path nvarchar(256)
, @login_name sysname
, @sid varbinary(85)
, @msg nvarchar(max)
@FilipDeVos
FilipDeVos / xml_raw_schema.sql
Created May 13, 2011 08:27
FOR XML RAW Schema Collection
IF EXISTS(SELECT * FROM sys.schemas WHERE name ='xml_raw_schema')
DROP XML SCHEMA COLLECTION dbo.xml_raw_schema
GO
CREATE XML SCHEMA COLLECTION xml_raw_schema AS
N'<?xml version="1.0"?>
<xsd:schema xmlns:targetNamespace="http://schemas.mycompany.com/myproduct"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@FilipDeVos
FilipDeVos / fn_strip_zeros.sql
Created May 13, 2011 08:21
Strip trailing zeros
CREATE FUNCTION dbo.fn_strip_zeros(@number numeric(38,10))
RETURNS varchar(38)
WITH ENCRYPTION
AS
BEGIN
DECLARE @result varchar(38)
DECLARE @decimal varchar(3)
SET @decimal = substring(convert(varchar(38), convert(numeric(38,10),1)/5 ), 2,1)
@FilipDeVos
FilipDeVos / install-hooks.bat
Created February 5, 2010 14:16
Subversion Hooks
@echo off
FOR /D %%I in (*) DO (
echo Installing hooks in %%I
copy pre-revprop-change.bat %%I\hooks\ /Y
copy pre-commit.bat %%I\hooks\ /Y
)
@FilipDeVos
FilipDeVos / _gvimrc
Created December 17, 2009 11:19
vim config files
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" options for gvim on Windows 7
"
" Author: Filip De Vos
" Last updated: 1st April 2010
"
" To use this conveniently I work like this:
" - check out the gist in my Git working folder with:
" cd ~/Documents/WorkingGit/
" git clone git://gist.github.com/258688.git vimconfig
@FilipDeVos
FilipDeVos / .gitignore
Created December 1, 2009 18:04 — forked from tobinharris/.gitignore
Standard .gitignore file & transform script for svn global-ignores
# .gitignore for .NET projects
# Thanks to Derick Bailey
# http://www.lostechies.com/blogs/derickbailey/archive/2009/05/18/a-net-c-developer-s-gitignore-file.aspx
# Additional Thanks to
# - Alexey Abramov
# Standard VS.NET and ReSharper Foo
obj
bin
*.csproj.user