Skip to content

Instantly share code, notes, and snippets.

@kopwei
kopwei / Git merge
Created August 8, 2013 10:47
How to merge github branch and local gerrit branch
1) Edit the local .git/config, add the following code:
[remote "github"]
fetch = +refs/heads/*:refs/remotes/github/*
url = git://github.com/PROJ_NAME
2) Check remote branches
git branch -r github
@kopwei
kopwei / gist:6904021
Created October 9, 2013 16:28
Bash string cutting with delimiter
Pattern Matching
In pattern matching, you can match from the left or from the right. The operators, along with their functions and examples, are shown below:
Operator: ${foo#t*is}
Function: deletes the shortest possible match from the left
Example:
$ export foo="this is a test"
@kopwei
kopwei / gist:9832139
Created March 28, 2014 13:00
Execute script as another user
su -c "Your command right here" -s /bin/sh otheruser
@kopwei
kopwei / gist:9c2fc33f9e3583239e3e
Created April 22, 2015 06:36
Install Latest Git on Ubuntu
# Install Latest Git on Ubuntu:
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
Gateway set up
The following example will focus on the most common gateway setup: an Ubuntu computer with two wired network adapters (eth0 and eth1) hosting ICS to a static internal network configured for the 192.168.0.x subnet.
For this example, eth0 is used to represent the network card connected to the Internet, and eth1 represents the network card connected to a client PC. You can replace eth0 and eth1 as needed for your situation. Also, any private IP subnet can be used for the internal network IP addresses.
In summary:
eth0 = the network adapter with internet (external or WAN).
eth1 = the network adapter to which a second computer is attached (internal or LAN).
@kopwei
kopwei / share_internet.sh
Last active November 27, 2018 14:32
Ubuntu 16 share internet connection
#!/bin/bash
set -e
INTERNET_INF=$1
SUB_INF=$2
if [ -z "$INTERNET_INF" ] || [ -z "$SUB_INF" ]; then
echo "Please enter 2 interfaces' names"
exit 1
fi
@kopwei
kopwei / net_config.md
Last active December 29, 2023 07:05
Ubuntu Bionic netplan config for Openvswitch bridged interface

Preparation

  • System ubuntu18.04.2 desktop
  • Internet interface name eth0 with dhcp.

Steps

  1. Disable network-manager:
@kopwei
kopwei / space_vim_file_icon.md
Created March 27, 2019 08:06
SpaceVim file-type icon issue on Ubuntu

This is a note for installing SpaceVIM on Ubuntu

I installed SpaceVIM on Ubuntu Bionic today but the file-type icons are shown in strange Chinese characters rather than the correct icons.

Check 1: Terminal Encoding

Set terminal profile encoding to UTF-8

Check 2: VIM Encoding

Set VIM encoding to UTF-8. Check the encoding via following command in VIM

@kopwei
kopwei / rancher_monitoring_arm64.md
Last active March 9, 2020 18:35
Enabling rancher monitoring on arm64 platform

This trying to explain how to enable monitoring on k3s/arm64

Deployments

prometheus-operator-monitoring-operator

  • coreos-configmap-reload
  • coreos-prometheus-operator

grafana-cluster-monitoring

  • nginx
@kopwei
kopwei / k3s-cluster.md
Last active August 9, 2024 03:17
K3s and Rancher on Raspberry Pi 4 Cluster

Deploy K3s and Rancher on Raspberry Pi 4 cluster

Today I tried to setup a small Kubernetes cluster on top of 3 Raspberry Pi 4 (4GB Memory). Here is the steps to install the cluster.

IMG_3817

Preparation

I have 3 Raspberry Pi 4 stacked with PoE headers and connected to a PoE switch at home. The are connected to Internet through a home router. All Pis are equipped with a 64GB Samsung SDXC card flushed with Ubuntu 20.04 image.