Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Ning Xie andyxning

:octocat:
View GitHub Profile
View add_linux_man_page_docset_to_Dash.sh
#!/bin/bash
# Under instructions in: https://blog.kapeli.com/linux-man-pages-in-dash
set -x
set -e
man_path_dest_dir="/usr/local/share/man"
man_pages_version="5.06"
linux_man_pages_download_link="https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/man-pages-${man_pages_version}.tar.xz"
View npd_kernel_monitor.json
{
"logPath": "/var/log/kern.log",
"lookback": "10m",
"startPattern": "Initializing cgroup subsys cpuset",
"bufferSize": 10,
"source": "npd",
"conditions": [
{
"type": "KernelDeadlock",
"reason": "KernelHasNoDeadlock",
View k8s_insufficient_cpu_message.md
pod (vv10dece4d-9avwu) failed to fit in any node fit failure on node (192.168.0.1): Insufficient CPU fit failure on node (192.168.0.2): Insufficient Memory fit failure on node (192.168.0.3): Insufficient Memory fit failure on node (192.168.0.4): Insufficient CPU fit failure on node (192.168.0.5): Insufficient CPU fit failure on node (192.168.0.6): Insufficient CPU fit failure on node (192.168.0.7): Insufficient CPU fit failure on node (192.168.0.8): Insufficient CPU fit failure on node (192.168.0.9): Insufficient CPU fit failure on node (192.168.0.10): Insufficient CPU fit failure on node (192.168.0.11): Insufficient CPU fit failure on node (192.168.0.12): Insufficient CPU fit failure on node (192.168.0.13): Insufficient CPU fit failure on node (192.168.0.14): Insufficient CPU fit failure on node (192.168.0.15): Insufficient Memory fit failure on node (192.168.0.16): Insufficient Memory fit failure on node (192.168.0.17): Insufficient CPU fit failure on node (192.168.0.18): Insufficient CPU fit failure on
View necessary_git_skills.md

Tags

  • update tags
    • git fetch <remote> 'refs/tags/*:refs/tags/*'
@andyxning
andyxning / NaN_Inf_Near_zero_MarshalJSON.go
Created Dec 15, 2015
NaN, Inf and Near zero value MarshalJSON
View NaN_Inf_Near_zero_MarshalJSON.go
type JsonSpecial float64
func (value JsonSpecial) MarshalJSON() ([]byte, error) {
// Handle NaN, Inf and near-zero values marshalling
if math.IsNaN(float64(value)) || math.IsInf(fload64(value), 0) {
return json.Marshal(nil)
} else if math.Exp(float64(value)) == 1 {
return json.Marshal(0)
}
View check_whether_an_ip_is_loopback.go
package main
import "fmt"
import "net"
func main() {
IPv4Loopback := net.ParseIP("127.0.0.1")
IPv6Loopback := net.ParseIP("::1")
NonIPv6LoopbackOne := net.ParseIP("2001:db8::1")
NonIPv6LoopbackTwo := net.ParseIP("fe80::1%lo0")
@andyxning
andyxning / sort_a_dict_in_python.py
Last active Nov 11, 2015
Sort a Dict in Python
View sort_a_dict_in_python.py
#/usr/bin/env python
# -*- coding: utf-8 -*-
a = {3:4, 1:2, 5:6}
# Demo1
#
# get a list of tuples consisting the dict,
# sort the list with tuple items
print sorted(a.items())
@andyxning
andyxning / get_current_function_name_in_python.py
Last active Apr 15, 2019
get current function name in Python
View get_current_function_name_in_python.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Note: This may only work in CPython. For more info please see python doc about sys._getframe
import sys
# This will also show that function name(co_name) in python is bounded to function code(f_code).
# i.e., function assignment will not change the attribute of "co_name", function name
@andyxning
andyxning / element_not_in_an_array_test_in_awk.txt
Created Aug 19, 2015
element not in an array test in awk
View element_not_in_an_array_test_in_awk.txt
# [reference 1](http://www.unix.com/302702781-post2.html)
# awesome in using Ternary Operator
awk '
BEGIN {
a["1"]="a";
a["2"]="b";
a["3"]="c";
}
{ print !( $1 in a) ? "x" : a[$1]; }
'
@andyxning
andyxning / single_quote_usage_in_awk.txt
Last active Aug 29, 2015
single quote usage in awk
View single_quote_usage_in_awk.txt
single quote using in awk
###### Using Single QUote in awk script
function ltrim_single_quote(s) { return sub(/^\047+/, "", s); return s}
function rtrim_single_quote(s) { return sub(/'\047+$/, "", s); return s}
function trim_single_quote(s) { return ltrim_single_quote(rtrim_single_quote(s)) }
* [reference 1](http://www.gnu.org/software/gawk/manual/html_node/Quoting.html)
You can’t perform that action at this time.