Skip to content

Instantly share code, notes, and snippets.

View FrankDeGroot's full-sized avatar

Frank de Groot - Schouten FrankDeGroot

View GitHub Profile
@FrankDeGroot
FrankDeGroot / dabblet.css
Created February 22, 2012 20:57 — forked from alexmwalker/dabblet.css
CSS3 Animated Flames *
/**
* CSS3 Animated Flames *
*/
body {background-color:#000}
#logfire {
position:relative;
background:url(http://sitepointstatic.com/examples/css3/animation/logfire.jpg?r=2) center top no-repeat;
height:400px;
@FrankDeGroot
FrankDeGroot / InsertGenerator.sql
Last active December 23, 2015 19:39
Create insert statements for a table for SQL Server 2005+.
/*
use tempdb
if exists(select null from sys.objects where name = 'a') drop table a
create table a (bt bit, ti tinyint, si smallint, i int, bi bigint, n numeric, de decimal, sm smallmoney, m money, f float, r real, dt datetime, sdt smalldatetime, da date, tm time, dto datetimeoffset, c char, vc varchar, te text, nc nchar, nvc nvarchar, nt ntext, im image, u uniqueidentifier, x xml, bn binary, vb varbinary)
insert a values(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '1-1-1', '1:1:1', '1-1-1', '''', '''', '''', '''', '''', '''', '''', '11111111-1111-1111-1111-111111111111', '<x x="''"/>', 1, 1)
insert a values(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
exec insertgenerator @Table = 'a', @uppercase = 1
exec insertgenerator @Table = 'dbo.a', @uppercase = 1
drop table a
*/
@FrankDeGroot
FrankDeGroot / checkfilelock.cs
Created September 24, 2013 12:11
Check if IOException is caused by a file lock.
private static bool IsFileLocked(IOException exception)
{
int errorCode = Marshal.GetHRForException(exception) & ((1 << 16) - 1);
return errorCode == 32 || errorCode == 33;
}
@FrankDeGroot
FrankDeGroot / comparelogs.ps1
Last active December 23, 2015 19:39
Compare Endeavour build server result with local build result with SourceGear DiffMerge. Compares with latest result on build server.
filter Get-LastChildItem { Join-Path $_ (gci $_ -Name | sort | select -Last 1) }
$Outs = 'C:\(ProductName)\Branch\99 - bin\Deliverables\Name\Log\Compile\Compile_result.xml',
"$('\\portal\DailyBuildResult\ProductName\Branch' | Get-LastChildItem | Get-LastChildItem)\CIName\Compile\compile.log" | % {
([xml](gc $_)).results.message |
where {$_.type -eq 'warning'} |
sort -CaseSensitive '#text' |
% {"<message>$($_.'#text')</message>"} |
Out-File ($Out = [IO.Path]::GetTempFileName())
$Out
}
@FrankDeGroot
FrankDeGroot / DataReaderStream.cs
Created September 24, 2013 12:15
Open IDataReader result column as stream using IDataReader.GetBytes.
using System;
using System.Data;
using System.IO;
namespace Company.Product
{
internal class DataReaderStream : Stream
{
private long _position = 0L;
private readonly IDataReader _reader;
@FrankDeGroot
FrankDeGroot / SqlExceptionHandler.cs
Created September 24, 2013 12:20
Reverse-formats SQL Server error message: SQL Server formats a template error message inserting table/column/index/etc. names. This code extracts those inserted names. This allows you to detect what table/column/index/etc. is causing trouble. Use this e.g. to detect attempts to insert non-unique values governed by a unique index without first ha…
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Text.RegularExpressions;
namespace Company.Product
{
using ModelTableAdapters;
@FrankDeGroot
FrankDeGroot / VSAllCaps.reg
Created September 24, 2013 12:23
Disable/Enable all caps menu items in Visual Studio.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General]
"SuppressUppercaseConversion "=dword:00000001
@FrankDeGroot
FrankDeGroot / eav.fsx
Created September 24, 2013 12:25
Experiment with entity/attribute/value table in SQL Server using F# script.
open System
open System.Data
open System.Data.Common
let exec exec sql =
let factory = DbProviderFactories.GetFactory("System.Data.SqlClient")
use connection = factory.CreateConnection()
connection.ConnectionString <- "Data Source=.;Initial Catalog=tempdb;Integrated Security=SSPI"
connection.Open()
use command = factory.CreateCommand()
@FrankDeGroot
FrankDeGroot / sqlxml.ps1
Last active December 23, 2015 19:39
Compare database table with XML contents. Kept for code that extracts parameters from a query string, adds them to a SqlCommand and copies values from variables with the same name.
$cn = new-object Data.SqlClient.SqlConnection 'Server=.;Database=CIA;Trusted_Connection=true'
$cn.open()
$q = @'
select count(*) from journaalposten.unv_conversierekeningschema
where grootboeksysteem='QIS' and maatschappij=@m and gb_rekening=@gbr and kostenplaats=@kp and kostendrager=@kd
'@
$cm = new-object Data.SqlClient.SqlCommand -a $q, $cn
$p = $cm.parameters
@FrankDeGroot
FrankDeGroot / gen.sql
Created September 25, 2013 11:06
Generate max 2^32 rows with a unique number.
with a(n) as (select 0 union all select 1),
b(n) as (select 2*x.n+y.n from a x, a y),
c(n) as (select 4*x.n+y.n from b x, b y),
d(n) as (select 16*x.n+y.n from c x, c y),
e(n) as (select 256*x.n+y.n from d x, d y),
f(n) as (select 65536*x.n+y.n from e x, e y)
select top 100000000 n from f