Skip to content

Instantly share code, notes, and snippets.

var mockConfiguration = new Mock<IConfiguration>();
// Set up the GetSection method to return a Mock<IConfigurationSection>
mockConfiguration.Setup(config => config.GetSection(It.IsAny<string>()))
.Returns(new Mock<IConfigurationSection>().Object); // returns a new Mock IConfigurationSection object
// Set up the Value property of the IConfigurationSection to return a specific value
mockConfiguration.Setup(config => config[It.IsAny<string>()])
.Returns("YourValue"); // returns "YourValue"
POST subjects/_update_by_query
{
"query": {
"match": {
"handleList.platform": "0"
}
},
"script": {
"source": """if (ctx._source.handleList != null) {
for (int i=ctx._source.handleList.length-1; i>=0; i--) {
@craigeddy
craigeddy / gist:4c44a5441a93fec89674691c72ffe6de
Created January 31, 2024 13:39
Query AppInsights Custom Event For a Custom Dimension
union isfuzzy=true customEvents
| where tostring(customDimensions.SubjectId) == "a1f9c74c-4cd4-4d56-9741-42042097634f"
| order by timestamp desc
| take 100
@craigeddy
craigeddy / Elasticsearch Word Cloud Aggregation
Last active April 7, 2023 11:56
Elasticsearch query that creates a word cloud from a partition of social media posts
GET posts/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"partitionKey.keyword": "9e6f80e6-d834-4d63-a37d-1845e90b4007"
}
},
@craigeddy
craigeddy / splunk_hec
Created June 18, 2021 16:18
Attempt To Verify Splunk Http Event Collector Connectivity
// this always succeeds :{
try
{
var ec = GetHttpEventCollector();
var errorHappened = false;
ec.OnError += ex =>
{
errorHappened = true;
health.AddChildItem(
@craigeddy
craigeddy / login.html
Last active May 20, 2021 15:04
FACTS Info Login
<div fxLayout="row" fxLayoutAlign="center">
<mat-card fxFlex="400px">
<mat-card-header fxLayoutAlign="center">
<mat-card-title>
<div class="mat-subheading-2"><strong>Welcome to FACTS Info - PEPFAR Module</strong></div>
<mat-card-subtitle *ngIf="loginPageMessage"><div [style.backgroundColor]="'yellow'" [innerHtml]="loginPageMessage"></div></mat-card-subtitle>
</mat-card-title>
</mat-card-header>
<mat-card-content>
<form [formGroup]="loginForm" (ngSubmit)="login(loginForm)" fxLayout="column">
@craigeddy
craigeddy / AutoMapper-Ignore
Last active November 25, 2019 16:52
How to tell AutoMapper to ignore a destination property
cfg.CreateMap<T<S>, T<D>>().ForMember(d => d.XYZ, opt => opt.Ignore())‎‎​
@craigeddy
craigeddy / Telerik RadGridView Grouped Columns
Last active September 5, 2017 11:19
Grouping columns programmatically in the Telerik RadGridView control for WinForms
// http://docs.telerik.com/devtools/winforms/gridview/view-definitions/column-groups-view
// Grouped columns do not wrap header text; see http://www.telerik.com/forums/grouping-column-headers
var view = new ColumnGroupsViewDefinition();
var group = new GridViewColumnGroup("Reference Data");
view.ColumnGroups.Add(group);
var groupRow = new GridViewColumnGroupRow();
group.Rows.Add(groupRow);