Skip to content

Instantly share code, notes, and snippets.

View wmeints's full-sized avatar

Willem Meints wmeints

View GitHub Profile
@wmeints
wmeints / GraphClient.cs
Last active July 7, 2020 13:11
A wrapper around the Gremlin.NET client to automatically log query costs and retry failed requests.
/// <summary>
/// Wrapper class for <see cref="IGremlinClient"/> that automatically retries send operations and logs
/// information about the CosmosDB dependency in Application Insights.
/// </summary>
public class GraphClient : IGraphClient
{
private readonly TelemetryClient _telemetryClient;
private readonly IGremlinClient _client;
private readonly IOptions<GremlinSettings> _gremlinSettings;
private readonly ILogger<GraphClient> _logger;
<CascadingValue Value="@ModalDialogService">
@ChildContent
<div class="modal @ModalClasses" tabindex="-1" role="dialog" style="@ModalStyles">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
@Title
</h5>
<button class="close" type="button" @onclick="HideDialog"></button>
mpg cylinders displacement horsepower weight acceleration model year origin car name
18 8 307 130 3504 12 70 1 chevrolet chevelle malibu
15 8 350 165 3693 11.5 70 1 buick skylark 320
18 8 318 150 3436 11 70 1 plymouth satellite
16 8 304 150 3433 12 70 1 amc rebel sst
17 8 302 140 3449 10.5 70 1 ford torino
15 8 429 198 4341 10 70 1 ford galaxie 500
14 8 454 220 4354 9 70 1 chevrolet impala
14 8 440 215 4312 8.5 70 1 plymouth fury iii
14 8 455 225 4425 10 70 1 pontiac catalina
@wmeints
wmeints / setup-cluster.sh
Created October 7, 2017 11:47
Setup kubernetes cluster quickly
#!/bin/sh
SUBSCRIPTION=$1
ENVIRONMENT=$2
az group create --name kubernetes-$ENVIRONMENT --location westeurope
az acs create --orchestrator-type kubernetes \
--resource-group kubernetes-$ENVIRONMENT \
--name $ENVIRONMENT \
--generate-ssh-keys \
@wmeints
wmeints / ITemplateService.cs
Last active August 27, 2020 03:20
A template service based on the ASP.NET Core razor engine
/// <summary>
/// Renders email content based on razor templates
/// </summary>
public interface ITemplateService
{
/// <summary>
/// Renders a template given the provided view model
/// </summary>
/// <typeparam name="TViewModel"></typeparam>
/// <param name="filename">Filename of the template to render</param>
@wmeints
wmeints / api-client.ts
Last active April 3, 2017 15:52
Short demo of how you can wrap standard HTTP behavior by adding additional operations on the observables it produces.
import { ApiRequestOptions } from './api-request-options.service';
import { Http, Response, RequestOptions, ResponseContentType } from '@angular/http';
import 'rxjs/add/observable/zip';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Rx';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
@Injectable()
@wmeints
wmeints / mappings.ts
Last active December 29, 2016 14:25
Converter functions for mapping object values
export type MappingRule = (data: any) => any;
export type MappingRules<T> = { [P in keyof T]?: MappingRule };
export type MapperFunction<T> = (input: T) => any;
// Maps property values based on rules that you supplied.
// Properties for which no rule was supplied are copied to the output.
// NOTICE: This mapper function does not support renaming properties.
export function mapObject<T>(input: T, rules: MappingRules<T>): any {
if(input === undefined || input === null) {
return input;
@wmeints
wmeints / ProxyProxyDance.ps1
Last active February 29, 2024 12:19
This script allows you to enable and disable your proxy settings quickly in case you work from two different locations like your home office and a workplace where they require you to use a proxy.
$internetSettings = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings";
# Determines the current state of the proxy
function Get-ProxyState() {
$settings = Get-ItemProperty -Path $internetSettings;
return $settings.ProxyEnable;
}
# Enables the proxy.
# IMPORTANT: Change the defaults to something that is useful to you!
@wmeints
wmeints / Clients.cs
Last active November 12, 2016 15:11
IdentityServer4 configuration
public class Clients
{
public static IEnumerable<Client> All => new[]
{
new Client()
{
AccessTokenType = AccessTokenType.Jwt,
ClientId = "9c328f06-01c7-4429-9870-7e55a73e2870",
RedirectUris = new List<string>
{
@wmeints
wmeints / PostIndexer.cs
Created September 13, 2015 14:42
Sample code for indexing logic in ASP.NET 5
using System;
using System.Threading.Tasks;
using Weblog.Models;
using Nest;
using Polly;
namespace Weblog.Services
{
public class PostIndexer: IPostIndexer
{