Skip to content

Instantly share code, notes, and snippets.

View jeromesun14's full-sized avatar

Sun Yongfeng jeromesun14

View GitHub Profile
#!/bin/bash
PORTS=`sed '1d' port_config.ini | awk '{print $1}'`
j=1
for i in ${PORTS[@]} ;
do
#echo "$i"
ip addr $1 $j.0.0.1/24 dev $i
@jeromesun14
jeromesun14 / handle_git_submodule.md
Last active November 1, 2018 01:22 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@jeromesun14
jeromesun14 / getLastRevised.py
Created November 20, 2018 10:38
python get particular text in a web page
# Please install BeautifulSoup4 first
# python getLastRevised.py to run this script
# e.g.
# ~$ python getLastRevised.py
# URL: 'http://iq.ul.com/ul/cert.aspx?ULID=234547' Last Revised: 2017-05-11
from bs4 import BeautifulSoup
import urllib2
url = "http://iq.ul.com/ul/cert.aspx?ULID=234547"
#!/bin/bash
# rename *.md to *.markdown
# https://unix.stackexchange.com/a/144330
for file in $(ls ./ | grep .md)
do
name=${file::-2}
echo $name
mv $file ${name}.markdown
@jeromesun14
jeromesun14 / iterm2-solarized.md
Created February 14, 2019 06:26 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@jeromesun14
jeromesun14 / tmux-cheatsheet.markdown
Created March 25, 2019 08:09 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@jeromesun14
jeromesun14 / install-git-completion.sh
Created April 17, 2019 09:19 — forked from johngibb/install-git-completion.sh
Mac OS X - Install Git Completion
URL="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
PROFILE="$HOME/.profile"
echo "Downloading git-completion..."
if ! curl "$URL" --silent --output "$HOME/.git-completion.bash"; then
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1
fi
@jeromesun14
jeromesun14 / vimrc
Last active April 24, 2019 02:46
My vimrc backup
" 1. Install bundle
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
"source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"behave mswin
set nu
" Configuration file for vim
set modelines=0 " CVE-2007-2438
@jeromesun14
jeromesun14 / WSL-ssh-server.md
Created June 3, 2020 09:06 — forked from dentechy/WSL-ssh-server.md
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@jeromesun14
jeromesun14 / itoa.sh
Created April 23, 2021 08:45 — forked from jjarmoc/itoa.sh
IP to Integer and Integer to IP conversions in bash.
#Handy functions for .bashrc loading.
#
# $ atoi 192.168.1.1
# 3232235777
# $ itoa 3232235777
# 192.168.1.1
function atoi
{