Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python2
#coding:utf-8
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.tcpserver import TCPServer
logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%d/%b/%Y %H:%M:%S]')
#!/usr/bin/env python3
if __name__ == '__main__':
import re
try:
while True:
l = input().split()
t = '\n'.join([' '.join(i.split(':', 1)) for i in l if re.match('\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+', i)])
if t:
print(t)
@m13253
m13253 / convert_xv_flv.c
Last active December 10, 2016 14:08
Convert Xunlei XV media file to FLV media file. Origin: http://hi.baidu.com/naylonslain/item/9586125a9f5979dbd58bac47
#include <stdio.h>
#include <stdlib.h>
int convert_file(char *szSourceFile, int bIsFastConv)
{
char szNewFileName[256] = {0};
int buffer[0x400];
int i;
char flag;
char data;
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.2-2smp i686) [Netscape]">
</head>
<body>
&nbsp;
<table BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#000000" NOSAVE >
<tr NOSAVE>
@m13253
m13253 / romantable.txt
Created February 23, 2014 07:08
romantable.txt from Mozc Japanese IME
- ー
~ 〜
. 。
, 、
/ ・
z/ ・
z. …
z, ‥
zh ←
zj ↓
@m13253
m13253 / anti-xp-2.php
Last active August 29, 2015 13:56 — forked from xfoxfu/anti-xp-2.php
<?php
/**
* Anti-XP Script
*
* @author 小傅Fox[<xfox@cotr.me>]
*/
/**
* 获得客户端的操作系统
* Source:{@link http://lok.me/a/1027.html}
*
@m13253
m13253 / gist:9546968
Last active August 29, 2015 13:57
My package selection for an initial ArchLinux installation
pacman -S -y --root /mnt --config /mnt/etc/pacman.conf.pacsave --cachedir /mnt/var/cache/pacman/pkg base base-devel bash-completion vim grub wireless_tools net-tools inetutils dnsutils btrfs-progs ntfsprogs ntfs-3g arch-install-scripts gnome gdm xorg-drivers networkmanager networkmanager-dispatcher-ntpd networkmanager-dispatcher-sshd networkmanager-openconnect networkmanager-openvpn networkmanager-pptp networkmanager-vpnc rp-pppoe
@m13253
m13253 / sysctl.conf
Last active August 29, 2015 13:59
TCP tuning for high latency network in sysctl.conf -- http://hong.im/2013/04/20/linux-tcp-tuning/
# http://hong.im/2013/04/20/linux-tcp-tuning/
net.ipv4.tcp_syncookies = 1
# 表示开启 SYN Cookies。当出现 SYN 等待队列溢出时,启用 cookies 来处理,可防范少量 SYN 攻击,默认为 0,表示关闭;
net.ipv4.tcp_tw_reuse = 1
# 表示开启重用。允许将 TIME-WAIT sockets 重新用于新的 TCP 连接,默认为 0,表示关闭;
net.ipv4.tcp_tw_recycle = 1
# 表示开启 TCP 连接中 TIME-WAIT sockets 的快速回收,默认为 0,表示关闭;
net.ipv4.tcp_fin_timeout = 15
# 修改系統默认的 TIMEOUT 时间。
@m13253
m13253 / imgopt.sh
Last active March 7, 2016 07:12
Optimize large-size images for web by interlacing
#!/bin/bash
# This program is released under MIT license.
# This program comes with absolutely no warranty and may cause damages, use it at your risk.
# The author of this program is StarBrilliant <echo bTEzMjUzQGhvdG1haWwuY29tCg== | base64 -d>
if [ "$#" -eq 0 ]
then
echo "Optimize large-size images for web by interlacing"
echo "Usage: $0 1.png 2.jpg ..."
echo "optipng and libjpeg are required."
@m13253
m13253 / dnsmasq.conf
Created May 12, 2014 14:46
My dnsmasq configuration
# Configuration file for dnsmasq.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
# Listen on this specific port instead of the standard DNS port
# (53). Setting this to zero completely disables DNS function,
# leaving only DHCP and/or TFTP.
#port=5353