Skip to content

Instantly share code, notes, and snippets.

View Fang-Li's full-sized avatar
🎯
Focusing

Fang-Li

🎯
Focusing
View GitHub Profile
@Fang-Li
Fang-Li / kubectl.md
Created March 31, 2022 14:47 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@Fang-Li
Fang-Li / awk.html
Created January 28, 2022 16:16 — forked from harryxu/awk.html
awk手册
<p>这个手册是我转载的,准备用markdown整理下格式,感觉原来的html太乱了。</p>
<p>TOC是通过python的markdown生成的,<a href="http://www.freewisdom.org/projects/python-markdown/">http://www.freewisdom.org/projects/python-markdown/</a></p>
<pre><code>markdown awk.md &gt; awk.html -x toc
</code></pre>
<p>以下全部内容是从 <a href="http://linuxfire.com.cn/~lily/awk.html">http://linuxfire.com.cn/~lily/awk.html</a> 转载的。</p>
<div id="awktoc">
<div class="toc">
<ul>
<li><a href="#awk">awk 手册</a><ul>
@Fang-Li
Fang-Li / install-pre-commit.sh
Created February 22, 2021 10:39 — forked from stefansundin/install-pre-commit.sh
Git pre-commit check to stop accidental commits to master and develop branches. There is also a variant with a core.whitespace check.
#!/bin/sh
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are four variants that I have built:
# - pre-commit: stops commits to "master" and "develop" branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set desired version like this before installing:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app="http://www.google.de"
@Fang-Li
Fang-Li / .bashrc
Created March 1, 2019 08:39 — forked from nvie/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@Fang-Li
Fang-Li / xmltest.erl
Created December 28, 2018 05:50 — forked from afternoon/xmltest.erl
Examples of generating XML with Erlang's xmerl library.
-module(xmltest).
-compile(export_all).
-include_lib("xmerl/include/xmerl.hrl").
%% @doc Helper function to generate XML from a data structure and print it
serialize(Data) ->
Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)),
io:format("~s~n", [Xml]).
file: g.erl
-module(g).
-compile(export_all).
-behaviour(gen_server).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
%%-------------------------------------------------------------------
%% Public API
@Fang-Li
Fang-Li / expect.sh
Created October 25, 2018 09:47
expect tcl 免密上传脚本
#!/usr/bin/expect -f
##########################################################
# 1.service ip
# 2.User
# 3.userPassword
# 4.serverPath [server端路径]
# 5.localPath [本地路径] ... 多个值
#返回值:
# 0 成功
# 1 参数个数不正确
@Fang-Li
Fang-Li / broadcast.erl
Created October 22, 2018 09:55 — forked from lilrooness/broadcast.erl
Erlang Chat Program
-module(broadcast).
-export([start/1]).
start(Port) ->
{ok, AcceptSocket} = gen_tcp:listen(Port, [binary, {active, false}]),
io:fwrite("Now listening for new connections"),
% Process managing client connections
ManagerId = spawn(fun() -> manage_clients([]) end),
@Fang-Li
Fang-Li / ekill
Created September 28, 2018 01:35 — forked from xinthink/ekill
Kill process by match the whole command line (like ps -ef) Usage: ekill <pattern> [signal]
#!/bin/bash
SIG="-2"
if [[ "$2" != "" ]]; then
SIG="$2"
fi
ps -ef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill $SIG