Skip to content

Instantly share code, notes, and snippets.

@xetys
xetys / javaswitch.sh
Created March 2, 2022 09:13
Java Version Switcher
#!/usr/bin/env bash
declare -A JDKS
JDKS[8]="/usr/lib/jvm/jdk1.8.0_251"
JDKS[11]="/usr/lib/jvm/jdk-11.0.9"
JDKS[14]="/usr/lib/jvm/jdk-14.0.1"
JDKS[16]="/usr/lib/jvm/jdk-16.0.2"
if [ "$#" -ne 1 ]; then
@xetys
xetys / Hard.java
Created October 9, 2018 21:01
Add Without Plus
public class Hard {
public static void main(String[] args) {
for(int i = 0; i < 100; i++) {
for(int j = 0; j < 100; j++) {
assert addWithoutPlus(i,j) == i + j;
}
}
@xetys
xetys / cloud-init-ubuntu18.yaml
Last active June 25, 2018 21:17
cloud-config docker
#cloud-config
package_update: true
runcmd:
- snap install docker --channel=17.03/stable
@xetys
xetys / .tmux.conf
Last active November 26, 2018 11:41
tmux dotfile
unbind C-b
set-option -g prefix C-x
bind-key C-x send-prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf
@xetys
xetys / hetzner-kube-demo.sh
Created January 30, 2018 00:05
hetzner-kube-demo
#!/bin/bash
# install openebs
kubectl apply -f https://raw.githubusercontent.com/openebs/openebs/master/k8s/openebs-operator.yaml
kubectl apply -f https://raw.githubusercontent.com/openebs/openebs/master/k8s/openebs-storageclasses.yaml
# install helm
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
@xetys
xetys / ubuntu16-kubeadm
Last active January 25, 2018 01:53
ubuntu16-kubeadm
#!/bin/bash
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
@xetys
xetys / commands.sh
Last active October 30, 2017 00:46
rancher cluster
# --volume-plugin-dir=/var/lib/rancher/etc/vol-plugins
apt update && apt install -y docker.io && docker pull rancher/server:stable && docker pull rancher/agent:v1.2.6
apt update && apt install -y docker.io && docker pull rancher/agent:v1.2.6
docker run -d --name=rancher-server --restart=unless-stopped -p 8080:8080 rancher/server:stable
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod a+x kubectl
mv kubectl /usr/local/bin
mkdir ~/.kube
touch ~/.kube/config
# --volume-plugin-dir=/var/lib/rancher/etc/vol-plugins
apt update && apt install -y docker.io && docker pull rancher/server:stable && docker pull rancher/agent:v1.2.6
apt update && apt install -y docker.io && docker pull rancher/agent:v1.2.6
docker run -d --name=rancher-server --restart=unless-stopped -p 8080:8080 rancher/server:stable
@xetys
xetys / storage-provisioner.sh
Last active June 2, 2017 15:00
The most ugliest dynamic storage provider for kubernetes (installed by kismatic enterprise toolkit)
#!/bin/bash
while true; do
kubectl get pvc --all-namespaces -o json | jq '.items[] | select(.metadata.annotations["volume.beta.kubernetes.io/storage-class"]=="auto-provision" and .status.phase=="Pending")' | jq -r '[.metadata.name, .spec.resources.requests.storage] | @csv' | sed s/\"//g | sed s/Gi//g | sed s/-pvc/-pv/ | awk -F ',' '{ print "./kismatic volume add " $2 " " $1 " -r 1 -d 2 -c=\"auto-provision\" -a 10.10.*.*"}' | sh
sleep 10
done;
@xetys
xetys / rancher-agent-ubuntu.sh
Created March 2, 2017 20:51
Install Rancher Agent on a fresh ubuntu 16.04
apt-get install -y apt-transport-https ca-certificates && \
apt-key adv \
--keyserver hkp://ha.pool.sks-keyservers.net:80 \
--recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list && \
apt-get update && \
apt-get install -y docker-engine=1.12.6-0~ubuntu-xenial && \
docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.0 <server-url>