Skip to content

Instantly share code, notes, and snippets.

View lynus's full-sized avatar

Lingyu Zhu lynus

  • National University of Defense Technology
  • Changsha, China
View GitHub Profile
@lynus
lynus / y-combinator.scm
Created March 10, 2021 08:27
How to derive Y combinator
(define (add1 x) (+ 1 x))
(define l3 '(1 2 3))
(define length
(lambda (l)
(cond ((null? l) 0)
(else (add1 (length (cdr l)))))))
(lambda (length)
@lynus
lynus / gist:6759624daec21cd87562e6cc5e23c0a8
Created February 5, 2020 04:03
query syscall number with your compiler
printf SYS_eventfd2 | gcc -include sys/syscall.h -E -
or check out ia32 syscall number:
printf SYS_eventfd2 | gcc -include sys/syscall.h -E -m32 -
@lynus
lynus / github_on_ssh_tunnel
Created May 1, 2013 16:13
Using github through ssh tunnel
repo所在的机器A不能访问外网,可以通过中间机器B使用github(clone,push,pull)
1.建立A到B的ssh 隧道。
2.分别修改~/.ssh/config 与 repo下面的 .git/config 文件
参考http://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/ 这篇文档。
使用文档中图4的‘多主机转发应用‘ 方法。建立 A到B的通道:
ssh -g -L 7001:github.com:22 middle-host
@lynus
lynus / gist:3726052
Created September 15, 2012 02:06
GFW三定律
GFW 第一定律:只要是“用户产生内容”(User-generated content, UGC) 的国外网站都会被和谐。
GFW 第二定律:只要是被和谐的网站,国内一定会至少有一个克隆版。
@lynus
lynus / gist:3652068
Created September 6, 2012 06:23
胡言乱语
1. C 程序员对于内存管理,计算机体系的理解能力;
2. C++ 程序员对元编程的理解能力;
3. Java程序员对于OO和设计模式的理解,对规模项目掌控的能力, 对虚拟机实现理解的能力;
4. Ruby程序员创造Web应用的能力;
5. Python 程序员在小中型Startup中应对各种问题的能力;
6. Javascript 程序员研究颠覆同行对Web交互认知的技术的能力;
@lynus
lynus / gist:3529115
Created August 30, 2012 13:59
tmux shortcut list
类似各种平铺式窗口管理器,tmux使用键盘操作,常用快捷键包括:
Ctrl+b 激活控制台;此时以下按键生效
系统操作 ? 列出所有快捷键;按q返回
d 脱离当前会话;这样可以暂时返回Shell界面,输入tmux attach能够重新进入之前的会话
D 选择要脱离的会话;在同时开启了多个会话时使用
Ctrl+z 挂起当前会话
r 强制重绘未脱离的会话
s 选择并切换会话;在同时开启了多个会话时使用
: 进入命令行模式;此时可以输入支持的命令,例如kill-server可以关闭服务器
@lynus
lynus / wan_ssh
Created August 24, 2012 06:39
openwrt:allow wan ssh into your wrt
by default,openwrt do not allow ssh access from wan, here are two method to change that:
1.login into your wrt from a lan host.issue the following command:
iptables -F
the command "flush away" all the firewall rules,including the one that rejects ssh request from wan.
now you can try ssh from anywhere.
aware that the firewall deactivation leads to highly security risk.and after the wrt restarts ,all default firewall configuration comes back.you hava to "flush" the rules once again.