Skip to content

Instantly share code, notes, and snippets.

View liuxd's full-sized avatar
🗿
Hi, there.

Allen Liu liuxd

🗿
Hi, there.
  • Tax Traders
  • Auckland, New Zealand
View GitHub Profile
<style>*{position:relative}</style><table><input></table>
<!-- 这段代码在IE6下运行会使ie6直接关闭页面 -->
@liuxd
liuxd / mm.sh
Last active September 7, 2017 01:36
[mm.sh] 命令行下的编程小助手。包括:智能git push,代码统计,批量的PHP文件语法检查三个小功能。
#!/bin/bash
#
# Install:
# cur_dir=`pwd`
# sudo ln -s $cur_dir/mm.sh /bin/mm
#显示彩色文本信息。
function cecho {
case $2 in
info )
@liuxd
liuxd / EventSource.php
Last active September 7, 2017 01:32
[EventSource.php] PHP实现EventSource服务端。
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
function esFlush($msg){
echo "data: ", $msg, "\n\n";
flush();
}
@liuxd
liuxd / phpinfo-plus.php
Created August 21, 2014 09:40
Beautify phpinfo().
<?php
date_default_timezone_set('Asia/Shanghai');
ob_start(); phpinfo();
$i = ob_get_contents();
ob_end_clean();
$html = str_replace(
"module_Zend Optimizer", "module_Zend_Optimizer",
preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $i)
<?php
ob_start();
while (1) {
echo str_pad(time(), 4096);
sleep(1);
ob_flush();
flush();
}
@liuxd
liuxd / cfg.sh
Last active September 7, 2017 01:35
[sly-consumer.sh] A good consumer shell.
## default settings
max_interval=10
max_worker=20
## worker config
interval_num=0
worker_num=0
## cmd
job='/usr/bin/php /home/www/release/mobile_push/job/msg.php'
@liuxd
liuxd / windows-cleaner.bat
Last active September 7, 2017 01:27
[windows-cleaner.bat] Windows下自动删除指定文件夹的批处理脚本。
@echo off
for /f %%i in (clear-list.txt) do (
echo 删除%%i
rd %%i
)
echo.
echo 操作完成!
echo.
@liuxd
liuxd / phantomjs-sample.js
Last active September 7, 2017 01:29
[phantomjs-sample.js] A sample for phantomjs,fetch index.baidu.com's data.
#!/usr/bin/env phantomjs
var fs = require('fs');
var page = require('webpage').create();
// Add cookie.
var cookie = fs.read('baidu.cookie');
var cookie_lines = cookie.split("\n");
for (i in cookie_lines) {
@liuxd
liuxd / getEncodeStr.html
Last active September 7, 2017 01:27
[getEncodeStr] 获得多种编码下的浏览器编码结果。
<html>
<script>
parent._urlEncode_iframe_callback && parent._urlEncode_iframe_callback(location.search.split('=')[1]);
</script>
</html>
@liuxd
liuxd / mass-rename.rb
Last active September 7, 2017 01:34
[mass-rename.rb] Mass rename files in Ruby.
#!/usr/bin/env ruby
#
# mass rename
#
# Old
#$ tree
#.
#├── 3DS《火焰之紋章if》壁紙補完①
#│   ├── 3DS\241\266\273\360\321\346\326\256\274y\325\302if\241\267\261\332\274\210\321a\315\352_201573192919.JPG
#│   ├── 3DS\241\266\273\360\321\346\326\256\274y\325\302if\241\267\261\332\274\210\321a\315\352_201573192927.JPG