Skip to content

Instantly share code, notes, and snippets.

Avatar

Dreampuf dreampuf

View GitHub Profile
@dreampuf
dreampuf / elasticcache_d100
Last active Aug 28, 2021
Performance: AWS MemoryDB vs Elasticcache
View elasticcache_d100
$ ./memtier_benchmark -s ENDPOINT -d 100
[RUN #1] Preparing benchmark client...
[RUN #1] Launching threads now...
[RUN #1 100%, 54 secs] 0 threads: 2000000 ops, 38847 (avg: 36961) ops/sec, 1.84MB/sec (avg: 1.75MB/sec), 5.15 (avg: 5.41) msec latency
4 Threads
50 Connections per thread
10000 Requests per client
@dreampuf
dreampuf / launch.sh
Created Jul 8, 2020
How to create a vuejs3 project
View launch.sh
vue create PROJECT_NAME
# select features you need
cd PROJECT_NAME
vue add vue-next
rm src/shims-tsx.d.ts
sed -i '' 's/RouteConfig/RouteRecordRaw/g' src/router/index.ts # https://github.com/vuejs/vue-router-next/commit/fd49bbd085e9df7804994ea188f94384ac22e048
patch -p1 <<'EOF'
diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue
index dc773ba..01a7286 100644
--- a/src/components/HelloWorld.vue
@dreampuf
dreampuf / install_openjdk8.sh
Last active Jul 2, 2020
Install JDK8 on Jessie in 2020
View install_openjdk8.sh
cat > /etc/apt/sources.list.d/openjdk.list <<"EOF"
deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main
EOF
apt-get update
apt install -t jessie-backports openjdk-8-jdk
update-alternatives --config java # select java1.8
@dreampuf
dreampuf / bash
Last active Mar 21, 2020
How to get the golang package version of the latest git repo commit
View bash
# Credit: https://stackoverflow.com/a/59440771/398634
TZ=UTC git --no-pager show \
--quiet \
--abbrev=12 \
--date='format-local:%Y%m%d%H%M%S' \
--format="%cd-%h"
@dreampuf
dreampuf / main.go
Last active Dec 10, 2019
Golang SSHAgent Usage Example
View main.go
package main
/*
Golang SSHAgent Usage
https://orebibou.com/2019/03/golang%E3%81%A7ssh-agent%E3%81%8B%E3%82%89%E9%8D%B5%E3%82%92%E5%8F%96%E5%BE%97%E3%81%97%E3%81%A6ssh%E6%8E%A5%E7%B6%9A%E3%81%99%E3%82%8B/
*/
import (
"fmt"
"golang.org/x/crypto/ssh"
@dreampuf
dreampuf / chicken_soup.ipynb
Last active Nov 19, 2019
Greasy Chiken Soup
View chicken_soup.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dreampuf
dreampuf / ssh_test.go
Created Aug 27, 2019
Golang SSH Interactively shell show case
View ssh_test.go
package main
import (
"bytes"
"context"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"io/ioutil"
"net"
"os"
@dreampuf
dreampuf / calc.y
Last active Aug 22, 2019
hostlist generate by goyacc
View calc.y
%{
package main
import(
"fmt"
"bufio"
"os"
"strconv"
"unicode"
"unicode/utf8"
)
@dreampuf
dreampuf / build_node_exporter.sh
Created Aug 7, 2019
Build a Node Exporter RPM package
View build_node_exporter.sh
# Extract Node Exporter RPM package
# Download the official tar package
# https://prometheus.io/download/#node_exporter
VERSION=${VERSION:-0.18.1}
URL=https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gz
FILENAME=${URL##*/}
ROOT_PATH=$PWD/pkg
APP_ROOT_PATH=$ROOT_PATH/opt/node_exporter
ITERATION=${ITERATION:-1}
@dreampuf
dreampuf / instructions.sh
Created Apr 8, 2019
How to enable admission-pulgins in kubernetes of docker-desktop
View instructions.sh
# Install docker and kubernetes first
# Helpful link: https://www.docker.com/products/docker-desktop
# Then you need to get into the virtual machine by (it may change in the future, but the path should be similar)
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
# Change the line in /etc/kubernetes/manifests/kube-apiserver.yaml
# - --enable-admission-plugins=Initializers,NodeRestriction
# to
# - --enable-admission-plugins=Initializers,NodeRestriction,ValidatingAdmissionWebhook,MutatingAdmissionWebhook