Skip to content

Instantly share code, notes, and snippets.

@StevenLiekens
StevenLiekens / ibm-data-db2.md
Last active Oct 25, 2020
IBM DB .NET Core Provider
View ibm-data-db2.md

IBM.Data.DB2

There are three packages that target .NET Standard 2.0

  • [IBM.Data.DB2.Core] for Windows
  • [IBM.Data.DB2.Core-lnx] for Linux (which flavor? who knows...)
  • [IBM.Data.DB2.Core-osx] for Mac

Installation

@StevenLiekens
StevenLiekens / DiscriminatedJsonConverter.cs
Last active Jun 9, 2019
Configurable JsonConverter for deserializing discriminated JSON
View DiscriminatedJsonConverter.cs
using System;
using System.Diagnostics;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Infrastructure
{
public sealed class DiscriminatedJsonConverter : JsonConverter
{
View DesignedForInheritanceTest.cs
using System;
using System.Linq;
using System.Reflection;
using Xunit;
namespace YourLibName.Tests.PatternsAndPractices
{
public class DesignedForInheritanceTest
{
public DesignedForInheritanceTest()
View no-uncommited.ps1
# Check the working directory for modified files
# Exit with an error if there are any
$modified = git ls-files --modified
if ($modified -ne $null) {
Write-Error "Working directory contains modified files: $modified"
exit 1
}
View rollup-plugin-vue-unofficial.ts
import { Plugin, PluginContext } from 'rollup';
import { createFilter } from 'rollup-pluginutils';
import {
parse,
compileTemplate,
TemplateCompileResult
} from '@vue/component-compiler-utils';
import { VueTemplateCompiler } from '@vue/component-compiler-utils/dist/types';
import {
ObjectExpression,
View Controller.cs
[HttpGet("users/{userRef:email}")]
public async Task<IActionResult> GetUserByEmailAddress([EmailAddress]string userRef)
{
}
[HttpGet("users/{userRef}")]
public async Task<IActionResult> GetUserById(string userRef)
{
View RecoverPrimeFactors.cs
private static (BigInteger, BigInteger) RecoverPrimeFactors(BigInteger n, BigInteger e, BigInteger d)
{
// Inspired by https://www.di-mgt.com.au/rsa_factorize_n.html
var k = BigInteger.Subtract(BigInteger.Multiply(d, e), BigInteger.One);
var primes = new List<int>
{
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
@StevenLiekens
StevenLiekens / compare-files.ps1
Last active Jul 12, 2018
Comparing git-ls-files to actual filenames
View compare-files.ps1
Compare-Object `
-ReferenceObject (git ls-files | Resolve-Path -Relative | Sort-Object) `
-DifferenceObject (Get-ChildItem -Recurse -File | Resolve-Path -Relative | Sort-Object) `
-CaseSensitive `
-SyncWindow 0
@StevenLiekens
StevenLiekens / eolconfig.ps1
Last active Dec 23, 2018
Configure Git line normalization the right way (using PowerShell)
View eolconfig.ps1
# first install Git 2.16+
# https://git-scm.com/download/win
git --version
# (optional) reset machine settings because per-machine config makes no sense in team projects
# the default (when not set) for core.autocrlf is false (no eol conversions)
git config --unset core.autocrlf
git config --unset core.safecrlf
git config --unset core.eol
@StevenLiekens
StevenLiekens / ES6ModulesHttpModule.cs
Last active Jun 3, 2018
Make IIS support extension-less imports
View ES6ModulesHttpModule.cs
public class ES6ModulesHttpModule : IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.BeginRequest += ContextOnBeginRequest;
}
You can’t perform that action at this time.