Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
dlidstrom / Projections.cs
Created Dec 6, 2013
Create projections from C#.
View Projections.cs
private static void Main(string[] args)
{
var projectionsManager = new ProjectionsManager(new ConsoleLogger(), new IPEndPoint(IPAddress.Loopback, 1113));
const string projStr =
"fromCategory('12-testentity').foreachStream().whenAny(function(s, e) { linkTo('test-12', e) })";
var credentials = new UserCredentials("admin", "changeit");
projectionsManager.CreateContinuous("$test-12", projStr, credentials);
projectionsManager.Enable("$test-12", credentials);
View GuidUtility.cs
using System;
using System.Security.Cryptography;
using System.Text;
namespace Logos.Utility
{
/// <summary>
/// Helper methods for working with <see cref="Guid"/>.
/// </summary>
public static class GuidUtility
@dlidstrom
dlidstrom / SqlServerManagementStudioInstallation.md
Created Jan 14, 2014
Sql Server Management Studio Installation
View SqlServerManagementStudioInstallation.md
  1. Mount the iso file.
  2. Run setup.exe.
  3. Select “Installation” in the left menu.
  4. Select “New SQL Server stand-alone installation or add features to an existing installation”. (not logic … )

Press ok a number of times In setup Role: Select “SQL Server Feature installation”

In feature selection: Add “Management tools – Basic” and “Management tools - Complete”. “SQL Client connectivity SDK” is added by default. WARNING! Do not select anything related to “Instance features” unless you want a full SQL server 2012 instance on your computer.

@dlidstrom
dlidstrom / run-jasmine.js
Last active Jan 3, 2016
Runs Jasmine tests using PhantomJS. Adapted for use within TeamCity.
View run-jasmine.js
var system = require('system'),
env = system.env;
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
View JobBase.cs
public abstract class JobBase : IInterruptableJob
{
protected JobBase()
{
Log = LogManager.GetLogger(GetType());
}
public IKernel Kernel { get; set; }
protected ILog Log { get; private set; }
View BackgroundTasksQueueProcessor.cs
public class BackgroundTasksQueueProcessor : MessageQueueProcessorBase
{
private static readonly JsonSerializerSettings SerializerSettings
= new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
private readonly IKernel kernel;
public BackgroundTasksQueueProcessor(
IKernel kernel,
string importQueue,
View JobInstaller.cs
public class JobInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Classes.FromThisAssembly()
.BasedOn<IJob>()
.WithServiceAllInterfaces()
.Configure(x => x.Named(x.Implementation.ToString()))
.LifestylePerThread());
View JobStartable.cs
public abstract class JobStartable : IStartable
{
private static readonly ILog Log = LogManager.GetLogger(typeof(JobStartable));
private readonly IScheduler scheduler;
protected JobStartable(IScheduler scheduler)
{
this.scheduler = scheduler;
}
@dlidstrom
dlidstrom / Program.cs
Created Feb 4, 2014
Castle Windsor typed app settings
View Program.cs
[AppSettings("smtp:")]
public interface SmtpConfiguration
{
string Name { get; set; }
int Port { get; set; }
string Username { get; set; }
}
View ContextFactory.cs
public static class ContextFactory
{
public static ICommandQueryContext CreateContext()
{
// this environment variable determines if we are running inside TeamCity
if (Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") == null)
return new InMemoryContext();
// we are inside TeamCity, use a database with unique name
// that includes test method and test class