Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# 请取标准输入,将 iptables 的规则转成 nginx acl 规则
# 使用:
# iptables-save | ./ipt2acl.sh > acl.conf
#
# 目前只支持两种形式的 ACCEPT 规则
# 1. INPUT -s [./0-9]+ -j ACCEPT
# 2. INPUT -m iprange --src-range [.0-9]+-[.0-9]+ -j ACCEPT
#
@jxinging
jxinging / ipt2acl.sh
Created July 31, 2017 08:58
将 iptables 的规则转成 nginx acl 规则
#!/bin/bash
# 请取标准输入,将 iptables 的规则转成 nginx acl 规则
# 使用:
# iptables-save | ./ipt2acl.sh > acl.conf
#
# 目前只处理两种形式的 ACCEPT 规则
# 1. INPUT -s [./0-9]+ -j ACCEPT
# 2. INPUT -m iprange --src-range [.0-9]+-[.0-9]+ -j ACCEPT
#
#!/usr/bin/env python2.7
# coding: utf8
""" """
import sys
import re
import os
from ipip import IP
#coding: utf8
from functools import wraps
class logit(object):
def __init__(self, logfile='out.log'):
self.logfile = logfile
def __call__(self, func):
@wraps(func)
@jxinging
jxinging / falling-char.js
Created April 1, 2016 05:08
字符下落效果
$(function(){
function getElementLeft(element){
  var actualLeft = element.offsetLeft;
  var current = element.offsetParent;
  while (current !== null){
    actualLeft += current.offsetLeft;
    current = current.offsetParent;
  }
  return actualLeft;
}
# 生成 socks5 协议的连接命令16进制数据,用于 haproxy的 tcp-check send-binary
# 参考:
# - <https://zh.wikipedia.org/wiki/SOCKS#SOCKS5>, "SOCKS5请求格式" 部分
# - <http://cbonte.github.io/haproxy-dconv/configuration-1.7.html#4.2-tcp-check%20send-binary>
socks5_connect_binary = lambda domain, port: "05010003"+"%02x" % len(domain)+"".join(["%02x" % ord(x) for x in domain])+"%04x" % int(port)
@jxinging
jxinging / musicbox_login.py
Created February 29, 2016 09:26
网易云音乐命令行版本登录工具
#!/usr/bin/env python2.7
# coding: utf8
""" 网易云音乐命令行版本<https://github.com/darknessomi/musicbox>登录工具
因为使用内置的登录系统一直出现 501 错误码,所以写了这个小工具
原理:
提取网页版登录的 response 供命令行版本使用, 从而得到 Cookie 和用户 ID 信息
使用方法:
1. 使用 Chrome 打开网易云音乐网页版
@jxinging
jxinging / configloader.py
Last active August 27, 2015 03:00
Python config loader
import imp
class ConfigLoader(object):
def __init__(self):
self.__conf = None
def load_file(self, path):
assert self.__conf is None
if self.__conf is None:
@jxinging
jxinging / logger.py
Created August 25, 2015 11:35
python logger
import logging
console = logging.StreamHandler()
console.setFormatter(logging.Formatter('%(levelname)s:%(name)s:%(asctime)s# %(message)s',
datefmt="%Y-%m-%d %H:%M:%S"))
logger = logging.getLogger("hls-grabber")
logger.addHandler(console)
@jxinging
jxinging / ipdetect.py
Last active August 29, 2015 14:25
机器网络接口信息探测(获取机器的公网IP,内网IP信息)
# coding: utf8
from subprocess import check_output
from socket import inet_aton
import struct
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO