Skip to content

Instantly share code, notes, and snippets.

@rfpedrosa
rfpedrosa / db-migrations-spec.yml
Last active March 31, 2021 11:28
AWS CodePipeline: run migrations in AWS CodeBuild
# Based on https://github.com/PrakashTrove/AWS-CodeBuild-NetCore/blob/master/buildspec.yml
# AWS CodeBuild spec to run Entity Framework migrations before a deployment
# In order to AWS CodeBuild has access to RDS, I had to manually setup a Inbound rule:
# https://ctoasaservice.org/2019/01/23/aws-codebuild-and-access-to-rds/
version: 0.2
phases:
install:
runtime-versions:
dotnet: latest
@jeshan
jeshan / cdk-profile-plugin.js
Last active April 28, 2022 20:01
How to select AWS profiles per account in AWS CDK
const { CredentialProviderChain } = require('aws-sdk');
const AWS = require('aws-sdk');
const accountProvider = require('./account-provider');
let getEnv = function(accountId) {
// TODO: insert logic to get your desired profile name
return profileName;
};
let getProvider = async (accountId, mode) => {
@hyrmn
hyrmn / DapperExtensions.cs
Last active November 19, 2024 17:50
Extension methods for calling Dapper asynchronously with a Polly retry
public static class DapperExtensions
{
private static readonly IEnumerable<TimeSpan> RetryTimes = new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(3)
};
private static readonly AsyncRetryPolicy RetryPolicy = Policy
@JonCole
JonCole / AzureRedis-PatchingExplained.md
Last active October 22, 2019 17:28
AzureRedis-PatchingProces
@nfriedly
nfriedly / WatsonSTTWebsocketExample.cs
Last active January 29, 2021 20:07
C# example of streaming Watson Speech to Text results over a WebSocket
// Note: The official .net SDK is in progress. It doesn't support streaming Speech to Text at the time of writing,
// but it will soon. Please check it out before using this code.
//
// https://github.com/watson-developer-cloud/dotnet-standard-sdk
using System;
using System.Net.WebSockets;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Threading;
@JonCole
JonCole / DiagnoseRedisErrors-ClientSide.md
Last active January 6, 2020 17:52
Diagnosing Redis errors caused by issues on the client side
@JonCole
JonCole / ThreadPool.md
Last active August 29, 2024 09:23
Intro to CLR ThreadPool Growth

ThreadPool Growth: Some Important Details

The CLR ThreadPool has two types of threads - "Worker" and "I/O Completion Port" (aka IOCP) threads.

  • Worker threads are used when for things like processing Task.Run(…) or ThreadPool.QueueUserWorkItem(…) methods. These threads are also used by various components in the CLR when work needs to happen on a background thread.
  • IOCP threads are used when asynchronous IO happens (e.g. reading from the network).

The thread pool provides new worker threads or I/O completion threads on demand (without any throttling) until it reaches the "Minimum" setting for each type of thread. By default, the minimum number of threads is set to the number of processors on a system.

Once the number of existing (busy) threads hits the "minimum" number of threads, the ThreadPool will throttle the rate at which is injects new threads to one thread per 500 milliseconds. This means that if your system gets a burst of work needing an IOCP thread, it will proces

@veikkoeeva
veikkoeeva / gist:4414609e828375c898f3
Last active January 17, 2017 16:52
Custom Orleans host in F#
namespace OrleansHostingUtilities
open System
open Orleans.Runtime.Configuration
open Orleans.Runtime
open System.Reflection
open System.Globalization
open System.Threading
open System.Net
@a-vasyliev
a-vasyliev / example.com.conf
Created March 25, 2015 11:42
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key
@edwinf
edwinf / UpdateNonSettingParameters
Created January 22, 2015 15:58
Pre-Deployment script to change additional settings in the cscfg file for Octopus Cloud Service deployments.
$subnetName = $OctopusParameters["Azure Subnet Name"]
$virtualNetworkName = $OctopusParameters["Azure Virtual Network Name"]
$sslCert = $OctopusParameters["Azure SSLCertificate Thumbprint"]
$caCert = $OctopusParameters["Azure CACertificate Thumbprint"]
$vmName = $OctopusParameters["Azure Vm Name"]
$pathToCSCFG = [System.IO.Path]::Combine($OctopusOriginalPackageDirectoryPath, "ServiceConfiguration.Cloud.cscfg")
$xml = [xml](Get-Content $pathToCSCFG)
if (![string]::IsNullOrEmpty($virtualNetworkName)){