Skip to content

Instantly share code, notes, and snippets.

View kaichao's full-sized avatar

Kaichao kaichao

  • CNIC
  • Beijing, China
View GitHub Profile
@kaichao
kaichao / disable-ipv6-in-centos7.txt
Created September 3, 2019 08:23
centos7下禁用IPv6
编辑/etc/default/grub文件:
GRUB_CMDLINE_LINUX参数加上ipv6.disable=1
以root运行命令:
grub2-mkconfig -o /boot/grub2/grub.cfg
编辑/etc/ssh/sshd_config 文件,增加一行:
AddressFamily inet
@kaichao
kaichao / HanoiTower.java
Last active September 7, 2019 05:54
Hanoi Tower
import java.util.Stack;
/**
* 递归求解汉诺塔
*/
public class HanoiTower {
// 三个塔 a、b、c
Stack<Integer> a,b,c;
public static void main(String[] args) {
@kaichao
kaichao / Grib2Reader.java
Last active September 7, 2019 06:03
read grib2 大气数据文件
String dataFile = "data/NWP_NMC_T639R/Z_NAFP_C_BABJ_20161108000000_P_CNPC-T639-GMFS-HNEHE-00000.grib2";
try {
// open netcdf/grib/grib2 file from argument
NetcdfDataset gid = NetcdfDataset.openDataset(dataFile);
// get all grid tables in the file
List<Variable> variables = gid.getReferencedFile().getVariables();
for (int i = 0; i < variables.size(); i++) {
Variable var = variables.get(i);
if ((!var.isMetadata()) && (!var.getRanges().isEmpty())) {
System.out.format("%s, %s: %s %s\n", var.getName(), var.getDataType().toString(),var.getRanges().toString(),var.getUnitsString());
@kaichao
kaichao / oi-template.md
Last active April 18, 2020 11:21
oi template

信息学程序模板

#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    if(freopen("bus.in","r",stdin)==NULL)
        printf("error while opening input file.\n");
    if(freopen("bus.out","w",stdout)==NULL)
 printf("error while opening output file.\n");
@kaichao
kaichao / memo.md
Last active May 15, 2020 22:39
备忘
@kaichao
kaichao / digital-ocean.md
Last active June 18, 2020 03:08
centos7升级内核,安装docker-ce

安装CentOS 7.x,升级内核

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
yum --enablerepo=elrepo-kernel install -y kernel-ml

# 若出错,则运行以下命令
#grub2-mkconfig -o /boot/grub2/grub-efi.cfg
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
## Cannot git-clone from github
```bash
git clone https://github.com/kaichao/app-mwa.git
Cloning into 'app-mwa'...
fatal: unable to access 'https://github.com/kaichao/app-mwa.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.
```
@kaichao
kaichao / shell-cmd.md
Last active November 6, 2024 12:27
常用shell命令

brew的proxy设置

git config --global http.proxy 'socks5://10.255.128.1:1080'
git config --global https.proxy 'socks5://10.255.128.1:1080'

echo 'proxy=socks5://10.255.128.1:1080' >> ~/.curlrc 

CentOS7上的git2

@kaichao
kaichao / log-http-headers.md
Last active March 3, 2026 11:58
nginx: Log complete request/response with all headers

1. switch nginx image to openresty/openresty

2. add the following to server/location (/etc/nginx/conf.d/default.conf)

   set $req_header "";
   set $resp_header "";
   header_filter_by_lua_block{ 
      local h = ngx.req.get_headers();
      for k, v in pairs(h) do
         ngx.var.req_header = ngx.var.req_header .. k.."="..v.." ";
@kaichao
kaichao / offline-rpm-install.md
Last active April 4, 2026 01:55
Offline Installation on Rocky Linux 9.4 Using Docker

Prerequisites

  • A networked server with Docker installed (can be any Linux distribution)
  • A target offline server running Rocky Linux 9.4
  • Both servers have the same architecture (e.g., x86_64)

Key Concept

The container image (rockylinux/rockylinux:9.4) provides an environment identical to the target offline server. This ensures all downloaded RPM packages are compatible, regardless of the networked server's host operating system.

Step 1: Download Offline Packages on the Networked Server