• Categories page in githubio with js

    Since githubio does not support “jekyll-archives”, I just implemented it with js although it is very easy it seems.

    the code is here

    and the webpage is here

    Just set style.display for every post in the contents

    But maybe it would be slow if the contents is too large.

    BTW, is there any pure static blog framework which only use js?

    unlike jekyll use ruby to refresh static page

    maybe ajax is better?

  • 现在实验室服务器自动打开网络通的配置

    涉及的机器及其网络环境:

    • A:实验室服务器:拥有外网ip,但没有网络通就会被学校防火墙限制在校内

    • B:瀚海星云的一台云主机:没有外网ip,但是靠NAT可以访问外网

    • C:自己的腾讯云主机:不解释

    C上跑一个python脚本,利用wsgiref监听127.0.0.1的c端口,一收到http request,则运行连接网络通的脚本

    C通过ssh tunnel把c端口forward到B上127.0.0.1的b端口上

    B再通过反向ssh tunnel把这个端口forward到A上127.0.0.1的a端口上

    在A上的apache2上设置了某个地址proxy到127.0.0.1的a端口上

    现在访问A上的那个网址就可以给C打开网络通啦

  • An Interesting Search with c macro

    question:insert “+” or “-“ into “123456789” and ensure the result is 100, output all the situations.

    code:

    #include <stdio.h>
    #include <stdlib.h>
    
    #define C10(x) if((x)==num)printf("%s = %d\n",#x,num);
    #define C9(x) C10(x##9);C10(x+9);C10(x-9);
    #define C8(x) C9(x##8);C9(x+8);C9(x-8);
    #define C7(x) C8(x##7);C8(x+7);C8(x-7);
    #define C6(x) C7(x##6);C7(x+6);C7(x-6);
    #define C5(x) C6(x##5);C6(x+5);C6(x-5);
    #define C4(x) C5(x##4);C5(x+4);C5(x-4);
    #define C3(x) C4(x##3);C4(x+3);C4(x-3);
    #define C2(x) C3(x##2);C3(x+2);C3(x-2);
    
    int main(int argc,char ** argv){
      int num;
      if(argc==1) num = 100;
      else        num = atoi(argv[1]);
      C2(1);
      C2(-1);
      return 0;
    }

    output:

    123+45-67+8-9 = 100
    123+4-5+67-89 = 100
    123-45-67+89 = 100
    123-4-5-6-7+8-9 = 100
    12+3+4+5-6-7+89 = 100
    12+3-4+5+67+8+9 = 100
    12-3-4+5-6+7+89 = 100
    1+23-4+56+7+8+9 = 100
    1+23-4+5+6+78-9 = 100
    1+2+34-5+67-8+9 = 100
    1+2+3-4+5+6+78+9 = 100
    -1+2-3+4+5+6+78+9 = 100

    it uses macro to expand all the situation, which is a little interesting so I post it here.

  • 今天数理方程期末考试一道题不会写TAT

    的初值问题

    考试没有写出来TAT

    许轶臣的解法如下:

    所以

    解得

    带入原方程

    得到