Skip to content

Instantly share code, notes, and snippets.

@kekru
kekru / 01-sonar-aggregate-generic-testdata.md
Last active August 9, 2023 13:47
Aggregate Sonar Generic Test Data Execution

Sonarqube aggregate Generic Test Data Execution

This is how to combine multiple SonarQube test data reports in the Generic Execution format, using node js.

This can be useful, if you run multiple jest tests, exporting with jest-sonar-reporter and want to combine the results to pass it to SonarQube

We will use glob to find files and xml2js to combine them.

@laughinghan
laughinghan / Every possible TypeScript type.md
Last active June 19, 2024 10:18
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@l13t
l13t / values.yaml
Created January 16, 2019 13:21
alertmanager alerts to slack for prometheus-operator
.......some config.....
alertmanager:
## Deploy alertmanager
##
enabled: true
## Service account for Alertmanager to use.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
##

Owin Authentication with Web API 2

Using Microsoft.Owin.Security along with .NET Web API 2 for authentication on Single Page Applications.

My example is split up into 2 different projects, API which is WebAPI2 project and MyProj which is a basic MVC that contains primarily only JavaScript/CSS/etc and the startup classes.

API > AccountController.cs

namespace API

{

@devoyster
devoyster / ProtobufAutoContract.cs
Created December 13, 2011 21:24
protobuf-net registering type at runtime
var model = RuntimeTypeModel.Default;
// Obtain all serializable types having no explicit proto contract
var serializableTypes = Assembly.GetExecutingAssembly()
.GetTypes()
.Where(t => t.IsSerializable && !Attribute.IsDefined(t, typeof(ProtoContractAttribute)));
foreach (var type in serializableTypes)
{
var metaType = model.Add(type, false);
metaType.AsReferenceDefault = true;