Skip to content

Instantly share code, notes, and snippets.

@Romiko
Romiko / UndeployAzure.ps1
Created February 8, 2012 01:08
UndeployAzure
#requires -version 2.0
param (
[parameter(Mandatory=$true)] [string]$AzureServiceName,
[parameter(Mandatory=$true)] [string]$AzureDeploymentSlot,
[parameter(Mandatory=$true)] [string]$AzureSubscriptionId,
[parameter(Mandatory=$true)] [string]$AzureCertificateThumbprint)
$ErrorActionPreference = "Stop"
if ((Get-PSSnapin -Registered -Name AzureManagementCmdletsSnapIn -ErrorAction SilentlyContinue) -eq $null)
@Romiko
Romiko / AzureTraceListener.xml
Created February 7, 2012 04:20
Azure Trace Listener
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
@Romiko
Romiko / WindowsDiagnosticsWAKEUP.cs
Created February 7, 2012 04:00
Wait for Windows Diagnostics to wake up
static void WaitForWindowsAzureDiagnosticsInfrastructureToCatchUp()
{
// According to http://l.tath.am/k6uPrK, the diagnostics infrastructure takes a
// few seconds to start. If a crash occurs during this time, we'd never be
// able to find out why.
// We also need to do this at the /end/ of the role. Even if we explicitly flush
// the trace, it'll still lose the last few messages if we exit too quickly.
Thread.Sleep(TimeSpan.FromSeconds(10));
}
@Romiko
Romiko / Neo4jClientDeserializer
Created January 24, 2012 05:56
Neo4jClient JSON Deserializer
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
@Romiko
Romiko / ProposedJsonCypherResult.json
Created January 21, 2012 02:55
ProposedJsonCypherResult.json
{'data' : [
[
{
'column1': {
'outgoing_relationships' : 'http://foo/db/data/node/0/relationships/out',
'data' : {
'Bar' : '1',
'Baz' : '11'
},
'traverse' : 'http://foo/db/data/node/0/traverse/{returnType}',
@Romiko
Romiko / CypherTableResult.cs
Created January 21, 2012 02:46
CypherTableResult
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace Neo4jClient.ApiModels.Cypher
{
public class DataRow<TCol1, TCol2, TCol3>
{
[JsonProperty("column1")]
public TCol1 Column1 { get; set; }
@Romiko
Romiko / CypherResultProposedUnitTest.cs
Created January 21, 2012 02:42
Unit Test - Proposed Cypher Result
[Test]
public void StartWithTwoNodesInSeperateColumnsShouldReturnIEnumerableOfObjects()
{
//Arrange
const string cypherExpectedQuery = "start myNode=node({foo}) return myNode";
var parameters = new Dictionary<string, object>
{
{"foo", 123}
};
@Romiko
Romiko / CacheService.cs
Created December 13, 2011 01:37
Caching
using System;
using System.Runtime.Caching;
namespace MyStory.Logic.Services
{
public class CacheService : ICacheService
{
readonly ObjectCache cache;
readonly CacheItemPolicy defaultPolicy;
readonly IConfigOverrideProvider configOverrideProvider;
@Romiko
Romiko / GremlinIfThenElse.cs
Created December 6, 2011 11:00
Gremlin .Net IfThenElse
using NUnit.Framework;
using Neo4jClient.Gremlin;
namespace Neo4jClient.Test.Gremlin
{
[TestFixture]
public class IfThenElseTests
{
[Test]
public void IfThenElseVShouldAppendSteps()
@Romiko
Romiko / uniqueObject.cs
Created December 4, 2011 20:29
Gremlin Distinct Example
using NUnit.Framework;
using Neo4jClient.Gremlin;
namespace Neo4jClient.Test.Gremlin
{
[TestFixture]
public class GremlinDistinctStepTests
{
[Test]
public void GremlinDistinctAppendStepToNodeQuery()