Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
dlidstrom / gist:7dd9ed85135a11e3022e
Created July 29, 2014 12:05
Composite or prime?
6907067014839121052034232957437347382888368781532520019311054659093702822564971162269141121965617545613897865904269544243721348093953041840506282278098321
@dlidstrom
dlidstrom / serialize.cs
Created February 20, 2014 09:42
Serialize into xml
var serializer = new XmlSerializer(command.GetType());
MemoryStream stream = null;
try
{
stream = new MemoryStream();
var streamRef = stream;
using (var writer = new XmlTextWriter(stream, Encoding.Unicode))
{
// stream is owned by writer and will be disposed automatically
stream = null;
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
@dlidstrom
dlidstrom / Program.cs
Created February 4, 2014 14:56
Castle Windsor typed app settings
[AppSettings("smtp:")]
public interface SmtpConfiguration
{
string Name { get; set; }
int Port { get; set; }
string Username { get; set; }
}
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;
}
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());
public class BackgroundTasksQueueProcessor : MessageQueueProcessorBase
{
private static readonly JsonSerializerSettings SerializerSettings
= new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
private readonly IKernel kernel;
public BackgroundTasksQueueProcessor(
IKernel kernel,
string importQueue,
public abstract class JobBase : IInterruptableJob
{
protected JobBase()
{
Log = LogManager.GetLogger(GetType());
}
public IKernel Kernel { get; set; }
protected ILog Log { get; private set; }
@dlidstrom
dlidstrom / run-jasmine.js
Last active January 3, 2016 07:49
Runs Jasmine tests using PhantomJS. Adapted for use within TeamCity.
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.
@dlidstrom
dlidstrom / SqlServerManagementStudioInstallation.md
Created January 14, 2014 10:09
Sql Server Management Studio Installation
  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.