Skip to content

Instantly share code, notes, and snippets.

View incfly's full-sized avatar

Jianfei Hu incfly

  • ClickHouse
  • San Francisco Bay Area
View GitHub Profile
@incfly
incfly / memusg
Created January 14, 2013 07:58 — forked from netj/memusg
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
set -um
# check input
[ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; }
<p>hello world</p>
in
<embed src="https://www.cco.purdue.edu/student/resume/resumesamples.pdf" width="800" height="600">
#define _cp(a,b) ((a)<(b))
//k+1's element. jilin's template
int kth_element(int n, int a[], int k){
int l = 0, r = n-1, i, j, key;
while (l < r){
for (i=l-1, j = r+1, key = a[(i+j)>>1]; i < j; ){
// j--, i++ at beginning of the loop is because, if i < j but a[i] == a[j] == key
// then not progress any more. i, j points to end of range that is done.
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
@incfly
incfly / python_mock.py
Last active August 29, 2015 14:24
Mock module.function
############################################################
# how mock really work: just replace the attribute.
############################################################
class MyClass(object):
def getname(self):
return 'real getname'
def fake_getname():
return 'fake getname'
package main
import "fmt"
type Person struct{
Name string
Age int
}
func main() {
@incfly
incfly / instruction.sh
Last active May 31, 2018 17:37
Envoy Multiplexing Test
# download github envoy repo.
cd ${PATH_TO_ENVOY_REPO}
# build
./ci/run_envoy_docker.sh './ci/do_ci.sh bazel.dev'
# start envoy with following config.
/tmp/envoy-docker-build/envoy/source/exe/envoy-fastbuild -c configs/istio-multiplexing.yaml
# Separate terminal.
# TCP, should see google web page
@incfly
incfly / multiplex-test.sh
Last active August 3, 2022 10:16
script to run istio multiplex e2e test
function setup() {
export NS="istio-system"
# export TAG=$(awk 'FNR == 2 {print substr($0,5) } ' .istio.mk)
export TAG="multi-0610-a"
export HUB="gcr.io/jianfeih-test"
echo $NS, $TAG
}
function remove_ns() {
setup
@incfly
incfly / proxyv2_build.sh
Created June 20, 2018 16:28
Build istio proxyv2 image
git clone https://github.com/istio/proxy
git clone https://github.com/istio/istio
pushd istio
# Build the binary and docker first
make && make docker
# Get the command line to build proxyv2 image, this shows the artifact path for proxyv2 docker image
# say it's /golang/out/linux_amd64/release/docker_build/proxyv2
make docker.push --dry-run | grep proxyv2
function send_req() {
ITER=${ITER:-3}
for i in `seq 0 $ITER`; do
echo "iteration $i starts...."
for from in "foo" "bar" "legacy"; do
for to in "foo"; do
echo "from ${from}.sleep to ${to}.httpbin"; kubectl exec $(kubectl get pod -l app=sleep -n ${from} -o jsonpath={.items..metadata.name}) -c sleep -n ${from} -- curl http://httpbin.${to}:8000/ip -s ;
done;
done;
echo "iteration $i ends...."