Skip to content

Instantly share code, notes, and snippets.

View ChinaXing's full-sized avatar
🤣
I may be slow to respond.

chinaxing ChinaXing

🤣
I may be slow to respond.
View GitHub Profile
@ChinaXing
ChinaXing / gist:4325495
Created December 18, 2012 06:13
bash char and char-code convert method
print -v variable "%o" \'A # variable: 101 in octal
echo $'\101' # produce: A, 101 is octal code of Character 'A'
echo $'\x41' # produce: A, 41 is hex code of Character 'A'
echo $'\u4e2d' # produce: 中, 4e2d is hex code order of ‘中’ in unicode character table.
print "%x" \'中 # produce: 4e2d, ...
@ChinaXing
ChinaXing / check_host.sh
Created January 24, 2013 05:16
check_host : 检查服务器的网络链接和进程,输出json格式。可扩展
#!/bin/env bash
############################################################
#Author : ChinaXing - chen.yack@gmail.com
#Create : 2013-01-20 15:56
#Function : check hosts status
# 检查服务器状态:
# 1. 网络链接
# a. ESTAB链接列表
# b. LISTEN端口列表
# 2. 进程
@ChinaXing
ChinaXing / yum-install.sh
Last active December 14, 2015 12:39
yum install package-lists, return the result.
#!/bin/env bash
# -----------------------------------------------------------------------------------------
# Function : install rpm package by yum tool
#
# Date : 2013-04-24
# 2013-05-07, 去掉日志输出,只输出结果,输出结果进行调整
# 2013-06-08, 添加选项化参数,增加appname 这一参数
# 2014-03-06, 如果appname目录没有则创建
# 2014-03-12, 增加t-admin-noweb-tomcat, t-admin-deploy-withnginx 分为tomcat和jboss
#
@ChinaXing
ChinaXing / gist:5268863
Last active December 15, 2015 13:39
show cpu map in numa scene
#!/bin/sh
#****************************************************************#
# ScriptName: cpu-map.sh
# Author: yunxing.cyx@taobao.com
# Create Date: 2013-03-29 13:03
# Modify Author: $SHTERM_REAL_USER@alibaba-inc.com
# Modify Date: 2013-03-29 13:03
# Function:
#***************************************************************#
cat /proc/cpuinfo \
@ChinaXing
ChinaXing / mojolicious-publish
Created May 30, 2013 03:41
Declare relative-Array in bash 4.0
#!/bin/env bash
declare -A COLORS=( ["RED"]=31 ["YELLOW"]=33 )
COLOR_DEFAULT=YELLOW
function c_echo
{
cb="\e[0;${COLORS[${2:-$COLOR_DEFAULT}]};1m"
ce="\e[0m"
echo -e "${cb}$1${ce}"
}
@ChinaXing
ChinaXing / rsync-no-root.mkd
Last active December 20, 2015 01:39
rsync 非root用户运行配置

server端配置

#假设为admin用户,主机A为server端

  1. rsyncd.conf 配置文件

     max connections = 4
     syslog facility = local5
    

pid file = /tmp/_rsyncd.pid

@ChinaXing
ChinaXing / copy-column-data.sql
Created July 22, 2013 09:22
mysql set one column data from another column
UPDATE tableA SET column2 = column1
@ChinaXing
ChinaXing / Perl-operator-precedence-show.pl
Created August 7, 2013 14:58
use B::Deparse module to see operator precedence
#
perl -MO=Deparse,-p -e ' my $x = \ $fh->fh '
# prints :
# (my $x = \($fh->fh));
@ChinaXing
ChinaXing / sub-closure-vars.pl
Created August 8, 2013 09:33
Show closure variables of a subroutine
# PadWalker
use warnings;
use strict;
use PadWalker;
my $a = "A";
my $b = "B";
@ChinaXing
ChinaXing / code-ref-to-source.pl
Created August 8, 2013 09:43
use B::Deparse module get source code of subroutine from its reference
# --- use B::Deparse module --- #
use B::Deparse; # or -MO=Deparse
sub mysub {
my $x = 20;
print "The X is : ", $x, "\n";
}
my $deparse = B::Deparse->new;