Skip to content

Instantly share code, notes, and snippets.

View jijiechen's full-sized avatar
🎯
Focusing

Jay Jijie Chen jijiechen

🎯
Focusing
View GitHub Profile
@jijiechen
jijiechen / stat-github-action-runners.sh
Last active October 30, 2024 06:34
Stat runner usage of GitHub actions runners in a repo
#!/bin/bash
# set -x
ORG=kumahq
REPO=kuma
SELF_HOSTED_TAG=kong
if [[ ! -z "$1" ]]; then
ORG=$1
fi
if [[ ! -z "$2" ]]; then
@jijiechen
jijiechen / envoy-config-listeners-vips.json
Last active January 17, 2024 06:38
kuma vip listeners
{
"configs": [
{
"@type": "type.googleapis.com/envoy.admin.v3.BootstrapConfigDump",
"bootstrap": { },
"last_updated": "2024-01-16T07:23:56.160Z"
},
{
"@type": "type.googleapis.com/envoy.admin.v3.ClustersConfigDump",
"version_info": "3586351e-0f89-466a-8321-bc4da29e4bd2",
@jijiechen
jijiechen / egress-mtls-authz.yaml
Created November 27, 2021 14:04 — forked from yangminzhu/egress-mtls-authz.yaml
Example policies to enforce mTLS between sidecar and egress gateway
# Example policies to enforce mTLS between sidecar and egress gateway, the connection between sidecar
# and egress gateway could be:
# 1. plaintext in (Istio) mTLS or
# 2. TLS in (Istio) mTLS;
# An AuthorizationPolicy is applied on egress gateway to enforce egress access control.
---
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
name: httpbin-org-ext
@jijiechen
jijiechen / deploy-service.sh
Last active November 2, 2020 02:04
Create a incremented version of Kubernetes deployment for a microservice by exporting the current version deployment
#!/bin/bash
# This script depends on the "yq" utility: https://github.com/mikefarah/yq
SERVICE_NAME=$1
NEW_IMAGE=$2
LATEST_VERSION=$(kubectl get deployment --selector app=$SERVICE_NAME -o 'jsonpath={.items[*].metadata.labels.version}' | tr " " "\n" | sed 's/^v//' | sort -n -r | tr "\n" " " | cut -d ' ' -f 1)
NEXT_VERSION=$((LATEST_VERSION+1))
@jijiechen
jijiechen / trust-ca-cert.sh
Last active July 16, 2020 14:54
Trust ca cert on Linux based on hostname and port
#!/bin/sh
FULL_HOST=$1
if [ -z "$FULL_HOST" ]; then
FULL_HOST=localhost:443
fi
HOST=$(echo $FULL_HOST | cut -d ':' -f 1)
PORT=$(echo $FULL_HOST | cut -d ':' -f 2)
@jijiechen
jijiechen / SampleTest.cs
Created July 10, 2016 07:40
Example code to demo default IHttpResponseFeature throwing System.NotImplementedException
using Xunit;
using MyNamespace;
using Microsoft.AspNetCore.TestHost;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Hosting;
using System.Threading.Tasks;
@jijiechen
jijiechen / MergeDirectories.cs
Last active May 10, 2016 14:40
Copy or move a directory into destination directory and merge their contents
public static void MergeDirectories(string sourceDir, string destDir, bool moveMode = false, bool overwriteMode = false)
{
if (!Directory.Exists(destDir))
{
Directory.CreateDirectory(destDir);
}
var dir = new DirectoryInfo(sourceDir);
foreach (var file in dir.GetFiles())
@jijiechen
jijiechen / AspNetCore.Mono.UseSynchronousFileProvider.cs
Last active April 11, 2016 13:53
Configure Mvc to use a synchronous IFileProvider instance to prevent from hangs when generating Razor view result. See https://github.com/aspnet/Hosting/issues/604
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.Extensions.Primitives;
using System;
@jijiechen
jijiechen / cleanup-zhihu-single-anwser.js
Last active October 17, 2015 02:52
javascript code to clean up Zhihu anwser page
// javascript code to clean up Zhihu anwser page
$('#zh-question-answer-wrap .zm-item-rich-text .zm-editable-content').first().prepend('<p>作者:<strong>' + $.trim($('.zm-item-answer-author-info:first').text()).replace(/,/, ' </strong>').replace(/收起/g, '') + '</p>');
[".zu-top",
"#zh-footer",
".zu-main-sidebar",
".zm-tag-editor",
"#zh-question-meta-wrap",
".zm-votebar",