Skip to content

Instantly share code, notes, and snippets.

@cocowalla
cocowalla / ElmahRateLimiter.cs
Last active August 29, 2015 14:26
Elmah email rate limiter
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using Elmah;
public class ElmahRateLimiter
{
@cocowalla
cocowalla / custom-component.ts
Created June 1, 2017 07:30
Custom Component attribute that allows template and style inheritance with Angular 4
///<reference path="../../../../node_modules/reflect-metadata/reflect-metadata.d.ts"/>"
import { Component } from "@angular/core";
// Customer Component attribute that allows template and style inheritance (Angular doesn't support this)
// Based on https://medium.com/@ttemplier/angular2-decorators-and-class-inheritance-905921dbd1b7
// Updated to work with Angular 4
export function CustomComponent(annotation: any) {
return function (target: Function) {
var parentTarget = Object.getPrototypeOf(target.prototype).constructor;
var parentAnnotations = Reflect.getMetadata("annotations", parentTarget);
@cocowalla
cocowalla / new-latency.md
Created August 4, 2017 12:21
Benchmarks before and after PR #21
BenchmarkDotNet=v0.10.6, OS=Windows 7 SP1 (6.1.7601)
Processor=Intel Xeon CPU E3-1545M v5 2.90GHz, ProcessorCount=8
Frequency=2835966 Hz, Resolution=352.6135 ns, Timer=TSC
  [Host]     : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.7.2053.0
  DefaultJob : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.7.2053.0

@cocowalla
cocowalla / ClaimsIdentity.cs
Last active November 9, 2018 15:49
Attempt at adding a custom ClaimsIdentity to the Principal
builder.AddOpenIdConnect(options =>
{
options.Events = new OpenIdConnectEvents
{
OnTokenValidated = async ctx =>
{
var db = ctx.HttpContext.RequestServices.GetRequiredService<DataContext>();
// Get the user's Azure Active Directory ID
var userId = Guid.Parse(ctx.Principal.FindFirst(OBJECT_ID_CLAIM_TYPE).Value);
@cocowalla
cocowalla / gist:97ba28c28d5f7a3a09c1cd58a443f84a
Last active February 10, 2018 20:44
Docker build output
Sending build context to Docker daemon 36.86kB
Step 1/6 : FROM postgres:9.6-alpine
---> 613fcd71a3c8
Step 2/6 : MAINTAINER Linhe Huo <linhe.huo@gmail.com>
---> Using cache
---> 5ded9a9ddcee
Step 3/6 : ENV PLV8_VERSION v2.0.3
---> Using cache
---> ff3c92b5174b
Step 4/6 : ENV DEPOT_TOOLS /depot_tools
@cocowalla
cocowalla / rabbit-azure.txt
Created February 12, 2018 10:32
RabbitMQ <--> Azure Service Bus
+
Internal network | Azure
|
|
+--------+ | +----------+
| Client +---+ | +---+ Consumer |
+--------+ | | | +----------+
| | |
| +-----------------+ | +-------------------+ |
+-+ RabbitMQ Broker +---------+ Azure Service Bus +--+
@cocowalla
cocowalla / dotnetlayout.md
Created February 26, 2018 08:23 — forked from davidfowl/dotnetlayout.md
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
{
// Configure the daemon below:
"options": {
// Select the osquery config plugin.
"config_plugin": "filesystem",
// Select the osquery logging plugin.
"logger_plugin": "filesystem",
// The log directory stores info, warning, and errors.
@cocowalla
cocowalla / Program.cs
Created June 6, 2018 18:37
Simple console app for testing how mod_nss handles client certificates
using System;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
namespace NssTest
{
class Program
@cocowalla
cocowalla / Dockerfile
Last active December 11, 2018 18:37
Web MQTT not using certfile from config
FROM rabbitmq:3.7.5-management-alpine
RUN rabbitmq-plugins enable \
rabbitmq_amqp1_0 \
rabbitmq_shovel \
rabbitmq_shovel_management \
rabbitmq_auth_mechanism_ssl \
rabbitmq_mqtt \
rabbitmq_web_mqtt