Skip to content

Instantly share code, notes, and snippets.

View silenceshell's full-sized avatar
🐈
Coding

silenceshell silenceshell

🐈
Coding
View GitHub Profile
kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec | select( has ("volumes") ).volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'
@silenceshell
silenceshell / loopmount
Last active January 7, 2019 07:39
create a loopback file and mount it
#!/bin/bash
# sudo loopmount file size mount-point
touch $1
truncate -s $2 $1
mke2fs -t ext4 -F $1 1> /dev/null 2> /dev/null
if [[ ! -d $3 ]]; then
echo $3 " not exist, creating..."
mkdir $3
@silenceshell
silenceshell / fish_prompt.fish
Created September 26, 2018 03:52
fish prompt(ps1) with kubernetes server ip and namespace
function fish_prompt --description 'Write out the prompt'
set laststatus $status
function _git_branch_name
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (git status -s --ignore-submodules=dirty ^/dev/null)
end
function _k8s_cluster
echo (kubectl config view --minify --output 'jsonpath={..server}' 2>/dev/null | cut -d':' -f2 |cut -d'.' -f4)
#!/bin/bash
for container in $(docker ps -q); do
iflink=`docker exec -it $container bash -c 'cat /sys/class/net/eth0/iflink'`
iflink=`echo $iflink|tr -d '\r'`
veth=`grep -l $iflink /sys/class/net/veth*/ifindex`
veth=`echo $veth|sed -e 's;^.*net/\(.*\)/ifindex$;\1;'`
echo $container:$veth
done
@silenceshell
silenceshell / Openvswitch LTS in CentOS 7.md
Created March 15, 2018 11:35 — forked from umardx/Openvswitch LTS in CentOS 7.md
Installation Openvswitch LTS in CentOS 7

The most recent release from the LTS series: http://openvswitch.org/releases/openvswitch-2.5.4.tar.gz

Instructions:

As the root user let’s install some packages:

yum -y install wget openssl-devel gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool python-twisted-core python-zope-interface PyQt4 desktop-file-utils libcap-ng-devel groff checkpolicy selinux-policy-devel

Add a new user and switch to that user:

@silenceshell
silenceshell / gist:d97c3d9b0ba21d71f21c3a60db1fb284
Last active November 29, 2023 05:26 — forked from jordelver/gist:3073101
Set the Mac OS X SOCKS proxy on the command line

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

1 ssh to remote server as a SOCKS server

ssh -D 6080 {user}@{ssh_server} -p {ssh_port}
@silenceshell
silenceshell / 0_reuse_code.js
Created August 31, 2017 02:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@silenceshell
silenceshell / dockerhub-v2-api-organization.sh
Created August 31, 2017 02:06 — forked from kizbitz/dockerhub-v2-api-organization.sh
Get the list of images and tags for a Docker Hub organization account
#!/bin/bash
# Example for the Docker Hub V2 API
# Returns all images and tags associated with a Docker Hub organization account.
# Requires 'jq': https://stedolan.github.io/jq/
# set username, password, and organization
UNAME=""
UPASS=""
ORG=""