Skip to content

Instantly share code, notes, and snippets.

@maliubiao
maliubiao / tcpinfo.py
Last active August 29, 2015 14:05
功能: 1, 获取系统当前所有的tcp链接信息, 2: 找到绑定某个端口的进程tcpinfo.port_to_pid(port)
import os
import struct
import socket
state_table = (
"EMPTY SLOT",
"ESTABLISHED",
"SENT",
"RECV",
"WAIT1",
@maliubiao
maliubiao / backup.py
Created August 20, 2014 07:53
backup your file automatically.
#! /usr/bin/env python
"""
backup your file automatically.
"""
import os
import time
import shutil
import sys
@maliubiao
maliubiao / read_torrent.py
Last active February 28, 2019 16:26
access torrent data
import torrent
import sys
import os.path
import time
def get_meta(path):
f = open(path, "r")
s = f.read()
@maliubiao
maliubiao / socks5.go
Last active June 16, 2020 07:42
Socks5RoundTripper for net/http
package socks5
import (
"bufio"
"bytes"
"encoding/binary"
"errors"
"net"
"net/http"
"strconv"
@maliubiao
maliubiao / memstat.go
Last active August 29, 2015 14:03
memstat.go
package main
import (
"fmt"
"runtime"
)
type Stats struct {
name string
value uint64
@maliubiao
maliubiao / typesize.py
Created June 23, 2014 11:55
python blt type size
import sys
class kls():
def m(self): pass
def func():
pass
def gen():
@maliubiao
maliubiao / compare.html
Last active August 29, 2015 14:02
compare uri query components
<!doctype html>
<html>
<head>
<title>compare url</title>
</head>
<style rel="stylesheet">
.mark-red {
background-color: #eb0013;
}
.mark-yellow {
@maliubiao
maliubiao / json_loc.py
Last active August 29, 2015 14:02
json helper
import json
def find_end(json, start):
if start < 0:
start = 0
stack = []
i = start
json_len = len(json)
while i < json_len:
@maliubiao
maliubiao / string_format.js
Last active August 29, 2015 14:02
string_format.js
/*
* {% ABC %}
*
*/
function string_format(format, context) {
if ((typeof format != "string") ||
(typeof context != "object")) {
return;
@maliubiao
maliubiao / exception_demo.js
Last active August 29, 2015 14:01
a javascript exception demo
function defineException(name) {
var Exception = function(message) {
this.message = message;
}
Exception.prototype.name = name;
return Exception;
}
var ValueException = defineException("ValueException");
var AssertException = defineException("AssertException");