Skip to content

Instantly share code, notes, and snippets.

View mjul's full-sized avatar

Martin Jul mjul

View GitHub Profile
@mjul
mjul / ResharperUnitTestTemplate
Created January 13, 2012 15:18
C# Unit Test "File Template" for Resharper (mstest)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace $namespace$
{
[TestClass]
public class $class_under_test$
@mjul
mjul / Tree.feature
Created January 27, 2012 12:29
Tip for formatting tree data structures in Cucumber / SpecFlow
# You can use indentation to make tree data more readable in tables
# The step defs use the ids to link up the data, and trims
# the indentation / underscores which is just there to
# visualize the tree structure
Given the following org units
| id | parent | name |
| 1 | | Corporate |
| 11 | 1 | __ Danish Subsidiary |
| 12 | 1 | __ Partner Company |
@mjul
mjul / master.proj
Created March 22, 2012 17:04
MSBuild start and stop WCF service host
<PropertyGroup>
<WcfSvcHost>$(MSBuildProjectDirectory)\Build\WcfServiceHost\wcfsvchost.exe</WcfSvcHost>
<AsyncStartWcfServiceHostCode>
<![CDATA[
Public Shared Function ScriptMain() as String
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.arguments = "/service:App\MyApp.Server.Services\bin\Debug\MyApp.Server.Services.dll /config:App\MyApp.Server.Services\bin\Debug\MyApp.Server.Services.dll.config"
@mjul
mjul / app.config
Created July 31, 2012 14:42
SpecFlow set default language for features to (example, set it to #language: da)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<specFlow>
<language feature="da-DK" tool="" />
</specFlow>
@mjul
mjul / pallet-intro.clj
Created August 24, 2012 23:13
Start and stop an Amazon EC2 server in EU region from Pallet
(defn start [config]
(pallet.core/converge
(pallet.core/group-spec "mygroup"
:count 1
:node-spec (pallet.core/node-spec
:image {:os-family :ubuntu}
:location {:location-id "eu-west-1"})) ;; :location-id is the name of the AWS Region
:compute config))
@mjul
mjul / Instructions.md
Created August 25, 2012 14:51
How to make pallet-hadoop-example work without #<JSchException com.jcraft.jsch.JSchException: Auth fail>

First, generate a set of SSH keys in the local directory (./ec2key_rsa) to use for the experiment with the ssh-keygen command:

pallet-hadoop-example$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/mjul/.ssh/id_rsa): ./ec2key_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ./ec2key_rsa.
Your public key has been saved in ./ec2key_rsa.pub.
@mjul
mjul / DataApplicationException.cs
Last active October 13, 2015 12:18
Easily add context to exceptions using anonymous types. // throw new DataException("Import failed.", null, new { DataSource = "FileMaker", Type = "Student", StudentNumber = 123 });
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
namespace ClassLibrary1
{
/// <summary>
@mjul
mjul / CSharpCallingJavascript.cs
Created February 26, 2013 15:15
Compile and call JavaScript code from .NET (C#). Opens up the possibility to use for example ClojureScript core.logic as a rule engine in C# business applications.
using System;
using System.CodeDom.Compiler;
using Microsoft.JScript;
namespace JavascriptFromDotNet
{
class Program
{
private const string Source = @"
package Test
@mjul
mjul / convert-visio-drawings-to-pdf.ps1
Created March 21, 2013 11:10
Convert the Visio drawings in the current directory to PDF
# Convert Visio (2013) documents to PDF
$drawings = Get-ChildItem -Filter "*.vsdx"
Write-Host "Converting Visio documents to PDF..." -ForegroundColor Cyan
try
{
$visio = New-Object -ComObject Visio.Application
$visio.Visible = $true
@mjul
mjul / LinqExpressionsTest.cs
Created May 2, 2013 11:36
Navigating Linq expression trees to get names of nodes, member accessors etc. This can be used to compile Linq expressions, e.g. transforming expressions to query code for external systems like services or databases.
using System;
using System.Linq.Expressions;
using NUnit.Framework;
namespace LinqExperiments
{
[TestFixture]
public class LinqExpressionsTest
{
private class NumberedText