Skip to content

Instantly share code, notes, and snippets.

@alkampfergit
alkampfergit / gist:bcb8364c67ba7703152a
Created December 15, 2014 16:46
NEventStore mongo provider get count of events by type
db.Commits.aggregate([
{$sort: {_id:1}},
{$unwind : "$Events"},
{$project : { event : '$Events.Payload.Body._t'}},
{$group : {
'_id' : '$event',
'count' : {$sum : 1}}
}
])
@alkampfergit
alkampfergit / gist:19cc4314874c4f754b59
Last active August 29, 2015 14:12
Regex Filter aggregation with NEST
.....
//this filters result of the query, then apply aggregations on terms.
//if you want to filter result of the aggregation you will need reducers
//https://github.com/elasticsearch/elasticsearch/issues/8110
.Aggregations(a1 => a1
.Filter("filter", fd => fd.Filter(f =>
f.Regexp(f3 => f3
.OnField(d => d.MdFacets)
.Value(parameters.FacetName + @"\|.*"))
@alkampfergit
alkampfergit / gist:342f1f47a498914cb74f
Created January 8, 2015 11:25
Dynamically compose query to ElasticSerach with C# nest
/// <summary>
/// returns a lambda function that compose query in And or Or
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
private static Func<QueryContainer, QueryContainer, QueryContainer> GetQueryComposer(QueryTypeEnum queryType)
{
Func<QueryContainer, QueryContainer, QueryContainer> composer = (q1, q2) => q1 || q2;
if (queryType == QueryTypeEnum.And)
composer = (q1, q2) => q1 && q2;
@alkampfergit
alkampfergit / gist:b96a3cfe05759bcab098
Created March 31, 2015 09:30
Git configuration for Diff and Merge in Visual Studio
[diff]
tool = vsdiffmerge
[difftool]
prompt = true
[difftool "vsdiffmerge"]
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
keepbackup = false
trustexistcode = true
[merge]
tool = vsdiffmerge
@alkampfergit
alkampfergit / vagrantfile
Created June 5, 2015 08:55
Vagrant configuration for Greylog and hyper-v provider
Vagrant.configure(2) do |config|
config.vm.box = "tomassrnka/trusty64"
config.vm.hostname = "graylog"
config.vm.network :forwarded_port, guest: 9000, host: 9000
config.vm.network :forwarded_port, guest: 12900, host: 12900
config.vm.network :forwarded_port, guest: 12201, host: 12201, protocol: 'udp'
config.vm.network :forwarded_port, guest: 12201, host: 12201, protocol: 'tcp'
config.vm.provider "hyperv" do |v|
@alkampfergit
alkampfergit / gist:5d7448fb7b65e70f83bd
Created July 9, 2015 10:16
Metarunner used to install teamcity gitversion plugin
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="GitVersion">
<description>Execute GitVersion</description>
<settings>
<parameters>
<param name="mr.GitVersion.gitCheckoutDir" value="" spec="text description='The directory containing .git relative to the working directory. Leave blank for the working directory itself.' display='normal' label='Git Repository Directory:'" />
<param name="mr.GitVersion.output" value="buildserver" spec="checkbox checkedValue='buildserver' description='Update the TeamCity build number or output JSON?' display='normal' label='Update TeamCity build version:' uncheckedValue='json'" />
<param name="mr.GitVersion.outputFile" value="" spec="text description='Optional path to a file relative to the working directory to output the json into if you selected JSON above.' display='normal' label='Json output file:'" />
<param name="mr.GitVersion.url" value="" spec="text description='Optional URL to remote git repository if you have not already checked o
@alkampfergit
alkampfergit / gist:0ea3b0772a38ff7bc833
Created September 1, 2015 10:38
Get count of events in NEventstore backed up by MongoDb
db.getCollection('Commits').aggregate([
{$unwind : "$Events"},
{$project : {"Events.Payload.Body._t" : 1, _id : -1}},
{$group : {_id : "$Events.Payload.Body._t" , count : {$sum : 1}}}
])
tags = [];
[1,2,3,4].forEach(function(num)
{
tags.push(''+num);
db.SampleData.insert({
num: NumberInt(num),
tags:tags
})
})
@alkampfergit
alkampfergit / gist:bbb2af06c1ddd71ce0fe941554a885db
Created April 8, 2016 10:59
Git merge settings for Visual Studio
[diff]
tool = vsdiffmerge
[difftool]
prompt = true
[difftool "vsdiffmerge"]
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
keepbackup = false
trustexistcode = true
[merge]
tool = vsdiffmerge
@alkampfergit
alkampfergit / gist:c7a5b6a6fdd794ee577ebd55cb954eb5
Last active June 22, 2017 14:36
Mongodb - Delete all database that starts with a specific string.
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
if (db.getName().startsWith('blah'))
{
print( "dropping db " + db.getName() );
db.dropDatabase();
}
}