Posts

Showing posts from October, 2015

Tomcat Block IP

Change the <Tomcat install path>\conf\context.xml file test in Tomcat 6 and Tomcat 7 Add following context between <Context> tag <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="<IP Address>"/> Example: <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="1\.2\.3\.4"/>

Loan Interest

等额本息计算公式:〔贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数-1〕 等额本金计算公式:每月还款金额 = (贷款本金 ÷ 还款月数)+(本金 — 已归还本金累计额)×每月利率 贷款本金:430,000 年贷款利息:5.6% 贷款周期:30年 周贷款利息:5.6%/52=0.001077 贷款周期:30×52=1560周 等额本息:[430,000 * 0.001077*(1+0.001077)^1560] / [(1+0.001077)^1560-1] =569.27 等额本金:第一周=430,000 / 1560 + 430,000 * 0.001077 = 275.64 + 463.08 = 738.72                       第一周=430,000 / 1560 + (430,000 - 275.64) * 0.001077 = 275.64 + 463.08 = 738.72

Linux RHEL7 Firewall

Check current setting: iptables-save Add 80 port to public rule:  #firewall-cmd --zone=public --add-port=80/tcp --permanent #firewall-cmd --reload #iptables-save|grep 80

Regular Expression

Regular Expression format: special character + normal character 1. find express which start with FROM or SUBJECT:  ^(FROM|SUBJECT):  2. replace <emphasis>ip address </emphasis>  to <inet>ip address</inet> (perl) s!<emphasis>([0-9]+(\.[0-9]+){3})</emphasis>!<inet>$1</inet>! Special Character 1. ^: start of line 2. $: end of line ^$: match empty line ^cat: match line start with "cat" cat$: match line end with "cat" ^cat$: match line only contains "cat" 3. []: character group A. [0-9]: match all number B. [a-z]: match all lower letter C. [A-Z]: match all upper letter D. [0-9A-Za-z]: match all number, lower letter and upper letter gr[ae]y --> gray / grey <H[123]> --> <H1> / <H2> / <H3> <H[1-3]> --> <H1> / <H2> / <H3> 4. [^]: get rid of character group [^1-6]: no match 1~6; 5. . : match one any item ...

Linux Port Forward

Proxy server: CentOS 6. 6 --> IP_a Backend server: windows server 2003 --> IP_b Steps: 1. Enable ip_forward vim /etc/sysctl.conf net.ipv4.ip_forward=1 sysctl -p 2. Add firewall rules: iptables -t nat -A PREROUTING -p tcp --dport 21 -j DNAT --to-destination IP_b:21 iptables -t nat -A POSTROUTING -p tcp -d IP_b --dport 21 -j SNAT --to-source IP_a iptables -t nat -A PREROUTING  -p tcp  --dport 61000:61100 -j DNAT --to IP_b:61000-61100 service iptables save 3. Comment firewall rules: vim /etc/sysconfig/iptables #-A FORWARD -j REJECT --reject-with icmp-host-prohibited 4. Restart firewall: service iptables restart