Skip to content

Instantly share code, notes, and snippets.

View rasmuskl's full-sized avatar

Rasmus Kromann-Larsen rasmuskl

View GitHub Profile
@rasmuskl
rasmuskl / Client.cs
Created December 10, 2011 17:30
ZeroMQ test
using System;
using System.Diagnostics;
using ZeroMQ.Sockets;
namespace Client
{
public class Program
{
public static void Main(string[] args)
{
@rasmuskl
rasmuskl / cleansvn.bat
Created December 12, 2011 15:08
Batch: Clean svn non-versioned and ignored files
@echo off
echo Cleaning non-versioned and ignored files...
FOR /f "usebackq tokens=2*" %%f IN (`svn status --no-ignore ^| findstr /B [?I]`) DO IF [%%g] == [] (rd /q /s "%%f" 2>nul) ELSE (rd /q /s "%%f %%g" 2>nul)
FOR /f "usebackq tokens=2*" %%f IN (`svn status --no-ignore ^| findstr /B [?I]`) DO IF [%%g] == [] (del /q /f /s "%%f" 2>nul) ELSE (rd /q /f /s "%%f %%g" 2>nul)
echo Done.
@rasmuskl
rasmuskl / copy-flatten.ps1
Created December 14, 2011 12:48
PowerShell: Copy-flatten
gci -Recurse -Filter *.ccj | % { Copy-Item $_.FullName c:\rules }
@rasmuskl
rasmuskl / pre-commit.bat
Created December 14, 2011 14:47
SVN pre-commit hook for enforcing presence of 'review'
@echo off
SET REPOS=%1%
SET TXN=%2%
REM Allow configuration tool updates
svnlook log %REPOS% -t %TXN% | findstr /C:"Configuration tool commited update to corticon rule" > nul
IF %ERRORLEVEL% EQU 0 (EXIT 0)
REM Verify commit message contains "Review:" (case-insensitive)
@rasmuskl
rasmuskl / create-site.ps1
Created December 15, 2011 20:17
PowerShell: Creating IIS7 site + AppPool
param([string]$site=$(throw "Site argument is required."))
function vdir-exists([string]$name)
{
if((Test-Path -path $name) -eq $False)
{
return $False
}
(Get-Item $name).GetType().Name -eq "ConfigurationElement"
@rasmuskl
rasmuskl / restore.sql
Created December 15, 2011 21:08
SQL Server: Restore + Restore incremental
ALTER DATABASE [AspectoWeb] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE [AspectoWeb]
FROM DISK = N'C:\Users\RasmusKL\Desktop\www.aspectoweb.com_backup_2011_12_15_030005_0285276\www.aspectoweb.com_backup_2011_12_14_031114_3950159.wbak'
WITH NORECOVERY, REPLACE
RESTORE DATABASE [AspectoWeb]
FROM DISK = N'C:\Users\RasmusKL\Desktop\www.aspectoweb.com_backup_2011_12_15_030005_0285276\www.aspectoweb.com_backup_2011_12_15_030005_0285276.bak'
WITH RECOVERY
@rasmuskl
rasmuskl / example.cs
Created December 16, 2011 16:02
Autofixture question
public class TestClass
{
public void Test1()
{
var fixture = new Fixture();
// This doesn't let me pass 42?
sut.Freeze<int>("importantNumber");
var sut = fixture.CreateAnonymous<ToBeInstantiated>();
@rasmuskl
rasmuskl / copy.xml
Created December 19, 2011 12:40
MSBuild: Copy files
<Target Name="CopyDirectoryWithStructure">
<ItemGroup>
<CopyFiles1 Include="$(ProjectDir)TestData\**" Exclude="$(ProjectDir)TestData\**\.svn\**" />
</ItemGroup>
<Copy SourceFiles="@(CopyFiles1)" DestinationFolder="$(ProjectDir)..\..\bin\test\TestData\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
@rasmuskl
rasmuskl / rakefile.rb
Created December 19, 2011 13:39
Example web rakefile
require 'albacore'
$msbuildpath = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe'
$aspnet_compiler_path = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe'
$publishdir = 'Publish'
$major_version = '1'
task :default => [:full]
task :full => [:publish, :zip] do
@rasmuskl
rasmuskl / nh-updates.cs
Created December 30, 2011 15:50
NHibernate get pending updates
public static List<string> GetPendingDatabaseUpdates()
{
var sessionFactoryProvider = ObjectFactory.GetInstance<ISessionFactoryProvider>();
var updater = new SchemaUpdate(sessionFactoryProvider.Configuration);
var updates = new List<string>();
updater.Execute(updates.Add, false);
return updates;
}