Skip to content

Instantly share code, notes, and snippets.

@honwhy
honwhy / server.js
Created May 26, 2016 14:31
ajax 302 code
var http = require('http');
http.createServer(function(req, res) {
if(req.url == '/') {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(makeHtml());
} else if(req.url == '/ajax302'){
res.writeHead(302, {
'Content-Type': 'text/html',
//'Location': 'http://localhost:9000/forward' // alert 200
'Location': 'https://github.com/join' // alert 0
@honwhy
honwhy / gist:fa372b5b136e893b390e
Created August 20, 2014 03:27
删除文件289行开始都结尾的内容
sed -i '289,$d' filename
@honwhy
honwhy / delete empty files
Created August 14, 2014 14:51
批量删除文件大小为0的文件
honwhy@eos:images$ find . -size 0
./18342-106vq6i
./16601-1bgsvrc
./16601-v389qr
./16601-1lsd6ei
./21398-haoave
./18342-zwtoqd
./18342-1404c4x
./20513-1b0wtmo
./18342-14g3r6i
@honwhy
honwhy / gist:af426d38ae34c6da2a14
Created August 11, 2014 14:18
善用history历史记录
在终端输入的命令被记录在history中
只是输入history就可以看到从前的命令
如果要再次执行从前的命令,只要 !1725
!linenumber 即可
@honwhy
honwhy / gist:d7aecec03c3e22012f64
Last active August 29, 2015 14:05
use regular expression in sed command
#!/bin/bash
# 在Linux终端使用sed命令,使用正则表达式时+没有被当作元字符
# 1. 使用如下命令
sed -i '/^[0-9]+/d' some.txt
cat some.txt
# 并不能够将数字开头的行删除
# 2. 使用如下命令
sed -i '/^[0-9]\+/d' some.txt