Skip to content

Instantly share code, notes, and snippets.

View mivano's full-sized avatar

Michiel van Oudheusden mivano

View GitHub Profile
@mivano
mivano / logstash
Created March 21, 2014 15:07
ElasticSearch Logstash index template
{
"template": "logstash*",
"settings": {
"index.analysis.analyzer.default.stopwords": "_none_",
"index.number_of_replicas": "1",
"index.query.default_field": "message",
"index.refresh_interval": "5s",
"index.number_of_shards": "4",
"index.store.compress.stored": "true",
"index.analysis.analyzer.default.type": "standard",
@mivano
mivano / create log table
Last active August 29, 2015 13:58
Serilog Log table create SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Logs](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Message] [nvarchar](max) NULL,
[MessageTemplate] [nvarchar](max) NULL,
@mivano
mivano / gist:bbb7563b31177e038608
Last active August 29, 2015 14:03 — forked from nblumhardt/gist:8914175
Serilog extension for log context
public static class LoggerExtensions
{
public static ILogger ForHere(
this ILogger logger,
[CallerFilePath] string sourceFile = null,
[CallerLineNumber] int sourceLine = 0)
{
return logger
.ForContext("SourceFile", sourceFile)
.ForContext("SourceLine", sourceLine);
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy Unrestricted
if (Test-PendingReboot) { Invoke-Reboot }
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
@mivano
mivano / README.md
Last active August 29, 2015 14:11 — forked from hofmannsven/README.md
Git Cheatlist
# setup certificate properties including the commonName (DNSName) property for Chrome 58+
$certificate = New-SelfSignedCertificate `
-Subject localhost `
-DnsName localhost `
-KeyAlgorithm RSA `
-KeyLength 2048 `
-NotBefore (Get-Date) `
-NotAfter (Get-Date).AddYears(2) `
-CertStoreLocation "cert:CurrentUser\My" `
-FriendlyName "Localhost Certificate for .NET Core" `
@mivano
mivano / xunit_fact.snippet
Created August 30, 2017 10:09 — forked from marcduiker/xunit_fact.snippet
Visual Studio C# snippet for xUnit test methods (Facts) using the naming convention proposed by http://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html. Import the snippet using the SnippetManager in VS and type `fact[tab][tab]` inside a class to insert the snippet.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>xUnit Fact</Title>
<Shortcut>fact</Shortcut>
<Description>Code snippet for an xUnit test method (Fact) following the naming convention UnitOfWork_StateUnderTest_ExpectedBehaviour.</Description>
. { Invoke-WebRequest -UseBasicParsing http://boxstarter.org/bootstrapper.ps1 } | Invoke-Expression
Get-Boxstarter -Force
Install-BoxstarterPackage `
-PackageName https://gist.githubusercontent.com/mivano/2b078f267d3ca1e9996c07085eb59a60/raw/Windows10-Setup.ps1 `
-Credential (Get-Credential -Message "Please provide login credentials for Boxstarter reboots")
@mivano
mivano / StringExtensions.cs
Created January 12, 2018 08:39
StringExtensions conversions
public static class StringExtensions {
private delegate bool TryParseDelegate<T>(string s, out T result);
private static T To<T>(string value, TryParseDelegate<T> parse)
=> parse(value, out T result) ? result : default;
public static int ToInt32(this string value)
=> To<int>(value, int.TryParse);
public static DateTime ToDateTime(this string value)
=> To<DateTime>(value, DateTime.TryParse);
public static IPAddress ToIPAddress(this string value)
=> To<IPAddress>(value, IPAddress.TryParse);