Skip to content

Instantly share code, notes, and snippets.

@MikeJansen
MikeJansen / yq-functions.sh
Created January 2, 2023 16:58
yq functions
# Pipe YAML or JSON, optionally query it, and display as colorized YAML in less
function y() { yq -C "$@" | less -R; }
function yj() { yq -C -p=j -o=y "$@" | less -R; }
@MikeJansen
MikeJansen / gcp-compute-status.sh
Last active January 2, 2023 16:55
List compute across GCP projects with status
for p in $(gcloud projects list --format json|yq -p=j '.[]|.projectId');
do
PRJ=$p gcloud compute instances list --format json --project $p |yq -p=j '.[]|[env(PRJ), .status, .name]|@csv';
done
@MikeJansen
MikeJansen / extract_kubecfg_cert.sh
Last active December 15, 2022 14:35 — forked from xueshanf/extract_kubecfg_cert.sh
Extract kubernetes cluster credentials from kubecfg
#!/bin/bash
# Input: ./extract_kubecfg_cert.sh my-cluster-name username
# Output: ./my-cluster-name-ca.crt ./username.crt ./username.key
# Exit on error
abort(){
echo $1 && exit 1
}
# Prerequistes
@MikeJansen
MikeJansen / DelegatingActionDescriptor.cs
Created November 5, 2012 13:35
Custom IHttpActionSelector
namespace Radar.Common.WebServer.Api.Controllers
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
@MikeJansen
MikeJansen / HttpRequestMessageHelper.cs
Created May 10, 2012 14:36
HttpRequestMessage.GetClientIpAddress for ASP.NET MVC 4 / Web API
// Original idea: http://stackoverflow.com/questions/9565889/get-the-ip-address-of-the-remote-host
using System.Net.Http;
using System.ServiceModel.Channels;
using System.Web;
namespace CrowSoftware.Api
{
public static class HttpRequestMessageHelper
{
@MikeJansen
MikeJansen / nightly-build-to-gac.cmd
Created May 7, 2012 15:08
ASP.NET MVC 4 - update GAC from nightly build http://is.gd/lAht03
@echo off
rem *********************************************************************************
rem *
rem * See http://is.gd/lAht03
rem *
rem * Update ASP.NET MVC4 nightly build in the GAC
rem *
rem * Run from the solution's packages folder.
rem *
rem * nightly-build-to-gac.cmd [build-no-filter]
@MikeJansen
MikeJansen / QueuedWrapperTarget.cs
Created February 3, 2012 14:04
The Benefits of Trace Level Logging in Production Without the Drawback of Enormous Files
namespace NLog.Targets.Wrappers
{
using System.Collections.Generic;
using System.ComponentModel;
using NLog.Common;
/// <summary>
/// A target that places events in a fixed size FIFO queue and only logs the most recent events
/// when an event of sufficient severity is logged. This provides context to more severe events
/// without filling up the logs when no severe events are occurring.
@MikeJansen
MikeJansen / gist:1178973
Created August 29, 2011 18:07
JFreeChart - Test Phase Report
package com.necam.eadd.jira.plugin.report.magicchart;
import java.awt.BasicStroke;
import java.awt.Color;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;