Skip to content

Instantly share code, notes, and snippets.

View hpcsc's full-sized avatar

David Nguyen hpcsc

View GitHub Profile
@hpcsc
hpcsc / handlers.go
Created July 11, 2021 22:47 — forked from dstroot/handlers.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"io"
"net/http"
"sync/atomic"
)
func index() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@hpcsc
hpcsc / merge-terraform-state.sh
Created April 19, 2020 09:58
Script to merge source terraform state into destination state
#!/bin/bash
SOURCE=$1
DESTINATION=$2
if [ -z "${SOURCE}" ] || [ -z "${DESTINATION}" ]; then
echo "=== source and destination are required"
echo "Usage: $0 source destination"
exit 1
fi;
@hpcsc
hpcsc / AUsage.cs
Created January 24, 2020 10:01 — forked from davidfowl/AUsage.cs
Header propagation HttpClientFactory middleware
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("myclient");
// Global header propagation for any HttpClient that comes from HttpClientFactory
services.AddHeaderPropagation(options =>
{
options.HeaderNames.Add("Correlation-Id");
});
}
@hpcsc
hpcsc / hack.sh
Created March 3, 2019 12:43
md viewer in terminal
#!/usr/bin/env bash
FZF_DEFAULT_OPTS="--reverse --height 30% --header 'Choose markdown file'"
CACHE_DIR=$HOME/.hack/
function check_prerequisite() {
local prerequisites=(curl mdless jq fzf)
for tool in ${prerequisites[@]}; do
type ${tool} >/dev/null 2>&1 || { echo >&2 "I require $tool but it's not installed."; exit 1; }
@hpcsc
hpcsc / Example1.cs
Created August 24, 2016 07:33 — forked from davidfowl/Example1.cs
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)